Bug 328991 - [quick fix] Boxing warning should allow "valueOf" quick fix for primitives
Summary: [quick fix] Boxing warning should allow "valueOf" quick fix for primitives
Status: CLOSED DUPLICATE of bug 204352
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-28 19:50 EDT by Scott Johnson CLA
Modified: 2010-10-29 02:20 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***