jdk-24/test/langtools/tools/javac/LocalClassCtorPrologue.java
2024-04-04 21:13:49 +00:00

33 lines
693 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8328649
* @summary Verify local classes in constructor prologues don't have enclosing instances
* @compile/fail/ref=LocalClassCtorPrologue.out -XDrawDiagnostics LocalClassCtorPrologue.java
* @enablePreview
*/
class LocalClassCtorPrologue {
int x;
LocalClassCtorPrologue() {
class Local {
{
x++; // this should fail
}
}
super();
}
public class Inner {
public Inner() {
class Local {
{
x++; // this should work
}
};
super();
}
}
}