src/share/classes/com/sun/tools/javac/comp/Lower.java

changeset 2027
4932bb04c4b8
parent 2013
2de3750d65a5
child 2047
5f915a0c9615
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Sat Sep 14 15:23:21 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Sat Sep 14 19:04:47 2013 +0100
     1.3 @@ -1479,7 +1479,12 @@
     1.4       *  @param owner      The class in which the definitions go.
     1.5       */
     1.6      List<JCVariableDecl> freevarDefs(int pos, List<VarSymbol> freevars, Symbol owner) {
     1.7 -        long flags = FINAL | SYNTHETIC;
     1.8 +        return freevarDefs(pos, freevars, owner, 0);
     1.9 +    }
    1.10 +
    1.11 +    List<JCVariableDecl> freevarDefs(int pos, List<VarSymbol> freevars, Symbol owner,
    1.12 +            long additionalFlags) {
    1.13 +        long flags = FINAL | SYNTHETIC | additionalFlags;
    1.14          if (owner.kind == TYP &&
    1.15              target.usePrivateSyntheticFields())
    1.16              flags |= PRIVATE;
    1.17 @@ -1542,7 +1547,7 @@
    1.18              (owner.isConstructor() && c.isInner() &&
    1.19               !c.isPrivate() && !c.isStatic());
    1.20          long flags =
    1.21 -            FINAL | (isMandated ? MANDATED : SYNTHETIC);
    1.22 +            FINAL | (isMandated ? MANDATED : SYNTHETIC) | PARAMETER;
    1.23          VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags);
    1.24          owner.extraParams = owner.extraParams.prepend(outerThis);
    1.25          return makeOuterThisVarDecl(pos, outerThis);
    1.26 @@ -1626,7 +1631,8 @@
    1.27      JCTree makeTwrTry(JCTry tree) {
    1.28          make_at(tree.pos());
    1.29          twrVars = twrVars.dup();
    1.30 -        JCBlock twrBlock = makeTwrBlock(tree.resources, tree.body, 0);
    1.31 +        JCBlock twrBlock = makeTwrBlock(tree.resources, tree.body,
    1.32 +                tree.finallyCanCompleteNormally, 0);
    1.33          if (tree.catchers.isEmpty() && tree.finalizer == null)
    1.34              result = translate(twrBlock);
    1.35          else
    1.36 @@ -1635,7 +1641,8 @@
    1.37          return result;
    1.38      }
    1.39  
    1.40 -    private JCBlock makeTwrBlock(List<JCTree> resources, JCBlock block, int depth) {
    1.41 +    private JCBlock makeTwrBlock(List<JCTree> resources, JCBlock block,
    1.42 +            boolean finallyCanCompleteNormally, int depth) {
    1.43          if (resources.isEmpty())
    1.44              return block;
    1.45  
    1.46 @@ -1691,17 +1698,20 @@
    1.47          make.at(TreeInfo.endPos(block));
    1.48          JCBlock finallyClause = makeTwrFinallyClause(primaryException, expr);
    1.49          make.at(oldPos);
    1.50 -        JCTry outerTry = make.Try(makeTwrBlock(resources.tail, block, depth + 1),
    1.51 +        JCTry outerTry = make.Try(makeTwrBlock(resources.tail, block,
    1.52 +                                    finallyCanCompleteNormally, depth + 1),
    1.53                                    List.<JCCatch>of(catchClause),
    1.54                                    finallyClause);
    1.55 +        outerTry.finallyCanCompleteNormally = finallyCanCompleteNormally;
    1.56          stats.add(outerTry);
    1.57 -        return make.Block(0L, stats.toList());
    1.58 +        JCBlock newBlock = make.Block(0L, stats.toList());
    1.59 +        return newBlock;
    1.60      }
    1.61  
    1.62      private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) {
    1.63          // primaryException.addSuppressed(catchException);
    1.64          VarSymbol catchException =
    1.65 -            new VarSymbol(0, make.paramName(2),
    1.66 +            new VarSymbol(SYNTHETIC, make.paramName(2),
    1.67                            syms.throwableType,
    1.68                            currentMethodSym);
    1.69          JCStatement addSuppressionStatement =
    1.70 @@ -1716,6 +1726,7 @@
    1.71          JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement));
    1.72          List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock));
    1.73          JCTry tryTree = make.Try(tryBlock, catchClauses, null);
    1.74 +        tryTree.finallyCanCompleteNormally = true;
    1.75  
    1.76          // if (primaryException != null) {try...} else resourceClose;
    1.77          JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)),
    1.78 @@ -2016,7 +2027,7 @@
    1.79  
    1.80          // catchParam := ClassNotFoundException e1
    1.81          VarSymbol catchParam =
    1.82 -            new VarSymbol(0, make.paramName(1),
    1.83 +            new VarSymbol(SYNTHETIC, make.paramName(1),
    1.84                            syms.classNotFoundExceptionType,
    1.85                            classDollarSym);
    1.86  
    1.87 @@ -2704,7 +2715,7 @@
    1.88              JCVariableDecl otdef = null;
    1.89              if (currentClass.hasOuterInstance())
    1.90                  otdef = outerThisDef(tree.pos, m);
    1.91 -            List<JCVariableDecl> fvdefs = freevarDefs(tree.pos, fvs, m);
    1.92 +            List<JCVariableDecl> fvdefs = freevarDefs(tree.pos, fvs, m, PARAMETER);
    1.93  
    1.94              // Recursively translate result type, parameters and thrown list.
    1.95              tree.restype = translate(tree.restype);
    1.96 @@ -3363,18 +3374,18 @@
    1.97           */
    1.98          private void visitArrayForeachLoop(JCEnhancedForLoop tree) {
    1.99              make_at(tree.expr.pos());
   1.100 -            VarSymbol arraycache = new VarSymbol(0,
   1.101 +            VarSymbol arraycache = new VarSymbol(SYNTHETIC,
   1.102                                                   names.fromString("arr" + target.syntheticNameChar()),
   1.103                                                   tree.expr.type,
   1.104                                                   currentMethodSym);
   1.105              JCStatement arraycachedef = make.VarDef(arraycache, tree.expr);
   1.106 -            VarSymbol lencache = new VarSymbol(0,
   1.107 +            VarSymbol lencache = new VarSymbol(SYNTHETIC,
   1.108                                                 names.fromString("len" + target.syntheticNameChar()),
   1.109                                                 syms.intType,
   1.110                                                 currentMethodSym);
   1.111              JCStatement lencachedef = make.
   1.112                  VarDef(lencache, make.Select(make.Ident(arraycache), syms.lengthVar));
   1.113 -            VarSymbol index = new VarSymbol(0,
   1.114 +            VarSymbol index = new VarSymbol(SYNTHETIC,
   1.115                                              names.fromString("i" + target.syntheticNameChar()),
   1.116                                              syms.intType,
   1.117                                              currentMethodSym);
   1.118 @@ -3456,7 +3467,7 @@
   1.119                                             names.iterator,
   1.120                                             eType,
   1.121                                             List.<Type>nil());
   1.122 -            VarSymbol itvar = new VarSymbol(0, names.fromString("i" + target.syntheticNameChar()),
   1.123 +            VarSymbol itvar = new VarSymbol(SYNTHETIC, names.fromString("i" + target.syntheticNameChar()),
   1.124                                              types.erasure(types.asSuper(iterator.type.getReturnType(), syms.iteratorType.tsym)),
   1.125                                              currentMethodSym);
   1.126  

mercurial