5b9932f8f3
8322882: Null pointer error when compiling Static initializer in a local class 8334248: Invalid error for early construction local class constructor method reference 8330037: Compiler produces invalid bytecode for method class creation from static method Reviewed-by: jlahoda, vromero
45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
/*
|
|
* @test /nodynamiccopyright/
|
|
* @bug 8322882
|
|
* @summary Disallow attempts to access a free variable proxy field from a static method
|
|
* @compile/fail/ref=LocalFreeVarStaticInstantiate.out -XDrawDiagnostics LocalFreeVarStaticInstantiate.java
|
|
*/
|
|
|
|
class LocalFreeVarStaticInstantiate {
|
|
|
|
// local class in method
|
|
static void foo(Object there) {
|
|
class Local {
|
|
{
|
|
there.hashCode();
|
|
}
|
|
|
|
static {
|
|
new Local(); // can't get there from here
|
|
}
|
|
|
|
static Runnable r = () -> {
|
|
new Local(); // can't get there from here
|
|
};
|
|
}
|
|
}
|
|
|
|
// local class in lambda
|
|
static Runnable foo = () -> {
|
|
Object there = "";
|
|
class Local {
|
|
{
|
|
there.hashCode();
|
|
}
|
|
|
|
static {
|
|
new Local(); // can't get there from here
|
|
}
|
|
|
|
static Runnable r = () -> {
|
|
new Local(); // can't get there from here
|
|
};
|
|
}
|
|
};
|
|
}
|