mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
Reviewed-by: jjg, jfranck, sundar
This commit is contained in:
parent
3c77de74be
commit
a4bac02fa4
3 changed files with 56 additions and 6 deletions
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8030218
|
||||
* @summary javac, compile time error isn't shown when final static field is not assigned, follow-up
|
||||
* @compile/fail/ref=CompileTimeErrorForNonAssignedStaticFieldTest.out -XDrawDiagnostics CompileTimeErrorForNonAssignedStaticFieldTest.java
|
||||
*/
|
||||
|
||||
public class CompileTimeErrorForNonAssignedStaticFieldTest {
|
||||
private final static int i;
|
||||
|
||||
public CompileTimeErrorForNonAssignedStaticFieldTest()
|
||||
throws InstantiationException {
|
||||
throw new InstantiationException("Can't instantiate");
|
||||
}
|
||||
|
||||
static class Inner {
|
||||
private final int j;
|
||||
public Inner(int x)
|
||||
throws InstantiationException {
|
||||
if (x == 0) {
|
||||
throw new InstantiationException("Can't instantiate");
|
||||
} else {
|
||||
j = 1;
|
||||
}
|
||||
System.out.println(j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue