changeset 755:b635a35cbb89

Minor syntactic changes: *) Lambda must start with the special token '#{' (no separator allowed between '#' and '{') *) 'default' keyword on extension method is now optional (compiler warns you about it)
author mcimadamore
date Mon, 29 Nov 2010 16:58:44 +0000
parents 83c22f23d80c
children 3122e07ad069
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Unlambda.java src/share/classes/com/sun/tools/javac/parser/JavacParser.java src/share/classes/com/sun/tools/javac/parser/Scanner.java src/share/classes/com/sun/tools/javac/parser/Token.java src/share/classes/com/sun/tools/javac/resources/compiler.properties test/tools/javac/defender/Neg01.java test/tools/javac/defender/Neg02.java test/tools/javac/diags/examples.not-yet.txt test/tools/javac/diags/examples/DefaultAllowedInIntfAnnotationMember.java test/tools/javac/lambda/BadLambdaToken.java test/tools/javac/lambda/BadLambdaToken.out test/tools/javac/lambda/BadOrder.java test/tools/javac/lambda/BadReturn.java test/tools/javac/lambda/BadReturn.out test/tools/javac/lambda/DefiniteAssignment01.java test/tools/javac/lambda/DeprecatedExtensionKeyword.java test/tools/javac/lambda/DeprecatedExtensionKeyword.out test/tools/javac/lambda/ExceptionTransparency02.java
diffstat 19 files changed, 173 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Nov 29 16:58:44 2010 +0000
@@ -781,11 +781,6 @@
                     (tree.mods.flags & (ABSTRACT | NATIVE)) == 0 &&
                     !relax)
                     log.error(tree.pos(), "missing.meth.body.or.decl.abstract");
