Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2019-08-28 12:03:11 -0400
committerManoj Palat2019-09-03 05:36:53 -0400
commitc8645ac64da6ad9e7b05904f9dac2245f164a319 (patch)
treef4f34063fefbf771b4a1c0dfffcf5c61ece209ea
parent99acad986550d985eb9fc5323cbe17608bbd16d5 (diff)
downloadeclipse.jdt.core-I20190903-1800.tar.gz
eclipse.jdt.core-I20190903-1800.tar.xz
eclipse.jdt.core-I20190903-1800.zip
results in compile error (Object not found) Change-Id: I2d459551491df5581ebefdb13e8bfe8f2b5cb01e Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java6
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java29
3 files changed, 29 insertions, 16 deletions
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java
index 0709ad5215..c3a28d0239 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java
@@ -43,6 +43,7 @@ import org.eclipse.jdt.internal.compiler.util.Util;
public class ClasspathJep247Jdk12 extends ClasspathJep247 {
Map<String, IModule> modules;
+ static String MODULE_INFO = "module-info.sig"; //$NON-NLS-1$
public ClasspathJep247Jdk12(File jdkHome, String release, AccessRuleSet accessRuleSet) {
super(jdkHome, release, accessRuleSet);
@@ -173,9 +174,8 @@ public class ClasspathJep247Jdk12 extends ClasspathJep247 {
public FileVisitResult visitFile(java.nio.file.Path f, BasicFileAttributes attrs) throws IOException {
if (attrs.isDirectory() || f.getNameCount() < 3)
return FileVisitResult.CONTINUE;
- byte[] content = null;
- if (Files.exists(f)) {
- content = JRTUtil.safeReadBytes(f);
+ if (f.getFileName().toString().equals(MODULE_INFO) && Files.exists(f)) {
+ byte[] content = JRTUtil.safeReadBytes(f);
if (content == null)
return FileVisitResult.CONTINUE;
Path m = f.subpath(1, f.getNameCount() - 1);
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index 7828c82a9c..f9199fdfe9 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -32,6 +32,8 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.zip.ZipFile;
+import javax.lang.model.SourceVersion;
+
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
@@ -169,12 +171,16 @@ public class FileSystem implements IModuleAwareNameEnvironment, SuffixConstants
/** Tasks resulting from --add-reads or --add-exports command line options. */
Map<String,UpdatesByKind> moduleUpdates = new HashMap<>();
+ static boolean isJRE12Plus = false;
private boolean hasLimitModules = false;
- static final boolean isJRE12Plus;
static {
- isJRE12Plus = CompilerOptions.VERSION_12.equals(System.getProperty("java.specification.version")); //$NON-NLS-1$
+ try {
+ isJRE12Plus = SourceVersion.valueOf("RELEASE_12") != null; //$NON-NLS-1$
+ } catch(IllegalArgumentException iae) {
+ // fall back to default
+ }
}
/*
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java
index d507ed14dc..5a3dc959fd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java
@@ -51,10 +51,13 @@ import org.eclipse.jdt.internal.core.util.Util;
public class ClasspathJrtWithReleaseOption extends ClasspathJrt {
+ static String MODULE_INFO = "module-info.sig"; //$NON-NLS-1$
+
final String release;
String releaseInHex;
private String[] subReleases;
private java.nio.file.FileSystem fs;
+ protected Path releasePath;
protected Path modulePath;
private String modPathString;
private boolean isJRE12Plus;
@@ -134,15 +137,15 @@ public class ClasspathJrtWithReleaseOption extends ClasspathJrt {
return;
}
}
- Path releasePath = this.fs.getPath("/"); //$NON-NLS-1$
- this.isJRE12Plus = isJRE12Plus(releasePath);
+ this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
+ this.isJRE12Plus = isJRE12Plus(this.releasePath);
Path modPath = this.fs.getPath(this.releaseInHex + (this.isJRE12Plus ? "" : "-modules")); //$NON-NLS-1$ //$NON-NLS-2$
if (Files.exists(modPath)) {
this.modulePath = modPath;
this.modPathString = this.zipFilename + "|"+ modPath.toString(); //$NON-NLS-1$
}
- if (!Files.exists(releasePath.resolve(this.releaseInHex))) {
+ if (!Files.exists(this.releasePath.resolve(this.releaseInHex))) {
Exception e = new IllegalArgumentException("release " + this.release + " is not found in the system"); //$NON-NLS-1$//$NON-NLS-2$
throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, e.getMessage(), e));
}
@@ -152,7 +155,7 @@ public class ClasspathJrtWithReleaseOption extends ClasspathJrt {
}
if (this.release != null) {
List<String> sub = new ArrayList<>();
- try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(releasePath)) {
+ try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(this.releasePath)) {
for (final java.nio.file.Path subdir : stream) {
String rel = JRTUtil.sanitizedFileName(subdir);
if (rel.contains(this.releaseInHex)) {
@@ -226,10 +229,12 @@ public class ClasspathJrtWithReleaseOption extends ClasspathJrt {
return;
Set<IModule> cache = ModulesCache.get(jrt.modPathString);
if (cache == null) {
- try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(jrt.modulePath)) {
+ try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(jrt.releasePath)) {
for (final java.nio.file.Path subdir : stream) {
-
- Files.walkFileTree(subdir, Collections.EMPTY_SET, 1, new FileVisitor<java.nio.file.Path>() {
+ if (!subdir.getFileName().toString().contains(jrt.releaseInHex)) {
+ continue;
+ }
+ Files.walkFileTree(subdir, Collections.EMPTY_SET, 2, new FileVisitor<java.nio.file.Path>() {
@Override
public FileVisitResult preVisitDirectory(java.nio.file.Path dir, BasicFileAttributes attrs)
throws IOException {
@@ -239,14 +244,16 @@ public class ClasspathJrtWithReleaseOption extends ClasspathJrt {
@Override
public FileVisitResult visitFile(java.nio.file.Path f, BasicFileAttributes attrs)
throws IOException {
- byte[] content = null;
- if (Files.exists(f)) {
- content = JRTUtil.safeReadBytes(f);
+ if (attrs.isDirectory() || f.getNameCount() < 3) {
+ return FileVisitResult.CONTINUE;
+ }
+ if (f.getFileName().toString().equals(MODULE_INFO)) {
+ byte[] content = JRTUtil.safeReadBytes(f);
if (content == null)
return FileVisitResult.CONTINUE;
jrt.acceptModule(content);
}
- return FileVisitResult.CONTINUE;
+ return FileVisitResult.SKIP_SIBLINGS;
}
@Override

Back to the top