langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
changeset 15377 515846bb6637
parent 15375 d2529dc91d77
child 15385 ee1eebe7e210
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Jan 21 20:15:16 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Jan 21 20:19:53 2013 +0000
@@ -124,6 +124,7 @@
         this.allowLambda = source.allowLambda();
         this.allowMethodReferences = source.allowMethodReferences();
         this.allowDefaultMethods = source.allowDefaultMethods();
+        this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
         this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
         this.keepDocComments = keepDocComments;
         docComments = newDocCommentTable(keepDocComments, fac);
@@ -198,6 +199,10 @@
      */
     boolean allowDefaultMethods;
 
+    /** Switch: should we allow static methods in interfaces?
+     */
+    boolean allowStaticInterfaceMethods;
+
     /** Switch: should we allow intersection types in cast?
      */
     boolean allowIntersectionTypesInCast;
@@ -3093,6 +3098,9 @@
                               List<JCTypeParameter> typarams,
                               boolean isInterface, boolean isVoid,
                               Comment dc) {
+        if (isInterface && (mods.flags & Flags.STATIC) != 0) {
+            checkStaticInterfaceMethods();
+        }
         List<JCVariableDecl> params = formalParameters();
         if (!isVoid) type = bracketsOpt(type);
         List<JCExpression> thrown = List.nil();
@@ -3494,6 +3502,12 @@
             allowIntersectionTypesInCast = true;
         }
     }
+    void checkStaticInterfaceMethods() {
+        if (!allowStaticInterfaceMethods) {
+            log.error(token.pos, "static.intf.methods.not.supported.in.source", source.name);
+            allowStaticInterfaceMethods = true;
+        }
+    }
 
     /*
      * a functional source tree and end position mappings