Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329437 - [1.5] Java Compiler incorrectly warns that a cast from Integer to int is unnecessary
Summary: [1.5] Java Compiler incorrectly warns that a cast from Integer to int is unne...
Status: CLOSED DUPLICATE of bug 418795
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 minor with 1 vote (vote)
Target Milestone: 4.16 M1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-04 09:59 EDT by Rune Glerup CLA
Modified: 2020-03-20 18:38 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rune Glerup CLA 2010-11-04 09:59:40 EDT
Build Identifier: 20100617-1415

The Eclipse Java compiler incorrectly reports that a cast from Integer to int is unnecessary. Consider the following code:

public class Test {

	public static void main(String... args) {
		Integer a = new Integer(10);
		Integer b = new Integer(10);
		boolean abEqual = (int)a == (int)b;
		System.out.println(abEqual);
	}

}

Here the program will not produce the same result, if the casts are removed.

Reproducible: Always

Steps to Reproduce:
1. Compile the example program
2. Run the program: Prints 'true'
3. Remove the casts
4. Re-compile the program
5. Run the program: Prints 'false'
Comment 1 Srikanth Sankaran CLA 2012-02-15 06:28:47 EST
*** Bug 371597 has been marked as a duplicate of this bug. ***
Comment 2 Srikanth Sankaran CLA 2013-10-07 08:00:09 EDT
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=418795
Comment 3 Eclipse Genie CLA 2019-04-08 04:41:40 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Dani Megert CLA 2019-04-08 06:04:34 EDT
Looks like this got fixed some time ago.
Comment 5 Stephan Herrmann CLA 2020-03-20 18:38:24 EDT
(In reply to Dani Megert from comment #4)
> Looks like this got fixed some time ago.

no, the bogus warning is still raised (if enabled).

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