Bug 572673 - [17] Implement Elements.isAutomaticModule(ModuleElement)

Change-Id: I69920b93d9f8ad83efcae4eb4eac87245eca0f66
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/179904
diff --git a/org.eclipse.jdt.compiler.apt.tests/.classpath b/org.eclipse.jdt.compiler.apt.tests/.classpath
index 883f44e..8e7bfae 100644
--- a/org.eclipse.jdt.compiler.apt.tests/.classpath
+++ b/org.eclipse.jdt.compiler.apt.tests/.classpath
@@ -16,7 +16,7 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="lib" path="lib/javax15api.jar"/>
+	<classpathentry kind="lib" path="lib/javax17api.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
index eb7f88f..a861f0b 100644
--- a/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
@@ -19,6 +19,6 @@
  org.eclipse.jdt.compiler.apt.tests.processors.visitors
 Import-Package: org.eclipse.jdt.internal.compiler.tool;resolution:=optional
 Eclipse-BundleShape: dir
-Bundle-ClassPath: lib/javax15api.jar,
+Bundle-ClassPath: lib/javax17api.jar,
  .
 Automatic-Module-Name: org.eclipse.jdt.compiler.apt.tests
diff --git a/org.eclipse.jdt.compiler.apt.tests/build.properties b/org.eclipse.jdt.compiler.apt.tests/build.properties
index 06642fc..7046723 100644
--- a/org.eclipse.jdt.compiler.apt.tests/build.properties
+++ b/org.eclipse.jdt.compiler.apt.tests/build.properties
@@ -27,4 +27,4 @@
                .
 src.includes = about.html
 compilerArg=-proc:none
-jars.extra.classpath = lib/javax15api.jar
+jars.extra.classpath = lib/javax17api.jar
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
index 64a0c91..693619d 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/javax17api.jar b/org.eclipse.jdt.compiler.apt.tests/lib/javax17api.jar
new file mode 100644
index 0000000..050b9a7
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/javax17api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/lib.x.jar b/org.eclipse.jdt.compiler.apt.tests/lib/lib.x.jar
new file mode 100644
index 0000000..5aa2ee5
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/lib.x.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/BaseElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/BaseElementProcessor.java
index ca9487a..7e4a06e 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/BaseElementProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/BaseElementProcessor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2020 IBM Corporation.
+ * Copyright (c) 2020, 2021 IBM Corporation.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -8,6 +8,10 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  *
+ * 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
  *******************************************************************************/
@@ -45,7 +49,6 @@
 
 import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
 
-@SuppressWarnings("preview")
 @SupportedAnnotationTypes("*")
 abstract class BaseElementProcessor extends BaseProcessor {
 	boolean reportSuccessAlready = true;
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java
index 1321b3f..dd89ca6 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java
@@ -56,6 +56,7 @@
 import javax.lang.model.type.NoType;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
 import javax.tools.JavaFileObject;
 
 import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
@@ -896,6 +897,30 @@
 		}
 		return false;
 	}
