| Summary: | [quick fix] Boxing warning should allow "valueOf" quick fix for primitives | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Scott Johnson <scottj> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | daniel_megert, remy.suen, scottj |
| Version: | 3.6.1 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Enhancements and issues for Eclipse's Java tooling support goes to JDT. *** This bug has been marked as a duplicate of bug 204352 *** |
Build Identifier: 20100917-0705 When an autoboxing warning is given, there is a quick fix available in the popup menu that would allow the user to add a warning suppression to the statement for autoboxing, but no option is available that would allow a code change to occur. It seems that for autoboxing from int to Integer, for example, there should also be a quick fix option that would wrap the statement in an Integer.valueOf() call. This seems like a reasonable choice for all primitives, as I find myself performing this action quite frequently. Reproducible: Always Steps to Reproduce: 1. Create the following code in Eclipse: public class BoxingTest { public static void main(String[] args) { int originalInt = 0; Integer boxedInt = originalInt; } } 2. Eclipse will report the following warning (assuming it's turned on): The expression of type int is boxed into Integer. The only two quick fixes available are both to add a @SuppressWarnings annotation to either the method or variable itself. I feel there should be another quickfix option that would change the code from: Integer boxedInt = originalInt; to: Integer boxedInt = Integer.valueOf(originalInt);