8334043: VerifyError when inner class is accessed in prologue
Reviewed-by: mcimadamore
This commit is contained in:
parent
b42fe86e81
commit
d4c1373717
src/jdk.compiler/share/classes/com/sun/tools/javac/comp
test/langtools/tools/javac/SuperInit
@ -3861,7 +3861,20 @@ public class Resolve {
|
||||
|
||||
// Get the symbol's qualifier, if any
|
||||
JCExpression lhs = TreeInfo.skipParens(assign.lhs);
|
||||
JCExpression base = lhs instanceof JCFieldAccess select ? select.selected : null;
|
||||
JCExpression base;
|
||||
switch (lhs.getTag()) {
|
||||
case IDENT:
|
||||
base = null;
|
||||
break;
|
||||
case SELECT:
|
||||
JCFieldAccess select = (JCFieldAccess)lhs;
|
||||
base = select.selected;
|
||||
if (!TreeInfo.isExplicitThisReference(types, (ClassType)env.enclClass.type, base))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
// If an early reference, the field must not be declared in a superclass
|
||||
if (isEarlyReference(env, base, v) && v.owner != env.enclClass.sym)
|
||||
|
@ -158,4 +158,15 @@ public class EarlyAssignments {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Inner8 {
|
||||
class Inner8a {
|
||||
int x;
|
||||
}
|
||||
|
||||
public Inner8() {
|
||||
this.new Inner8a().x = 1; // FAIL - illegal early access
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ EarlyAssignments.java:134:17: compiler.err.cant.ref.before.ctor.called: super
|
||||
EarlyAssignments.java:139:23: compiler.err.cant.ref.before.ctor.called: this
|
||||
EarlyAssignments.java:148:13: compiler.err.cant.assign.initialized.before.ctor.called: x
|
||||
EarlyAssignments.java:157:13: compiler.err.cant.assign.val.to.var: final, x
|
||||
EarlyAssignments.java:168:13: compiler.err.cant.ref.before.ctor.called: this
|
||||
- compiler.note.preview.filename: EarlyAssignments.java, DEFAULT
|
||||
- compiler.note.preview.recompile
|
||||
25 errors
|
||||
26 errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user