8030214: fix for JDK-8020216 breaks the build
authorvromero
Mon, 16 Dec 2013 17:33:18 +0000
changeset 22150 af8945f58fc6
parent 22149 c7e024d637bf
child 22151 cb8daa93eeb1
8030214: fix for JDK-8020216 breaks the build Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
langtools/test/tools/javac/flow/T8020216/CompileTimeErrorForNonAssignedStaticFieldTest.java
langtools/test/tools/javac/flow/T8020216/CompileTimeErrorForNonAssignedStaticFieldTest.out
--- 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;
             }
         }
 
--- 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);
-        }
-    }
-
-}
--- 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