8068489: remove unnecessary complexity in Flow and Bits, after JDK-8064857

Mon, 15 Jun 2015 10:10:16 -0700

author
vromero
date
Mon, 15 Jun 2015 10:10:16 -0700
changeset 2820
7f6d6b80a58b
parent 2817
976523f1d562
child 2821
1ddf51024f37

8068489: remove unnecessary complexity in Flow and Bits, after JDK-8064857
Reviewed-by: mcimadamore

src/share/classes/com/sun/tools/javac/comp/Flow.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/util/Bits.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Jun 12 18:44:36 2015 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Mon Jun 15 10:10:16 2015 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -353,17 +353,17 @@
    1.11                  this.tree = tree;
    1.12              }
    1.13  
    1.14 -            void resolveJump(JCTree tree) {
    1.15 +            void resolveJump() {
    1.16                  //do nothing
    1.17              }
    1.18          }
    1.19  
    1.20 -        abstract void markDead(JCTree tree);
    1.21 +        abstract void markDead();
    1.22  
    1.23          /** Record an outward transfer of control. */
    1.24 -        void recordExit(JCTree tree, P pe) {
    1.25 +        void recordExit(P pe) {
    1.26              pendingExits.append(pe);
    1.27 -            markDead(tree);
    1.28 +            markDead();
    1.29          }
    1.30  
    1.31          /** Resolve all jumps of this statement. */
    1.32 @@ -377,7 +377,7 @@
    1.33                  P exit = exits.head;
    1.34                  if (exit.tree.hasTag(jk.treeTag) &&
    1.35                          jk.getTarget(exit.tree) == tree) {
    1.36 -                    exit.resolveJump(tree);
    1.37 +                    exit.resolveJump();
    1.38                      resolved = true;
    1.39                  } else {
    1.40                      pendingExits.append(exit);
    1.41 @@ -420,7 +420,7 @@
    1.42          private boolean alive;
    1.43  
    1.44          @Override
    1.45 -        void markDead(JCTree tree) {
    1.46 +        void markDead() {
    1.47              alive = false;
    1.48          }
    1.49  
    1.50 @@ -464,7 +464,7 @@
    1.51              ListBuffer<PendingExit> pendingExitsPrev = pendingExits;
    1.52              Lint lintPrev = lint;
    1.53  
    1.54 -            pendingExits = new ListBuffer<PendingExit>();
    1.55 +            pendingExits = new ListBuffer<>();
    1.56              lint = lint.augment(tree.sym);
    1.57  
    1.58              try {
    1.59 @@ -513,7 +513,7 @@
    1.60                      log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt");
    1.61  
    1.62                  List<PendingExit> exits = pendingExits.toList();
    1.63 -                pendingExits = new ListBuffer<PendingExit>();
    1.64 +                pendingExits = new ListBuffer<>();
    1.65                  while (exits.nonEmpty()) {
    1.66                      PendingExit exit = exits.head;
    1.67                      exits = exits.tail;
    1.68 @@ -542,7 +542,7 @@
    1.69  
    1.70          public void visitDoLoop(JCDoWhileLoop tree) {
    1.71              ListBuffer<PendingExit> prevPendingExits = pendingExits;
    1.72 -            pendingExits = new ListBuffer<PendingExit>();
    1.73 +            pendingExits = new ListBuffer<>();
    1.74              scanStat(tree.body);
    1.75              alive |= resolveContinues(tree);
    1.76              scan(tree.cond);
    1.77 @@ -552,7 +552,7 @@
    1.78  
    1.79          public void visitWhileLoop(JCWhileLoop tree) {
    1.80              ListBuffer<PendingExit> prevPendingExits = pendingExits;
    1.81 -            pendingExits = new ListBuffer<PendingExit>();
    1.82 +            pendingExits = new ListBuffer<>();
    1.83              scan(tree.cond);
    1.84              alive = !tree.cond.type.isFalse();
    1.85              scanStat(tree.body);
    1.86 @@ -564,7 +564,7 @@
    1.87          public void visitForLoop(JCForLoop tree) {
    1.88              ListBuffer<PendingExit> prevPendingExits = pendingExits;
    1.89              scanStats(tree.init);
    1.90 -            pendingExits = new ListBuffer<PendingExit>();
    1.91 +            pendingExits = new ListBuffer<>();
    1.92              if (tree.cond != null) {
    1.93                  scan(tree.cond);
    1.94                  alive = !tree.cond.type.isFalse();
    1.95 @@ -582,7 +582,7 @@
    1.96              visitVarDef(tree.var);
    1.97              ListBuffer<PendingExit> prevPendingExits = pendingExits;
    1.98              scan(tree.expr);
    1.99 -            pendingExits = new ListBuffer<PendingExit>();
   1.100 +            pendingExits = new ListBuffer<>();
   1.101              scanStat(tree.body);
   1.102              alive |= resolveContinues(tree);
   1.103              resolveBreaks(tree, prevPendingExits);
   1.104 @@ -591,14 +591,14 @@
   1.105  
   1.106          public void visitLabelled(JCLabeledStatement tree) {
   1.107              ListBuffer<PendingExit> prevPendingExits = pendingExits;
   1.108 -            pendingExits = new ListBuffer<PendingExit>();
   1.109 +            pendingExits = new ListBuffer<>();
   1.110              scanStat(tree.body);
   1.111              alive |= resolveBreaks(tree, prevPendingExits);
   1.112          }
   1.113  
   1.114          public void visitSwitch(JCSwitch tree) {
   1.115              ListBuffer<PendingExit> prevPendingExits = pendingExits;
   1.116 -            pendingExits = new ListBuffer<PendingExit>();
   1.117 +            pendingExits = new ListBuffer<>();
   1.118              scan(tree.selector);
   1.119              boolean hasDefault = false;
   1.120              for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
   1.121 @@ -625,7 +625,7 @@
   1.122  
   1.123          public void visitTry(JCTry tree) {
   1.124              ListBuffer<PendingExit> prevPendingExits = pendingExits;
   1.125 -            pendingExits = new ListBuffer<PendingExit>();
   1.126 +            pendingExits = new ListBuffer<>();
   1.127              for (JCTree resource : tree.resources) {
   1.128                  if (resource instanceof JCVariableDecl) {
   1.129                      JCVariableDecl vdecl = (JCVariableDecl) resource;
   1.130 @@ -688,21 +688,21 @@
   1.131          }
   1.132  
   1.133          public void visitBreak(JCBreak tree) {
   1.134 -            recordExit(tree, new PendingExit(tree));
   1.135 +            recordExit(new PendingExit(tree));
   1.136          }
   1.137  
   1.138          public void visitContinue(JCContinue tree) {
   1.139 -            recordExit(tree, new PendingExit(tree));
   1.140 +            recordExit(new PendingExit(tree));
   1.141          }
   1.142  
   1.143          public void visitReturn(JCReturn tree) {
   1.144              scan(tree.expr);
   1.145 -            recordExit(tree, new PendingExit(tree));
   1.146 +            recordExit(new PendingExit(tree));
   1.147          }
   1.148  
   1.149          public void visitThrow(JCThrow tree) {
   1.150              scan(tree.expr);
   1.151 -            markDead(tree);
   1.152 +            markDead();
   1.153          }
   1.154  
   1.155          public void visitApply(JCMethodInvocation tree) {
   1.156 @@ -756,7 +756,7 @@
   1.157              try {
   1.158                  attrEnv = env;
   1.159                  Flow.this.make = make;
   1.160 -                pendingExits = new ListBuffer<PendingExit>();
   1.161 +                pendingExits = new ListBuffer<>();
   1.162                  alive = true;
   1.163                  scan(tree);
   1.164              } finally {
   1.165 @@ -803,7 +803,7 @@
   1.166          }
   1.167  
   1.168          @Override
   1.169 -        void markDead(JCTree tree) {
   1.170 +        void markDead() {
   1.171              //do nothing
   1.172          }
   1.173  
   1.174 @@ -1201,16 +1201,16 @@
   1.175              }
   1.176  
   1.177          public void visitBreak(JCBreak tree) {
   1.178 -            recordExit(tree, new FlowPendingExit(tree, null));
   1.179 +            recordExit(new FlowPendingExit(tree, null));
   1.180          }
   1.181  
   1.182          public void visitContinue(JCContinue tree) {
   1.183 -            recordExit(tree, new FlowPendingExit(tree, null));
   1.184 +            recordExit(new FlowPendingExit(tree, null));
   1.185          }
   1.186  
   1.187          public void visitReturn(JCReturn tree) {
   1.188              scan(tree.expr);
   1.189 -            recordExit(tree, new FlowPendingExit(tree, null));
   1.190 +            recordExit(new FlowPendingExit(tree, null));
   1.191          }
   1.192  
   1.193          public void visitThrow(JCThrow tree) {
   1.194 @@ -1228,7 +1228,7 @@
   1.195              else {
   1.196                  markThrown(tree, tree.expr.type);
   1.197              }
   1.198 -            markDead(tree);
   1.199 +            markDead();
   1.200          }
   1.201  
   1.202          public void visitApply(JCMethodInvocation tree) {
   1.203 @@ -1379,12 +1379,10 @@
   1.204       * effectively-final local variables/parameters.
   1.205       */
   1.206  
   1.207 -    public abstract class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer<P>.AbstractAssignPendingExit>
   1.208 -        extends BaseAnalyzer<P> {
   1.209 -
   1.210 +    public class AssignAnalyzer extends BaseAnalyzer<AssignAnalyzer.AssignPendingExit> {
   1.211          /** The set of definitely assigned variables.
   1.212           */
   1.213 -        protected Bits inits;
   1.214 +        final Bits inits;
   1.215  
   1.216          /** The set of definitely unassigned variables.
   1.217           */
   1.218 @@ -1432,20 +1430,20 @@
   1.219           */
   1.220          Scope unrefdResources;
   1.221  
   1.222 -        /** Set when processing a loop body the second time for DU analysis. */
   1.223 +        /** Modified when processing a loop body the second time for DU analysis. */
   1.224          FlowKind flowKind = FlowKind.NORMAL;
   1.225  
   1.226 -        /** The starting position of the analysed tree */
   1.227 +        /** The starting position of the analyzed tree */
   1.228          int startPos;
   1.229  
   1.230 -        public class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit {
   1.231 +        public class AssignPendingExit extends BaseAnalyzer.PendingExit {
   1.232  
   1.233              final Bits inits;
   1.234              final Bits uninits;
   1.235              final Bits exit_inits = new Bits(true);
   1.236              final Bits exit_uninits = new Bits(true);
   1.237  
   1.238 -            public AbstractAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
   1.239 +            public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
   1.240                  super(tree);
   1.241                  this.inits = inits;
   1.242                  this.uninits = uninits;
   1.243 @@ -1454,13 +1452,13 @@
   1.244              }
   1.245  
   1.246              @Override
   1.247 -            public void resolveJump(JCTree tree) {
   1.248 +            void resolveJump() {
   1.249                  inits.andSet(exit_inits);
   1.250                  uninits.andSet(exit_uninits);
   1.251              }
   1.252          }
   1.253  
   1.254 -        public AbstractAssignAnalyzer() {
   1.255 +        public AssignAnalyzer() {
   1.256              this.inits = new Bits();
   1.257              uninits = new Bits();
   1.258              uninitsTry = new Bits();
   1.259 @@ -1473,7 +1471,7 @@
   1.260          private boolean isInitialConstructor = false;
   1.261  
   1.262          @Override
   1.263 -        protected void markDead(JCTree tree) {
   1.264 +         void markDead() {
   1.265              if (!isInitialConstructor) {
   1.266                  inits.inclRange(returnadr, nextadr);
   1.267              } else {
   1.268 @@ -1520,35 +1518,41 @@
   1.269              }
   1.270              sym.adr = nextadr;
   1.271              vardecls[nextadr] = varDecl;
   1.272 -            exclVarFromInits(varDecl, nextadr);
   1.273 +            inits.excl(nextadr);
   1.274              uninits.incl(nextadr);
   1.275              nextadr++;
   1.276          }
   1.277  
   1.278 -        protected void exclVarFromInits(JCTree tree, int adr) {
   1.279 -            inits.excl(adr);
   1.280 -        }
   1.281 -
   1.282 -        protected void assignToInits(JCTree tree, Bits bits) {
   1.283 -            inits.assign(bits);
   1.284 -        }
   1.285 -
   1.286 -        protected void andSetInits(JCTree tree, Bits bits) {
   1.287 -            inits.andSet(bits);
   1.288 -        }
   1.289 -
   1.290 -        protected void orSetInits(JCTree tree, Bits bits) {
   1.291 -            inits.orSet(bits);
   1.292 -        }
   1.293 -
   1.294          /** Record an initialization of a trackable variable.
   1.295           */
   1.296          void letInit(DiagnosticPosition pos, VarSymbol sym) {
   1.297              if (sym.adr >= firstadr && trackable(sym)) {
   1.298 -                if (uninits.isMember(sym.adr)) {
   1.299 -                    uninit(sym);
   1.300 +                if ((sym.flags() & EFFECTIVELY_FINAL) != 0) {
   1.301 +                    if (!uninits.isMember(sym.adr)) {
   1.302 +                        //assignment targeting an effectively final variable
   1.303 +                        //makes the variable lose its status of effectively final
   1.304 +                        //if the variable is _not_ definitively unassigned
   1.305 +                        sym.flags_field &= ~EFFECTIVELY_FINAL;
   1.306 +                    } else {
   1.307 +                        uninit(sym);
   1.308 +                    }
   1.309 +                } else if ((sym.flags() & FINAL) != 0) {
   1.310 +                    if ((sym.flags() & PARAMETER) != 0) {
   1.311 +                        if ((sym.flags() & UNION) != 0) { //multi-catch parameter
   1.312 +                            log.error(pos, "multicatch.parameter.may.not.be.assigned", sym);
   1.313 +                        } else {
   1.314 +                            log.error(pos, "final.parameter.may.not.be.assigned",
   1.315 +                                  sym);
   1.316 +                        }
   1.317 +                    } else if (!uninits.isMember(sym.adr)) {
   1.318 +                        log.error(pos, flowKind.errKey, sym);
   1.319 +                    } else {
   1.320 +                        uninit(sym);
   1.321 +                    }
   1.322                  }
   1.323                  inits.incl(sym.adr);
   1.324 +            } else if ((sym.flags() & FINAL) != 0) {
   1.325 +                log.error(pos, "var.might.already.be.assigned", sym);
   1.326              }
   1.327          }
   1.328          //where
   1.329 @@ -1583,7 +1587,14 @@
   1.330              checkInit(pos, sym, "var.might.not.have.been.initialized");
   1.331          }
   1.332  
   1.333 -        void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {}
   1.334 +        void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {
   1.335 +            if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
   1.336 +                trackable(sym) &&
   1.337 +                !inits.isMember(sym.adr)) {
   1.338 +                log.error(pos, errkey, sym);
   1.339 +                inits.incl(sym.adr);
   1.340 +            }
   1.341 +        }
   1.342  
   1.343          /** Utility method to reset several Bits instances.
   1.344           */
   1.345 @@ -1607,7 +1618,7 @@
   1.346  
   1.347          /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets.
   1.348           */
   1.349 -        protected void merge(JCTree tree) {
   1.350 +        protected void merge() {
   1.351              inits.assign(initsWhenFalse.andSet(initsWhenTrue));
   1.352              uninits.assign(uninitsWhenFalse.andSet(uninitsWhenTrue));
   1.353          }
   1.354 @@ -1623,7 +1634,7 @@
   1.355              if (tree != null) {
   1.356                  scan(tree);
   1.357                  if (inits.isReset()) {
   1.358 -                    merge(tree);
   1.359 +                    merge();
   1.360                  }
   1.361              }
   1.362          }
   1.363 @@ -1641,7 +1652,7 @@
   1.364           */
   1.365          void scanCond(JCTree tree) {
   1.366              if (tree.type.isFalse()) {
   1.367 -                if (inits.isReset()) merge(tree);
   1.368 +                if (inits.isReset()) merge();
   1.369                  initsWhenTrue.assign(inits);
   1.370                  initsWhenTrue.inclRange(firstadr, nextadr);
   1.371                  uninitsWhenTrue.assign(uninits);
   1.372 @@ -1649,7 +1660,7 @@
   1.373                  initsWhenFalse.assign(inits);
   1.374                  uninitsWhenFalse.assign(uninits);
   1.375              } else if (tree.type.isTrue()) {
   1.376 -                if (inits.isReset()) merge(tree);
   1.377 +                if (inits.isReset()) merge();
   1.378                  initsWhenFalse.assign(inits);
   1.379                  initsWhenFalse.inclRange(firstadr, nextadr);
   1.380                  uninitsWhenFalse.assign(uninits);
   1.381 @@ -1668,173 +1679,202 @@
   1.382  
   1.383          /* ------------ Visitor methods for various sorts of trees -------------*/
   1.384  
   1.385 -        @Override
   1.386          public void visitClassDef(JCClassDecl tree) {
   1.387              if (tree.sym == null) {
   1.388                  return;
   1.389              }
   1.390  
   1.391 -            JCClassDecl classDefPrev = classDef;
   1.392 -            int firstadrPrev = firstadr;
   1.393 -            int nextadrPrev = nextadr;
   1.394 -            ListBuffer<P> pendingExitsPrev = pendingExits;
   1.395 +            Lint lintPrev = lint;
   1.396 +            lint = lint.augment(tree.sym);
   1.397 +            try {
   1.398 +                if (tree.sym == null) {
   1.399 +                    return;
   1.400 +                }
   1.401  
   1.402 -            pendingExits = new ListBuffer<P>();
   1.403 -            if (tree.name != names.empty) {
   1.404 -                firstadr = nextadr;
   1.405 -            }
   1.406 -            classDef = tree;
   1.407 -            try {
   1.408 -                // define all the static fields
   1.409 -                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.410 -                    if (l.head.hasTag(VARDEF)) {
   1.411 -                        JCVariableDecl def = (JCVariableDecl)l.head;
   1.412 -                        if ((def.mods.flags & STATIC) != 0) {
   1.413 -                            VarSymbol sym = def.sym;
   1.414 -                            if (trackable(sym)) {
   1.415 -                                newVar(def);
   1.416 +                JCClassDecl classDefPrev = classDef;
   1.417 +                int firstadrPrev = firstadr;
   1.418 +                int nextadrPrev = nextadr;
   1.419 +                ListBuffer<AssignPendingExit> pendingExitsPrev = pendingExits;
   1.420 +
   1.421 +                pendingExits = new ListBuffer<>();
   1.422 +                if (tree.name != names.empty) {
   1.423 +                    firstadr = nextadr;
   1.424 +                }
   1.425 +                classDef = tree;
   1.426 +                try {
   1.427 +                    // define all the static fields
   1.428 +                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.429 +                        if (l.head.hasTag(VARDEF)) {
   1.430 +                            JCVariableDecl def = (JCVariableDecl)l.head;
   1.431 +                            if ((def.mods.flags & STATIC) != 0) {
   1.432 +                                VarSymbol sym = def.sym;
   1.433 +                                if (trackable(sym)) {
   1.434 +                                    newVar(def);
   1.435 +                                }
   1.436                              }
   1.437                          }
   1.438                      }
   1.439 -                }
   1.440  
   1.441 -                // process all the static initializers
   1.442 -                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.443 -                    if (!l.head.hasTag(METHODDEF) &&
   1.444 -                        (TreeInfo.flags(l.head) & STATIC) != 0) {
   1.445 -                        scan(l.head);
   1.446 +                    // process all the static initializers
   1.447 +                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.448 +                        if (!l.head.hasTag(METHODDEF) &&
   1.449 +                            (TreeInfo.flags(l.head) & STATIC) != 0) {
   1.450 +                            scan(l.head);
   1.451 +                        }
   1.452                      }
   1.453 -                }
   1.454  
   1.455 -                // define all the instance fields
   1.456 -                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.457 -                    if (l.head.hasTag(VARDEF)) {
   1.458 -                        JCVariableDecl def = (JCVariableDecl)l.head;
   1.459 -                        if ((def.mods.flags & STATIC) == 0) {
   1.460 -                            VarSymbol sym = def.sym;
   1.461 -                            if (trackable(sym)) {
   1.462 -                                newVar(def);
   1.463 +                    // define all the instance fields
   1.464 +                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.465 +                        if (l.head.hasTag(VARDEF)) {
   1.466 +                            JCVariableDecl def = (JCVariableDecl)l.head;
   1.467 +                            if ((def.mods.flags & STATIC) == 0) {
   1.468 +                                VarSymbol sym = def.sym;
   1.469 +                                if (trackable(sym)) {
   1.470 +                                    newVar(def);
   1.471 +                                }
   1.472                              }
   1.473                          }
   1.474                      }
   1.475 -                }
   1.476 +                    // process all the instance initializers
   1.477 +                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.478 +                        if (!l.head.hasTag(METHODDEF) &&
   1.479 +                            (TreeInfo.flags(l.head) & STATIC) == 0) {
   1.480 +                            scan(l.head);
   1.481 +                        }
   1.482 +                    }
   1.483  
   1.484 -                // process all the instance initializers
   1.485 -                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.486 -                    if (!l.head.hasTag(METHODDEF) &&
   1.487 -                        (TreeInfo.flags(l.head) & STATIC) == 0) {
   1.488 -                        scan(l.head);
   1.489 +                    // process all the methods
   1.490 +                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.491 +                        if (l.head.hasTag(METHODDEF)) {
   1.492 +                            scan(l.head);
   1.493 +                        }
   1.494                      }
   1.495 -                }
   1.496 -
   1.497 -                // process all the methods
   1.498 -                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
   1.499 -                    if (l.head.hasTag(METHODDEF)) {
   1.500 -                        scan(l.head);
   1.501 -                    }
   1.502 +                } finally {
   1.503 +                    pendingExits = pendingExitsPrev;
   1.504 +                    nextadr = nextadrPrev;
   1.505 +                    firstadr = firstadrPrev;
   1.506 +                    classDef = classDefPrev;
   1.507                  }
   1.508              } finally {
   1.509 -                pendingExits = pendingExitsPrev;
   1.510 -                nextadr = nextadrPrev;
   1.511 -                firstadr = firstadrPrev;
   1.512 -                classDef = classDefPrev;
   1.513 +                lint = lintPrev;
   1.514              }
   1.515          }
   1.516  
   1.517 -        @Override
   1.518          public void visitMethodDef(JCMethodDecl tree) {
   1.519              if (tree.body == null) {
   1.520                  return;
   1.521              }
   1.522 -            /*  Ignore synthetic methods, except for translated lambda methods.
   1.523 +
   1.524 +            /*  MemberEnter can generate synthetic methods ignore them
   1.525               */
   1.526 -            if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) {
   1.527 +            if ((tree.sym.flags() & SYNTHETIC) != 0) {
   1.528                  return;
   1.529              }
   1.530  
   1.531 -            final Bits initsPrev = new Bits(inits);
   1.532 -            final Bits uninitsPrev = new Bits(uninits);
   1.533 -            int nextadrPrev = nextadr;
   1.534 -            int firstadrPrev = firstadr;
   1.535 -            int returnadrPrev = returnadr;
   1.536 +            Lint lintPrev = lint;
   1.537 +            lint = lint.augment(tree.sym);
   1.538 +            try {
   1.539 +                if (tree.body == null) {
   1.540 +                    return;
   1.541 +                }
   1.542 +                /*  Ignore synthetic methods, except for translated lambda methods.
   1.543 +                 */
   1.544 +                if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) {
   1.545 +                    return;
   1.546 +                }
   1.547  
   1.548 -            Assert.check(pendingExits.isEmpty());
   1.549 -            boolean lastInitialConstructor = isInitialConstructor;
   1.550 -            try {
   1.551 -                isInitialConstructor = TreeInfo.isInitialConstructor(tree);
   1.552 +                final Bits initsPrev = new Bits(inits);
   1.553 +                final Bits uninitsPrev = new Bits(uninits);
   1.554 +                int nextadrPrev = nextadr;
   1.555 +                int firstadrPrev = firstadr;
   1.556 +                int returnadrPrev = returnadr;
   1.557  
   1.558 -                if (!isInitialConstructor) {
   1.559 -                    firstadr = nextadr;
   1.560 -                }
   1.561 -                for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
   1.562 -                    JCVariableDecl def = l.head;
   1.563 -                    scan(def);
   1.564 -                    Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag");
   1.565 -                    /*  If we are executing the code from Gen, then there can be
   1.566 -                     *  synthetic or mandated variables, ignore them.
   1.567 -                     */
   1.568 -                    initParam(def);
   1.569 -                }
   1.570 -                // else we are in an instance initializer block;
   1.571 -                // leave caught unchanged.
   1.572 -                scan(tree.body);
   1.573 +                Assert.check(pendingExits.isEmpty());
   1.574 +                boolean lastInitialConstructor = isInitialConstructor;
   1.575 +                try {
   1.576 +                    isInitialConstructor = TreeInfo.isInitialConstructor(tree);
   1.577  
   1.578 -                if (isInitialConstructor) {
   1.579 -                    boolean isSynthesized = (tree.sym.flags() &
   1.580 -                                             GENERATEDCONSTR) != 0;
   1.581 -                    for (int i = firstadr; i < nextadr; i++) {
   1.582 -                        JCVariableDecl vardecl = vardecls[i];
   1.583 -                        VarSymbol var = vardecl.sym;
   1.584 -                        if (var.owner == classDef.sym) {
   1.585 -                            // choose the diagnostic position based on whether
   1.586 -                            // the ctor is default(synthesized) or not
   1.587 -                            if (isSynthesized) {
   1.588 -                                checkInit(TreeInfo.diagnosticPositionFor(var, vardecl),
   1.589 -                                    var, "var.not.initialized.in.default.constructor");
   1.590 -                            } else {
   1.591 -                                checkInit(TreeInfo.diagEndPos(tree.body), var);
   1.592 +                    if (!isInitialConstructor) {
   1.593 +                        firstadr = nextadr;
   1.594 +                    }
   1.595 +                    for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
   1.596 +                        JCVariableDecl def = l.head;
   1.597 +                        scan(def);
   1.598 +                        Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag");
   1.599 +                        /*  If we are executing the code from Gen, then there can be
   1.600 +                         *  synthetic or mandated variables, ignore them.
   1.601 +                         */
   1.602 +                        initParam(def);
   1.603 +                    }
   1.604 +                    // else we are in an instance initializer block;
   1.605 +                    // leave caught unchanged.
   1.606 +                    scan(tree.body);
   1.607 +
   1.608 +                    if (isInitialConstructor) {
   1.609 +                        boolean isSynthesized = (tree.sym.flags() &
   1.610 +                                                 GENERATEDCONSTR) != 0;
   1.611 +                        for (int i = firstadr; i < nextadr; i++) {
   1.612 +                            JCVariableDecl vardecl = vardecls[i];
   1.613 +                            VarSymbol var = vardecl.sym;
   1.614 +                            if (var.owner == classDef.sym) {
   1.615 +                                // choose the diagnostic position based on whether
   1.616 +                                // the ctor is default(synthesized) or not
   1.617 +                                if (isSynthesized) {
   1.618 +                                    checkInit(TreeInfo.diagnosticPositionFor(var, vardecl),
   1.619 +                                        var, "var.not.initialized.in.default.constructor");
   1.620 +                                } else {
   1.621 +                                    checkInit(TreeInfo.diagEndPos(tree.body), var);
   1.622 +                                }
   1.623                              }
   1.624                          }
   1.625                      }
   1.626 -                }
   1.627 -                List<P> exits = pendingExits.toList();
   1.628 -                pendingExits = new ListBuffer<>();
   1.629 -                while (exits.nonEmpty()) {
   1.630 -                    P exit = exits.head;
   1.631 -                    exits = exits.tail;
   1.632 -                    Assert.check(exit.tree.hasTag(RETURN), exit.tree);
   1.633 -                    if (isInitialConstructor) {
   1.634 -                        assignToInits(exit.tree, exit.exit_inits);
   1.635 -                        for (int i = firstadr; i < nextadr; i++) {
   1.636 -                            checkInit(exit.tree.pos(), vardecls[i].sym);
   1.637 +                    List<AssignPendingExit> exits = pendingExits.toList();
   1.638 +                    pendingExits = new ListBuffer<>();
   1.639 +                    while (exits.nonEmpty()) {
   1.640 +                        AssignPendingExit exit = exits.head;
   1.641 +                        exits = exits.tail;
   1.642 +                        Assert.check(exit.tree.hasTag(RETURN), exit.tree);
   1.643 +                        if (isInitialConstructor) {
   1.644 +                            inits.assign(exit.exit_inits);
   1.645 +                            for (int i = firstadr; i < nextadr; i++) {
   1.646 +                                checkInit(exit.tree.pos(), vardecls[i].sym);
   1.647 +                            }
   1.648                          }
   1.649                      }
   1.650 +                } finally {
   1.651 +                    inits.assign(initsPrev);
   1.652 +                    uninits.assign(uninitsPrev);
   1.653 +                    nextadr = nextadrPrev;
   1.654 +                    firstadr = firstadrPrev;
   1.655 +                    returnadr = returnadrPrev;
   1.656 +                    isInitialConstructor = lastInitialConstructor;
   1.657                  }
   1.658              } finally {
   1.659 -                assignToInits(tree, initsPrev);
   1.660 -                uninits.assign(uninitsPrev);
   1.661 -                nextadr = nextadrPrev;
   1.662 -                firstadr = firstadrPrev;
   1.663 -                returnadr = returnadrPrev;
   1.664 -                isInitialConstructor = lastInitialConstructor;
   1.665 +                lint = lintPrev;
   1.666              }
   1.667          }
   1.668  
   1.669          protected void initParam(JCVariableDecl def) {
   1.670              inits.incl(def.sym.adr);
   1.671              uninits.excl(def.sym.adr);
   1.672 -            }
   1.673 +        }
   1.674  
   1.675          public void visitVarDef(JCVariableDecl tree) {
   1.676 -            boolean track = trackable(tree.sym);
   1.677 -            if (track && tree.sym.owner.kind == MTH) {
   1.678 -                newVar(tree);
   1.679 -            }
   1.680 -            if (tree.init != null) {
   1.681 -                scanExpr(tree.init);
   1.682 -                if (track) {
   1.683 -                    letInit(tree.pos(), tree.sym);
   1.684 +            Lint lintPrev = lint;
   1.685 +            lint = lint.augment(tree.sym);
   1.686 +            try{
   1.687 +                boolean track = trackable(tree.sym);
   1.688 +                if (track && tree.sym.owner.kind == MTH) {
   1.689 +                    newVar(tree);
   1.690                  }
   1.691 +                if (tree.init != null) {
   1.692 +                    scanExpr(tree.init);
   1.693 +                    if (track) {
   1.694 +                        letInit(tree.pos(), tree.sym);
   1.695 +                    }
   1.696 +                }
   1.697 +            } finally {
   1.698 +                lint = lintPrev;
   1.699              }
   1.700          }
   1.701  
   1.702 @@ -1844,18 +1884,14 @@
   1.703              nextadr = nextadrPrev;
   1.704          }
   1.705  
   1.706 -        int getLogNumberOfErrors() {
   1.707 -            return 0;
   1.708 -        }
   1.709 -
   1.710          public void visitDoLoop(JCDoWhileLoop tree) {
   1.711 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.712 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.713              FlowKind prevFlowKind = flowKind;
   1.714              flowKind = FlowKind.NORMAL;
   1.715              final Bits initsSkip = new Bits(true);
   1.716              final Bits uninitsSkip = new Bits(true);
   1.717 -            pendingExits = new ListBuffer<P>();
   1.718 -            int prevErrors = getLogNumberOfErrors();
   1.719 +            pendingExits = new ListBuffer<>();
   1.720 +            int prevErrors = log.nerrors;
   1.721              do {
   1.722                  final Bits uninitsEntry = new Bits(uninits);
   1.723                  uninitsEntry.excludeFrom(nextadr);
   1.724 @@ -1866,28 +1902,28 @@
   1.725                      initsSkip.assign(initsWhenFalse);
   1.726                      uninitsSkip.assign(uninitsWhenFalse);
   1.727                  }
   1.728 -                if (getLogNumberOfErrors() !=  prevErrors ||
   1.729 +                if (log.nerrors !=  prevErrors ||
   1.730                      flowKind.isFinal() ||
   1.731                      new Bits(uninitsEntry).diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
   1.732                      break;
   1.733 -                assignToInits(tree.cond, initsWhenTrue);
   1.734 +                inits.assign(initsWhenTrue);
   1.735                  uninits.assign(uninitsEntry.andSet(uninitsWhenTrue));
   1.736                  flowKind = FlowKind.SPECULATIVE_LOOP;
   1.737              } while (true);
   1.738              flowKind = prevFlowKind;
   1.739 -            assignToInits(tree, initsSkip);
   1.740 +            inits.assign(initsSkip);
   1.741              uninits.assign(uninitsSkip);
   1.742              resolveBreaks(tree, prevPendingExits);
   1.743          }
   1.744  
   1.745          public void visitWhileLoop(JCWhileLoop tree) {
   1.746 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.747 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.748              FlowKind prevFlowKind = flowKind;
   1.749              flowKind = FlowKind.NORMAL;
   1.750              final Bits initsSkip = new Bits(true);
   1.751              final Bits uninitsSkip = new Bits(true);
   1.752              pendingExits = new ListBuffer<>();
   1.753 -            int prevErrors = getLogNumberOfErrors();
   1.754 +            int prevErrors = log.nerrors;
   1.755              final Bits uninitsEntry = new Bits(uninits);
   1.756              uninitsEntry.excludeFrom(nextadr);
   1.757              do {
   1.758 @@ -1896,11 +1932,11 @@
   1.759                      initsSkip.assign(initsWhenFalse) ;
   1.760                      uninitsSkip.assign(uninitsWhenFalse);
   1.761                  }
   1.762 -                assignToInits(tree, initsWhenTrue);
   1.763 +                inits.assign(initsWhenTrue);
   1.764                  uninits.assign(uninitsWhenTrue);
   1.765                  scan(tree.body);
   1.766                  resolveContinues(tree);
   1.767 -                if (getLogNumberOfErrors() != prevErrors ||
   1.768 +                if (log.nerrors != prevErrors ||
   1.769                      flowKind.isFinal() ||
   1.770                      new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) {
   1.771                      break;
   1.772 @@ -1911,21 +1947,21 @@
   1.773              flowKind = prevFlowKind;
   1.774              //a variable is DA/DU after the while statement, if it's DA/DU assuming the
   1.775              //branch is not taken AND if it's DA/DU before any break statement
   1.776 -            assignToInits(tree.body, initsSkip);
   1.777 +            inits.assign(initsSkip);
   1.778              uninits.assign(uninitsSkip);
   1.779              resolveBreaks(tree, prevPendingExits);
   1.780          }
   1.781  
   1.782          public void visitForLoop(JCForLoop tree) {
   1.783 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.784 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.785              FlowKind prevFlowKind = flowKind;
   1.786              flowKind = FlowKind.NORMAL;
   1.787              int nextadrPrev = nextadr;
   1.788              scan(tree.init);
   1.789              final Bits initsSkip = new Bits(true);
   1.790              final Bits uninitsSkip = new Bits(true);
   1.791 -            pendingExits = new ListBuffer<P>();
   1.792 -            int prevErrors = getLogNumberOfErrors();
   1.793 +            pendingExits = new ListBuffer<>();
   1.794 +            int prevErrors = log.nerrors;
   1.795              do {
   1.796                  final Bits uninitsEntry = new Bits(uninits);
   1.797                  uninitsEntry.excludeFrom(nextadr);
   1.798 @@ -1935,7 +1971,7 @@
   1.799                          initsSkip.assign(initsWhenFalse);
   1.800                          uninitsSkip.assign(uninitsWhenFalse);
   1.801                      }
   1.802 -                    assignToInits(tree.body, initsWhenTrue);
   1.803 +                    inits.assign(initsWhenTrue);
   1.804                      uninits.assign(uninitsWhenTrue);
   1.805                  } else if (!flowKind.isFinal()) {
   1.806                      initsSkip.assign(inits);
   1.807 @@ -1946,7 +1982,7 @@
   1.808                  scan(tree.body);
   1.809                  resolveContinues(tree);
   1.810                  scan(tree.step);
   1.811 -                if (getLogNumberOfErrors() != prevErrors ||
   1.812 +                if (log.nerrors != prevErrors ||
   1.813                      flowKind.isFinal() ||
   1.814                      new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
   1.815                      break;
   1.816 @@ -1956,7 +1992,7 @@
   1.817              flowKind = prevFlowKind;
   1.818              //a variable is DA/DU after a for loop, if it's DA/DU assuming the
   1.819              //branch is not taken AND if it's DA/DU before any break statement
   1.820 -            assignToInits(tree.body, initsSkip);
   1.821 +            inits.assign(initsSkip);
   1.822              uninits.assign(uninitsSkip);
   1.823              resolveBreaks(tree, prevPendingExits);
   1.824              nextadr = nextadrPrev;
   1.825 @@ -1965,7 +2001,7 @@
   1.826          public void visitForeachLoop(JCEnhancedForLoop tree) {
   1.827              visitVarDef(tree.var);
   1.828  
   1.829 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.830 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.831              FlowKind prevFlowKind = flowKind;
   1.832              flowKind = FlowKind.NORMAL;
   1.833              int nextadrPrev = nextadr;
   1.834 @@ -1974,14 +2010,14 @@
   1.835              final Bits uninitsStart = new Bits(uninits);
   1.836  
   1.837              letInit(tree.pos(), tree.var.sym);
   1.838 -            pendingExits = new ListBuffer<P>();
   1.839 -            int prevErrors = getLogNumberOfErrors();
   1.840 +            pendingExits = new ListBuffer<>();
   1.841 +            int prevErrors = log.nerrors;
   1.842              do {
   1.843                  final Bits uninitsEntry = new Bits(uninits);
   1.844                  uninitsEntry.excludeFrom(nextadr);
   1.845                  scan(tree.body);
   1.846                  resolveContinues(tree);
   1.847 -                if (getLogNumberOfErrors() != prevErrors ||
   1.848 +                if (log.nerrors != prevErrors ||
   1.849                      flowKind.isFinal() ||
   1.850                      new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
   1.851                      break;
   1.852 @@ -1989,21 +2025,21 @@
   1.853                  flowKind = FlowKind.SPECULATIVE_LOOP;
   1.854              } while (true);
   1.855              flowKind = prevFlowKind;
   1.856 -            assignToInits(tree.body, initsStart);
   1.857 +            inits.assign(initsStart);
   1.858              uninits.assign(uninitsStart.andSet(uninits));
   1.859              resolveBreaks(tree, prevPendingExits);
   1.860              nextadr = nextadrPrev;
   1.861          }
   1.862  
   1.863          public void visitLabelled(JCLabeledStatement tree) {
   1.864 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.865 -            pendingExits = new ListBuffer<P>();
   1.866 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.867 +            pendingExits = new ListBuffer<>();
   1.868              scan(tree.body);
   1.869              resolveBreaks(tree, prevPendingExits);
   1.870          }
   1.871  
   1.872          public void visitSwitch(JCSwitch tree) {
   1.873 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.874 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.875              pendingExits = new ListBuffer<>();
   1.876              int nextadrPrev = nextadr;
   1.877              scanExpr(tree.selector);
   1.878 @@ -2011,7 +2047,7 @@
   1.879              final Bits uninitsSwitch = new Bits(uninits);
   1.880              boolean hasDefault = false;
   1.881              for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
   1.882 -                assignToInits(l.head, initsSwitch);
   1.883 +                inits.assign(initsSwitch);
   1.884                  uninits.assign(uninits.andSet(uninitsSwitch));
   1.885                  JCCase c = l.head;
   1.886                  if (c.pat == null) {
   1.887 @@ -2020,19 +2056,19 @@
   1.888                      scanExpr(c.pat);
   1.889                  }
   1.890                  if (hasDefault) {
   1.891 -                    assignToInits(null, initsSwitch);
   1.892 +                    inits.assign(initsSwitch);
   1.893                      uninits.assign(uninits.andSet(uninitsSwitch));
   1.894                  }
   1.895                  scan(c.stats);
   1.896                  addVars(c.stats, initsSwitch, uninitsSwitch);
   1.897                  if (!hasDefault) {
   1.898 -                    assignToInits(l.head.stats.last(), initsSwitch);
   1.899 +                    inits.assign(initsSwitch);
   1.900                      uninits.assign(uninits.andSet(uninitsSwitch));
   1.901                  }
   1.902                  // Warn about fall-through if lint switch fallthrough enabled.
   1.903              }
   1.904              if (!hasDefault) {
   1.905 -                andSetInits(null, initsSwitch);
   1.906 +                inits.andSet(initsSwitch);
   1.907              }
   1.908              resolveBreaks(tree, prevPendingExits);
   1.909              nextadr = nextadrPrev;
   1.910 @@ -2051,16 +2087,10 @@
   1.911                  }
   1.912              }
   1.913  
   1.914 -        boolean isEnabled(Lint.LintCategory lc) {
   1.915 -            return false;
   1.916 -        }
   1.917 -
   1.918 -        void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {}
   1.919 -
   1.920          public void visitTry(JCTry tree) {
   1.921              ListBuffer<JCVariableDecl> resourceVarDecls = new ListBuffer<>();
   1.922              final Bits uninitsTryPrev = new Bits(uninitsTry);
   1.923 -            ListBuffer<P> prevPendingExits = pendingExits;
   1.924 +            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
   1.925              pendingExits = new ListBuffer<>();
   1.926              final Bits initsTry = new Bits(inits);
   1.927              uninitsTry.assign(uninits);
   1.928 @@ -2083,10 +2113,10 @@
   1.929              int nextadrCatch = nextadr;
   1.930  
   1.931              if (!resourceVarDecls.isEmpty() &&
   1.932 -                    isEnabled(Lint.LintCategory.TRY)) {
   1.933 +                    lint.isEnabled(Lint.LintCategory.TRY)) {
   1.934                  for (JCVariableDecl resVar : resourceVarDecls) {
   1.935                      if (unrefdResources.includes(resVar.sym)) {
   1.936 -                        reportWarning(Lint.LintCategory.TRY, resVar.pos(),
   1.937 +                        log.warning(Lint.LintCategory.TRY, resVar.pos(),
   1.938                                      "try.resource.not.referenced", resVar.sym);
   1.939                          unrefdResources.remove(resVar.sym);
   1.940                      }
   1.941 @@ -2102,7 +2132,7 @@
   1.942  
   1.943              for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
   1.944                  JCVariableDecl param = l.head.param;
   1.945 -                assignToInits(tree.body, initsCatchPrev);
   1.946 +                inits.assign(initsCatchPrev);
   1.947                  uninits.assign(uninitsCatchPrev);
   1.948                  scan(param);
   1.949                  /* If this is a TWR and we are executing the code from Gen,
   1.950 @@ -2115,9 +2145,9 @@
   1.951                  nextadr = nextadrCatch;
   1.952              }
   1.953              if (tree.finalizer != null) {
   1.954 -                assignToInits(tree.finalizer, initsTry);
   1.955 +                inits.assign(initsTry);
   1.956                  uninits.assign(uninitsTry);
   1.957 -                ListBuffer<P> exits = pendingExits;
   1.958 +                ListBuffer<AssignPendingExit> exits = pendingExits;
   1.959                  pendingExits = prevPendingExits;
   1.960                  scan(tree.finalizer);
   1.961                  if (!tree.finallyCanCompleteNormally) {
   1.962 @@ -2127,19 +2157,19 @@
   1.963                      // FIX: this doesn't preserve source order of exits in catch
   1.964                      // versus finally!
   1.965                      while (exits.nonEmpty()) {
   1.966 -                        P exit = exits.next();
   1.967 +                        AssignPendingExit exit = exits.next();
   1.968                          if (exit.exit_inits != null) {
   1.969                              exit.exit_inits.orSet(inits);
   1.970                              exit.exit_uninits.andSet(uninits);
   1.971                          }
   1.972                          pendingExits.append(exit);
   1.973                      }
   1.974 -                    orSetInits(tree, initsEnd);
   1.975 +                    inits.orSet(initsEnd);
   1.976                  }
   1.977              } else {
   1.978 -                assignToInits(tree, initsEnd);
   1.979 +                inits.assign(initsEnd);
   1.980                  uninits.assign(uninitsEnd);
   1.981 -                ListBuffer<P> exits = pendingExits;
   1.982 +                ListBuffer<AssignPendingExit> exits = pendingExits;
   1.983                  pendingExits = prevPendingExits;
   1.984                  while (exits.nonEmpty()) pendingExits.append(exits.next());
   1.985              }
   1.986 @@ -2150,7 +2180,7 @@
   1.987              scanCond(tree.cond);
   1.988              final Bits initsBeforeElse = new Bits(initsWhenFalse);
   1.989              final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
   1.990 -            assignToInits(tree.cond, initsWhenTrue);
   1.991 +            inits.assign(initsWhenTrue);
   1.992              uninits.assign(uninitsWhenTrue);
   1.993              if (tree.truepart.type.hasTag(BOOLEAN) &&
   1.994                  tree.falsepart.type.hasTag(BOOLEAN)) {
   1.995 @@ -2163,7 +2193,7 @@
   1.996                  final Bits initsAfterThenWhenFalse = new Bits(initsWhenFalse);
   1.997                  final Bits uninitsAfterThenWhenTrue = new Bits(uninitsWhenTrue);
   1.998                  final Bits uninitsAfterThenWhenFalse = new Bits(uninitsWhenFalse);
   1.999 -                assignToInits(tree.truepart, initsBeforeElse);
  1.1000 +                inits.assign(initsBeforeElse);
  1.1001                  uninits.assign(uninitsBeforeElse);
  1.1002                  scanCond(tree.falsepart);
  1.1003                  initsWhenTrue.andSet(initsAfterThenWhenTrue);
  1.1004 @@ -2174,10 +2204,10 @@
  1.1005                  scanExpr(tree.truepart);
  1.1006                  final Bits initsAfterThen = new Bits(inits);
  1.1007                  final Bits uninitsAfterThen = new Bits(uninits);
  1.1008 -                assignToInits(tree.truepart, initsBeforeElse);
  1.1009 +                inits.assign(initsBeforeElse);
  1.1010                  uninits.assign(uninitsBeforeElse);
  1.1011                  scanExpr(tree.falsepart);
  1.1012 -                andSetInits(tree.falsepart, initsAfterThen);
  1.1013 +                inits.andSet(initsAfterThen);
  1.1014                  uninits.andSet(uninitsAfterThen);
  1.1015              }
  1.1016          }
  1.1017 @@ -2186,46 +2216,42 @@
  1.1018              scanCond(tree.cond);
  1.1019              final Bits initsBeforeElse = new Bits(initsWhenFalse);
  1.1020              final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
  1.1021 -            assignToInits(tree.cond, initsWhenTrue);
  1.1022 +            inits.assign(initsWhenTrue);
  1.1023              uninits.assign(uninitsWhenTrue);
  1.1024              scan(tree.thenpart);
  1.1025              if (tree.elsepart != null) {
  1.1026                  final Bits initsAfterThen = new Bits(inits);
  1.1027                  final Bits uninitsAfterThen = new Bits(uninits);
  1.1028 -                assignToInits(tree.thenpart, initsBeforeElse);
  1.1029 +                inits.assign(initsBeforeElse);
  1.1030                  uninits.assign(uninitsBeforeElse);
  1.1031                  scan(tree.elsepart);
  1.1032 -                andSetInits(tree.elsepart, initsAfterThen);
  1.1033 +                inits.andSet(initsAfterThen);
  1.1034                  uninits.andSet(uninitsAfterThen);
  1.1035              } else {
  1.1036 -                andSetInits(tree.thenpart, initsBeforeElse);
  1.1037 +                inits.andSet(initsBeforeElse);
  1.1038                  uninits.andSet(uninitsBeforeElse);
  1.1039              }
  1.1040          }
  1.1041  
  1.1042 -        protected P createNewPendingExit(JCTree tree, Bits inits, Bits uninits) {
  1.1043 -            return null;
  1.1044 -        }
  1.1045 -
  1.1046          @Override
  1.1047          public void visitBreak(JCBreak tree) {
  1.1048 -            recordExit(tree, createNewPendingExit(tree, inits, uninits));
  1.1049 +            recordExit(new AssignPendingExit(tree, inits, uninits));
  1.1050          }
  1.1051  
  1.1052          @Override
  1.1053          public void visitContinue(JCContinue tree) {
  1.1054 -            recordExit(tree, createNewPendingExit(tree, inits, uninits));
  1.1055 +            recordExit(new AssignPendingExit(tree, inits, uninits));
  1.1056          }
  1.1057  
  1.1058          @Override
  1.1059          public void visitReturn(JCReturn tree) {
  1.1060              scanExpr(tree.expr);
  1.1061 -            recordExit(tree, createNewPendingExit(tree, inits, uninits));
  1.1062 +            recordExit(new AssignPendingExit(tree, inits, uninits));
  1.1063          }
  1.1064  
  1.1065          public void visitThrow(JCThrow tree) {
  1.1066              scanExpr(tree.expr);
  1.1067 -            markDead(tree.expr);
  1.1068 +            markDead();
  1.1069          }
  1.1070  
  1.1071          public void visitApply(JCMethodInvocation tree) {
  1.1072 @@ -2244,10 +2270,10 @@
  1.1073              final Bits prevUninits = new Bits(uninits);
  1.1074              final Bits prevInits = new Bits(inits);
  1.1075              int returnadrPrev = returnadr;
  1.1076 -            ListBuffer<P> prevPending = pendingExits;
  1.1077 +            ListBuffer<AssignPendingExit> prevPending = pendingExits;
  1.1078              try {
  1.1079                  returnadr = nextadr;
  1.1080 -                pendingExits = new ListBuffer<P>();
  1.1081 +                pendingExits = new ListBuffer<>();
  1.1082                  for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
  1.1083                      JCVariableDecl def = l.head;
  1.1084                      scan(def);
  1.1085 @@ -2263,7 +2289,7 @@
  1.1086              finally {
  1.1087                  returnadr = returnadrPrev;
  1.1088                  uninits.assign(prevUninits);
  1.1089 -                assignToInits(tree, prevInits);
  1.1090 +                inits.assign(prevInits);
  1.1091                  pendingExits = prevPending;
  1.1092              }
  1.1093          }
  1.1094 @@ -2279,11 +2305,11 @@
  1.1095              scanCond(tree.cond);
  1.1096              uninitsExit.andSet(uninitsWhenTrue);
  1.1097              if (tree.detail != null) {
  1.1098 -                assignToInits(tree, initsWhenFalse);
  1.1099 +                inits.assign(initsWhenFalse);
  1.1100                  uninits.assign(uninitsWhenFalse);
  1.1101                  scanExpr(tree.detail);
  1.1102              }
  1.1103 -            assignToInits(tree, initsExit);
  1.1104 +            inits.assign(initsExit);
  1.1105              uninits.assign(uninitsExit);
  1.1106          }
  1.1107  
  1.1108 @@ -2351,7 +2377,7 @@
  1.1109                  scanCond(tree.lhs);
  1.1110                  final Bits initsWhenFalseLeft = new Bits(initsWhenFalse);
  1.1111                  final Bits uninitsWhenFalseLeft = new Bits(uninitsWhenFalse);
  1.1112 -                assignToInits(tree.lhs, initsWhenTrue);
  1.1113 +                inits.assign(initsWhenTrue);
  1.1114                  uninits.assign(uninitsWhenTrue);
  1.1115                  scanCond(tree.rhs);
  1.1116                  initsWhenFalse.andSet(initsWhenFalseLeft);
  1.1117 @@ -2361,7 +2387,7 @@
  1.1118                  scanCond(tree.lhs);
  1.1119                  final Bits initsWhenTrueLeft = new Bits(initsWhenTrue);
  1.1120                  final Bits uninitsWhenTrueLeft = new Bits(uninitsWhenTrue);
  1.1121 -                assignToInits(tree.lhs, initsWhenFalse);
  1.1122 +                inits.assign(initsWhenFalse);
  1.1123                  uninits.assign(uninitsWhenFalse);
  1.1124                  scanCond(tree.rhs);
  1.1125                  initsWhenTrue.andSet(initsWhenTrueLeft);
  1.1126 @@ -2436,136 +2462,6 @@
  1.1127          }
  1.1128      }
  1.1129  
  1.1130 -    public class AssignAnalyzer extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> {
  1.1131 -
  1.1132 -        public class AssignPendingExit extends AbstractAssignAnalyzer<AssignPendingExit>.AbstractAssignPendingExit {
  1.1133 -
  1.1134 -            public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
  1.1135 -                super(tree, inits, uninits);
  1.1136 -            }
  1.1137 -        }
  1.1138 -
  1.1139 -        @Override
  1.1140 -        protected AssignPendingExit createNewPendingExit(JCTree tree,
  1.1141 -            Bits inits, Bits uninits) {
  1.1142 -            return new AssignPendingExit(tree, inits, uninits);
  1.1143 -        }
  1.1144 -
  1.1145 -        /** Record an initialization of a trackable variable.
  1.1146 -         */
  1.1147 -        @Override
  1.1148 -        void letInit(DiagnosticPosition pos, VarSymbol sym) {
  1.1149 -            if (sym.adr >= firstadr && trackable(sym)) {
  1.1150 -                if ((sym.flags() & EFFECTIVELY_FINAL) != 0) {
  1.1151 -                    if (!uninits.isMember(sym.adr)) {
  1.1152 -                        //assignment targeting an effectively final variable
  1.1153 -                        //makes the variable lose its status of effectively final
  1.1154 -                        //if the variable is _not_ definitively unassigned
  1.1155 -                        sym.flags_field &= ~EFFECTIVELY_FINAL;
  1.1156 -                    } else {
  1.1157 -                        uninit(sym);
  1.1158 -                    }
  1.1159 -                }
  1.1160 -                else if ((sym.flags() & FINAL) != 0) {
  1.1161 -                    if ((sym.flags() & PARAMETER) != 0) {
  1.1162 -                        if ((sym.flags() & UNION) != 0) { //multi-catch parameter
  1.1163 -                            log.error(pos, "multicatch.parameter.may.not.be.assigned", sym);
  1.1164 -                        }
  1.1165 -                        else {
  1.1166 -                            log.error(pos, "final.parameter.may.not.be.assigned",
  1.1167 -                                  sym);
  1.1168 -                        }
  1.1169 -                    } else if (!uninits.isMember(sym.adr)) {
  1.1170 -                        log.error(pos, flowKind.errKey, sym);
  1.1171 -                    } else {
  1.1172 -                        uninit(sym);
  1.1173 -                    }
  1.1174 -                }
  1.1175 -                inits.incl(sym.adr);
  1.1176 -            } else if ((sym.flags() & FINAL) != 0) {
  1.1177 -                log.error(pos, "var.might.already.be.assigned", sym);
  1.1178 -            }
  1.1179 -        }
  1.1180 -
  1.1181 -        @Override
  1.1182 -        void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {
  1.1183 -            if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
  1.1184 -                trackable(sym) &&
  1.1185 -                !inits.isMember(sym.adr)) {
  1.1186 -                log.error(pos, errkey, sym);
  1.1187 -                inits.incl(sym.adr);
  1.1188 -            }
  1.1189 -        }
  1.1190 -
  1.1191 -        @Override
  1.1192 -        void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos,
  1.1193 -            String key, Object ... args) {
  1.1194 -            log.warning(lc, pos, key, args);
  1.1195 -        }
  1.1196 -
  1.1197 -        @Override
  1.1198 -        int getLogNumberOfErrors() {
  1.1199 -            return log.nerrors;
  1.1200 -        }
  1.1201 -
  1.1202 -        @Override
  1.1203 -        boolean isEnabled(Lint.LintCategory lc) {
  1.1204 -            return lint.isEnabled(lc);
  1.1205 -        }
  1.1206 -
  1.1207 -        @Override
  1.1208 -        public void visitClassDef(JCClassDecl tree) {
  1.1209 -            if (tree.sym == null) {
  1.1210 -                return;
  1.1211 -            }
  1.1212 -
  1.1213 -            Lint lintPrev = lint;
  1.1214 -            lint = lint.augment(tree.sym);
  1.1215 -            try {
  1.1216 -                super.visitClassDef(tree);
  1.1217 -            } finally {
  1.1218 -                lint = lintPrev;
  1.1219 -            }
  1.1220 -        }
  1.1221 -
  1.1222 -        @Override
  1.1223 -        public void visitMethodDef(JCMethodDecl tree) {
  1.1224 -            if (tree.body == null) {
  1.1225 -                return;
  1.1226 -            }
  1.1227 -
  1.1228 -            /*  MemberEnter can generate synthetic methods ignore them
  1.1229 -             */
  1.1230 -            if ((tree.sym.flags() & SYNTHETIC) != 0) {
  1.1231 -                return;
  1.1232 -            }
  1.1233 -
  1.1234 -            Lint lintPrev = lint;
  1.1235 -            lint = lint.augment(tree.sym);
  1.1236 -            try {
  1.1237 -                super.visitMethodDef(tree);
  1.1238 -            } finally {
  1.1239 -                lint = lintPrev;
  1.1240 -            }
  1.1241 -        }
  1.1242 -
  1.1243 -        @Override
  1.1244 -        public void visitVarDef(JCVariableDecl tree) {
  1.1245 -            if (tree.init == null) {
  1.1246 -                super.visitVarDef(tree);
  1.1247 -            } else {
  1.1248 -                Lint lintPrev = lint;
  1.1249 -                lint = lint.augment(tree.sym);
  1.1250 -                try{
  1.1251 -                    super.visitVarDef(tree);
  1.1252 -                } finally {
  1.1253 -                    lint = lintPrev;
  1.1254 -                }
  1.1255 -            }
  1.1256 -        }
  1.1257 -
  1.1258 -    }
  1.1259 -
  1.1260      /**
  1.1261       * This pass implements the last step of the dataflow analysis, namely
  1.1262       * the effectively-final analysis check. This checks that every local variable
  1.1263 @@ -2578,7 +2474,7 @@
  1.1264          JCTree currentTree; //local class or lambda
  1.1265  
  1.1266          @Override
  1.1267 -        void markDead(JCTree tree) {
  1.1268 +        void markDead() {
  1.1269              //do nothing
  1.1270          }
  1.1271  
  1.1272 @@ -2715,7 +2611,7 @@
  1.1273              try {
  1.1274                  attrEnv = env;
  1.1275                  Flow.this.make = make;
  1.1276 -                pendingExits = new ListBuffer<PendingExit>();
  1.1277 +                pendingExits = new ListBuffer<>();
  1.1278                  scan(tree);
  1.1279              } finally {
  1.1280                  pendingExits = null;
     2.1 --- a/src/share/classes/com/sun/tools/javac/util/Bits.java	Fri Jun 12 18:44:36 2015 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/util/Bits.java	Mon Jun 15 10:10:16 2015 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -84,20 +84,6 @@
    2.11  
    2.12      }
    2.13  
    2.14 -    public enum BitsOpKind {
    2.15 -        INIT,
    2.16 -        CLEAR,
    2.17 -        INCL_BIT,
    2.18 -        EXCL_BIT,
    2.19 -        ASSIGN,
    2.20 -        AND_SET,
    2.21 -        OR_SET,
    2.22 -        DIFF_SET,
    2.23 -        XOR_SET,
    2.24 -        INCL_RANGE,
    2.25 -        EXCL_RANGE,
    2.26 -    }
    2.27 -
    2.28      private final static int wordlen = 32;
    2.29      private final static int wordshift = 5;
    2.30      private final static int wordmask = wordlen - 1;

mercurial