1.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jan 21 20:15:16 2013 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jan 21 20:19:53 2013 +0000 1.3 @@ -124,6 +124,7 @@ 1.4 this.allowLambda = source.allowLambda(); 1.5 this.allowMethodReferences = source.allowMethodReferences(); 1.6 this.allowDefaultMethods = source.allowDefaultMethods(); 1.7 + this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); 1.8 this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast(); 1.9 this.keepDocComments = keepDocComments; 1.10 docComments = newDocCommentTable(keepDocComments, fac); 1.11 @@ -198,6 +199,10 @@ 1.12 */ 1.13 boolean allowDefaultMethods; 1.14 1.15 + /** Switch: should we allow static methods in interfaces? 1.16 + */ 1.17 + boolean allowStaticInterfaceMethods; 1.18 + 1.19 /** Switch: should we allow intersection types in cast? 1.20 */ 1.21 boolean allowIntersectionTypesInCast; 1.22 @@ -3093,6 +3098,9 @@ 1.23 List<JCTypeParameter> typarams, 1.24 boolean isInterface, boolean isVoid, 1.25 Comment dc) { 1.26 + if (isInterface && (mods.flags & Flags.STATIC) != 0) { 1.27 + checkStaticInterfaceMethods(); 1.28 + } 1.29 List<JCVariableDecl> params = formalParameters(); 1.30 if (!isVoid) type = bracketsOpt(type); 1.31 List<JCExpression> thrown = List.nil(); 1.32 @@ -3494,6 +3502,12 @@ 1.33 allowIntersectionTypesInCast = true; 1.34 } 1.35 } 1.36 + void checkStaticInterfaceMethods() { 1.37 + if (!allowStaticInterfaceMethods) { 1.38 + log.error(token.pos, "static.intf.methods.not.supported.in.source", source.name); 1.39 + allowStaticInterfaceMethods = true; 1.40 + } 1.41 + } 1.42 1.43 /* 1.44 * a functional source tree and end position mappings