< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java

Print this page

2518                 if (resource instanceof JCVariableDecl variableDecl) {
2519                     visitVarDef(variableDecl);
2520                     unrefdResources.enter(variableDecl.sym);
2521                     resourceVarDecls.append(variableDecl);
2522                 } else if (resource instanceof JCExpression expression) {
2523                     scanExpr(expression);
2524                 } else {
2525                     throw new AssertionError(tree);  // parser error
2526                 }
2527             }
2528             scan(tree.body);
2529             uninitsTry.andSet(uninits);
2530             final Bits initsEnd = new Bits(inits);
2531             final Bits uninitsEnd = new Bits(uninits);
2532             int nextadrCatch = nextadr;
2533 
2534             if (!resourceVarDecls.isEmpty() &&
2535                     lint.isEnabled(Lint.LintCategory.TRY)) {
2536                 for (JCVariableDecl resVar : resourceVarDecls) {
2537                     if (unrefdResources.includes(resVar.sym)) {
2538                         log.warning(Lint.LintCategory.TRY, resVar.pos(),



2539                                     Warnings.TryResourceNotReferenced(resVar.sym));

2540                         unrefdResources.remove(resVar.sym);
2541                     }
2542                 }
2543             }
2544 
2545             /*  The analysis of each catch should be independent.
2546              *  Each one should have the same initial values of inits and
2547              *  uninits.
2548              */
2549             final Bits initsCatchPrev = new Bits(initsTry);
2550             final Bits uninitsCatchPrev = new Bits(uninitsTry);
2551 
2552             for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
2553                 JCVariableDecl param = l.head.param;
2554                 inits.assign(initsCatchPrev);
2555                 uninits.assign(uninitsCatchPrev);
2556                 scan(param);
2557                 /* If this is a TWR and we are executing the code from Gen,
2558                  * then there can be synthetic variables, ignore them.
2559                  */

2518                 if (resource instanceof JCVariableDecl variableDecl) {
2519                     visitVarDef(variableDecl);
2520                     unrefdResources.enter(variableDecl.sym);
2521                     resourceVarDecls.append(variableDecl);
2522                 } else if (resource instanceof JCExpression expression) {
2523                     scanExpr(expression);
2524                 } else {
2525                     throw new AssertionError(tree);  // parser error
2526                 }
2527             }
2528             scan(tree.body);
2529             uninitsTry.andSet(uninits);
2530             final Bits initsEnd = new Bits(inits);
2531             final Bits uninitsEnd = new Bits(uninits);
2532             int nextadrCatch = nextadr;
2533 
2534             if (!resourceVarDecls.isEmpty() &&
2535                     lint.isEnabled(Lint.LintCategory.TRY)) {
2536                 for (JCVariableDecl resVar : resourceVarDecls) {
2537                     if (unrefdResources.includes(resVar.sym)) {
2538                         // Project Loom local: we don't want to see warnings for ScopeLocalBinders.
2539                         String resVarType = resVar.vartype.toString();
2540                         if (! "java.lang.ScopeLocal.Binder".equals(resVarType)) {
2541                             log.warning(Lint.LintCategory.TRY, resVar.pos(),
2542                                     Warnings.TryResourceNotReferenced(resVar.sym));
2543                         }
2544                         unrefdResources.remove(resVar.sym);
2545                     }
2546                 }
2547             }
2548 
2549             /*  The analysis of each catch should be independent.
2550              *  Each one should have the same initial values of inits and
2551              *  uninits.
2552              */
2553             final Bits initsCatchPrev = new Bits(initsTry);
2554             final Bits uninitsCatchPrev = new Bits(uninitsTry);
2555 
2556             for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
2557                 JCVariableDecl param = l.head.param;
2558                 inits.assign(initsCatchPrev);
2559                 uninits.assign(uninitsCatchPrev);
2560                 scan(param);
2561                 /* If this is a TWR and we are executing the code from Gen,
2562                  * then there can be synthetic variables, ignore them.
2563                  */
< prev index next >