src/share/classes/com/sun/tools/javac/parser/JavacParser.java

changeset 840
7f8794f9cc14
parent 831
812c6251ea78
child 850
2ab47c4cd618
     1.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Jan 24 16:38:56 2011 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Jan 25 17:02:56 2011 -0800
     1.3 @@ -142,7 +142,7 @@
     1.4       */
     1.5      boolean allowAnnotations;
     1.6  
     1.7 -    /** Switch: should we recognize automatic resource management?
     1.8 +    /** Switch: should we recognize try-with-resources?
     1.9       */
    1.10      boolean allowTWR;
    1.11  
    1.12 @@ -2184,29 +2184,23 @@
    1.13          while (S.token() == SEMI) {
    1.14              // All but last of multiple declarators subsume a semicolon
    1.15              storeEnd(defs.elems.last(), S.endPos());
    1.16 +            int semiColonPos = S.pos();
    1.17              S.nextToken();
    1.18 +            if (S.token() == RPAREN) { // Illegal trailing semicolon
    1.19 +                                       // after last resource
    1.20 +                error(semiColonPos, "try.resource.trailing.semi");
    1.21 +                break;
    1.22 +            }
    1.23              defs.append(resource());
    1.24          }
    1.25          return defs.toList();
    1.26      }
    1.27  
    1.28 -    /** Resource =
    1.29 -     *    VariableModifiers Type VariableDeclaratorId = Expression
    1.30 -     *  | Expression
    1.31 +    /** Resource = VariableModifiersOpt Type VariableDeclaratorId = Expression
    1.32       */
    1.33      JCTree resource() {
    1.34 -        int pos = S.pos();
    1.35 -        if (S.token() == FINAL || S.token() == MONKEYS_AT) {
    1.36 -            return variableDeclaratorRest(pos, optFinal(0), parseType(),
    1.37 -                                          ident(), true, null);
    1.38 -        } else {
    1.39 -            JCExpression t = term(EXPR | TYPE);
    1.40 -            if ((lastmode & TYPE) != 0 && S.token() == IDENTIFIER)
    1.41 -                return variableDeclaratorRest(pos, toP(F.at(pos).Modifiers(Flags.FINAL)), t,
    1.42 -                                              ident(), true, null);
    1.43 -            else
    1.44 -                return t;
    1.45 -        }
    1.46 +        return variableDeclaratorRest(S.pos(), optFinal(Flags.FINAL),
    1.47 +                                      parseType(), ident(), true, null);
    1.48      }
    1.49  
    1.50      /** CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}

mercurial