+	public void testBug572673() {
+		Set<? extends Element> rootElements = roundEnv.getRootElements();
+		Set<ModuleElement> modulesIn = ElementFilter.modulesIn(rootElements);
+		assertEquals("incorrect modules" , 1, modulesIn.size());
+		boolean found = false;
+		for (ModuleElement moduleElement : modulesIn) {
+			if (moduleElement.getQualifiedName().toString().equals("mod.one")) {
+				found = true;
+				List<? extends Directive> directives = moduleElement.getDirectives();
+				List<Directive> requires = filterDirective(directives, DirectiveKind.REQUIRES);
+				assertEquals("incorrect requires" , 2, requires.size());
+				for (Directive r : requires) {
+					RequiresDirective req = (RequiresDirective) r;
+					ModuleElement depModule = req.getDependency();
+					if (_elementUtils.isAutomaticModule(depModule)) {
+						assertEquals("incorrect auto-module", "lib.x", depModule.getQualifiedName().toString());
+					} else {
+						assertEquals("incorrect non auto-module", "java.base", depModule.getQualifiedName().toString());
+					}
+				}
+			}
+		}
+		assertTrue("module not found", found);
+	}
 	private void validateModifiers(ExecutableElement method, Modifier[] expected) {
 		Set<Modifier> modifiers = method.getModifiers();
 		List<Modifier> list = new ArrayList<>(modifiers);
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/RecordElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/RecordElementProcessor.java
index 76223d3..0122e4c 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/RecordElementProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/RecordElementProcessor.java
@@ -54,7 +54,6 @@
 import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
 
 @SupportedAnnotationTypes("*")
-@SuppressWarnings("preview")
 public class RecordElementProcessor extends BaseElementProcessor {
 	boolean reportSuccessAlready = true;
 	RoundEnvironment roundEnv = null;
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/module-info.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/module-info.java
new file mode 100644
index 0000000..3936742
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/module-info.java
@@ -0,0 +1,3 @@
+module mod.one { 
+	requires lib.x;
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/pkg/Entity1.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/pkg/Entity1.java
new file mode 100644
index 0000000..069dbdf
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/pkg/Entity1.java
@@ -0,0 +1,9 @@
+//package targets.bug535819;
+////import javax.persistence.Entity;
+//
+//@Deprecated
+//public class Entity1 {
+//
+////	private String name;
+//
+//}
\ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/pkg/Finder.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/pkg/Finder.java
new file mode 100644
index 0000000..d02fc70
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug572673/pkg/Finder.java
@@ -0,0 +1,16 @@
+//
+//package targets.bug535819;
+//
+//import javax.annotation.Nonnull;
+//
+////import targets.bug535819.query.QEntity1;
+//import targets.bug535819.query.QEntity2;
+//
+//public class Finder {
+//
+//	@Nonnull
+//	public static QEntity2 getQuery2() {
+//		return new QEntity2();
+//	}
+//
+//}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
index 377d9d7..56a4184 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2017 BEA Systems, Inc.
+ * Copyright (c) 2007, 2021 BEA Systems, Inc.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -63,7 +63,7 @@
 	public static String _jls8ProcessorJarPath;
 
 	// locations to copy and generate files
-	private static String _tmpFolder;
+	public static String _tmpFolder;
 
 	private static JavaCompiler _eclipseCompiler;
 
@@ -261,6 +261,9 @@
 			e.printStackTrace();
 		}
 	}
+	public interface InjectCustomOptions {
+		public void execute(List<String> options);
+	}
 	/*
 	 * First compiles the given files without processor, then processes them
 	 * with the just compiled binaries.
@@ -282,7 +285,7 @@
 		copyOptions.add("-s");
 		copyOptions.add(_tmpGenFolderName);
 		addProcessorPaths(copyOptions, true, true);
-		options.add("-XprintRounds");
+		copyOptions.add("-XprintRounds");
 		CompilationTask task = compiler.getTask(printWriter, manager, listener, copyOptions, null, units);
 		Boolean result = task.call();
 
@@ -346,7 +349,9 @@
 			List<String> options,
 			File targetFolder,
 			DiagnosticListener<? super JavaFileObject> diagnosticListener,
-			boolean useJLS8Processors, boolean addProcessorsToClasspath) {
+			boolean useJLS8Processors, 
+			boolean addProcessorsToClasspath,
+			InjectCustomOptions custom) {
 		StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
 
 		// create new list containing inputfile
@@ -359,6 +364,7 @@
 		options.add("-s");
 		options.add(_tmpGenFolderName);
 		addProcessorPaths(options, useJLS8Processors, addProcessorsToClasspath);
+		if (custom != null) custom.execute(options);
 		// use writer to prevent System.out/err to be polluted with problems
 		StringWriter writer = new StringWriter();
 		CompilationTask task = compiler.getTask(writer, manager, diagnosticListener, options, null, units);
@@ -370,7 +376,14 @@
 		}
 		return result.booleanValue();
 	}
-
+	public static boolean compileTreeWithErrors(
+			JavaCompiler compiler,
+			List<String> options,
+			File targetFolder,
+			DiagnosticListener<? super JavaFileObject> diagnosticListener,
+			boolean useJLS8Processors, boolean addProcessorsToClasspath) {
+			return compileTreeWithErrors(compiler, options, targetFolder, diagnosticListener, useJLS8Processors, addProcessorsToClasspath, null);
+		}
 	/**
 	 * Recursively collect all the files under some root.  Ignore directories named "CVS".
 	 * Used when compiling multiple source files.
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java9ElementsTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java9ElementsTests.java
index b903900..fbcb6df 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java9ElementsTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java9ElementsTests.java
@@ -422,7 +422,20 @@
 	}
 	public void testBug535819() throws IOException {
 		JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
-		internalTest(compiler, MODULE_PROC, "testBug535819", null, "bug535819", true);
+		internalTest(compiler, MODULE_PROC, "testBug535819", null, "bug535819", true, null);
+	}
+	public void testBug572673() throws IOException {
+		if (!canRunJava17()) {
+			return;
+		}
+		JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+		final String autoModuleJar = BatchTestUtils.setupProcessorJar("lib/lib.x.jar", BatchTestUtils._tmpFolder);
+		internalTest(compiler, MODULE_PROC, "testBug572673", null, "bug572673", true, 
+				(options) -> {
+					options.add("--module-path");
+					options.add(BatchTestUtils._jls8ProcessorJarPath + 
+							File.pathSeparator + autoModuleJar);
+				});
 	}
 	protected void internalTestWithBinary(JavaCompiler compiler, String processor, String compliance, String testMethod, String testClass, String resourceArea) throws IOException {
 		if (!canRunJava9()) {
@@ -482,9 +495,10 @@
 		assertEquals("succeeded", System.getProperty(processor));
 	}
 	private void internalTest(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea) throws IOException {
-		internalTest(compiler, processor, testMethod, testClass, resourceArea, false);
+		internalTest(compiler, processor, testMethod, testClass, resourceArea, false, null);
 	}
-	private void internalTest(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea, boolean continueWithErrors) throws IOException {
+	private void internalTest(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea, 
+			boolean continueWithErrors, BatchTestUtils.InjectCustomOptions custom) throws IOException {
 		if (!canRunJava9()) {
 			return;
 		}
@@ -507,7 +521,7 @@
 		PrintWriter printWriter = new PrintWriter(errBuffer);
 		TestDiagnosticListener diagnosticListener = new TestDiagnosticListener(printWriter);
 		if (continueWithErrors) {
-			BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, diagnosticListener, true, true);
+			BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, diagnosticListener, true, true, custom);
 		} else {
 			BatchTestUtils.compileTree(compiler, options, targetFolder, true);
 		}
@@ -560,7 +574,14 @@
 		BatchTestUtils.compileInModuleMode(compiler, options, processor, srcRoot, null, true, binaryMode);
 		assertEquals("succeeded", System.getProperty(processor));
 	}
-	
+	public boolean canRunJava17() {
+		try {
+			SourceVersion.valueOf("RELEASE_17");
+		} catch(IllegalArgumentException iae) {
+			return false;
+		}
+		return true;
+	}
 	public boolean canRunJava9() {
 		try {
 			SourceVersion.valueOf("RELEASE_9");
diff --git a/org.eclipse.jdt.compiler.apt/build.properties b/org.eclipse.jdt.compiler.apt/build.properties
index 59281dd..8538c59 100644
--- a/org.eclipse.jdt.compiler.apt/build.properties
+++ b/org.eclipse.jdt.compiler.apt/build.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2005, 2020 IBM Corporation and others.
+# Copyright (c) 2005, 2021 IBM Corporation and others.
 #
 # This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License 2.0
@@ -22,4 +22,4 @@
 output.. = bin/
 source.. = src/
 
-jars.extra.classpath = lib/javax15api.jar
+jars.extra.classpath = lib/javax17api.jar
diff --git a/org.eclipse.jdt.compiler.apt/lib/javax17api.jar b/org.eclipse.jdt.compiler.apt/lib/javax17api.jar
new file mode 100644
index 0000000..050b9a7
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt/lib/javax17api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java
index 60bb931..06c9d03 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl9.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2017 BEA Systems, Inc. and others
+ * Copyright (c) 2006, 2021 BEA Systems, Inc. and others
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -8,6 +8,10 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  *
+ * 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:
  *    Igor Fedorenko - extracted from ElementsImpl
  *******************************************************************************/
@@ -182,4 +186,8 @@
 			return null;
 		return (PackageElement) _env.getFactory().newElement(p);
 	}
