Bug 489207 Submitted -[1.9] Latest Jigsaw JRE is no longer recognized
Presence of jrt-fs.jar means we are dealing with a Jigsaw JDK/JRE.
diff --git a/org.eclipse.jdt.core.tests.model/workspace/ConvertToModule/.classpath b/org.eclipse.jdt.core.tests.model/workspace/ConvertToModule/.classpath
index 8589a09..aeedbc3 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/ConvertToModule/.classpath
+++ b/org.eclipse.jdt.core.tests.model/workspace/ConvertToModule/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="jdt.test"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.9"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9.0"/>
<classpathentry kind="lib" path="m1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JimageUtil.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JimageUtil.java
index f8033a2..eac9925 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JimageUtil.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JimageUtil.java
@@ -50,7 +50,7 @@
static final String MULTIPLE = "MU"; //$NON-NLS-1$
static final String DEFAULT_PACKAGE = ""; //$NON-NLS-1$
static final String MODULES_ON_DEMAND = System.getProperty("modules"); //$NON-NLS-1$
- static final String JRT_FS_JAR = "jrt-fs.jar"; //$NON-NLS-1$
+ public static final String JRT_FS_JAR = "jrt-fs.jar"; //$NON-NLS-1$
static URI JRT_URI = URI.create("jrt:/"); //$NON-NLS-1$
public static int NOTIFY_FILES = 0x0001;
public static int NOTIFY_PACKAGES = 0x0002;
@@ -126,8 +126,6 @@
/**
* Given the path of a modular image file, this method walks the archive content and
* notifies the supplied visitor about packages and files visited.
- * Note: At the moment, there's no way to open any arbitrary image. Currently,
- * this method uses the JRT file system provider to look inside the JRE.
*
* The file system contains the following top level directories:
* /modules/$MODULE/$PATH
@@ -136,7 +134,7 @@
* this method only notifies its clients of the entries within the modules sub-directory. The
* clients can decide which notifications they want to receive. See {@link JimageUtil#NOTIFY_ALL},
* {@link JimageUtil#NOTIFY_FILES}, {@link JimageUtil#NOTIFY_PACKAGES} and {@link JimageUtil#NOTIFY_MODULES}.
- *
+ *
* @param image a java.io.File handle to the JRT image.
* @param visitor an instance of JimageVisitor to be notified of the entries in the JRT image.
* @param notify flag indicating the notifications the client is interested in.
@@ -174,8 +172,15 @@
initialize(image);
}
void initialize(File image) throws IOException {
- String jdkHome = image.getParentFile().getParentFile().getParent();
- URL url = Paths.get(jdkHome, JimageUtil.JRT_FS_JAR).toUri().toURL();
+ URL url = null;
+ if (image.toString().endsWith(JimageUtil.JRT_FS_JAR)) {
+ url = image.toPath().toUri().toURL();
+ } else if (image.isDirectory()) {
+ url = image.toPath().toUri().toURL();
+ } else {
+ String jdkHome = image.getParentFile().getParentFile().getParent();
+ url = Paths.get(jdkHome, JimageUtil.JRT_FS_JAR).toUri().toURL();
+ }
URLClassLoader loader = new URLClassLoader(new URL[] { url });
HashMap<String, ?> env = new HashMap<>();
this.jrt = FileSystems.newFileSystem(JimageUtil.JRT_URI, env, loader);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
index c1818df..455ced0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
@@ -908,7 +908,9 @@
* implementation is not creating extra strings.
*/
public final static boolean isJimageName(String name) {
- int nameLength = name == null ? 0 : name.length();
+ if (name.endsWith(JimageUtil.JRT_FS_JAR))
+ return true;
+ int nameLength = name.length();
int suffixLength = SUFFIX_JIMAGE.length;
if (nameLength < suffixLength) return false;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index 426da9b..85f8320 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * 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
@@ -128,6 +128,7 @@
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
+import org.eclipse.jdt.internal.compiler.util.JimageUtil;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.core.JavaProjectElementInfo.ProjectCache;
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
@@ -2710,6 +2711,9 @@
if (path.getFileExtension() != null && path.getFileExtension().equalsIgnoreCase(JIMAGE_EXT)) {
return true;
}
+ if (path.toString().endsWith(JimageUtil.JRT_FS_JAR)) {
+ return true;
+ }
return false;
}