-                if (tree.defaultValue != null) {
-                    if ((owner.flags() & ANNOTATION) == 0)
-                        log.error(tree.pos(),
-                                  "default.allowed.in.intf.annotation.member");
-                }
             } else if ((owner.flags() & INTERFACE) != 0 && !isDefender) {
                 log.error(tree.body.pos(), "intf.meth.cant.have.body");
             } else if ((tree.mods.flags & ABSTRACT) != 0) {
--- a/src/share/classes/com/sun/tools/javac/comp/Unlambda.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Unlambda.java	Mon Nov 29 16:58:44 2010 +0000
@@ -34,7 +34,6 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.code.Type.*;
-import org.omg.CORBA.INITIALIZE;
 
 
 /** This pass translates away lambda expressions
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Nov 29 16:58:44 2010 +0000
@@ -30,6 +30,7 @@
 
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
 import static com.sun.tools.javac.util.ListBuffer.lb;
@@ -978,7 +979,8 @@
                     return F.at(pos).Unary(unoptag(token), t);
                 }
             } else return illegal();
-            break;        
+            break;
+        case LAMBDA:
         case HASH:
             t = lambdaExpressionOrStatement();
             break;
@@ -1049,7 +1051,7 @@
                     case INTLITERAL: case LONGLITERAL: case FLOATLITERAL:
                     case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
                     case TRUE: case FALSE: case NULL:
-                        case NEW: case IDENTIFIER: case HASH: case ASSERT: case ENUM:
+                        case NEW: case IDENTIFIER: case HASH: case LAMBDA: case ASSERT: case ENUM:
                     case BYTE: case SHORT: case CHAR: case INT:
                     case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
                         JCExpression t1 = term3();
@@ -1395,17 +1397,19 @@
     JCExpression lambdaExpressionOrStatement() {
         checkLambda();
         int pos = S.pos();
-        accept(HASH);        
         return lambdaExpressionOrStatement(pos);
     }
 
     JCExpression lambdaExpressionOrStatement(int pos) {
+        if (S.token() == HASH) {
+            log.error(pos, "bad.lambda.token", LAMBDA);
+            accept(HASH);
+        }
         return lambdaExpressionOrStatement(pos, isLambdaWithArgs());
     }
 
     boolean isLambdaWithArgs() {
         S.pushState();
-        accept(LBRACE);
         boolean arrowFound = false;
         loop: while (S.token() != EOF) {
             switch (S.token()) {
@@ -1423,8 +1427,9 @@
         mode = EXPR;
         checkLambda();
         int pos2 = S.pos();
-        if (S.token() == LBRACE) {
-            accept(LBRACE);
+        if (S.token() == LBRACE ||
+                S.token() == LAMBDA) {
+            S.nextToken();
 
             List<JCVariableDecl> args = List.nil();
             if (hasArgs) {
@@ -1958,7 +1963,7 @@
         JCClassDecl body = null;
         if (S.token() == LBRACE) {
             int pos = S.pos();
-            List<JCTree> defs = classOrInterfaceBody(names.empty, false);
+            List<JCTree> defs = classOrInterfaceBody(names.empty, false, false);
             JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
             body = toP(F.at(pos).AnonymousClassDef(mods, defs));
         }
@@ -2942,7 +2947,7 @@
             S.nextToken();
             implementing = typeList();
         }
-        List<JCTree> defs = classOrInterfaceBody(name, false);
+        List<JCTree> defs = classOrInterfaceBody(name, false, false);
         JCClassDecl result = toP(F.at(pos).ClassDef(
             mods, name, typarams, extending, implementing, defs));
         attach(result, dc);
@@ -2966,7 +2971,7 @@
             S.nextToken();
             extending = typeList();
         }
-        List<JCTree> defs = classOrInterfaceBody(name, true);
+        List<JCTree> defs = classOrInterfaceBody(name, true, (mods.flags & Flags.ANNOTATION) != 0);
         JCClassDecl result = toP(F.at(pos).ClassDef(
             mods, name, typarams, null, extending, defs));
         attach(result, dc);
@@ -3022,7 +3027,7 @@
             S.nextToken();
             while (S.token() != RBRACE && S.token() != EOF) {
                 defs.appendList(classOrInterfaceBodyDeclaration(enumName,
-                                                                false));
+                                                                false, false));
                 if (S.pos() <= errorEndPos) {
                     // error recovery
                    skip(false, true, true, false);
@@ -3054,7 +3059,7 @@
         JCClassDecl body = null;
         if (S.token() == LBRACE) {
             JCModifiers mods1 = F.at(Position.NOPOS).Modifiers(Flags.ENUM | Flags.STATIC);
-            List<JCTree> defs = classOrInterfaceBody(names.empty, false);
+            List<JCTree> defs = classOrInterfaceBody(names.empty, false, false);
             body = toP(F.at(identPos).AnonymousClassDef(mods1, defs));
         }
         if (args.isEmpty() && body == null)
@@ -3088,7 +3093,7 @@
     /** ClassBody     = "{" {ClassBodyDeclaration} "}"
      *  InterfaceBody = "{" {InterfaceBodyDeclaration} "}"
      */
-    List<JCTree> classOrInterfaceBody(Name className, boolean isInterface) {
+    List<JCTree> classOrInterfaceBody(Name className, boolean isInterface, boolean isAnno) {
         accept(LBRACE);
         if (S.pos() <= errorEndPos) {
             // error recovery
@@ -3098,7 +3103,7 @@
         }
         ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
         while (S.token() != RBRACE && S.token() != EOF) {
-            defs.appendList(classOrInterfaceBodyDeclaration(className, isInterface));
+            defs.appendList(classOrInterfaceBodyDeclaration(className, isInterface, isAnno));
             if (S.pos() <= errorEndPos) {
                // error recovery
                skip(false, true, true, false);
@@ -3125,12 +3130,11 @@
      *    | ModifiersOpt Type Ident
      *      ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest | DefenderMethodDeclaratorRest ";" )
      */
-    List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) {
+    List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface, boolean isAnno) {
         if (S.token() == SEMI) {
             S.nextToken();
             return List.<JCTree>nil();
         } else {
-            boolean isExtension = false;
             String dc = S.docComment();
             int pos = S.pos();
             JCModifiers mods = modifiersOpt();
@@ -3149,10 +3153,8 @@
 
                 Name name = S.name();
                 if (isInterface && name.equals(names._extension)) {
-                    checkDefenderMethods();
+                    log.warning(pos, "redundant.extension.keyword");
                     accept(IDENTIFIER);
-                    mods.flags |= Flags.DEFENDER;
-                    isExtension = true;
                 }
                 pos = S.pos();
                 JCExpression type;
@@ -3175,15 +3177,13 @@
                     if (isInterface || name != className)
                         log.error(pos, "invalid.meth.decl.ret.type.req");
                     return List.of(methodDeclaratorRest(
-                        pos, mods, null, names.init, typarams,
-                        isInterface, true, isExtension, dc));
+                        pos, mods, null, names.init, typarams, isAnno, true, dc));
                 } else {
                     pos = S.pos();
                     name = ident();
                     if (S.token() == LPAREN) {
                         return List.of(methodDeclaratorRest(
-                            pos, mods, type, name, typarams,
-                            isInterface, isVoid, isExtension, dc));
+                            pos, mods, type, name, typarams, isAnno, isVoid, dc));
                     } else if (!isVoid && typarams.isEmpty()) {
                         List<JCTree> defs =
                             variableDeclaratorsRest(pos, mods, type, name, isInterface, dc,
@@ -3222,8 +3222,8 @@
                               JCExpression type,
                               Name name,
                               List<JCTypeParameter> typarams,
-                              boolean isInterface, boolean isVoid,
-                              boolean isDefender,
+                              boolean isAnno,
+                              boolean isVoid,
                               String dc) {
         List<JCVariableDecl> params = formalParameters();
 
@@ -3249,42 +3249,44 @@
         }
         JCBlock body = null;
         JCExpression defaultValue;
-        if (isDefender) {
-            //a defender method declaration is turned into an ordinary method
-            //declaration where the method body is a standard method call to
-            //the extended method.
-            //
-            // e.g.
-            // extension T reduce(T arg) default Collections.<T>reduce;
-            //
-            // --> T reduce(T arg) { Collections.<T>reduce(this, arg); }
-            int prevMode = mode;
-            mode = EXPR;
-            accept(DEFAULT);
-            List<JCExpression> defenderMethodParams = List.<JCExpression>of(toP(F.at(pos).Ident(names._this)));
-            for (JCVariableDecl param : params) {
-                defenderMethodParams =
-                        defenderMethodParams.append(toP(F.at(pos).Ident(param.name)));
-            }
-            List<JCExpression> args = typeArgumentsOpt();
-            JCExpression meth = toP(F.at(pos).Ident(ident()));
-            while (args == null && S.token() == DOT) {
-                accept(DOT);
-                args = typeArgumentsOpt(EXPR);
-                meth = toP(F.at(pos).Select(meth, ident()));
-            }
-            JCMethodInvocation defaultImpl = toP(F.at(pos).Apply(args, meth, defenderMethodParams, false));
-            body = toP(F.at(pos).Block(0, List.<JCStatement>of(toP(F.at(pos).Exec(defaultImpl)))));
-            defaultValue = null;
-            mode = prevMode;
-        }
-        else if (S.token() == LBRACE) {
+        if (S.token() == LBRACE) {
             body = block();
             defaultValue = null;
         } else {
             if (S.token() == DEFAULT) {
                 accept(DEFAULT);
-                defaultValue = annotationValue();
+                if (isAnno) {
+                    defaultValue = annotationValue();
+                } else {
+                    checkDefenderMethods();
+                    //a defender method declaration is turned into an ordinary method
+                    //declaration where the method body is a standard method call to
+                    //the extended method.
+                    //
+                    // e.g.
+                    // extension T reduce(T arg) default Collections.<T>reduce;
+                    //
+                    // --> T reduce(T arg) { Collections.<T>reduce(this, arg); }
+                    int prevMode = mode;
+                    mode = EXPR;
+                    mods.flags |= Flags.DEFENDER;
+                    List<JCExpression> defenderMethodParams = List.<JCExpression>of(toP(F.at(pos).Ident(names._this)));
+                    for (JCVariableDecl param : params) {
+                        defenderMethodParams =
+                                defenderMethodParams.append(toP(F.at(pos).Ident(param.name)));
+                    }
+                    List<JCExpression> args = typeArgumentsOpt();
+                    JCExpression meth = toP(F.at(pos).Ident(ident()));
+                    while (args == null && S.token() == DOT) {
+                        accept(DOT);
+                        args = typeArgumentsOpt(EXPR);
+                        meth = toP(F.at(pos).Select(meth, ident()));
+                    }
+                    JCMethodInvocation defaultImpl = toP(F.at(pos).Apply(args, meth, defenderMethodParams, false));
+                    body = toP(F.at(pos).Block(0, List.<JCStatement>of(toP(F.at(pos).Exec(defaultImpl)))));
+                    defaultValue = null;
+                    mode = prevMode;
+                }
             } else {
                 defaultValue = null;
             }
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Mon Nov 29 16:58:44 2010 +0000
@@ -1097,6 +1097,9 @@
                         } else {
                             lexError(pos, "unclosed.bytecode.ident");
                         }
+                    } else if (ch == '{') {
+                        scanChar();
+                        token = LAMBDA;
                     } else if (allowMethodReferences && scanOperator('#')) {
                     } else {
                         token = HASH;
--- a/src/share/classes/com/sun/tools/javac/parser/Token.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/src/share/classes/com/sun/tools/javac/parser/Token.java	Mon Nov 29 16:58:44 2010 +0000
@@ -111,6 +111,7 @@
     COMMA(","),
     DOT("."),
     HASH("#"),
+    LAMBDA("#{"),
     ARROW("->"),
     ELLIPSIS("..."),
     EQ("="),
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Nov 29 12:04:48 2010 +0000
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Nov 29 16:58:44 2010 +0000
@@ -183,8 +183,6 @@
 compiler.err.concrete.inheritance.conflict=\
     methods {0} from {1} and {2} from {3} are inherited with the same signature
 
-compiler.err.default.allowed.in.intf.annotation.member=\
-    default value only allowed in an @interface member
 compiler.err.doesnt.exist=\
     package {0} does not exist
 compiler.err.duplicate.annotation=\
@@ -418,6 +416,8 @@
     not a statement
 compiler.err.not.encl.class=\
     not an enclosing class: {0}
+compiler.err.bad.lambda.token=\
+    A lambda expression must be start with the ''{0}'' token (no separators)
 
 compiler.err.operator.cant.be.applied=\
     operator {0} cannot be applied to {1}
@@ -938,6 +938,10 @@
     found raw type: {0}\n\
     missing type parameters for generic class {1}
 
+compiler.warn.redundant.extension.keyword=\
+    The ''extension'' keyword is no longer required to denote an extension method.\n\
+    (might be disallowed in future versions of the compiler)
+
 #####
 
 ## The following are tokens which are non-terminals in the language. They should
--- a/test/tools/javac/defender/Neg01.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/defender/Neg01.java	Mon Nov 29 16:58:44 2010 +0000
@@ -29,8 +29,8 @@
  */
 
 class Neg01 {
-    interface IA { extension int m() default Neg01.m1; }
-    interface IB { extension int m() default Neg01.m2; }
+    interface IA { int m() default Neg01.m1; }
+    interface IB { int m() default Neg01.m2; }
 
     static class A implements IA {}
     static class B implements IB {}
--- a/test/tools/javac/defender/Neg02.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/defender/Neg02.java	Mon Nov 29 16:58:44 2010 +0000
@@ -30,11 +30,11 @@
 
 class Neg02 {
      interface A {
-         extension void m() default Neg02.impl;
+         void m() default Neg02.impl;
      }
 
      interface B {
-         extension void m() default Neg02.impl;
+         void m() default Neg02.impl;
      }
 
      static class X implements A, B { }
--- a/test/tools/javac/diags/examples.not-yet.txt	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/diags/examples.not-yet.txt	Mon Nov 29 16:58:44 2010 +0000
@@ -157,3 +157,5 @@
 compiler.note.potential.lambda.found                                             #LAMBDA
 compiler.warn.cyclic.lambda.inference.throws                                     #LAMBDA
 compiler.warn.cyclic.lambda.inference.throws.1                                   #LAMBDA
+compiler.err.bad.lambda.token                                                    #LAMBDA
+compiler.warn.redundant.extension.keyword                                        #LAMBDA
--- a/test/tools/javac/diags/examples/DefaultAllowedInIntfAnnotationMember.java	Mon Nov 29 12:04:48 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.default.allowed.in.intf.annotation.member
-
-interface DefaultAllowedInIntfAnnotationMember {
-    String value() default "";
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/BadLambdaToken.java	Mon Nov 29 16:58:44 2010 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary check that lambda expression starts with '#{' (no separators)
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadLambdaToken.out -XDrawDiagnostics BadLambdaToken.java
+ *
+ */
+class BadLambdaToken {
+
+    interface SAM {
+        void m(Integer x);
+    }
+
+    void test() {
+        SAM s = # { int x -> };
+        SAM s = #
+                { int x -> };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/BadLambdaToken.out	Mon Nov 29 16:58:44 2010 +0000
@@ -0,0 +1,3 @@
+BadLambdaToken.java:38:17: compiler.err.bad.lambda.token: #{
+BadLambdaToken.java:39:17: compiler.err.bad.lambda.token: #{
+2 errors
--- a/test/tools/javac/lambda/BadOrder.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/lambda/BadOrder.java	Mon Nov 29 16:58:44 2010 +0000
@@ -29,7 +29,7 @@
  */
 
 class Test {
-   SAM s = # {};
+   SAM s = #{};
 }
 
 abstract class SAM {
--- a/test/tools/javac/lambda/BadReturn.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/lambda/BadReturn.java	Mon Nov 29 16:58:44 2010 +0000
@@ -35,7 +35,7 @@
     }
 
     static void testNeg1() {
-        SAM s = # {
+        SAM s = #{
             if (true) {
                 return "";
             } else {
@@ -44,11 +44,11 @@
     }
 
     static void testNeg2() {
-        SAM s = # { return System.out.println(""); };
+        SAM s = #{ return System.out.println(""); };
     }
 
     static void testPos() {
-        SAM s = # {
+        SAM s = #{
             if (false) {
                 return 10;
             }
--- a/test/tools/javac/lambda/BadReturn.out	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/lambda/BadReturn.out	Mon Nov 29 16:58:44 2010 +0000
@@ -1,3 +1,3 @@
 BadReturn.java:42:42: compiler.err.prob.found.req: (compiler.misc.incompatible.types), void, java.lang.Comparable<?>
-BadReturn.java:47:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), void, java.lang.Comparable<?>
+BadReturn.java:47:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), void, java.lang.Comparable<?>
 2 errors
--- a/test/tools/javac/lambda/DefiniteAssignment01.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/lambda/DefiniteAssignment01.java	Mon Nov 29 16:58:44 2010 +0000
@@ -46,7 +46,7 @@
     }
 
     public static void main(String[] args) {
-        final SAM s = # { i -> assertTrue(i == 0); };
+        final SAM s = #{ i -> assertTrue(i == 0); };
         assert(assertionCount == 1);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/DeprecatedExtensionKeyword.java	Mon Nov 29 16:58:44 2010 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary check that compiler warns about use of 'extension' keyword in extenxion method decl
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=DeprecatedExtensionKeyword.out -Werror -XDrawDiagnostics DeprecatedExtensionKeyword.java
+ *
+ */
+class DeprecatedExtensionKeyword {
+
+    interface I {
+        extension void m1() default DeprecatedExtensionKeyword.m;
+        void m2() default DeprecatedExtensionKeyword.m;
+    }
+
+    static void m(I i) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/DeprecatedExtensionKeyword.out	Mon Nov 29 16:58:44 2010 +0000
@@ -0,0 +1,4 @@
+DeprecatedExtensionKeyword.java:34:9: compiler.warn.redundant.extension.keyword
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- a/test/tools/javac/lambda/ExceptionTransparency02.java	Mon Nov 29 12:04:48 2010 +0000
+++ b/test/tools/javac/lambda/ExceptionTransparency02.java	Mon Nov 29 16:58:44 2010 +0000
@@ -39,16 +39,16 @@
     public static <throws E> void m2(Block<E> block1, Block<E> block2) throws E {}
 
     public static void main(String[] args) {
-        m1(# { } );
-        m2(# { }, # { });
+        m1(#{ } );
+        m2(#{ }, #{ });
         try {
-            m2(# { throw new A(); }, # { });
-            m2(# { }, # { throw new A(); });
+            m2(#{ throw new A(); }, #{ });
+            m2(#{ }, #{ throw new A(); });
         }
         catch (A a) {}
         try {
-            m2(# { throw new A(); }, # { throw new B(); });
-            m2(# { throw new B(); }, # { throw new A(); });
+            m2(#{ throw new A(); }, #{ throw new B(); });
+            m2(#{ throw new B(); }, #{ throw new A(); });
         }
         catch (final A | B ex) {}
     }