FULL PRODUCT VERSION :
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The following code compiles successfully with javac:
public class BugReport<T> {
private T n;
public void error() {
BugReport<Integer> val = new BugReport<Integer>();
val.n = 0;
Integer.toString(val.n++);
}
public static void main(String[] args) {
BugReport.class.getMethods();
}
}
However, when run with `java BugReport', it always throws the following error:
Exception in thread "main" java.lang.VerifyError: (class: BugReport, method: error signature: ()V) Incompatible object argument for function call
This is likely due to the generics/autoboxing combination that fails in this case at the line Integer.toString(val.n++).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the code from the description and run it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error.
ACTUAL -
This error:
Exception in thread "main" java.lang.VerifyError: (class: BugReport, method: error signature: ()V) Incompatible object argument for function call
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: (class: BugReport, method: error signature: ()V) Incompatible object argument for function call
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class BugReport<T> {
private T n;
public void error() {
BugReport<Integer> val = new BugReport<Integer>();
val.n = 0;
Integer.toString(val.n++);
}
public static void main(String[] args) {
BugReport.class.getMethods();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
val.n++ can be moved out of the method call and the call itself can be changed to Integer.toString(val.n).