FULL PRODUCT VERSION :
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
EXTRA RELEVANT SYSTEM CONFIGURATION :
TextPad
A DESCRIPTION OF THE PROBLEM :
"However, a Java implementation may, if it chooses, wrap commonly occurring values
into identical objects, and thus the comparison might succeed. This ambiguity is not
what you want. The remedy is to call the equals method when comparing wrapper objects.
java.lang.Integer a = 1000;
javal.lang.Integer b = 1000;"
Amazon Core Java Volume I (8th Edition)
http://www.amazon.com/Core-Java-TM-I-Fundamentals-8th/dp/0132354764, Pg. 212.
This statement could not be confirmed, however, I do not have any knowledge of Java internals.
REGRESSION. Last worked in version 1.4.2
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.*;
public class TestEight
{
public static void main (String[] args)
{
Integer one = 1;
Integer two = 1;
if (one == two) System.out.println("one == two");
if (one.equals(two)) System.out.println("one.equals(two)");
}
}
---------- END SOURCE ----------