-
Bug
-
Resolution: Fixed
-
P3
-
17, 18
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8318465 | 17.0.10-oracle | Weibing Xiao | P3 | Resolved | Fixed | b04 |
JDK-8318664 | 17.0.10 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
Creation of a static child class(AA) of an non static class(A) without enclosing class (EnclosingClass) throws VerifyError at runtime instead of an compiler error at compile time.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code provided
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compile time error
ACTUAL -
VerifyError at runtime:
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
EnclosingClass$A$AA.<init>()V @2: getfield
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'EnclosingClass$A$AA'
Current Frame:
bci: @2
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0000000: 2a2a b400 01b7 0007 b1
at EnclosingClass$A.create(EnclosingClass.java:12)
at EnclosingClass.main(EnclosingClass.java:18)
---------- BEGIN SOURCE ----------
public class EnclosingClass {
public abstract class A {
public static class AA extends A {
}
public static A create() {
return new AA();
}
}
public static void main(String[] args) {
A.create();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Make A static - it should not compile this way.
FREQUENCY : always
- backported by
-
JDK-8318465 Create a non static nested class without enclosing class throws VerifyError
- Resolved
-
JDK-8318664 Create a non static nested class without enclosing class throws VerifyError
- Resolved
- duplicates
-
JDK-8317377 StackOverflowError on Nested Class Inheritance
- Closed
- relates to
-
JDK-8254321 Allow static members to be declared in inner classes
- Closed
- links to
-
Commit openjdk/jdk17u-dev/64146764
-
Commit openjdk/jdk/f96aee74
-
Review openjdk/jdk17u-dev/1894
-
Review openjdk/jdk/11954