Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-02-27 19:54:58 +0000
committerMike Rennie2013-02-27 19:54:58 +0000
commit63ec01831b3e1b65532b49210ffb0a339e5f1667 (patch)
tree0e69ff835def034dfcba71b84dfbad97cd879aad
parent43f55d1504cf2971566eac420daa4d2348e91cf2 (diff)
downloadeclipse.jdt.debug-63ec01831b3e1b65532b49210ffb0a339e5f1667.tar.gz
eclipse.jdt.debug-63ec01831b3e1b65532b49210ffb0a339e5f1667.tar.xz
eclipse.jdt.debug-63ec01831b3e1b65532b49210ffb0a339e5f1667.zip
Bug 399098 - Allow supplying pre-built JDT indexes for a JRE - cloning
erases index location
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java25
-rw-r--r--org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java6
2 files changed, 30 insertions, 1 deletions
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java
index aefb00b22..827fa3a7b 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java
@@ -210,6 +210,31 @@ public class ClasspathContainerTests extends AbstractDebugTest {
// and it should have a value of the original indexURL in its string form.
assertEquals(indexURL.toString(), indexloc);
}
+
+ /**
+ * Tests that an index can be added to a {@link LibraryLocation} and that successive calls to
+ * {@link JavaRuntime#getLibraryLocations(IVMInstall)} does not erase the index infos
+ *
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=399098
+ * @since 3.8.100
+ */
+ public void testJREContainerIndex2() throws Exception {
+ // get the current VM
+ IVMInstall def = JavaRuntime.getDefaultVMInstall();
+ LibraryLocation[] libs = JavaRuntime.getLibraryLocations(def);
+ // generate an index for the first library location only (to save time - do not need an index for all libraries)
+ URL indexURL = this.getIndexForLibrary(libs[0]);
+ // clone the current VM, but only add the one library that was indexed
+ VMStandin newVMStandin = new VMStandin(def.getVMInstallType(), "index.jre");
+ newVMStandin.setName("JRE with pre-built index");
+ newVMStandin.setInstallLocation(def.getInstallLocation());
+ final LibraryLocation[] newLibs = new LibraryLocation[1];
+ newLibs[0] = new LibraryLocation(libs[0].getSystemLibraryPath(), libs[0].getSystemLibrarySourcePath(), libs[0].getPackageRootPath(), libs[0].getJavadocLocation(), indexURL);
+ newVMStandin.setLibraryLocations(newLibs);
+ IVMInstall newVM = newVMStandin.convertToRealVM();
+ libs = JavaRuntime.getLibraryLocations(newVM);
+ assertNotNull("There should be an index file for: "+libs[0].getSystemLibraryPath(), libs[0].getIndexLocation());
+ }
/**
* Generates and returns a {@link URL} to the index file for a given {@link LibraryLocation} into the state location
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
index 2c4c985fd..ee4b0eb30 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
@@ -1676,6 +1676,7 @@ public final class JavaRuntime {
IPath[] sourcePaths;
IPath[] sourceRootPaths;
URL[] javadocLocations;
+ URL[] indexes;
LibraryLocation[] locations= vm.getLibraryLocations();
if (locations == null) {
URL defJavaDocLocation = vm.getJavadocLocation();
@@ -1688,6 +1689,7 @@ public final class JavaRuntime {
sourcePaths = new IPath[dflts.length];
sourceRootPaths = new IPath[dflts.length];
javadocLocations= new URL[dflts.length];
+ indexes = new URL[dflts.length];
for (int i = 0; i < dflts.length; i++) {
libraryPaths[i]= dflts[i].getSystemLibraryPath();
if (defJavaDocLocation == null) {
@@ -1712,16 +1714,18 @@ public final class JavaRuntime {
sourcePaths = new IPath[locations.length];
sourceRootPaths = new IPath[locations.length];
javadocLocations= new URL[locations.length];
+ indexes = new URL[locations.length];
for (int i = 0; i < locations.length; i++) {
libraryPaths[i]= locations[i].getSystemLibraryPath();
sourcePaths[i]= locations[i].getSystemLibrarySourcePath();
sourceRootPaths[i]= locations[i].getPackageRootPath();
javadocLocations[i]= locations[i].getJavadocLocation();
+ indexes[i] = locations[i].getIndexLocation();
}
}
locations = new LibraryLocation[sourcePaths.length];
for (int i = 0; i < sourcePaths.length; i++) {
- locations[i] = new LibraryLocation(libraryPaths[i], sourcePaths[i], sourceRootPaths[i], javadocLocations[i]);
+ locations[i] = new LibraryLocation(libraryPaths[i], sourcePaths[i], sourceRootPaths[i], javadocLocations[i], indexes[i]);
}
return locations;
}

Back to the top