Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328991

Summary: [quick fix] Boxing warning should allow "valueOf" quick fix for primitives
Product: [Eclipse Project] JDT Reporter: Scott Johnson <scottj>
Component: UIAssignee: 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:

Description Scott Johnson CLA 2010-10-28 19:50:49 EDT
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);
Comment 1 Remy Suen CLA 2010-10-28 20:04:21 EDT
Enhancements and issues for Eclipse's Java tooling support goes to JDT.
Comment 2 Dani Megert CLA 2010-10-29 02:20:14 EDT

*** This bug has been marked as a duplicate of bug 204352 ***