8005166: Add support for static interface methods

Mon, 21 Jan 2013 20:19:53 +0000

author
mcimadamore
date
Mon, 21 Jan 2013 20:19:53 +0000
changeset 1513
cf84b07a82db
parent 1512
b12ffdfa1341
child 1514
be443002e970

8005166: Add support for static interface methods
Summary: Support public static interface methods
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Flags.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/code/Source.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/code/Symbol.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Attr.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Check.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/parser/JavacParser.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/resources/compiler.properties file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/Static01.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/Static02.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/Static02.out file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/StaticImport1.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/StaticImport2.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/StaticImport2.out file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/StaticImport3.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/StaticImport3.out file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/pkg/A.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/pkg/B.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/static/import/pkg/C.java file | annotate | diff | comparison | revisions
test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/IllegalStaticIntfMethCall.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/StaticIntfMethodNotSupported.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Mon Jan 21 20:15:16 2013 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Mon Jan 21 20:19:53 2013 +0000
     1.3 @@ -280,7 +280,7 @@
     1.4                                  SYNCHRONIZED | FINAL | STRICTFP;
     1.5      public static final long
     1.6          ExtendedStandardFlags       = (long)StandardFlags | DEFAULT,
     1.7 -        InterfaceDefaultMethodMask  = ABSTRACT | PUBLIC | STRICTFP | DEFAULT,
     1.8 +        InterfaceMethodMask         = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT,
     1.9          LocalVarFlags               = FINAL | PARAMETER;
    1.10  
    1.11  
     2.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java	Mon Jan 21 20:15:16 2013 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Mon Jan 21 20:19:53 2013 +0000
     2.3 @@ -206,6 +206,9 @@
     2.4      public boolean allowDefaultMethods() {
     2.5          return compareTo(JDK1_8) >= 0;
     2.6      }
     2.7 +    public boolean allowStaticInterfaceMethods() {
     2.8 +        return compareTo(JDK1_8) >= 0;
     2.9 +    }
    2.10      public boolean allowStrictMethodClashCheck() {
    2.11          return compareTo(JDK1_8) >= 0;
    2.12      }
     3.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Jan 21 20:15:16 2013 +0000
     3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Jan 21 20:19:53 2013 +0000
     3.3 @@ -1233,7 +1233,8 @@
     3.4              case Flags.PRIVATE:
     3.5                  return false;
     3.6              case Flags.PUBLIC:
     3.7 -                return true;
     3.8 +                return !this.owner.isInterface() ||
     3.9 +                        (flags_field & STATIC) == 0;
    3.10              case Flags.PROTECTED:
    3.11                  return (origin.flags() & INTERFACE) == 0;
    3.12              case 0:
    3.13 @@ -1247,6 +1248,18 @@
    3.14              }
    3.15          }
    3.16  
    3.17 +        @Override
    3.18 +        public boolean isInheritedIn(Symbol clazz, Types types) {
    3.19 +            switch ((int)(flags_field & Flags.AccessFlags)) {
    3.20 +                case PUBLIC:
    3.21 +                    return !this.owner.isInterface() ||
    3.22 +                            clazz == owner ||
    3.23 +                            (flags_field & STATIC) == 0;
    3.24 +                default:
    3.25 +                    return super.isInheritedIn(clazz, types);
    3.26 +            }
    3.27 +        }
    3.28 +
    3.29          /** The implementation of this (abstract) symbol in class origin;
    3.30           *  null if none exists. Synthetic methods are not considered
    3.31           *  as possible implementations.
     4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jan 21 20:15:16 2013 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jan 21 20:19:53 2013 +0000
     4.3 @@ -954,8 +954,7 @@
     4.4                  // Empty bodies are only allowed for
     4.5                  // abstract, native, or interface methods, or for methods
     4.6                  // in a retrofit signature class.
     4.7 -                if (isDefaultMethod || ((owner.flags() & INTERFACE) == 0 &&
     4.8 -                    (tree.mods.flags & (ABSTRACT | NATIVE)) == 0) &&
     4.9 +                if (isDefaultMethod || (tree.sym.flags() & (ABSTRACT | NATIVE)) == 0 &&
    4.10                      !relax)
    4.11                      log.error(tree.pos(), "missing.meth.body.or.decl.abstract");
    4.12                  if (tree.defaultValue != null) {
    4.13 @@ -3481,6 +3480,15 @@
    4.14              env.info.defaultSuperCallSite = null;
    4.15          }
    4.16  
    4.17 +        if (sym.isStatic() && site.isInterface()) {
    4.18 +            Assert.check(env.tree.hasTag(APPLY));
    4.19 +            JCMethodInvocation app = (JCMethodInvocation)env.tree;
    4.20 +            if (app.meth.hasTag(SELECT) &&
    4.21 +                    !TreeInfo.isStaticSelector(((JCFieldAccess)app.meth).selected, names)) {
    4.22 +                log.error(env.tree.pos(), "illegal.static.intf.meth.call", site);
    4.23 +            }
    4.24 +        }
    4.25 +
    4.26          // Compute the identifier's instantiated type.
    4.27          // For methods, we need to compute the instance type by
    4.28          // Resolve.instantiate from the symbol's type as well as
     5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Jan 21 20:15:16 2013 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Jan 21 20:19:53 2013 +0000
     5.3 @@ -1058,9 +1058,12 @@
     5.4                  } else
     5.5                      mask = ConstructorFlags;
     5.6              }  else if ((sym.owner.flags_field & INTERFACE) != 0) {
     5.7 -                if ((flags & DEFAULT) != 0) {
     5.8 -                    mask = InterfaceDefaultMethodMask;
     5.9 -                    implicit = PUBLIC | ABSTRACT;
    5.10 +                if ((flags & (DEFAULT | STATIC)) != 0) {
    5.11 +                    mask = InterfaceMethodMask;
    5.12 +                    implicit = PUBLIC;
    5.13 +                    if ((flags & DEFAULT) != 0) {
    5.14 +                        implicit |= ABSTRACT;
    5.15 +                    }
    5.16                  } else {
    5.17                      mask = implicit = InterfaceMethodFlags;
    5.18                  }
    5.19 @@ -1130,6 +1133,10 @@
    5.20                                  PRIVATE | STATIC | DEFAULT))
    5.21                   &&
    5.22                   checkDisjoint(pos, flags,
    5.23 +                                STATIC,
    5.24 +                                DEFAULT)
    5.25 +                 &&
    5.26 +                 checkDisjoint(pos, flags,
    5.27                                 ABSTRACT | INTERFACE,
    5.28                                 FINAL | NATIVE | SYNCHRONIZED)
    5.29                   &&
     6.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Jan 21 20:15:16 2013 +0000
     6.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Jan 21 20:19:53 2013 +0000
     6.3 @@ -124,6 +124,7 @@
     6.4          this.allowLambda = source.allowLambda();
     6.5          this.allowMethodReferences = source.allowMethodReferences();
     6.6          this.allowDefaultMethods = source.allowDefaultMethods();
     6.7 +        this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
     6.8          this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
     6.9          this.keepDocComments = keepDocComments;
    6.10          docComments = newDocCommentTable(keepDocComments, fac);
    6.11 @@ -198,6 +199,10 @@
    6.12       */
    6.13      boolean allowDefaultMethods;
    6.14  
    6.15 +    /** Switch: should we allow static methods in interfaces?
    6.16 +     */
    6.17 +    boolean allowStaticInterfaceMethods;
    6.18 +
    6.19      /** Switch: should we allow intersection types in cast?
    6.20       */
    6.21      boolean allowIntersectionTypesInCast;
    6.22 @@ -3093,6 +3098,9 @@
    6.23                                List<JCTypeParameter> typarams,
    6.24                                boolean isInterface, boolean isVoid,
    6.25                                Comment dc) {
    6.26 +        if (isInterface && (mods.flags & Flags.STATIC) != 0) {
    6.27 +            checkStaticInterfaceMethods();
    6.28 +        }
    6.29          List<JCVariableDecl> params = formalParameters();
    6.30          if (!isVoid) type = bracketsOpt(type);
    6.31          List<JCExpression> thrown = List.nil();
    6.32 @@ -3494,6 +3502,12 @@
    6.33              allowIntersectionTypesInCast = true;
    6.34          }
    6.35      }
    6.36 +    void checkStaticInterfaceMethods() {
    6.37 +        if (!allowStaticInterfaceMethods) {
    6.38 +            log.error(token.pos, "static.intf.methods.not.supported.in.source", source.name);
    6.39 +            allowStaticInterfaceMethods = true;
    6.40 +        }
    6.41 +    }
    6.42  
    6.43      /*
    6.44       * a functional source tree and end position mappings
     7.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jan 21 20:15:16 2013 +0000
     7.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jan 21 20:19:53 2013 +0000
     7.3 @@ -948,6 +948,11 @@
     7.4  compiler.err.default.overrides.object.member=\
     7.5      default method {0} in {1} {2} overrides a member of java.lang.Object
     7.6  
     7.7 +# 0: type
     7.8 +compiler.err.illegal.static.intf.meth.call=\
     7.9 +    illegal static interface method call\n\
    7.10 +    the receiver expression should be replaced with the type qualifier ''{0}''
    7.11 +
    7.12  # 0: type, 1: message segment
    7.13  compiler.err.illegal.default.super.call=\
    7.14      bad type qualifier {0} in default super call\n\
    7.15 @@ -2213,6 +2218,11 @@
    7.16      intersection types in cast are not supported in -source {0}\n\
    7.17      (use -source 8 or higher to enable default methods)
    7.18  
    7.19 +# 0: string
    7.20 +compiler.err.static.intf.methods.not.supported.in.source=\
    7.21 +    static interface methods are not supported in -source {0}\n\
    7.22 +    (use -source 8 or higher to enable static interface methods)
    7.23 +
    7.24  ########################################
    7.25  # Diagnostics for verbose resolution
    7.26  # used by Resolve (debug only)
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/tools/javac/defaultMethods/static/Static01.java	Mon Jan 21 20:19:53 2013 +0000
     8.3 @@ -0,0 +1,51 @@
     8.4 +/*
     8.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.
    8.11 + *
    8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.15 + * version 2 for more details (a copy is included in the LICENSE file that
    8.16 + * accompanied this code).
    8.17 + *
    8.18 + * You should have received a copy of the GNU General Public License version
    8.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.21 + *
    8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.23 + * or visit www.oracle.com if you need additional information or have any
    8.24 + * questions.
    8.25 + */
    8.26 +
    8.27 +/*
    8.28 + * @test
    8.29 + * @bug 8005166
    8.30 + * @summary Add support for static interface methods
    8.31 + *          smoke test for static interface methods
    8.32 + * @compile -XDallowStaticInterfaceMethods Static01.java
    8.33 + */
    8.34 +public class Static01 {
    8.35 +
    8.36 +    static int assertionCount = 0;
    8.37 +
    8.38 +    static void assertTrue(boolean cond) {
    8.39 +        assertionCount++;
    8.40 +        if (!cond)
    8.41 +            throw new AssertionError();
    8.42 +    }
    8.43 +
    8.44 +    interface I {
    8.45 +        public static void test() {
    8.46 +            assertTrue(true);
    8.47 +        }
    8.48 +    }
    8.49 +
    8.50 +    public static void main(String[] args) {
    8.51 +        I.test();
    8.52 +        assertTrue(assertionCount == 1);
    8.53 +    }
    8.54 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/tools/javac/defaultMethods/static/Static02.java	Mon Jan 21 20:19:53 2013 +0000
     9.3 @@ -0,0 +1,42 @@
     9.4 +/*
     9.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.
    9.11 + *
    9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.15 + * version 2 for more details (a copy is included in the LICENSE file that
    9.16 + * accompanied this code).
    9.17 + *
    9.18 + * You should have received a copy of the GNU General Public License version
    9.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.21 + *
    9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.23 + * or visit www.oracle.com if you need additional information or have any
    9.24 + * questions.
    9.25 + */
    9.26 +
    9.27 +/*
    9.28 + * @test
    9.29 + * @bug 8005166
    9.30 + * @summary Add support for static interface methods
    9.31 + *          smoke test for static interface methods
    9.32 + * @compile/fail/ref=Static02.out -XDrawDiagnostics -XDallowStaticInterfaceMethods Static02.java
    9.33 + */
    9.34 +class Static02 {
    9.35 +
    9.36 +    interface I {
    9.37 +        public static void test() { }
    9.38 +    }
    9.39 +
    9.40 +    public static void main(String[] args) {
    9.41 +        I.test(); //ok
    9.42 +        I i = new I() {};
    9.43 +        i.test(); //no!
    9.44 +    }
    9.45 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/tools/javac/defaultMethods/static/Static02.out	Mon Jan 21 20:19:53 2013 +0000
    10.3 @@ -0,0 +1,2 @@
    10.4 +Static02.java:40:15: compiler.err.illegal.static.intf.meth.call: Static02.I
    10.5 +1 error
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java	Mon Jan 21 20:19:53 2013 +0000
    11.3 @@ -0,0 +1,243 @@
    11.4 +/*
    11.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + */
   11.26 +
   11.27 +/*
   11.28 + * @test
   11.29 + * @bug 8005166
   11.30 + * @summary Add support for static interface methods
   11.31 + *          Smoke test for static interface method hiding
   11.32 + */
   11.33 +
   11.34 +import com.sun.source.util.JavacTask;
   11.35 +import java.net.URI;
   11.36 +import java.util.Arrays;
   11.37 +import javax.tools.Diagnostic;
   11.38 +import javax.tools.JavaCompiler;
   11.39 +import javax.tools.JavaFileObject;
   11.40 +import javax.tools.SimpleJavaFileObject;
   11.41 +import javax.tools.StandardJavaFileManager;
   11.42 +import javax.tools.ToolProvider;
   11.43 +
   11.44 +
   11.45 +public class InterfaceMethodHidingTest {
   11.46 +
   11.47 +    static int checkCount = 0;
   11.48 +
   11.49 +    enum SignatureKind {
   11.50 +        VOID_INTEGER("void m(Integer s)", "return;"),
   11.51 +        STRING_INTEGER("String m(Integer s)", "return null;"),
   11.52 +        VOID_STRING("void m(String s)", "return;"),
   11.53 +        STRING_STRING("String m(String s)", "return null;");
   11.54 +
   11.55 +        String sigStr;
   11.56 +        String retStr;
   11.57 +
   11.58 +        SignatureKind(String sigStr, String retStr) {
   11.59 +            this.sigStr = sigStr;
   11.60 +            this.retStr = retStr;
   11.61 +        }
   11.62 +
   11.63 +        boolean overrideEquivalentWith(SignatureKind s2) {
   11.64 +            switch (this) {
   11.65 +                case VOID_INTEGER:
   11.66 +                case STRING_INTEGER:
   11.67 +                    return s2 == VOID_INTEGER || s2 == STRING_INTEGER;
   11.68 +                case VOID_STRING:
   11.69 +                case STRING_STRING:
   11.70 +                    return s2 == VOID_STRING || s2 == STRING_STRING;
   11.71 +                default:
   11.72 +                    throw new AssertionError("bad signature kind");
   11.73 +            }
   11.74 +        }
   11.75 +    }
   11.76 +
   11.77 +    enum MethodKind {
   11.78 +        VIRTUAL("", "#M #S;"),
   11.79 +        STATIC("static", "#M #S { #BE; #R }"),
   11.80 +        DEFAULT("default", "#M #S { #BE; #R }");
   11.81 +
   11.82 +        String modStr;
   11.83 +        String methTemplate;
   11.84 +
   11.85 +        MethodKind(String modStr, String methTemplate) {
   11.86 +            this.modStr = modStr;
   11.87 +            this.methTemplate = methTemplate;
   11.88 +        }
   11.89 +
   11.90 +        boolean inherithed() {
   11.91 +            return this != STATIC;
   11.92 +        }
   11.93 +
   11.94 +        static boolean overrides(MethodKind mk1, SignatureKind sk1, MethodKind mk2, SignatureKind sk2) {
   11.95 +            return sk1 == sk2 &&
   11.96 +                    mk2.inherithed() &&
   11.97 +                    mk1 != STATIC;
   11.98 +        }
   11.99 +
  11.100 +        String getBody(BodyExpr be, SignatureKind sk) {
  11.101 +            return methTemplate.replaceAll("#BE", be.bodyExprStr)
  11.102 +                    .replaceAll("#R", sk.retStr)
  11.103 +                    .replaceAll("#M", modStr)
  11.104 +                    .replaceAll("#S", sk.sigStr);
  11.105 +        }
  11.106 +    }
  11.107 +
  11.108 +    enum BodyExpr {
  11.109 +        NONE(""),
  11.110 +        THIS("Object o = this");
  11.111 +
  11.112 +        String bodyExprStr;
  11.113 +
  11.114 +        BodyExpr(String bodyExprStr) {
  11.115 +            this.bodyExprStr = bodyExprStr;
  11.116 +        }
  11.117 +
  11.118 +        boolean allowed(MethodKind mk) {
  11.119 +            return this == NONE ||
  11.120 +                    mk != MethodKind.STATIC;
  11.121 +        }
  11.122 +    }
  11.123 +
  11.124 +    public static void main(String... args) throws Exception {
  11.125 +
  11.126 +        //create default shared JavaCompiler - reused across multiple compilations
  11.127 +        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
  11.128 +        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
  11.129 +
  11.130 +        for (MethodKind mk1 : MethodKind.values()) {
  11.131 +            for (SignatureKind sk1 : SignatureKind.values()) {
  11.132 +                for (BodyExpr be1 : BodyExpr.values()) {
  11.133 +                    for (MethodKind mk2 : MethodKind.values()) {
  11.134 +                        for (SignatureKind sk2 : SignatureKind.values()) {
  11.135 +                            for (BodyExpr be2 : BodyExpr.values()) {
  11.136 +                                for (MethodKind mk3 : MethodKind.values()) {
  11.137 +                                    for (SignatureKind sk3 : SignatureKind.values()) {
  11.138 +                                        for (BodyExpr be3 : BodyExpr.values()) {
  11.139 +                                            new InterfaceMethodHidingTest(mk1, mk2, mk3, sk1, sk2, sk3, be1, be2, be3).run(comp, fm);
  11.140 +                                        }
  11.141 +                                    }
  11.142 +                                }
  11.143 +                            }
  11.144 +                        }
  11.145 +                    }
  11.146 +                }
  11.147 +            }
  11.148 +        }
  11.149 +        System.out.println("Total check executed: " + checkCount);
  11.150 +    }
  11.151 +
  11.152 +    MethodKind mk1, mk2, mk3;
  11.153 +    SignatureKind sk1, sk2, sk3;
  11.154 +    BodyExpr be1, be2, be3;
  11.155 +    JavaSource source;
  11.156 +    DiagnosticChecker diagChecker;
  11.157 +
  11.158 +    InterfaceMethodHidingTest(MethodKind mk1, MethodKind mk2, MethodKind mk3,
  11.159 +            SignatureKind sk1, SignatureKind sk2, SignatureKind sk3, BodyExpr be1, BodyExpr be2, BodyExpr be3) {
  11.160 +        this.mk1 = mk1;
  11.161 +        this.mk2 = mk2;
  11.162 +        this.mk3 = mk3;
  11.163 +        this.sk1 = sk1;
  11.164 +        this.sk2 = sk2;
  11.165 +        this.sk3 = sk3;
  11.166 +        this.be1 = be1;
  11.167 +        this.be2 = be2;
  11.168 +        this.be3 = be3;
  11.169 +        this.source = new JavaSource();
  11.170 +        this.diagChecker = new DiagnosticChecker();
  11.171 +    }
  11.172 +
  11.173 +    class JavaSource extends SimpleJavaFileObject {
  11.174 +
  11.175 +        String template = "interface Sup {\n" +
  11.176 +                          "   default void sup() { }\n" +
  11.177 +                          "}\n" +
  11.178 +                          "interface A extends Sup {\n" +
  11.179 +                          "   #M1\n" +
  11.180 +                          "}\n" +
  11.181 +                          "interface B extends A, Sup {\n" +
  11.182 +                          "   #M2\n" +
  11.183 +                          "}\n" +
  11.184 +                          "interface C extends B, Sup {\n" +
  11.185 +                          "   #M3\n" +
  11.186 +                          "}\n";
  11.187 +
  11.188 +        String source;
  11.189 +
  11.190 +        public JavaSource() {
  11.191 +            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
  11.192 +            source = template.replaceAll("#M1", mk1.getBody(be1, sk1))
  11.193 +                    .replaceAll("#M2", mk2.getBody(be2, sk2))
  11.194 +                    .replaceAll("#M3", mk3.getBody(be3, sk3));
  11.195 +        }
  11.196 +
  11.197 +        @Override
  11.198 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
  11.199 +            return source;
  11.200 +        }
  11.201 +    }
  11.202 +
  11.203 +    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
  11.204 +        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
  11.205 +                Arrays.asList("-XDallowStaticInterfaceMethods"), null, Arrays.asList(source));
  11.206 +        try {
  11.207 +            ct.analyze();
  11.208 +        } catch (Throwable ex) {
  11.209 +            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
  11.210 +        }
  11.211 +        check();
  11.212 +    }
  11.213 +
  11.214 +    void check() {
  11.215 +        boolean errorExpected =
  11.216 +                !be1.allowed(mk1) || !be2.allowed(mk2) || !be3.allowed(mk3);
  11.217 +
  11.218 +        if (mk1.inherithed()) {
  11.219 +            errorExpected |=
  11.220 +                    sk2.overrideEquivalentWith(sk1) && !MethodKind.overrides(mk2, sk2, mk1, sk1) ||
  11.221 +                    sk3.overrideEquivalentWith(sk1) && !MethodKind.overrides(mk3, sk3, mk1, sk1);
  11.222 +        }
  11.223 +
  11.224 +        if (mk2.inherithed()) {
  11.225 +            errorExpected |=
  11.226 +                    sk3.overrideEquivalentWith(sk2) && !MethodKind.overrides(mk3, sk3, mk2, sk2);
  11.227 +        }
  11.228 +
  11.229 +        checkCount++;
  11.230 +        if (diagChecker.errorFound != errorExpected) {
  11.231 +            throw new AssertionError("Problem when compiling source:\n" + source.getCharContent(true) +
  11.232 +                    "\nfound error: " + diagChecker.errorFound);
  11.233 +        }
  11.234 +    }
  11.235 +
  11.236 +    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
  11.237 +
  11.238 +        boolean errorFound;
  11.239 +
  11.240 +        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  11.241 +            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
  11.242 +                errorFound = true;
  11.243 +            }
  11.244 +        }
  11.245 +    }
  11.246 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/tools/javac/defaultMethods/static/import/StaticImport1.java	Mon Jan 21 20:19:53 2013 +0000
    12.3 @@ -0,0 +1,38 @@
    12.4 +/*
    12.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 +/*
   12.28 + * @test
   12.29 + * @bug 8005166
   12.30 + * @summary Add support for static interface methods
   12.31 + *          Smoke test for static imports of static interface methods
   12.32 + * @compile -XDallowStaticInterfaceMethods StaticImport1.java
   12.33 + */
   12.34 +
   12.35 +import static pkg.A.*;
   12.36 +
   12.37 +class StaticImport1 {
   12.38 +    void test() {
   12.39 +        m();
   12.40 +    }
   12.41 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/tools/javac/defaultMethods/static/import/StaticImport2.java	Mon Jan 21 20:19:53 2013 +0000
    13.3 @@ -0,0 +1,38 @@
    13.4 +/*
    13.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 + * or visit www.oracle.com if you need additional information or have any
   13.24 + * questions.
   13.25 + */
   13.26 +
   13.27 +/*
   13.28 + * @test
   13.29 + * @bug 8005166
   13.30 + * @summary Add support for static interface methods
   13.31 + *          Smoke test for static imports of static interface methods
   13.32 + * @compile/fail/ref=StaticImport2.out -XDrawDiagnostics -XDallowStaticInterfaceMethods StaticImport2.java
   13.33 + */
   13.34 +
   13.35 +import static pkg.B.*;
   13.36 +
   13.37 +class StaticImport2 {
   13.38 +    void test() {
   13.39 +        m();
   13.40 +    }
   13.41 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/defaultMethods/static/import/StaticImport2.out	Mon Jan 21 20:19:53 2013 +0000
    14.3 @@ -0,0 +1,2 @@
    14.4 +StaticImport2.java:36:9: compiler.err.cant.resolve.location.args: kindname.method, m, , , (compiler.misc.location: kindname.class, StaticImport2, null)
    14.5 +1 error
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/defaultMethods/static/import/StaticImport3.java	Mon Jan 21 20:19:53 2013 +0000
    15.3 @@ -0,0 +1,38 @@
    15.4 +/*
    15.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 + * or visit www.oracle.com if you need additional information or have any
   15.24 + * questions.
   15.25 + */
   15.26 +
   15.27 +/*
   15.28 + * @test
   15.29 + * @bug 8005166
   15.30 + * @summary Add support for static interface methods
   15.31 + *          Smoke test for static imports of static interface methods
   15.32 + * @compile/fail/ref=StaticImport3.out -XDrawDiagnostics -XDallowStaticInterfaceMethods StaticImport3.java
   15.33 + */
   15.34 +
   15.35 +import static pkg.C.*;
   15.36 +
   15.37 +class StaticImport3 {
   15.38 +    void test() {
   15.39 +        m();
   15.40 +    }
   15.41 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/defaultMethods/static/import/StaticImport3.out	Mon Jan 21 20:19:53 2013 +0000
    16.3 @@ -0,0 +1,2 @@
    16.4 +StaticImport3.java:36:9: compiler.err.cant.resolve.location.args: kindname.method, m, , , (compiler.misc.location: kindname.class, StaticImport3, null)
    16.5 +1 error
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/tools/javac/defaultMethods/static/import/pkg/A.java	Mon Jan 21 20:19:53 2013 +0000
    17.3 @@ -0,0 +1,28 @@
    17.4 +/*
    17.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.23 + * or visit www.oracle.com if you need additional information or have any
   17.24 + * questions.
   17.25 + */
   17.26 +
   17.27 +package pkg;
   17.28 +
   17.29 +public interface A {
   17.30 +    static void m() { }
   17.31 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javac/defaultMethods/static/import/pkg/B.java	Mon Jan 21 20:19:53 2013 +0000
    18.3 @@ -0,0 +1,26 @@
    18.4 +/*
    18.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +package pkg;
   18.28 +
   18.29 +public interface B extends A { }
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javac/defaultMethods/static/import/pkg/C.java	Mon Jan 21 20:19:53 2013 +0000
    19.3 @@ -0,0 +1,26 @@
    19.4 +/*
    19.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +package pkg;
   19.28 +
   19.29 +public class C implements A { }
    20.1 --- a/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Mon Jan 21 20:15:16 2013 +0000
    20.2 +++ b/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Mon Jan 21 20:19:53 2013 +0000
    20.3 @@ -23,7 +23,7 @@
    20.4  
    20.5  /*
    20.6   * @test
    20.7 - * @bug 7192245 8005851
    20.8 + * @bug 7192245 8005851 8005166
    20.9   * @summary Automatic test for checking set of allowed modifiers on interface methods
   20.10   */
   20.11  
   20.12 @@ -54,7 +54,7 @@
   20.13          }
   20.14  
   20.15          List<String> getOptions() {
   20.16 -            return Arrays.asList("-source", versionString);
   20.17 +            return Arrays.asList("-XDallowStaticInterfaceMethods", "-source", versionString);
   20.18          }
   20.19      }
   20.20  
   20.21 @@ -77,32 +77,6 @@
   20.22              this.modStr = modStr;
   20.23          }
   20.24  
   20.25 -        boolean isAllowed(EnclosingKind ek, ModifierKind otherMod) {
   20.26 -            if (this == otherMod) return false;
   20.27 -            switch (this) {
   20.28 -                case NONE:
   20.29 -                    return true;
   20.30 -                case ABSTRACT:
   20.31 -                    return otherMod != PRIVATE;
   20.32 -                case NATIVE:
   20.33 -                    return otherMod != ABSTRACT &&
   20.34 -                            otherMod != STRICTFP;
   20.35 -                case FINAL:
   20.36 -                case STATIC:
   20.37 -                case SYNCHRONIZED:
   20.38 -                case STRICTFP:
   20.39 -                     return otherMod != ABSTRACT;
   20.40 -                case PUBLIC:
   20.41 -                    return true;
   20.42 -                case PROTECTED:
   20.43 -                    return ek == EnclosingKind.ABSTRACT_CLASS;
   20.44 -                case DEFAULT:
   20.45 -                    return otherMod != ABSTRACT;
   20.46 -                default:
   20.47 -                    return true;
   20.48 -            }
   20.49 -        }
   20.50 -
   20.51          static boolean intersect(ModifierKind mk, ModifierKind... mks) {
   20.52              for (ModifierKind mk2 : mks) {
   20.53                  if (mk == mk2) return true;
   20.54 @@ -113,7 +87,7 @@
   20.55          static boolean compatible(MethodKind mk, ModifierKind mod1, ModifierKind mod2, EnclosingKind ek) {
   20.56              if (intersect(ABSTRACT, mod1, mod2) || intersect(NATIVE, mod1, mod2)) {
   20.57                  return mk == MethodKind.NO_BODY;
   20.58 -            } else if (intersect(DEFAULT, mod1, mod2)) {
   20.59 +            } else if (intersect(DEFAULT, mod1, mod2) || intersect(STATIC, mod1, mod2)) {
   20.60                  return mk == MethodKind.BODY;
   20.61              } else {
   20.62                  return ek == EnclosingKind.INTERFACE ?
   20.63 @@ -123,7 +97,6 @@
   20.64  
   20.65          boolean compatible(EnclosingKind ek) {
   20.66              switch (this) {
   20.67 -                case STATIC:
   20.68                  case PRIVATE:
   20.69                  case PROTECTED:
   20.70                      return ek != EnclosingKind.INTERFACE;
   20.71 @@ -176,16 +149,16 @@
   20.72  
   20.73          static Result[][] allowedModifierPairs = {
   20.74              /*                     NONE  PUBLIC  PROTECTED  PRIVATE  ABSTRACT  STATIC  NATIVE  SYNCHRONIZED  FINAL  STRICTFP  DEFAULT */
   20.75 -            /* NONE */           { T   , T    , C        , C       , T       , C     , C     , C           , C    , C       , I   },
   20.76 -            /* PUBLIC */         { T   , F    , F        , F       , T       , C     , C     , C           , C    , C       , I   },
   20.77 +            /* NONE */           { T   , T    , C        , C       , T       , T     , C     , C           , C    , C       , I   },
   20.78 +            /* PUBLIC */         { T   , F    , F        , F       , T       , T     , C     , C           , C    , C       , I   },
   20.79              /* PROTECTED */      { C   , F    , F        , F       , C       , C     , C     , C           , C    , C       , F   },
   20.80              /* PRIVATE */        { C   , F    , F        , F       , F       , C     , C     , C           , C    , C       , F   },
   20.81              /* ABSTRACT */       { T   , T    , C        , F       , F       , F     , F     , F           , F    , F       , F   },
   20.82 -            /* STATIC */         { C   , C    , C        , C       , F       , F     , C     , C           , C    , C       , F   },
   20.83 +            /* STATIC */         { T   , T    , C        , C       , F       , F     , C     , C           , C    , T       , F   },
   20.84              /* NATIVE */         { C   , C    , C        , C       , F       , C     , F     , C           , C    , F       , F   },
   20.85              /* SYNCHRONIZED */   { C   , C    , C        , C       , F       , C     , C     , F           , C    , C       , F   },
   20.86              /* FINAL */          { C   , C    , C        , C       , F       , C     , C     , C           , F    , C       , F   },
   20.87 -            /* STRICTFP */       { C   , C    , C        , C       , F       , C     , F     , C           , C    , F       , I   },
   20.88 +            /* STRICTFP */       { C   , C    , C        , C       , F       , T     , F     , C           , C    , F       , I   },
   20.89              /* DEFAULT */        { I   , I    , F        , F       , F       , F     , F     , F           , F    , I       , F   }};
   20.90      }
   20.91  
   20.92 @@ -291,6 +264,9 @@
   20.93          errorExpected |= ModifierKind.intersect(ModifierKind.DEFAULT, modk1, modk2) &&
   20.94                  vk == VersionKind.PRE_LAMBDA;
   20.95  
   20.96 +        errorExpected |= ModifierKind.intersect(ModifierKind.STATIC, modk1, modk2) &&
   20.97 +                ek == EnclosingKind.INTERFACE && vk == VersionKind.PRE_LAMBDA;
   20.98 +
   20.99          checkCount++;
  20.100          if (diagChecker.errorFound != errorExpected) {
  20.101              throw new AssertionError("Problem when compiling source:\n" + source.getCharContent(true) +
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/tools/javac/diags/examples/IllegalStaticIntfMethCall.java	Mon Jan 21 20:19:53 2013 +0000
    21.3 @@ -0,0 +1,34 @@
    21.4 +/*
    21.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 + * or visit www.oracle.com if you need additional information or have any
   21.24 + * questions.
   21.25 + */
   21.26 +
   21.27 +// key: compiler.err.illegal.static.intf.meth.call
   21.28 +// options: -XDallowStaticInterfaceMethods
   21.29 +
   21.30 +class IllegalStaticIntfMethCall {
   21.31 +    interface A {
   21.32 +        static void m() { }
   21.33 +    }
   21.34 +    void test(A a) {
   21.35 +        a.m();
   21.36 +    }
   21.37 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/tools/javac/diags/examples/StaticIntfMethodNotSupported.java	Mon Jan 21 20:19:53 2013 +0000
    22.3 @@ -0,0 +1,29 @@
    22.4 +/*
    22.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +// key: compiler.err.static.intf.methods.not.supported.in.source
   22.28 +// options: -source 7 -Xlint:-options -XDallowStaticInterfaceMethods
   22.29 +
   22.30 +interface StaticIntfMethodNotSupported {
   22.31 +    static void m() { }
   22.32 +}

mercurial