+	public boolean isAutomaticModule(ModuleElement module) {
+		ModuleBinding mBinding = ((ModuleElementImpl) module).binding;
+        return mBinding.isAutomatic();
+    }
 }
diff --git a/org.eclipse.jdt.compiler.tool.tests/.classpath b/org.eclipse.jdt.compiler.tool.tests/.classpath
index 0d1d3b3..bc3d693 100644
--- a/org.eclipse.jdt.compiler.tool.tests/.classpath
+++ b/org.eclipse.jdt.compiler.tool.tests/.classpath
@@ -6,7 +6,7 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="lib" path="lib/javax15api.jar"/>
+	<classpathentry kind="lib" path="lib/javax17api.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
index a89b388..b2f31af 100644
--- a/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
@@ -16,5 +16,5 @@
 Import-Package: org.eclipse.jdt.internal.compiler.tool
 Eclipse-BundleShape: dir
 Bundle-ClassPath: .,
- lib/javax15api.jar
+ lib/javax17api.jar
 Automatic-Module-Name: org.eclipse.jdt.compiler.tool.tests
diff --git a/org.eclipse.jdt.compiler.tool.tests/build.properties b/org.eclipse.jdt.compiler.tool.tests/build.properties
index 1ae25c6..2ae39ec 100644
--- a/org.eclipse.jdt.compiler.tool.tests/build.properties
+++ b/org.eclipse.jdt.compiler.tool.tests/build.properties
@@ -22,4 +22,4 @@
 src.includes = about.html
 source.. = src/
 output.. = bin/
