-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b70)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Class.getConstructor() and Class.getMethod() do not obey autoboxing rules. That is, Integer.TYPE and Integer.class are treated as distinct classes when lookups based on parameter classes are done.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the below program. First, run the way it is here. Then comment out the first Constructor line and uncomment the second. This time an exception will be thrown.
public class TestClass
{
public static void main(String[] args)
{
try
{
Constructor con = Color.class.getConstructor(Integer.class, Integer.class, Integer.class);
// Constructor con = Color.class.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE);
con.newInstance(100, 100, 100);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both method calls should return the same constructor.
ACTUAL -
Similar calls return a differetn result.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
This is the output when the testcase is initially run -
java.lang.NoSuchMethodException: java.awt.Color.<init>(java.lang.Integer, java.lang.Integer, java.lang.Integer)
at java.lang.Class.getConstructor0(Class.java:2674)
at java.lang.Class.getConstructor(Class.java:1656)
at TestClass.main(TestClass.java:10)
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b70)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Class.getConstructor() and Class.getMethod() do not obey autoboxing rules. That is, Integer.TYPE and Integer.class are treated as distinct classes when lookups based on parameter classes are done.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the below program. First, run the way it is here. Then comment out the first Constructor line and uncomment the second. This time an exception will be thrown.
public class TestClass
{
public static void main(String[] args)
{
try
{
Constructor con = Color.class.getConstructor(Integer.class, Integer.class, Integer.class);
// Constructor con = Color.class.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE);
con.newInstance(100, 100, 100);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both method calls should return the same constructor.
ACTUAL -
Similar calls return a differetn result.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
This is the output when the testcase is initially run -
java.lang.NoSuchMethodException: java.awt.Color.<init>(java.lang.Integer, java.lang.Integer, java.lang.Integer)
at java.lang.Class.getConstructor0(Class.java:2674)
at java.lang.Class.getConstructor(Class.java:1656)
at TestClass.main(TestClass.java:10)
REPRODUCIBILITY :
This bug can be reproduced always.