diff options
author | Michael Rennie | 2011-03-23 19:34:55 +0000 |
---|---|---|
committer | Michael Rennie | 2011-03-23 19:34:55 +0000 |
commit | 73a6ebb02aa847763f2bb5cfd1df890632192625 (patch) | |
tree | b80af4f2107dbea170d2b1cffac3512c124b9131 | |
parent | 183d19938443e02cebad4eaee78bee90fdfc7376 (diff) | |
download | eclipse.jdt.debug-73a6ebb02aa847763f2bb5cfd1df890632192625.tar.gz eclipse.jdt.debug-73a6ebb02aa847763f2bb5cfd1df890632192625.tar.xz eclipse.jdt.debug-73a6ebb02aa847763f2bb5cfd1df890632192625.zip |
Bug 266651 - [jre] "JRE System Library" default not used properly after Java update (also with symbolic links)v20110404v20110328
3 files changed, 55 insertions, 42 deletions
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java index c6c4d5fc7..e1d3dd54f 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2011 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 @@ -303,12 +303,8 @@ public class StandardVMPage extends AbstractVMInstallPage { */ protected void setFieldValuesToVM(VMStandin vm) { File dir = new File(fJRERoot.getText()); - try { - vm.setInstallLocation(dir.getCanonicalFile()); - } - catch (IOException e) { - vm.setInstallLocation(dir.getAbsoluteFile()); - } + File file = dir.getAbsoluteFile(); + vm.setInstallLocation(file); vm.setName(fVMName.getText()); vm.setJavadocLocation(getURL()); diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java index 011c115de..fa990c871 100644 --- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java +++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java @@ -23,6 +23,7 @@ import java.io.OutputStream; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -132,6 +133,12 @@ public class LaunchingPlugin extends Plugin implements IEclipsePreferences.IPref */ private static Map fgInstallTimeMap = null; /** + * List of install locations that have been detected to have changed + * + * @since 3.7 + */ + private static HashSet fgHasChanged = new HashSet(); + /** * Mutex for checking the time stamp of an install location * * @since 3.7 @@ -404,6 +411,8 @@ public class LaunchingPlugin extends Plugin implements IEclipsePreferences.IPref } else { fgLibraryInfoMap.put(javaInstallPath, info); } + //once the library info has been set we can forget it has changed + fgHasChanged.remove(javaInstallPath); saveLibraryInfo(); } @@ -932,6 +941,9 @@ public class LaunchingPlugin extends Plugin implements IEclipsePreferences.IPref */ public static boolean timeStampChanged(String location) { synchronized (installLock) { + if(fgHasChanged.contains(location)) { + return true; + } File file = new File(location); if(file.exists()) { if(fgInstallTimeMap == null) { @@ -948,6 +960,7 @@ public class LaunchingPlugin extends Plugin implements IEclipsePreferences.IPref stamp = new Long(fstamp); fgInstallTimeMap.put(location, stamp); writeInstallInfo(); + fgHasChanged.add(location); return true; } } diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java index e4c1cc53c..6ffcf0e29 100644 --- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java +++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java @@ -549,57 +549,61 @@ public class VMDefinitionsContainer { vmStandin.setName(name); File installLocation= new File(installPath); vmStandin.setInstallLocation(installLocation); + String install = installLocation.getAbsolutePath(); + //only consider a VM changed it is a standard VM + boolean changed = StandardVMType.ID_STANDARD_VM_TYPE.equals(vmType.getId()) && + LaunchingPlugin.timeStampChanged(install); container.addVM(vmStandin); // Look for subordinate nodes. These may be 'libraryLocation', // 'libraryLocations' or 'versionInfo'. - NodeList list = vmElement.getChildNodes(); - int length = list.getLength(); - for (int i = 0; i < length; ++i) { - Node node = list.item(i); - short type = node.getNodeType(); - if (type == Node.ELEMENT_NODE) { - Element subElement = (Element)node; - String subElementName = subElement.getNodeName(); - if (subElementName.equals("libraryLocation")) { //$NON-NLS-1$ - LibraryLocation loc = getLibraryLocation(subElement); + if(!changed) { + NodeList list = vmElement.getChildNodes(); + int length = list.getLength(); + for (int i = 0; i < length; ++i) { + Node node = list.item(i); + short type = node.getNodeType(); + if (type == Node.ELEMENT_NODE) { + Element subElement = (Element)node; + String subElementName = subElement.getNodeName(); + if (subElementName.equals("libraryLocation")) { //$NON-NLS-1$ + LibraryLocation loc = getLibraryLocation(subElement); vmStandin.setLibraryLocations(new LibraryLocation[]{loc}); - } else if (subElementName.equals("libraryLocations")) { //$NON-NLS-1$ - setLibraryLocations(vmStandin, subElement); - } else if (subElementName.equals("attributeMap")) { //$NON-NLS-1$ - NodeList entries = subElement.getElementsByTagName("entry"); //$NON-NLS-1$ - for (int j = 0; j < entries.getLength(); j++) { - Node entryNode = entries.item(j); - if (entryNode instanceof Element) { - Element entryElement = (Element) entryNode; - String key = entryElement.getAttribute("key"); //$NON-NLS-1$ - String value = entryElement.getAttribute("value"); //$NON-NLS-1$ - if (key != null && value != null) { - vmStandin.setAttribute(key, value); + } else if (subElementName.equals("libraryLocations")) { //$NON-NLS-1$ + setLibraryLocations(vmStandin, subElement); + } else if (subElementName.equals("attributeMap")) { //$NON-NLS-1$ + NodeList entries = subElement.getElementsByTagName("entry"); //$NON-NLS-1$ + for (int j = 0; j < entries.getLength(); j++) { + Node entryNode = entries.item(j); + if (entryNode instanceof Element) { + Element entryElement = (Element) entryNode; + String key = entryElement.getAttribute("key"); //$NON-NLS-1$ + String value = entryElement.getAttribute("value"); //$NON-NLS-1$ + if (key != null && value != null) { + vmStandin.setAttribute(key, value); + } } } } } + + // javadoc URL + String externalForm = vmElement.getAttribute("javadocURL"); //$NON-NLS-1$ + if (externalForm != null && externalForm.length() > 0) { + try { + vmStandin.setJavadocLocation(new URL(externalForm)); + } catch (MalformedURLException e) { + container.addStatus(new Status(IStatus.ERROR, LaunchingPlugin.ID_PLUGIN, + MessageFormat.format(LaunchingMessages.VMDefinitionsContainer_6, new String[]{name}), e)); + } + } } } - - // javadoc URL - String externalForm = vmElement.getAttribute("javadocURL"); //$NON-NLS-1$ - if (externalForm != null && externalForm.length() > 0) { - try { - vmStandin.setJavadocLocation(new URL(externalForm)); - } catch (MalformedURLException e) { - container.addStatus(new Status(IStatus.ERROR, LaunchingPlugin.ID_PLUGIN, - MessageFormat.format(LaunchingMessages.VMDefinitionsContainer_6, new String[]{name}), e)); - } - } - // vm Arguments String vmArgs = vmElement.getAttribute("vmargs"); //$NON-NLS-1$ if (vmArgs != null && vmArgs.length() >0) { vmStandin.setVMArgs(vmArgs); } - } else { String installPath= vmElement.getAttribute("path"); //$NON-NLS-1$ String name = vmElement.getAttribute("name"); //$NON-NLS-1$ |