# HG changeset patch # User vromero # Date 1387215198 0 # Node ID af8945f58fc6c3b20529a21db44f7736ea436e37 # Parent c7e024d637bfc2830f46b65559ca1c42ba8344a0 8030214: fix for JDK-8020216 breaks the build Reviewed-by: jjg diff -r c7e024d637bf -r af8945f58fc6 langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Dec 16 15:07:13 2013 +0000 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Dec 16 17:33:18 2013 +0000 @@ -1461,19 +1461,9 @@ this.names = names; } - boolean isInitialConstructor = false; - @Override protected void markDead(JCTree tree) { - if (!isInitialConstructor) { - inits.inclRange(returnadr, nextadr); - } else { - for (int address = returnadr; address < nextadr; address++) { - if (!(isFinalUninitializedStaticField(vardecls[address].sym))) { - inits.incl(address); - } - } - } + inits.inclRange(returnadr, nextadr); uninits.inclRange(returnadr, nextadr); } @@ -1486,16 +1476,8 @@ return sym.pos >= startPos && ((sym.owner.kind == MTH || - isFinalUninitializedField(sym))); - } - - boolean isFinalUninitializedField(VarSymbol sym) { - return ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && - classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)); - } - - boolean isFinalUninitializedStaticField(VarSymbol sym) { - return isFinalUninitializedField(sym) && sym.isStatic(); + ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && + classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)))); } /** Initialize new trackable variable by setting its address field @@ -1751,7 +1733,8 @@ Assert.check(pendingExits.isEmpty()); try { - isInitialConstructor = TreeInfo.isInitialConstructor(tree); + boolean isInitialConstructor = + TreeInfo.isInitialConstructor(tree); if (!isInitialConstructor) { firstadr = nextadr; @@ -1806,7 +1789,6 @@ nextadr = nextadrPrev; firstadr = firstadrPrev; returnadr = returnadrPrev; - isInitialConstructor = false; } } diff -r c7e024d637bf -r af8945f58fc6 langtools/test/tools/javac/flow/T8020216/CompileTimeErrorForNonAssignedStaticFieldTest.java --- a/langtools/test/tools/javac/flow/T8020216/CompileTimeErrorForNonAssignedStaticFieldTest.java Mon Dec 16 15:07:13 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8020216 - * @summary javac, compile time error isn't shown when final static field is not assigned - * @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); - } - } - -} diff -r c7e024d637bf -r af8945f58fc6 langtools/test/tools/javac/flow/T8020216/CompileTimeErrorForNonAssignedStaticFieldTest.out --- a/langtools/test/tools/javac/flow/T8020216/CompileTimeErrorForNonAssignedStaticFieldTest.out Mon Dec 16 15:07:13 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -CompileTimeErrorForNonAssignedStaticFieldTest.java:14:5: compiler.err.var.might.not.have.been.initialized: i -1 error