mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-22 08:21:27 +00:00
8334043: VerifyError when inner class is accessed in prologue
Reviewed-by: jpai Backport-of: d4c13737171b7ab7a8a29a69fa9965f8363c5aee
This commit is contained in:
parent
d9dd2d19b0
commit
12a61bce8d
@ -3863,7 +3863,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