-jars.extra.classpath = lib/javax15api.jar
+jars.extra.classpath = lib/javax17api.jar
diff --git a/org.eclipse.jdt.compiler.tool.tests/lib/javax17api.jar b/org.eclipse.jdt.compiler.tool.tests/lib/javax17api.jar
new file mode 100644
index 0000000..050b9a7
--- /dev/null
+++ b/org.eclipse.jdt.compiler.tool.tests/lib/javax17api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.tool/.classpath b/org.eclipse.jdt.compiler.tool/.classpath
index d3eb90a..ad51675 100644
--- a/org.eclipse.jdt.compiler.tool/.classpath
+++ b/org.eclipse.jdt.compiler.tool/.classpath
@@ -2,7 +2,7 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="lib" path="lib/javax15api.jar"/>
+	<classpathentry kind="lib" path="lib/javax17api.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF
index 6792902..0308031 100644
--- a/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.tool/META-INF/MANIFEST.MF
@@ -9,6 +9,6 @@
 Export-Package: META-INF.services,
  org.eclipse.jdt.internal.compiler.tool;x-internal:=true
 Fragment-Host: org.eclipse.jdt.core;bundle-version="[3.3.0,4.0.0)"
-Bundle-ClassPath: lib/javax15api.jar,
+Bundle-ClassPath: lib/javax17api.jar,
  .
 Automatic-Module-Name: org.eclipse.jdt.compiler.tool
diff --git a/org.eclipse.jdt.compiler.tool/build.properties b/org.eclipse.jdt.compiler.tool/build.properties
index d813e13..bedae34 100644
--- a/org.eclipse.jdt.compiler.tool/build.properties
+++ b/org.eclipse.jdt.compiler.tool/build.properties
@@ -18,6 +18,6 @@
                .,\
                about.html,\
                compiler_tool_fragment.properties,\
-               lib/javax15api.jar
+               lib/javax17api.jar
 src.includes = about.html
-jars.extra.classpath = lib/javax15api.jar
\ No newline at end of file
+jars.extra.classpath = lib/javax17api.jar
\ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.tool/lib/javax17api.jar b/org.eclipse.jdt.compiler.tool/lib/javax17api.jar
new file mode 100644
index 0000000..050b9a7
--- /dev/null
+++ b/org.eclipse.jdt.compiler.tool/lib/javax17api.jar
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
index a145a47..d3fc450 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2016, 2019 IBM Corporation and others.
+ * Copyright (c) 2016, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -8,6 +8,10 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  *
+ * 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
  *
@@ -834,6 +838,9 @@
 	public boolean isUnnamed() {
 		return false;
 	}
+	public boolean isAutomatic() {
+		return this.isAuto;
+	}
 	public boolean isOpen() {
 		return (this.modifiers & ClassFileConstants.ACC_OPEN) != 0;
 	}