Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2017-01-04 09:29:44 +0000
committerSasikanth Bharadwaj2017-04-27 04:58:34 +0000
commit22e180d67693c70eb2a4fb8c5802917a8c4c9c3e (patch)
tree8017941e6546d741824a4d283a56c4be0cd83b57
parentcb5a1629ec4abe9ac2961e6bb7c27b796e771ac8 (diff)
downloadeclipse.jdt.core-22e180d67693c70eb2a4fb8c5802917a8c4c9c3e.tar.gz
eclipse.jdt.core-22e180d67693c70eb2a4fb8c5802917a8c4c9c3e.tar.xz
eclipse.jdt.core-22e180d67693c70eb2a4fb8c5802917a8c4c9c3e.zip
bug 500636 - Annotations support in module-info
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java64
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java244
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java16
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java31
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rscbin33682 -> 33634 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rscbin582 -> 582 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rscbin2322 -> 2322 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rscbin1466 -> 1466 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rscbin2304 -> 2306 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rscbin852 -> 852 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rscbin7587 -> 7491 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rscbin31978 -> 31930 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rscbin6816 -> 6816 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rscbin778 -> 778 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rscbin2304 -> 2306 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rscbin3336 -> 3356 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rscbin2304 -> 2306 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rscbin1382 -> 1380 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rscbin258 -> 258 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rscbin778 -> 778 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rscbin15078 -> 14858 bytes
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties1
-rw-r--r--org.eclipse.jdt.core/grammar/java.g77
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java3
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java7
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java3
39 files changed, 464 insertions, 68 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java
index 5a70af1bcc..a67b46c71d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ModuleDeclarationSyntaxTest.java
@@ -491,4 +491,68 @@ public class ModuleDeclarationSyntaxTest extends AbstractSyntaxTreeTest {
options.targetJDK = ClassFileConstants.JDK9;
checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
}
+ public void test0025() throws IOException {
+ String source =
+ "@Foo\n" +
+ "module org.astro {\n" +
+ " exports org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Foo\n" +
+ "module org.astro {\n" +
+ " exports org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
+ "}\n";
+ CompilerOptions options = new CompilerOptions(getCompilerOptions());
+ options.complianceLevel = ClassFileConstants.JDK9;
+ options.sourceLevel = ClassFileConstants.JDK9;
+ options.targetJDK = ClassFileConstants.JDK9;
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
+ }
+ public void test0026() throws IOException {
+ String source =
+ "@Foo\n" +
+ "open module org.astro {\n" +
+ " exports org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Foo\n" +
+ "open module org.astro {\n" +
+ " exports org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
+ "}\n";
+ CompilerOptions options = new CompilerOptions(getCompilerOptions());
+ options.complianceLevel = ClassFileConstants.JDK9;
+ options.sourceLevel = ClassFileConstants.JDK9;
+ options.targetJDK = ClassFileConstants.JDK9;
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
+ }
+
+ public void test0027() throws IOException {
+ String source =
+ "@Foo @Bar(x = 2) @Baz(\"true\")\n" +
+ "open module org.astro {\n" +
+ " exports org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Foo @Bar(x = 2) @Baz(\"true\")\n" +
+ "open module org.astro {\n" +
+ " exports org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro to com.greetings, com.example1, com.example2;\n" +
+ " opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
+ "}\n";
+ CompilerOptions options = new CompilerOptions(getCompilerOptions());
+ options.complianceLevel = ClassFileConstants.JDK9;
+ options.sourceLevel = ClassFileConstants.JDK9;
+ options.targetJDK = ClassFileConstants.JDK9;
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
+ }
}
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 5ebfd6f667..a2dba715b6 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
@@ -591,6 +591,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("IllegalModifierForModule", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierForInterfaceMethod9", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalModifierForVariable", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalModifiersForElidedType", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -1458,6 +1459,7 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("IllegalModifierForMemberEnum", SKIP);
expectedProblemAttributes.put("IllegalModifierForMemberInterface", SKIP);
expectedProblemAttributes.put("IllegalModifierForMethod", SKIP);
+ expectedProblemAttributes.put("IllegalModifierForModule", SKIP);
expectedProblemAttributes.put("IllegalModifierForInterfaceMethod9", SKIP);
expectedProblemAttributes.put("IllegalModifierForVariable", SKIP);
expectedProblemAttributes.put("IllegalModifiersForElidedType", SKIP);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index c3a6f00568..81a1d8e50f 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -2616,6 +2616,250 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
deleteProject("Test");
}
}
+ public void test_annotations_in_moduleinfo() throws CoreException {
+ if (!isJRE9) return;
+ try {
+ String[] sources = new String[] {
+ "src/module-info.java",
+ "module org.astro {\n" +
+ " exports org.astro;\n" +
+ "}",
+ "src/org/astro/World.java",
+ "package org.astro;\n" +
+ "public interface World {\n" +
+ " public String name();\n" +
+ "}",
+ "src/org/astro/Foo.java",
+ "package org.astro;\n" +
+ "public @interface Foo {}"
+ };
+ IJavaProject p1 = setupModuleProject("org.astro", sources);
+ IClasspathEntry dep = JavaCore.newProjectEntry(p1.getPath());
+ String[] src = new String[] {
+ "src/module-info.java",
+ "import org.astro.Foo;\n" +
+ "import org.astro.World;\n" +
+ "@Foo\n" +
+ "module com.greetings {\n" +
+ " requires org.astro;\n" +
+ " exports com.greetings;\n" +
+ " provides World with com.greetings.MyWorld;\n" +
+ "}",
+ "src/com/greetings/MyWorld.java",
+ "package com.greetings;\n" +
+ "import org.astro.World;\n" +
+ "public class MyWorld implements World {\n" +
+ " public String name() {\n" +
+ " return \" My World!!\";\n" +
+ " }\n" +
+ "}"
+ };
+ IJavaProject p2 = setupModuleProject("com.greetings", src, new IClasspathEntry[] { dep });
+ p2.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers", "", markers);
+ } finally {
+ deleteProject("org.astro");
+ deleteProject("com.greetings");
+ }
+ }
+ public void test_unresolved_annotations() throws CoreException {
+ if (!isJRE9) return;
+ try {
+ String[] sources = new String[] {
+ "src/module-info.java",
+ "module org.astro {\n" +
+ " exports org.astro;\n" +
+ "}",
+ "src/org/astro/World.java",
+ "package org.astro;\n" +
+ "public interface World {\n" +
+ " public String name();\n" +
+ "}",
+ "src/org/astro/Foo.java",
+ "package org.astro;\n" +
+ "public @interface Foo {}"
+ };
+ IJavaProject p1 = setupModuleProject("org.astro", sources);
+ IClasspathEntry dep = JavaCore.newProjectEntry(p1.getPath());
+ String[] src = new String[] {
+ "src/module-info.java",
+ "import org.astro.Foo;\n" +
+ "import org.astro.World;\n" +
+ "@Foo @Bar\n" +
+ "module com.greetings {\n" +
+ " requires org.astro;\n" +
+ " exports com.greetings;\n" +
+ " provides World with com.greetings.MyWorld;\n" +
+ "}",
+ "src/com/greetings/MyWorld.java",
+ "package com.greetings;\n" +
+ "import org.astro.World;\n" +
+ "public class MyWorld implements World {\n" +
+ " public String name() {\n" +
+ " return \" My World!!\";\n" +
+ " }\n" +
+ "}"
+ };
+ IJavaProject p2 = setupModuleProject("com.greetings", src, new IClasspathEntry[] { dep });
+ p2.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers",
+ "Bar cannot be resolved to a type", markers);
+ } finally {
+ deleteProject("org.astro");
+ deleteProject("com.greetings");
+ }
+ }
+ public void test_illegal_modifiers() throws CoreException {
+ if (!isJRE9) return;
+ try {
+ String[] sources = new String[] {
+ "src/module-info.java",
+ "module org.astro {\n" +
+ " exports org.astro;\n" +
+ "}",
+ "src/org/astro/World.java",
+ "package org.astro;\n" +
+ "public interface World {\n" +
+ " public String name();\n" +
+ "}",
+ "src/org/astro/Foo.java",
+ "package org.astro;\n" +
+ "public @interface Foo {}"
+ };
+ IJavaProject p1 = setupModuleProject("org.astro", sources);
+ IClasspathEntry dep = JavaCore.newProjectEntry(p1.getPath());
+ String[] src = new String[] {
+ "src/module-info.java",
+ "import org.astro.Foo;\n" +
+ "import org.astro.World;\n" +
+ "@Foo\n" +
+ "private static module com.greetings {\n" +
+ " requires org.astro;\n" +
+ " exports com.greetings;\n" +
+ " provides World with com.greetings.MyWorld;\n" +
+ "}",
+ "src/com/greetings/MyWorld.java",
+ "package com.greetings;\n" +
+ "import org.astro.World;\n" +
+ "public class MyWorld implements World {\n" +
+ " public String name() {\n" +
+ " return \" My World!!\";\n" +
+ " }\n" +
+ "}"
+ };
+ IJavaProject p2 = setupModuleProject("com.greetings", src, new IClasspathEntry[] { dep });
+ p2.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers",
+ "Illegal modifier for module com.greetings; only open is permitted", markers);
+ } finally {
+ deleteProject("org.astro");
+ deleteProject("com.greetings");
+ }
+ }
+ public void test_annotations_with_target() throws CoreException {
+ if (!isJRE9) return;
+ try {
+ String[] sources = new String[] {
+ "src/module-info.java",
+ "module org.astro {\n" +
+ " exports org.astro;\n" +
+ "}",
+ "src/org/astro/World.java",
+ "package org.astro;\n" +
+ "public interface World {\n" +
+ " public String name();\n" +
+ "}",
+ "src/org/astro/Foo.java",
+ "package org.astro;\n" +
+ "import java.lang.annotation.ElementType;\n" +
+ "import java.lang.annotation.Target;\n" +
+ "@Target(ElementType.MODULE)\n" +
+ "public @interface Foo {}"
+ };
+ IJavaProject p1 = setupModuleProject("org.astro", sources);
+ IClasspathEntry dep = JavaCore.newProjectEntry(p1.getPath());
+ String[] src = new String[] {
+ "src/module-info.java",
+ "import org.astro.Foo;\n" +
+ "import org.astro.World;\n" +
+ "@Foo\n" +
+ "module com.greetings {\n" +
+ " requires org.astro;\n" +
+ " exports com.greetings;\n" +
+ " provides World with com.greetings.MyWorld;\n" +
+ "}",
+ "src/com/greetings/MyWorld.java",
+ "package com.greetings;\n" +
+ "import org.astro.World;\n" +
+ "public class MyWorld implements World {\n" +
+ " public String name() {\n" +
+ " return \" My World!!\";\n" +
+ " }\n" +
+ "}"
+ };
+ IJavaProject p2 = setupModuleProject("com.greetings", src, new IClasspathEntry[] { dep });
+ p2.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers", "", markers);
+ } finally {
+ deleteProject("org.astro");
+ deleteProject("com.greetings");
+ }
+ }
+ public void test_annotations_with_wrong_target() throws CoreException {
+ if (!isJRE9) return;
+ try {
+ String[] sources = new String[] {
+ "src/module-info.java",
+ "module org.astro {\n" +
+ " exports org.astro;\n" +
+ "}",
+ "src/org/astro/World.java",
+ "package org.astro;\n" +
+ "public interface World {\n" +
+ " public String name();\n" +
+ "}",
+ "src/org/astro/Foo.java",
+ "package org.astro;\n" +
+ "import java.lang.annotation.ElementType;\n" +
+ "import java.lang.annotation.Target;\n" +
+ "@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE})\n" +
+ "public @interface Foo {}"
+ };
+ IJavaProject p1 = setupModuleProject("org.astro", sources);
+ IClasspathEntry dep = JavaCore.newProjectEntry(p1.getPath());
+ String[] src = new String[] {
+ "src/module-info.java",
+ "import org.astro.Foo;\n" +
+ "import org.astro.World;\n" +
+ "@Foo\n" +
+ "module com.greetings {\n" +
+ " requires org.astro;\n" +
+ " exports com.greetings;\n" +
+ " provides World with com.greetings.MyWorld;\n" +
+ "}",
+ "src/com/greetings/MyWorld.java",
+ "package com.greetings;\n" +
+ "import org.astro.World;\n" +
+ "public class MyWorld implements World {\n" +
+ " public String name() {\n" +
+ " return \" My World!!\";\n" +
+ " }\n" +
+ "}"
+ };
+ IJavaProject p2 = setupModuleProject("com.greetings", src, new IClasspathEntry[] { dep });
+ p2.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers",
+ "The annotation @Foo is disallowed for this location", markers);
+ } finally {
+ deleteProject("org.astro");
+ deleteProject("com.greetings");
+ }
+ }
// sort by CHAR_START
protected void sortMarkers(IMarker[] markers) {
Arrays.sort(markers, (a,b) -> a.getAttribute(IMarker.CHAR_START, 0) - b.getAttribute(IMarker.CHAR_START, 0));
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index e5df6312dc..194015f49d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -12675,6 +12675,11 @@ public final class CompletionEngine
if(target != 0 && (target & TagBits.AnnotationForPackage) == 0) {
return false;
}
+ } else if (this.targetedElement == TagBits.AnnotationForModule) {
+ long target = typeBinding.getAnnotationTagBits() & TagBits.AnnotationTargetMASK;
+ if(target != 0 && (target & TagBits.AnnotationForModule) == 0) {
+ return false;
+ }
} else if ((this.targetedElement & (TagBits.AnnotationForType | TagBits.AnnotationForTypeUse)) != 0) {
if (scope.parent != null &&
scope.parent.parent != null &&
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 0c69f743e5..e5f6878c79 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
@@ -1931,6 +1931,8 @@ void setSourceStart(int sourceStart);
int InvalidServiceIntfType = TypeRelated + 1316;
/** @since 3.13 BETA_JAVA9 */
int InvalidServiceImplType = TypeRelated + 1317;
+ /** @since 3.13 BETA_JAVA9 */
+ int IllegalModifierForModule = TypeRelated + 1318;
/** @since 3.13 BETA_JAVA9 */
int DuplicateResource = Internal + 1251;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index cf5e4b289b..2722bd7a61 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -382,6 +382,8 @@ public class ClassFile implements TypeConstants, TypeIds {
long targetMask;
if (typeDeclaration.isPackageInfo())
targetMask = TagBits.AnnotationForPackage;
+ else if (this.referenceBinding.isModule()) // TODO: add isModuleInfo() to TypeDeclaration
+ targetMask = TagBits.AnnotationForModule;
else if (this.referenceBinding.isAnnotationType())
targetMask = TagBits.AnnotationForType | TagBits.AnnotationForAnnotationType;
else
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index 11f6b1c647..d96c5514eb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -4,6 +4,10 @@
* 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
@@ -286,6 +290,8 @@ public abstract class Annotation extends Expression {
case 'M' :
if (CharOperation.equals(elementName, TypeConstants.UPPER_METHOD))
return TagBits.AnnotationForMethod;
+ else if (CharOperation.equals(elementName, TypeConstants.UPPER_MODULE))
+ return TagBits.AnnotationForModule;
break;
case 'P' :
if (CharOperation.equals(elementName, TypeConstants.UPPER_PARAMETER))
@@ -634,6 +640,7 @@ public abstract class Annotation extends Expression {
builder.check(TagBits.AnnotationForPackage, TypeConstants.UPPER_PACKAGE);
builder.check(TagBits.AnnotationForTypeParameter, TypeConstants.TYPE_PARAMETER_TARGET);
builder.check(TagBits.AnnotationForTypeUse, TypeConstants.TYPE_USE_TARGET);
+ builder.check(TagBits.AnnotationForModule, TypeConstants.UPPER_MODULE);
if (builder.hasError()) {
repeatableAnnotationType.tagAsHavingDefectiveContainerType();
scope.problemReporter().repeatableAnnotationTypeTargetMismatch(culpritNode, repeatableAnnotationType, containerType, builder.toString());
@@ -1064,6 +1071,13 @@ public abstract class Annotation extends Expression {
}
break;
case Binding.TYPE :
+ if (((ReferenceBinding)recipient).isModule()) {
+ if ((metaTagBits & (TagBits.AnnotationForModule)) != 0) {
+ return AnnotationTargetAllowed.YES;
+ }
+ break;
+ }
+ //$FALL-THROUGH$
case Binding.GENERIC_TYPE :
if (((ReferenceBinding)recipient).isAnnotationType()) {
if ((metaTagBits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType | TagBits.AnnotationForTypeUse)) != 0)
@@ -1150,6 +1164,8 @@ public abstract class Annotation extends Expression {
long metaTagBits = annotationType.getAnnotationTagBits(); // could be forward reference
if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) {
// does not specify any target restriction - all locations supported in Java 7 and before are possible
+ // TBD - revisit for modules - as per 9.6.4.1, annotation without target is applicable for module declaration
+ // which is listed as a declaration context, but javac does not allow this
if (kind == Binding.TYPE_PARAMETER || kind == Binding.TYPE_USE) {
scope.problemReporter().explitAnnotationTargetRequired(annotation);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
index 923ea7bd1e..6a70cd8a88 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 IBM Corporation and others.
+ * Copyright (c) 2015, 2017 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
@@ -142,6 +142,14 @@ public class ModuleDeclaration extends TypeDeclaration {
public StringBuffer printHeader(int indent, StringBuffer output) {
+ if (this.annotations != null) {
+ for (int i = 0; i < this.annotations.length; i++) {
+ this.annotations[i].print(indent, output);
+ if (i != this.annotations.length - 1)
+ output.append(" "); //$NON-NLS-1$
+ }
+ output.append('\n');
+ }
if (isOpen()) {
output.append("open "); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
index cfd1fa7814..8c39603293 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
@@ -146,6 +146,8 @@ private static AnnotationBinding buildTargetAnnotation(long bits, LookupEnvironm
arraysize++;
if ((bits & TagBits.AnnotationForTypeParameter) != 0)
arraysize++;
+ if ((bits & TagBits.AnnotationForModule) != 0)
+ arraysize++;
Object[] value = new Object[arraysize];
if (arraysize > 0) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 7e34b3b0a2..7556ee3c4b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -43,6 +43,7 @@ import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
@@ -647,9 +648,12 @@ public class ClassScope extends Scope {
}
}
} else {
- if (sourceType.sourceName == TypeConstants.MODULE_INFO_NAME) {
+ if (sourceType.isModule()) {
// TBD - allowed only at source level 9 or above
modifiers = ClassFileConstants.AccModule;
+ if ((realModifiers & ~(ClassFileConstants.ACC_OPEN | ClassFileConstants.AccModule)) != 0) {
+ problemReporter().illegalModifierForModule((ModuleDeclaration) this.referenceContext);
+ }
if ((realModifiers & ClassFileConstants.ACC_OPEN) != 0) {
modifiers |= ClassFileConstants.ACC_OPEN;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java
index 5f76fed040..8cfe4b7d71 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java
@@ -1,9 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -120,11 +124,12 @@ public interface TagBits {
long AnnotationForPackage = ASTNode.Bit44L;
long AnnotationForTypeUse = ASTNode.Bit54L;
long AnnotationForTypeParameter = ASTNode.Bit55L;
+ long AnnotationForModule = ASTNode.Bit62L;
long SE7AnnotationTargetMASK = AnnotationForType | AnnotationForField | AnnotationForMethod
| AnnotationForParameter | AnnotationForConstructor | AnnotationForLocalVariable
| AnnotationForAnnotationType | AnnotationForPackage;
long AnnotationTargetMASK = SE7AnnotationTargetMASK | AnnotationTarget
- | AnnotationForTypeUse | AnnotationForTypeParameter;
+ | AnnotationForTypeUse | AnnotationForTypeParameter | AnnotationForModule;
// 2-bits for retention (should check (tagBits & RetentionMask) == RuntimeRetention
long AnnotationSourceRetention = ASTNode.Bit45L;
long AnnotationClassRetention = ASTNode.Bit46L;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
index eb536252ec..794d0a4b1f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
@@ -106,8 +106,9 @@ public interface TypeConstants {
char[] ANONYMOUS_METHOD = "lambda$".toCharArray(); //$NON-NLS-1$
char[] DESERIALIZE_LAMBDA = "$deserializeLambda$".toCharArray(); //$NON-NLS-1$
char[] LAMBDA_TYPE = "<lambda>".toCharArray(); //$NON-NLS-1$
-
- // jsr308
+ char[] UPPER_MODULE = "MODULE".toCharArray(); //$NON-NLS-1$
+
+ // jsr308
char[] TYPE_USE_TARGET = "TYPE_USE".toCharArray(); //$NON-NLS-1$
char[] TYPE_PARAMETER_TARGET = "TYPE_PARAMETER".toCharArray(); //$NON-NLS-1$
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 2f38b3f2e0..a2b2d19c07 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
@@ -5818,6 +5818,14 @@ protected void consumeEmptyModuleStatementsOpt() {
protected void consumeModuleStatements() {
concatNodeLists();
}
+protected void consumeModuleModifiers() {
+ checkComment(); // might update modifiers with AccDeprecated
+ // Merge with other modifiers
+ this.intStack[this.intPtr -1] |= this.modifiers;
+ resetModifiers();
+ // Account for the possible presence of annotations as well
+ this.expressionLengthStack[this.expressionLengthPtr - 1] += this.expressionLengthStack[this.expressionLengthPtr--];
+}
protected void consumeModuleHeader() {
// ModuleHeader ::= 'module' Name
@@ -5843,6 +5851,21 @@ protected void consumeModuleHeader() {
if (typeDecl.modifiersSourceStart >= 0) {
typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
}
+// int otherModifiersStart = this.intStack[this.intPtr--];
+// int otherModifiers = this.intStack[this.intPtr--];
+// if (otherModifiersStart >= 0) {
+// typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart = otherModifiersStart;
+// }
+ // Merge with other modifiers
+// typeDecl.modifiers |= otherModifiers;
+ if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.expressionStack,
+ (this.expressionPtr -= length) + 1,
+ typeDecl.annotations = new Annotation[length],
+ 0,
+ length);
+ }
pushOnAstStack(typeDecl);
this.listLength = 0;
@@ -6556,16 +6579,12 @@ protected void consumeRule(int act) {
consumeModuleDeclaration();
break;
- case 100 : if (DEBUG) { System.out.println("ModuleHeader ::= ModuleModifieropt module..."); } //$NON-NLS-1$
+ case 100 : if (DEBUG) { System.out.println("ModuleHeader ::= Modifiersopt ModuleModifieropt module"); } //$NON-NLS-1$
consumeModuleHeader();
break;
- case 101 : if (DEBUG) { System.out.println("ModuleModifieropt ::="); } //$NON-NLS-1$
- consumeDefaultModifiers();
- break;
-
case 102 : if (DEBUG) { System.out.println("ModuleModifieropt ::= ModuleModifier"); } //$NON-NLS-1$
- consumeModifiers();
+ consumeModuleModifiers();
break;
case 105 : if (DEBUG) { System.out.println("ModuleStatementsOpt ::="); } //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
index aefbf6e33e..f3bfae0436 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
@@ -18,20 +18,20 @@ public interface ParserBasicInformation {
ERROR_SYMBOL = 128,
MAX_NAME_LENGTH = 41,
- NUM_STATES = 1151,
+ NUM_STATES = 1152,
NT_OFFSET = 128,
SCOPE_UBOUND = 290,
SCOPE_SIZE = 291,
- LA_STATE_OFFSET = 16645,
+ LA_STATE_OFFSET = 16451,
MAX_LA = 1,
NUM_RULES = 851,
NUM_TERMINALS = 128,
NUM_NON_TERMINALS = 388,
NUM_SYMBOLS = 516,
- START_STATE = 943,
+ START_STATE = 895,
EOFT_SYMBOL = 60,
EOLT_SYMBOL = 60,
- ACCEPT_ACTION = 16644,
- ERROR_ACTION = 16645;
+ ACCEPT_ACTION = 16450,
+ ERROR_ACTION = 16451;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
index 02686d5ca8..230d7f4096 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
@@ -37,20 +37,20 @@ public interface TerminalTokens {
int TokenNameIdentifier = 22,
TokenNameabstract = 51,
- TokenNameassert = 72,
+ TokenNameassert = 73,
TokenNameboolean = 97,
- TokenNamebreak = 73,
+ TokenNamebreak = 74,
TokenNamebyte = 98,
TokenNamecase = 99,
TokenNamecatch = 100,
TokenNamechar = 101,
- TokenNameclass = 67,
- TokenNamecontinue = 74,
+ TokenNameclass = 66,
+ TokenNamecontinue = 75,
TokenNameconst = 126,
- TokenNamedefault = 75,
+ TokenNamedefault = 71,
TokenNamedo = 76,
TokenNamedouble = 102,
- TokenNameelse = 112,
+ TokenNameelse = 111,
TokenNameenum = 69,
TokenNameextends = 85,
TokenNamefalse = 39,
@@ -88,8 +88,8 @@ public interface TerminalTokens {
TokenNametry = 82,
TokenNamevoid = 108,
TokenNamevolatile = 59,
- TokenNamewhile = 71,
- TokenNamemodule = 110,
+ TokenNamewhile = 72,
+ TokenNamemodule = 112,
TokenNameopen = 113,
TokenNamerequires = 114,
TokenNametransitive = 120,
@@ -153,12 +153,12 @@ public interface TerminalTokens {
TokenNameEQUAL = 70,
TokenNameAT = 37,
TokenNameELLIPSIS = 121,
- TokenNameARROW = 111,
+ TokenNameARROW = 110,
TokenNameCOLON_COLON = 7,
TokenNameBeginLambda = 49,
TokenNameBeginIntersectionCast = 65,
TokenNameBeginTypeArguments = 83,
- TokenNameElidedSemicolonAndRightBrace = 66,
+ TokenNameElidedSemicolonAndRightBrace = 67,
TokenNameAT308 = 28,
TokenNameAT308DOTDOTDOT = 125,
TokenNameEOF = 60,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
index 7a6b2c808b..274fa5063e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc
index f6b30e4e5c..867a099f38 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser12.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc
index 4d102540c5..07b4bf6bbf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser14.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc
index 56b7929529..56d678fa71 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser15.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc
index d2faa6264d..9e8f5966ee 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser16.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc
index 6e692da032..353090ba35 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser17.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc
index adde4be0a3..266bf1bcf6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser18.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc
index 554f5c3d8e..df3f4df043 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc
@@ -1,2 +1,2 @@
-ppF!!m yF!!@@@@00m!!!!=== y##""!!Bd=!!!#!c =}G  0HH000lab  
-U  EFFoDKCU=E  % %S"#  \ No newline at end of file
+ooF!!m yF!!@@@@00m!!!!=== y##""!!Cd=!!!#!c =}H  0II000lab  
+U  EFFnDGBU=E  % %S"#  \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
index 42854ba95a..3a3cedb52a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc
index 9dc82bbd9e..3031ff9f42 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser21.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc
index 59aa6c9335..ec7d7e618c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser24.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
index 215202ee6d..95008983e9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
index 8d5026260a..a1145dcb17 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
index 09931cae4c..f56c662a2d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc
index f667b28973..28c6b22efb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser6.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc
index b84bf38433..30e76fa77b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser7.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc
index e7446fe0a9..e594f6b593 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser8.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc
index bc2102dff0..4b693991e9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser9.rsc
Binary files differ
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 629a7ce5a1..a2dce63581 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
@@ -2778,6 +2778,15 @@ public void illegalModifierForClass(SourceTypeBinding type) {
type.sourceStart(),
type.sourceEnd());
}
+public void illegalModifierForModule(ModuleDeclaration module) {
+ String[] arguments = new String[] {new String(module.moduleName)};
+ this.handle(
+ IProblem.IllegalModifierForModule,
+ arguments,
+ arguments,
+ module.sourceStart(),
+ module.sourceEnd());
+}
public void illegalModifierForEnum(SourceTypeBinding type) {
String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
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 63dfa32f30..345fcf6636 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
@@ -905,6 +905,7 @@
1315 = opens statement is not allowed, as module {0} is declared open
1316 = Invalid service interface {0}, must be a class, interface or annotation type
1317 = Invalid service implementation {0}, must be a public class or interface type
+1318 = Illegal modifier for module {0}; only open is permitted
### ELABORATIONS
## Access restrictions
diff --git a/org.eclipse.jdt.core/grammar/java.g b/org.eclipse.jdt.core/grammar/java.g
index 3bc5ad0bf8..41761de113 100644
--- a/org.eclipse.jdt.core/grammar/java.g
+++ b/org.eclipse.jdt.core/grammar/java.g
@@ -418,117 +418,118 @@ InternalCompilationUnit ::= $empty
/.$putCase consumeEmptyInternalCompilationUnit(); $break ./
/:$readableName CompilationUnit:/
---1.9 feature
+--Java9 features
InternalCompilationUnit ::= ImportDeclarations ReduceImports ModuleDeclaration
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeInternalCompilationUnitWithModuleDeclaration(); $break ./
InternalCompilationUnit ::= ModuleDeclaration
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeInternalCompilationUnitWithModuleDeclaration(); $break ./
ModuleDeclaration ::= ModuleHeader ModuleBody
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeModuleDeclaration(); $break ./
-ModuleHeader ::= ModuleModifieropt 'module' UnannotatableName
-/:$compliance 1.9:/
+-- to work around shift/reduce conflicts, we allow Modifiersopt in order to support annotations
+-- in a module declaration, and then report errors if any modifiers other than annotations are
+-- encountered
+ModuleHeader ::= Modifiersopt ModuleModifieropt 'module' UnannotatableName
+/:$compliance 9:/
/.$putCase consumeModuleHeader(); $break ./
ModuleModifieropt ::= $empty
-/:$compliance 1.9:/
-/.$putCase consumeDefaultModifiers(); $break ./
ModuleModifieropt ::= ModuleModifier
-/:$compliance 1.9:/
-/.$putCase consumeModifiers(); $break ./
+/:$compliance 9:/
+/.$putCase consumeModuleModifiers(); $break ./
ModuleModifier -> 'open'
ModuleBody ::= '{' ModuleStatementsOpt '}'
-/:$compliance 1.9:/
+/:$compliance 9:/
/:$no_statements_recovery:/
ModuleStatementsOpt ::= $empty
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeEmptyModuleStatementsOpt(); $break ./
ModuleStatementsOpt -> ModuleStatements
-/:$compliance 1.9:/
+/:$compliance 9:/
ModuleStatements ::= ModuleStatement
ModuleStatements ::= ModuleStatements ModuleStatement
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeModuleStatements(); $break ./
ModuleStatement ::= RequiresStatement
-/:$compliance 1.9:/
+/:$compliance 9:/
ModuleStatement ::= ExportsStatement
-/:$compliance 1.9:/
+/:$compliance 9:/
ModuleStatement ::= OpensStatement
-/:$compliance 1.9:/
+/:$compliance 9:/
ModuleStatement ::= UsesStatement
-/:$compliance 1.9:/
+/:$compliance 9:/
ModuleStatement ::= ProvidesStatement
-/:$compliance 1.9:/
+/:$compliance 9:/
RequiresStatement ::= SingleRequiresModuleName ';'
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeRequiresStatement(); $break ./
SingleRequiresModuleName ::= 'requires' RequiresModifiersopt UnannotatableName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeSingleRequiresModuleName(); $break ./
RequiresModifiersopt ::= RequiresModifiers
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeModifiers(); $break ./
RequiresModifiersopt ::= $empty
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeDefaultModifiers(); $break ./
RequiresModifiers -> RequiresModifier
RequiresModifiers ::= RequiresModifiers RequiresModifier
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeModifiers2(); $break ./
RequiresModifier -> 'transitive'
RequiresModifier -> 'static'
ExportsStatement ::= ExportsHeader TargetModuleListopt ';'
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeExportsStatement(); $break ./
ExportsHeader ::= 'exports' SinglePkgName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeExportsHeader(); $break ./
TargetModuleListopt ::= $empty
TargetModuleListopt ::= 'to' TargetModuleNameList
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeTargetModuleList(); $break ./
TargetModuleName ::= UnannotatableName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeSingleTargetModuleName(); $break ./
TargetModuleNameList -> TargetModuleName
TargetModuleNameList ::= TargetModuleNameList ',' TargetModuleName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeTargetModuleNameList(); $break ./
SinglePkgName ::= UnannotatableName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeSinglePkgName(); $break ./
OpensStatement ::= OpensHeader TargetModuleListopt ';'
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeOpensStatement(); $break ./
OpensHeader ::= 'opens' SinglePkgName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeOpensHeader(); $break ./
UsesStatement ::= UsesHeader ';'
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeUsesStatement(); $break ./
UsesHeader ::= 'uses' Name
/.$putCase consumeUsesHeader(); $break ./
ProvidesStatement ::= ProvidesInterface WithClause ';'
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeProvidesStatement(); $break ./
ProvidesInterface ::= 'provides' Name
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeProvidesInterface(); $break ./
ServiceImplName ::= Name
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeSingleServiceImplName(); $break ./
ServiceImplNameList -> ServiceImplName
ServiceImplNameList ::= ServiceImplNameList ',' ServiceImplName
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeServiceImplNameList(); $break ./
WithClause ::= 'with' ServiceImplNameList
-/:$compliance 1.9:/
+/:$compliance 9:/
/.$putCase consumeWithClause(); $break ./
ReduceImports ::= $empty
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
index 00bc2171d4..d51f590cd0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
@@ -159,6 +159,9 @@ private IMemberValuePair[] getTargetElementTypes(long tagBits) {
if ((tagBits & TagBits.AnnotationForTypeParameter) != 0) {
values.add(elementType + new String(TypeConstants.TYPE_PARAMETER_TARGET));
}
+ if ((tagBits & TagBits.AnnotationForModule) != 0) {
+ values.add(elementType + new String(TypeConstants.UPPER_MODULE));
+ }
final Object value;
if (values.size() == 0) {
if ((tagBits & TagBits.AnnotationTarget) != 0)
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
index 1f378d7189..27c22234c9 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
@@ -153,6 +153,13 @@ public class BinaryIndexer extends AbstractIndexer implements SuffixConstants {
}
addFieldReference(TypeConstants.TYPE);
}
+ if ((bits & TagBits.AnnotationForModule) != 0) {
+ if (compoundName == null) {
+ compoundName = TypeConstants.JAVA_LANG_ANNOTATION_ELEMENTTYPE;
+ addTypeReference(compoundName[compoundName.length-1]);
+ }
+ addFieldReference(TypeConstants.UPPER_MODULE);
+ }
}
private void addBinaryRetentionAnnotation(long bits) {
char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java
index d87228dd89..c70848fd15 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java
@@ -31,7 +31,8 @@ private static final long TARGET_ANNOTATION_BITS =
TagBits.AnnotationForLocalVariable |
TagBits.AnnotationForField |
TagBits.AnnotationForConstructor |
- TagBits.AnnotationForAnnotationType;
+ TagBits.AnnotationForAnnotationType |
+ TagBits.AnnotationForModule;
private static final char[] JAVA_LANG_ANNOTATION_ELEMENTTYPE = CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_ELEMENTTYPE, '.');
public static char[] convertClassFileFormat(char[] name) {
return CharOperation.replaceOnCopy(name, '/', '.');

Back to the top