Bug 533036 - [10][batch] Batch compiler needs to support --release 10
Change-Id: Ibd7c88a966036d2f4d0e8500021d9164401ce0d1
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
# Conflicts:
# org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
# org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
Change-Id: I32e09ae56fac76ba973be2dc1328f205d3b43056
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
index 4754c0c..b072d21 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
@@ -4073,6 +4073,26 @@
"",
true);
}
+ public void testReleaseOption13a() {
+ runConformModuleTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ "}",
+ "module-info.java",
+ "module mod.one { \n" +
+ " requires java.base;\n" +
+ "}"
+ },
+ " --release 10 \"" + OUTPUT_DIR + File.separator + "module-info.java\" "
+ + "\"" + OUTPUT_DIR + File.separator + "p/X.java\"",
+ "",
+ "",
+ true);
+ }
public void testReleaseOption14() {
runNegativeModuleTest(
new String[] {
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
index a2cfda7..b3a691b 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
@@ -30,7 +30,8 @@
public class ClasspathJep247 extends ClasspathLocation {
private java.nio.file.FileSystem fs = null;
- private String release = null;
+ private String compliance = null;
+ private String releaseInHex = null;
private String[] subReleases = null;
private Path releasePath = null;
private File file = null;
@@ -38,7 +39,7 @@
public ClasspathJep247(File jdkHome, String release, AccessRuleSet accessRuleSet) {
super(accessRuleSet, null);
- this.release = release;
+ this.compliance = release;
this.file = jdkHome;
}
public List<Classpath> fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) {
@@ -66,7 +67,7 @@
}
}
} else {
- content = JRTUtil.safeReadBytes(this.fs.getPath(this.release, qualifiedBinaryFileName));
+ content = JRTUtil.safeReadBytes(this.fs.getPath(this.releaseInHex, qualifiedBinaryFileName));
}
if (content != null) {
reader = new ClassFileReader(content, qualifiedBinaryFileName.toCharArray());
@@ -89,9 +90,10 @@
}
public void initialize() throws IOException {
- if (this.release == null) {
+ if (this.compliance == null) {
return;
}
+ this.releaseInHex = Integer.toHexString(Integer.parseInt(this.compliance));
Path filePath = this.file.toPath().resolve("lib").resolve("ct.sym"); //$NON-NLS-1$ //$NON-NLS-2$
URI t = filePath.toUri();
if (!Files.exists(filePath)) {
@@ -107,9 +109,9 @@
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
}
- this.releasePath = this.fs.getPath(""); //$NON-NLS-1$
- if (!Files.exists(this.fs.getPath(this.release))) {
- throw new IllegalArgumentException("release " + this.release + " is not found in the system"); //$NON-NLS-1$//$NON-NLS-2$
+ this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
+ if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
+ throw new IllegalArgumentException("release " + this.compliance + " is not found in the system"); //$NON-NLS-1$//$NON-NLS-2$
}
}
void acceptModule(ClassFileReader reader) {
@@ -131,7 +133,7 @@
try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(this.releasePath)) {
for (final java.nio.file.Path subdir: stream) {
String rel = subdir.getFileName().toString();
- if (rel.contains(this.release)) {
+ if (rel.contains(this.releaseInHex)) {
sub.add(rel);
} else {
continue;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index 178f138..1139099 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -802,6 +802,11 @@
return ClassFileConstants.JDK1_8;
case '9':
return ClassFileConstants.JDK9;
+ case '1':
+ if (release.length() > 1 && release.charAt(1) == '0')
+ return ClassFileConstants.JDK10;
+ else
+ return 0;
default:
return 0; // unknown
}