-
Bug
-
Resolution: Fixed
-
P4
-
7u25, 9
-
b46
-
x86_64
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085312 | emb-9 | Maurizio Cimadamore | P4 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Server VM (build 23.25-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux didclab-ws4 3.10.0-sabayon #1 SMP Sat Jan 11 10:38:23 UTC 2014 i686 Intel(R) Xeon(R) CPU W3550 @ 3.07GHz GenuineIntel GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The compiler is generating bytecode which causes a VerifyError to be thrown when the class is loaded.
Specifically, the compiler is generating code which does not push arguments onto the stack in the right order before calling the constructor of an anonymous class which meets the following criteria:
1) The enclosing class E extends a generic superclass S<T>.
2) S has a field t of type T.
3) E defines T to be a concrete class C, and assigns a new instance of C to field t.
4) C has an inner class I.
5) The anonymous class extends I through the instance of C referred to by t. (i.e., t.new I() { })
(The exact names of the classes of course don't matter.)
ADDITIONAL REGRESSION INFORMATION:
$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Server VM (build 23.25-b01, mixed mode)
$ javac -version
javac 1.7.0_25
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Compile the attached source code.
2) Execute Test.class with no arguments.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No output.
ACTUAL -
A VerifyError (see Error Messages section).
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method E.<init>()V at offset 29
at Test.main(Test.java:8)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class S<T> { T t; }
class C { class I { }; }
class E extends S<C> {{
t = new C();
t.new I() { };
}};
public class Test {
public static void main(String[] args) { new E(); }
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Replacing
t.new I() { };
with
((C)t).new I() { };
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Server VM (build 23.25-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux didclab-ws4 3.10.0-sabayon #1 SMP Sat Jan 11 10:38:23 UTC 2014 i686 Intel(R) Xeon(R) CPU W3550 @ 3.07GHz GenuineIntel GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The compiler is generating bytecode which causes a VerifyError to be thrown when the class is loaded.
Specifically, the compiler is generating code which does not push arguments onto the stack in the right order before calling the constructor of an anonymous class which meets the following criteria:
1) The enclosing class E extends a generic superclass S<T>.
2) S has a field t of type T.
3) E defines T to be a concrete class C, and assigns a new instance of C to field t.
4) C has an inner class I.
5) The anonymous class extends I through the instance of C referred to by t. (i.e., t.new I() { })
(The exact names of the classes of course don't matter.)
ADDITIONAL REGRESSION INFORMATION:
$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Server VM (build 23.25-b01, mixed mode)
$ javac -version
javac 1.7.0_25
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Compile the attached source code.
2) Execute Test.class with no arguments.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No output.
ACTUAL -
A VerifyError (see Error Messages section).
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method E.<init>()V at offset 29
at Test.main(Test.java:8)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class S<T> { T t; }
class C { class I { }; }
class E extends S<C> {{
t = new C();
t.new I() { };
}};
public class Test {
public static void main(String[] args) { new E(); }
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Replacing
t.new I() { };
with
((C)t).new I() { };
- backported by
-
JDK-8085312 VerifyError due to missing checkcast
-
- Resolved
-