Bug 100182

Summary: [1.5][compiler] unecessary cast in case of boxing
Product: [Eclipse Project] JDT Reporter: Rémi Forax <forax>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Rémi Forax CLA 2005-06-15 09:57:25 EDT
eclipse raise an unecessary cast in a case that require a cast :

char c=...
System.out.println("%d\n",(int)c);

in this case, the cast is usefull because c must be box in Integer.
Comment 1 Olivier Thomann CLA 2005-06-15 11:56:15 EDT
*** Bug 100218 has been marked as a duplicate of this bug. ***
Comment 2 Philipe Mulet CLA 2005-10-18 04:31:56 EDT
There is no boxing there, it is either using 
PrintStream#println(char)
or 
PrintStream#println(int).

Now, there shouldn't be any warning signalled here.
Comment 3 Philipe Mulet CLA 2005-10-18 04:34:08 EDT
Actually, there is some boxing, but the example is wrong, it should be using
#printf(...) instead of #println(...)

public class X {
	public static void main(String[] s) {
		char c = 'a';
		System.out.printf("%d\n",(int)c);		
	}
}
Comment 4 Rémi Forax CLA 2005-10-18 04:38:11 EDT
oups, you are right,
it's a typo when i report the bug.

Rémi




Comment 5 Philipe Mulet CLA 2005-10-18 05:00:21 EDT
Changed diagnosis to tolerate this boxing scenario.
Added AutoboxingTest#test114-115.

Released both in 3.1.x and 3.2 streams.
Comment 6 Olivier Thomann CLA 2006-01-09 10:26:42 EST
Verified for 3.1.2 in M20060109-0800.
Comment 7 Olivier Thomann CLA 2006-01-10 10:29:16 EST
Verified for 3.2M4 in I20051215-1506