diff options
| author | Manoj Palat | 2016-06-28 05:11:11 +0000 |
|---|---|---|
| committer | Manoj Palat | 2016-06-28 05:11:11 +0000 |
| commit | 23da3645ea7a3db4dea8838527d8795348f824b8 (patch) | |
| tree | 2fb39f42934bca78ea97d545cb09957488f5340b | |
| parent | 1f3f4c739e6fa8cd6ee359a428229cbf145a0a8f (diff) | |
| download | eclipse.jdt.core-23da3645ea7a3db4dea8838527d8795348f824b8.tar.gz eclipse.jdt.core-23da3645ea7a3db4dea8838527d8795348f824b8.tar.xz eclipse.jdt.core-23da3645ea7a3db4dea8838527d8795348f824b8.zip | |
Fix for bug 488662 [1.9] Allow private methods in interfaces
Change-Id: If1a28c692f84fbcc9814db5bc6198bba6ccf0a4e
8 files changed, 345 insertions, 22 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java index 804249880a..255d68ca8a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java @@ -5,6 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Benjamin Muskalla - Contribution for bug 239066 @@ -558,6 +562,7 @@ public void test011_problem_categories() { expectedProblemAttributes.put("IllegalModifierCombinationFinalAbstractForClass", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); expectedProblemAttributes.put("IllegalModifierCombinationFinalVolatileForField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); expectedProblemAttributes.put("IllegalModifierCombinationForInterfaceMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); + expectedProblemAttributes.put("IllegalModifierCombinationForPrivateInterfaceMethod9", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); expectedProblemAttributes.put("IllegalModifierForAnnotationField", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); expectedProblemAttributes.put("IllegalModifierForAnnotationMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); expectedProblemAttributes.put("IllegalModifierForAnnotationMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); @@ -579,6 +584,7 @@ public void test011_problem_categories() { expectedProblemAttributes.put("IllegalModifierForMemberEnum", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); expectedProblemAttributes.put("IllegalModifierForMemberInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); expectedProblemAttributes.put("IllegalModifierForMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); + expectedProblemAttributes.put("IllegalModifierForInterfaceMethod9", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); expectedProblemAttributes.put("IllegalModifierForVariable", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); expectedProblemAttributes.put("IllegalModifiersForElidedType", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); expectedProblemAttributes.put("IllegalModifiers", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); @@ -1397,6 +1403,7 @@ public void test012_compiler_problems_tuning() { expectedProblemAttributes.put("IllegalModifierCombinationFinalAbstractForClass", SKIP); expectedProblemAttributes.put("IllegalModifierCombinationFinalVolatileForField", SKIP); expectedProblemAttributes.put("IllegalModifierCombinationForInterfaceMethod", SKIP); + expectedProblemAttributes.put("IllegalModifierCombinationForPrivateInterfaceMethod9", SKIP); expectedProblemAttributes.put("IllegalModifierForAnnotationField", SKIP); expectedProblemAttributes.put("IllegalModifierForAnnotationMemberType", SKIP); expectedProblemAttributes.put("IllegalModifierForAnnotationMethod", SKIP); @@ -1418,6 +1425,7 @@ public void test012_compiler_problems_tuning() { expectedProblemAttributes.put("IllegalModifierForMemberEnum", SKIP); expectedProblemAttributes.put("IllegalModifierForMemberInterface", SKIP); expectedProblemAttributes.put("IllegalModifierForMethod", SKIP); + expectedProblemAttributes.put("IllegalModifierForInterfaceMethod9", SKIP); expectedProblemAttributes.put("IllegalModifierForVariable", SKIP); expectedProblemAttributes.put("IllegalModifiersForElidedType", SKIP); expectedProblemAttributes.put("IllegalModifiers", SKIP); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest_9.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest_9.java new file mode 100644 index 0000000000..439705b36a --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InterfaceMethodsTest_9.java @@ -0,0 +1,275 @@ +/******************************************************************************* + * Copyright (c) 2016 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import org.eclipse.jdt.core.tests.junit.extension.TestCase; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; + +import junit.framework.Test; + +// Bug 488662 - [1.9] Allow private methods in interfaces +@SuppressWarnings({ "rawtypes" }) +public class InterfaceMethodsTest_9 extends AbstractComparableTest { + +// Static initializer to specify tests subset using TESTS_* static variables +// All specified tests which do not belong to the class are skipped... + static { +// TESTS_NAMES = new String[] { "testBug488662_001" }; +// TESTS_NUMBERS = new int[] { 561 }; +// TESTS_RANGE = new int[] { 1, 2049 }; + } + + public static Test suite() { + return buildMinimalComplianceTestSuite(testClass(), F_9); + } + + public static Test setUpTest(Test test) throws Exception { + TestCase.setUpTest(test); + RegressionTestSetup suite = new RegressionTestSetup(ClassFileConstants.JDK9); + suite.addTest(test); + return suite; + } + + public static Class testClass() { + return InterfaceMethodsTest_9.class; + } + + public InterfaceMethodsTest_9(String name) { + super(name); + } + + // private method - positive test + public void testBug488662_001() { + runConformTest( + new String[] { + "I.java", + "public interface I {\n" + + "@SuppressWarnings(\"unused\")\n" + + " private void foo() {}\n" + + "}\n", + }, + ""); + } + // private method legal combination of modifiers - positive test + public void testBug488662_002() { + runConformTest( + new String[] { + "I.java", + "public interface I {\n" + + "@SuppressWarnings(\"unused\")\n" + + " private static void foo() {}\n" + + "}\n", + }, + ""); + } + // private method legal combination of modifiers - positive test + public void testBug488662_003() { + runConformTest( + new String[] { + "I.java", + "public interface I {\n" + + "@SuppressWarnings(\"unused\")\n" + + " private strictfp void foo() {}\n" + + "}\n", + }, + ""); + } + + // missing method body - negative test + public void testBug488662_004() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + "@SuppressWarnings(\"unused\")\n" + + " private void foo();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 3)\n" + + " private void foo();\n" + + " ^^^^^\n" + + "This method requires a body instead of a semicolon\n" + + "----------\n"); + } + + // illegal modifier combination - negative test + public void testBug488662_005() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + "@SuppressWarnings(\"unused\")\n" + + " private default void foo();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 3)\n" + + " private default void foo();\n" + + " ^^^^^\n" + + "Illegal combination of modifiers for the private interface method foo; additionally only one of static and strictfp is permitted\n" + + "----------\n" + + "2. ERROR in I.java (at line 3)\n" + + " private default void foo();\n" + + " ^^^^^\n" + + "This method requires a body instead of a semicolon\n" + + "----------\n"); + } + // illegal modifier combination - negative test + public void testBug488662_006() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + " private abstract void foo();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 2)\n" + + " private abstract void foo();\n" + + " ^^^^^\n" + + "Illegal combination of modifiers for the private interface method foo; additionally only one of static and strictfp is permitted\n" + + "----------\n"); + } + + // illegal modifier combination - negative test + public void testBug488662_007() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + " private synchronized void foo();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 2)\n" + + " private synchronized void foo();\n" + + " ^^^^^\n" + + "Illegal modifier for the interface method foo; only public, private, abstract, default, static and strictfp are permitted\n" + + "----------\n" + + "2. ERROR in I.java (at line 2)\n" + + " private synchronized void foo();\n" + + " ^^^^^\n" + + "This method requires a body instead of a semicolon\n" + + "----------\n"); + } + + // reduced visibility modifier - negative test + public void testBug488662_008() { + runNegativeTest( + new String[] { + "X.java", + "interface I {\n"+ + " public default void foo() {}\n"+ + "}\n"+ + "public class X implements I{\n"+ + "@SuppressWarnings(\"unused\")\n" + + "@Override\n" + + " private void foo() {}\n"+ + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " private void foo() {}\n"+ + " ^^^^^\n" + + "Cannot reduce the visibility of the inherited method from I\n" + + "----------\n"); + } + + + // No unimplemented method error - positive test + public void testBug488662_009() { + runConformTest( + new String[] { + "X.java", + "interface I {\n"+ + " private void foo() {\n"+ + " }\n"+ + " public default void bar() {\n"+ + " foo();\n"+ + " }\n"+ + "}\n"+ + "public class X implements I{\n"+ + " public static void main(String[] args) {\n"+ + " new X().bar();\n"+ + " }\n"+ + "}\n" + }, + ""); + } + // illegal modifier combination - multiple errors - negative test + public void testBug488662_010() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + " private public void foo(){}\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 2)\n" + + " private public void foo(){}\n" + + " ^^^^^\n" + + "Illegal combination of modifiers for the private interface method foo; additionally only one of static and strictfp is permitted\n" + + "----------\n"); + } + // illegal modifier combination - negative test + public void testBug488662_011() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + " private protected void foo();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 2)\n" + + " private protected void foo();\n" + + " ^^^^^\n" + + "Illegal modifier for the interface method foo; only public, private, abstract, default, static and strictfp are permitted\n" + + "----------\n" + + "2. ERROR in I.java (at line 2)\n" + + " private protected void foo();\n" + + " ^^^^^\n" + + "This method requires a body instead of a semicolon\n" + + "----------\n"); + } + // illegal modifier combination - multiple errors - negative test + public void testBug488662_012() { + runNegativeTest( + new String[] { + "I.java", + "public interface I {\n" + + " private private public default protected void foo();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in I.java (at line 2)\n" + + " private private public default protected void foo();\n" + + " ^^^^^\n" + + "Duplicate modifier for the method foo in type I\n" + + "----------\n" + + "2. ERROR in I.java (at line 2)\n" + + " private private public default protected void foo();\n" + + " ^^^^^\n" + + "Illegal modifier for the interface method foo; only public, private, abstract, default, static and strictfp are permitted\n" + + "----------\n" + + "3. ERROR in I.java (at line 2)\n" + + " private private public default protected void foo();\n" + + " ^^^^^\n" + + "This method requires a body instead of a semicolon\n" + + "----------\n"); + } +}
\ No newline at end of file diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java index 189ffa1ff8..5192cb31b4 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java @@ -5,6 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * IBM Corporation - added the following constants @@ -1862,7 +1866,10 @@ void setSourceStart(int sourceStart); int IllegalStrictfpForAbstractInterfaceMethod = MethodRelated + 1057; /** @since 3.10 */ int IllegalDefaultModifierSpecification = MethodRelated + 1058; - + /** @since 3.12*/ + int IllegalModifierForInterfaceMethod9 = MethodRelated + 1059; + /** @since 3.12*/ + int IllegalModifierCombinationForPrivateInterfaceMethod9 = MethodRelated + 1060; /** @since 3.12 */ int UndefinedModule = TypeRelated + 1200; /** @since 3.12 */ diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java index 55cb793120..600fbcb5ea 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann - Contributions for @@ -297,7 +301,8 @@ public class MethodDeclaration extends AbstractMethodDeclaration { case TypeDeclaration.INTERFACE_DECL : if (compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8 && (this.modifiers & (ExtraCompilerModifiers.AccSemicolonBody | ClassFileConstants.AccAbstract)) == ExtraCompilerModifiers.AccSemicolonBody) { - if ((this.modifiers & (ClassFileConstants.AccStatic | ExtraCompilerModifiers.AccDefaultMethod)) != 0) { + boolean isPrivateMethod = compilerOptions.sourceLevel >= ClassFileConstants.JDK9 && (this.modifiers & ClassFileConstants.AccPrivate) != 0; + if (isPrivateMethod || ((this.modifiers & (ClassFileConstants.AccStatic | ExtraCompilerModifiers.AccDefaultMethod)) != 0)) { this.scope.problemReporter().methodNeedBody(this); } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java index ebdd045b6f..de18a358a5 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java @@ -5,6 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann - Contributions for @@ -165,6 +169,7 @@ private void checkAndSetModifiersForConstructor(MethodBinding methodBinding) { /** * Spec : 8.4.3 & 9.4 + * TODO: Add the spec section number for private interface methods from jls 9 */ private void checkAndSetModifiersForMethod(MethodBinding methodBinding) { int modifiers = methodBinding.modifiers; @@ -179,22 +184,27 @@ private void checkAndSetModifiersForMethod(MethodBinding methodBinding) { if (declaringClass.isInterface()) { int expectedModifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract; boolean isDefaultMethod = (modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0; // no need to check validity, is done by the parser - boolean reportIllegalModifierCombination = false; - boolean isJDK18orGreater = false; - if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8 && !declaringClass.isAnnotationType()) { + long sourceLevel = compilerOptions().sourceLevel; + if (sourceLevel >= ClassFileConstants.JDK1_8 && !declaringClass.isAnnotationType()) { expectedModifiers |= ClassFileConstants.AccStrictfp | ExtraCompilerModifiers.AccDefaultMethod | ClassFileConstants.AccStatic; - isJDK18orGreater = true; - if (!methodBinding.isAbstract()) { - reportIllegalModifierCombination = isDefaultMethod && methodBinding.isStatic(); - } else { - reportIllegalModifierCombination = isDefaultMethod || methodBinding.isStatic(); - if (methodBinding.isStrictfp()) { + expectedModifiers |= sourceLevel >= ClassFileConstants.JDK9 ? ClassFileConstants.AccPrivate : 0; + if (methodBinding.isAbstract()) { + if (methodBinding.isStrictfp()) problemReporter().illegalAbstractModifierCombinationForMethod((AbstractMethodDeclaration) this.referenceContext); + if (isDefaultMethod || methodBinding.isStatic()) { + problemReporter().illegalModifierCombinationForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext); } - } - if (reportIllegalModifierCombination) { + } else if (isDefaultMethod && methodBinding.isStatic()) { problemReporter().illegalModifierCombinationForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext); + } + if (sourceLevel >= ClassFileConstants.JDK9 && (methodBinding.modifiers & ClassFileConstants.AccPrivate) != 0) { + int remaining = realModifiers & ~expectedModifiers; + if (remaining == 0) { // check for the combination of allowed modifiers with private + remaining = realModifiers & ~(ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccStrictfp); + if (isDefaultMethod || remaining != 0) + problemReporter().illegalModifierCombinationForPrivateInterfaceMethod((AbstractMethodDeclaration) this.referenceContext); + } } // Kludge - The AccDefaultMethod bit is outside the lower 16 bits and got removed earlier. Putting it back. if (isDefaultMethod) { @@ -205,7 +215,7 @@ private void checkAndSetModifiersForMethod(MethodBinding methodBinding) { if ((declaringClass.modifiers & ClassFileConstants.AccAnnotation) != 0) problemReporter().illegalModifierForAnnotationMember((AbstractMethodDeclaration) this.referenceContext); else - problemReporter().illegalModifierForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext, isJDK18orGreater); + problemReporter().illegalModifierForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext, sourceLevel); } return; } @@ -342,6 +352,7 @@ MethodBinding createMethod(AbstractMethodDeclaration method) { // is necessary to ensure error reporting this.referenceContext = method; method.scope = this; + long sourceLevel = compilerOptions().sourceLevel; SourceTypeBinding declaringClass = referenceType().binding; int modifiers = method.modifiers | ExtraCompilerModifiers.AccUnresolved; if (method.isConstructor()) { @@ -351,7 +362,9 @@ MethodBinding createMethod(AbstractMethodDeclaration method) { checkAndSetModifiersForConstructor(method.binding); } else { if (declaringClass.isInterface()) {// interface or annotation type - if (method.isDefaultMethod() || method.isStatic()) { + if (sourceLevel >= ClassFileConstants.JDK9 && ((method.modifiers & ClassFileConstants.AccPrivate) != 0)) { // private method + // do nothing + } else if (method.isDefaultMethod() || method.isStatic()) { modifiers |= ClassFileConstants.AccPublic; // default method is not abstract } else { modifiers |= ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract; @@ -365,7 +378,6 @@ MethodBinding createMethod(AbstractMethodDeclaration method) { Argument[] argTypes = method.arguments; int argLength = argTypes == null ? 0 : argTypes.length; - long sourceLevel = compilerOptions().sourceLevel; if (argLength > 0) { Argument argument = argTypes[--argLength]; if (argument.isVarArgs() && sourceLevel >= ClassFileConstants.JDK1_5) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java index 4e583bca24..075a67778d 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java @@ -4795,7 +4795,8 @@ protected void consumeInterfaceMethodDeclaration(boolean hasSemicolonBody) { boolean isDefault = (md.modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0; boolean isStatic = (md.modifiers & ClassFileConstants.AccStatic) != 0; - boolean bodyAllowed = isDefault || isStatic; + boolean isPrivate = (md.modifiers & ClassFileConstants.AccPrivate) != 0; + boolean bodyAllowed = (this.parsingJava9Plus && isPrivate) || isDefault || isStatic; if (this.parsingJava8Plus) { if (bodyAllowed && hasSemicolonBody) { md.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; // avoid complaints regarding undocumented empty body diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index 9012ca218a..09120a1e94 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -2685,6 +2685,15 @@ public void illegalModifierCombinationForInterfaceMethod(AbstractMethodDeclarati methodDecl.sourceStart, methodDecl.sourceEnd); } +public void illegalModifierCombinationForPrivateInterfaceMethod(AbstractMethodDeclaration methodDecl) { + String[] arguments = new String[] {new String(methodDecl.selector)}; + this.handle( + IProblem.IllegalModifierCombinationForPrivateInterfaceMethod9, + arguments, + arguments, + methodDecl.sourceStart, + methodDecl.sourceEnd); +} public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) { String name = new String(fieldDecl.name); @@ -2803,13 +2812,14 @@ public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) { fieldDecl.sourceStart, fieldDecl.sourceEnd); } -public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl, boolean isJDK18orGreater) { +public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl, long level) { + + int problem = level < ClassFileConstants.JDK1_8 ? IProblem.IllegalModifierForInterfaceMethod : + level < ClassFileConstants.JDK9 ? IProblem.IllegalModifierForInterfaceMethod18 : IProblem.IllegalModifierForInterfaceMethod9; // cannot include parameter types since they are not resolved yet // and the error message would be too long this.handle( - isJDK18orGreater - ? IProblem.IllegalModifierForInterfaceMethod18 - : IProblem.IllegalModifierForInterfaceMethod, + problem, new String[] { new String(methodDecl.selector) }, diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties index 2003597c56..61ecf114d9 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties @@ -5,6 +5,9 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # +# This is an implementation of an early-draft specification developed under the Java +# Community Process (JCP) and is made available for testing and evaluation purposes +# only. The code is not compatible with any specification of the JCP. # # Contributors: # IBM Corporation - initial API and implementation @@ -856,6 +859,8 @@ 1056 = Illegal combination of modifiers for the interface method {0}; only one of abstract, default, or static permitted 1057 = strictfp is not permitted for abstract interface method {0} 1058 = Default methods are allowed only in interfaces. +1059 = Illegal modifier for the interface method {0}; only public, private, abstract, default, static and strictfp are permitted +1060 = Illegal combination of modifiers for the private interface method {0}; additionally only one of static and strictfp is permitted 1100 = Problem detected during type inference: {0} |
