Bug 100182 - [1.5][compiler] unecessary cast in case of boxing
Summary: [1.5][compiler] unecessary cast in case of boxing
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 100218 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-15 09:57 EDT by Rémi Forax CLA
Modified: 2006-01-10 10:29 EST (History)
0 users

See Also:


Attachments

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