Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 78364 Details for
Bug 201758
Breaking change in IVMInstall.getInstallLocation()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
ee-take2.patch (text/plain), 43.93 KB, created by
Darin Wright
on 2007-09-13 14:16:16 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2007-09-13 14:16:16 EDT
Size:
43.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.launching >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/plugin.xml,v >retrieving revision 1.69 >diff -u -r1.69 plugin.xml >--- plugin.xml 24 Aug 2007 17:52:38 -0000 1.69 >+++ plugin.xml 13 Sep 2007 18:13:03 -0000 >@@ -23,6 +23,10 @@ > class="org.eclipse.jdt.internal.launching.Standard11xVMType" > id="org.eclipse.jdt.launching.Standard11xVMType"> > </vmInstallType> >+ <vmInstallType >+ class="org.eclipse.jdt.internal.launching.EEVMType" >+ id="org.eclipse.jdt.launching.EEVMType"> >+ </vmInstallType> > </extension> > <extension > point="org.eclipse.debug.core.launchConfigurationTypes"> >Index: launching/org/eclipse/jdt/internal/launching/StandardVM.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVM.java,v >retrieving revision 1.8 >diff -u -r1.8 StandardVM.java >--- launching/org/eclipse/jdt/internal/launching/StandardVM.java 10 Aug 2007 20:00:35 -0000 1.8 >+++ launching/org/eclipse/jdt/internal/launching/StandardVM.java 13 Sep 2007 18:13:03 -0000 >@@ -41,10 +41,7 @@ > StandardVMType installType = (StandardVMType) getVMInstallType(); > File installLocation = getInstallLocation(); > if (installLocation != null) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getJavaVersion(installLocation); >- } >- File executable = StandardVMType.findJavaExecutable(installLocation); >+ File executable = getJavaExecutable(); > if (executable != null) { > String vmVersion = installType.getVMVersion(installLocation, executable); > // strip off extra info >@@ -64,4 +61,19 @@ > } > return null; > } >+ >+ /** >+ * Returns the java executable for this VM or <code>null</code> if cannot be found >+ * >+ * @return executable for this VM or <code>null</code> if none >+ */ >+ File getJavaExecutable() { >+ File installLocation = getInstallLocation(); >+ if (installLocation != null) { >+ return StandardVMType.findJavaExecutable(installLocation); >+ } >+ return null; >+ } >+ >+ > } >Index: launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java,v >retrieving revision 1.53 >diff -u -r1.53 StandardVMRunner.java >--- launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java 30 Jul 2007 18:57:47 -0000 1.53 >+++ launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java 13 Sep 2007 18:13:03 -0000 >@@ -171,11 +171,17 @@ > > // If no java command was specified, use default executable > if (command == null) { >- File exe = StandardVMType.findJavaExecutable(fVMInstance.getInstallLocation()); >+ File exe = null; >+ if (fVMInstance instanceof StandardVM) { >+ exe = ((StandardVM)fVMInstance).getJavaExecutable(); >+ } else { >+ exe = StandardVMType.findJavaExecutable(fVMInstance.getInstallLocation()); >+ } > if (exe == null) { > abort(MessageFormat.format(LaunchingMessages.StandardVMRunner_Unable_to_locate_executable_for__0__1, new String[]{fVMInstance.getName()}), null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); >+ } else { >+ return exe.getAbsolutePath(); > } >- return exe.getAbsolutePath(); > } > > // Build the path to the java executable. First try 'bin', and if that >Index: launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java,v >retrieving revision 1.34 >diff -u -r1.34 VMDefinitionsContainer.java >--- launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java 27 Jun 2007 20:03:57 -0000 1.34 >+++ launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java 13 Sep 2007 18:13:03 -0000 >@@ -23,6 +23,7 @@ > import java.util.List; > import java.util.Map; > import java.util.Set; >+import java.util.Map.Entry; > > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.DocumentBuilderFactory; >@@ -35,6 +36,7 @@ > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; > import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.jdt.launching.AbstractVMInstall; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstall2; > import org.eclipse.jdt.launching.IVMInstallType; >@@ -130,7 +132,7 @@ > } > vmList.add(vm); > File installLocation = vm.getInstallLocation(); >- if (installLocation == null || !vmInstallType.validateInstallLocation(installLocation).isOK()) { >+ if (installLocation == null || vmInstallType.validateInstallLocation(installLocation).getSeverity() == IStatus.ERROR) { > fInvalidVMList.add(vm); > } > fVMList.add(vm); >@@ -344,6 +346,23 @@ > } > } > >+ // vm attributes >+ if (vm instanceof AbstractVMInstall) { >+ Map attributes = ((AbstractVMInstall)vm).getAttributes(); >+ if (!attributes.isEmpty()) { >+ Element attrElement = doc.createElement("attributeMap"); //$NON-NLS-1$ >+ Iterator iterator = attributes.entrySet().iterator(); >+ while (iterator.hasNext()) { >+ Entry entry = (Entry) iterator.next(); >+ Element entryElement = doc.createElement("entry"); //$NON-NLS-1$ >+ entryElement.setAttribute("key", (String)entry.getKey()); //$NON-NLS-1$ >+ entryElement.setAttribute("value", (String)entry.getValue()); //$NON-NLS-1$ >+ attrElement.appendChild(entryElement); >+ } >+ element.appendChild(attrElement); >+ } >+ } >+ > return element; > } > >Index: launching/org/eclipse/jdt/internal/launching/EEVMType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/EEVMType.java,v >retrieving revision 1.1 >diff -u -r1.1 EEVMType.java >--- launching/org/eclipse/jdt/internal/launching/EEVMType.java 10 Aug 2007 20:00:35 -0000 1.1 >+++ launching/org/eclipse/jdt/internal/launching/EEVMType.java 13 Sep 2007 18:13:03 -0000 >@@ -28,6 +28,8 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.launching.AbstractVMInstallType; >+import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.LibraryLocation; > > import com.ibm.icu.text.MessageFormat; >@@ -38,7 +40,12 @@ > * > * @since 3.4 > */ >-public class EEVMType { >+public class EEVMType extends AbstractVMInstallType { >+ >+ /** >+ * VM Type id >+ */ >+ public static final String ID_EE_VM_TYPE = "org.eclipse.jdt.launching.EEVMType"; //$NON-NLS-1$ > > /** > * Map of {EE File -> {Map of {PropertyName -> PropertyValue}} >@@ -58,55 +65,43 @@ > public static final String PROP_CLASS_LIB_LEVEL = "-Dee.class.library.level"; //$NON-NLS-1$ > public static final String PROP_EXECUTABLE = "-Dee.executable"; //$NON-NLS-1$ > public static final String PROP_EXECUTABLE_CONSOLE = "-Dee.executable.console"; //$NON-NLS-1$ >+ public static final String PROP_JAVA_HOME = "-Djava.home"; //$NON-NLS-1$ > >- private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL}; >- >+ private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL, PROP_JAVA_HOME}; >+ > /** >- * Returns whether the given install location corresponds to an .ee file. >+ * Returns the library locations defined in the given definition file. > * >- * @param installLocation >- * @return whether the given install location corresponds to an .ee file. >+ * @param eeFile definition file >+ * @return library locations defined in the file or an empty collection if none > */ >- public static boolean isEEInstall(File installLocation) { >- if (installLocation.isFile()) { >- String name = installLocation.getName(); >- if (name.endsWith(".ee")) { //$NON-NLS-1$ >- return true; >- } >- } >- return false; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) >- */ >- public static LibraryLocation[] getDefaultLibraryLocations(File installLocation) { >+ public static LibraryLocation[] getLibraryLocations(File eeFile) { > >- Map properties = getProperties(installLocation); >+ Map properties = getProperties(eeFile); > if (properties == null) { > return new LibraryLocation[]{}; > } > > List allLibs = new ArrayList(); > >- String dirs = getProperty(PROP_ENDORSED_DIRS, installLocation); >+ String dirs = getProperty(PROP_ENDORSED_DIRS, eeFile); > if (dirs != null) { > // Add all endorsed libraries - they are first, as they replace >- allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation))); >+ allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile))); > } > > // next is the bootpath libraries >- dirs = getProperty(PROP_BOOT_CLASS_PATH, installLocation); >+ dirs = getProperty(PROP_BOOT_CLASS_PATH, eeFile); > if (dirs != null) { >- String[] bootpath = resolvePaths(dirs, installLocation); >+ String[] bootpath = resolvePaths(dirs, eeFile); > List boot = new ArrayList(bootpath.length); >- URL url = getDefaultJavadocLocation(installLocation); >+ URL url = getJavadocLocation(eeFile); > for (int i = 0; i < bootpath.length; i++) { > IPath path = new Path(bootpath[i]); > File lib = path.toFile(); > if (lib.exists() && lib.isFile()) { > LibraryLocation libraryLocation = new LibraryLocation(path, >- getDefaultSourceLocation(installLocation), >+ getDefaultSourceLocation(eeFile), > Path.EMPTY, > url); > boot.add(libraryLocation); >@@ -116,9 +111,9 @@ > } > > // Add all extension libraries >- dirs = getProperty(PROP_EXTENSION_DIRS, installLocation); >+ dirs = getProperty(PROP_EXTENSION_DIRS, eeFile); > if (dirs != null) { >- allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation))); >+ allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile))); > } > > >@@ -135,24 +130,32 @@ > return (LibraryLocation[])allLibs.toArray(new LibraryLocation[allLibs.size()]); > } > >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File) >+ >+ /** >+ * Returns the javadoc location specified in the definition file or <code>null</code> >+ * if none. >+ * >+ * @param eeFile definition file >+ * @return javadoc location specified in the definition file or <code>null</code> if none > */ >- public static URL getDefaultJavadocLocation(File installLocation) { >- String version = getProperty(PROP_LANGUAGE_LEVEL, installLocation); >+ public static URL getJavadocLocation(File eeFile) { >+ String version = getProperty(PROP_LANGUAGE_LEVEL, eeFile); > if (version != null) { > return StandardVMType.getDefaultJavadocLocation(version); > } > return null; > } > >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File) >+ /** >+ * Returns VM arguments defined in the given definition file or <code>null</code> if none. >+ * >+ * @param eeFile definition file >+ * @return VM arguments or <code>null</code> if none > */ >- public static String getDefaultVMArguments(File installLocation) { >- Map properties = getProperties(installLocation); >+ public static String getVMArguments(File eeFile) { >+ Map properties = getProperties(eeFile); > if (properties != null) { >- List args = (List) fgArguments.get(installLocation); >+ List args = (List) fgArguments.get(eeFile); > StringBuffer buf = new StringBuffer(); > Iterator iterator = args.iterator(); > while (iterator.hasNext()) { >@@ -185,20 +188,23 @@ > return Path.EMPTY; > } > >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) >+ /** >+ * Returns a status indicating if the given definition file is valid. >+ * >+ * @param eeFile definition file >+ * @return status indicating if the given definition file is valid > */ >- public static IStatus validateInstallLocation(File installLocation) { >- Map properties = getProperties(installLocation); >+ public static IStatus validateDefinitionFile(File eeFile) { >+ Map properties = getProperties(eeFile); > if (properties == null) { >- return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{installLocation.getName()} )); >+ return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{eeFile.getName()} )); > } > // validate required properties > for (int i = 0; i < REQUIRED_PROPERTIES.length; i++) { > String key = REQUIRED_PROPERTIES[i]; > String property = (String) properties.get(key); > if (property == null) { >- return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{installLocation.getName(), key} )); >+ return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{eeFile.getName(), key} )); > } > } > return Status.OK_STATUS; >@@ -209,7 +215,7 @@ > * is considered first. > * > * @param installLocation ee file >- * @return standard executable >+ * @return standard executable or <code>null</code> if none > */ > public static File getExecutable(File installLocation) { > String property = getProperty(PROP_EXECUTABLE, installLocation); >@@ -320,4 +326,40 @@ > } > return null; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.AbstractVMInstallType#doCreateVMInstall(java.lang.String) >+ */ >+ protected IVMInstall doCreateVMInstall(String id) { >+ return new EEVMInstall(this, id); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation() >+ */ >+ public File detectInstallLocation() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) >+ */ >+ public LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile) { >+ return new LibraryLocation[0]; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#getName() >+ */ >+ public String getName() { >+ // TODO: >+ return "Execution Environment Description"; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) >+ */ >+ public IStatus validateInstallLocation(File installLocationOrDefinitionFile) { >+ return new Status(IStatus.INFO, LaunchingPlugin.getUniqueIdentifier(), "Unable to validate install location."); >+ } > } >Index: launching/org/eclipse/jdt/internal/launching/StandardVMType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMType.java,v >retrieving revision 1.73 >diff -u -r1.73 StandardVMType.java >--- launching/org/eclipse/jdt/internal/launching/StandardVMType.java 10 Aug 2007 20:00:35 -0000 1.73 >+++ launching/org/eclipse/jdt/internal/launching/StandardVMType.java 13 Sep 2007 18:13:03 -0000 >@@ -79,9 +79,6 @@ > * <code>null</code>. > */ > public static File findJavaExecutable(File vmInstallLocation) { >- if (EEVMType.isEEInstall(vmInstallLocation)) { >- return EEVMType.getExecutable(vmInstallLocation); >- } > // Try each candidate in order. The first one found wins. Thus, the order > // of fgCandidateJavaLocations and fgCandidateJavaFiles is significant. > for (int i = 0; i < fgCandidateJavaFiles.length; i++) { >@@ -282,10 +279,6 @@ > * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(File) > */ > public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getDefaultLibraryLocations(installLocation); >- } >- > // Determine the java executable that corresponds to the specified install location > // and use this to generate library information. If no java executable was found, > // the 'standard' libraries will be returned. >@@ -446,9 +439,6 @@ > * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) > */ > public IStatus validateInstallLocation(File javaHome) { >- if (EEVMType.isEEInstall(javaHome)) { >- return EEVMType.validateInstallLocation(javaHome); >- } > IStatus status = null; > if (Platform.getOS().equals(Constants.OS_MACOSX)) { > status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_Standard_VM_not_supported_on_MacOS__1, null); >@@ -602,29 +592,15 @@ > * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File) > */ > public URL getDefaultJavadocLocation(File installLocation) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getDefaultJavadocLocation(installLocation); >- } else { >- File javaExecutable = findJavaExecutable(installLocation); >- if (javaExecutable != null) { >- LibraryInfo libInfo = getLibraryInfo(installLocation, javaExecutable); >- if (libInfo != null) { >- String version = libInfo.getVersion(); >- return getDefaultJavadocLocation(version); >- } >+ File javaExecutable = findJavaExecutable(installLocation); >+ if (javaExecutable != null) { >+ LibraryInfo libInfo = getLibraryInfo(installLocation, javaExecutable); >+ if (libInfo != null) { >+ String version = libInfo.getVersion(); >+ return getDefaultJavadocLocation(version); > } >- return null; > } >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File) >- */ >- public String getDefaultVMArguments(File installLocation) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getDefaultVMArguments(installLocation); >- } >- return super.getDefaultVMArguments(installLocation); >+ return null; > } > > /** >Index: launching/org/eclipse/jdt/launching/IVMInstall.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/IVMInstall.java,v >retrieving revision 1.22 >diff -u -r1.22 IVMInstall.java >--- launching/org/eclipse/jdt/launching/IVMInstall.java 10 Aug 2007 20:00:35 -0000 1.22 >+++ launching/org/eclipse/jdt/launching/IVMInstall.java 13 Sep 2007 18:13:03 -0000 >@@ -68,28 +68,17 @@ > void setName(String name); > /** > * Returns the root directory of the install location of this VM. >- * <p> >- * Since 3.4, this may also be a file describing a VM install. >- * For example, the standard VM installs support execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >+ * > * @return the root directory of this VM installation. May > * return <code>null</code>. > */ > File getInstallLocation(); > /** > * Sets the root directory of the install location of this VM. >- * <p> >- * Since 3.4, this may also be a file describing a VM install. >- * For example, the standard VM installs support execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * @param installLocationOrDefinitionFile the root directory or definition file for >- * this VM installation >+ * >+ * @param installLocation the root directory of this VM installation > */ >- void setInstallLocation(File installLocationOrDefinitionFile); >+ void setInstallLocation(File installLocation); > > /** > * Returns the VM type of this VM. >Index: launching/org/eclipse/jdt/launching/VMStandin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/VMStandin.java,v >retrieving revision 1.16 >diff -u -r1.16 VMStandin.java >--- launching/org/eclipse/jdt/launching/VMStandin.java 8 May 2006 20:39:12 -0000 1.16 >+++ launching/org/eclipse/jdt/launching/VMStandin.java 13 Sep 2007 18:13:04 -0000 >@@ -10,6 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.launching; > >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Map.Entry; >+ > > > /** >@@ -93,6 +97,15 @@ > setVMArguments(realVM.getVMArguments()); > fJavaVersion = null; > } >+ if (realVM instanceof AbstractVMInstall) { >+ AbstractVMInstall vm2 = (AbstractVMInstall) realVM; >+ Map attributes = vm2.getAttributes(); >+ Iterator iterator = attributes.entrySet().iterator(); >+ while (iterator.hasNext()) { >+ Entry entry = (Entry) iterator.next(); >+ setAttribute((String)entry.getKey(), (String)entry.getValue()); >+ } >+ } > } > > /** >@@ -126,7 +139,13 @@ > } > > if (realVM instanceof AbstractVMInstall) { >- ((AbstractVMInstall)realVM).setNotify(true); >+ AbstractVMInstall avm = (AbstractVMInstall) realVM; >+ Iterator iterator = getAttributes().entrySet().iterator(); >+ while (iterator.hasNext()) { >+ Entry entry = (Entry) iterator.next(); >+ avm.setAttribute((String)entry.getKey(), (String)entry.getValue()); >+ } >+ avm.setNotify(true); > } > if (!notify) { > JavaRuntime.fireVMAdded(realVM); >Index: launching/org/eclipse/jdt/launching/AbstractVMInstallType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractVMInstallType.java,v >retrieving revision 1.21 >diff -u -r1.21 AbstractVMInstallType.java >--- launching/org/eclipse/jdt/launching/AbstractVMInstallType.java 10 Aug 2007 20:00:35 -0000 1.21 >+++ launching/org/eclipse/jdt/launching/AbstractVMInstallType.java 13 Sep 2007 18:13:03 -0000 >@@ -157,29 +157,23 @@ > * implementation returns <code>null</code>, subclasses must override as > * appropriate. > * <p> >- * Since 3.4, the argument may also be a file describing a VM install. >- * For example, the standard VM installs support execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * <p> > * Note, this method would ideally be added to <code>IVMInstallType</code>, > * but it would have been a breaking API change between 2.0 and 2.1. Thus, > * it has been added to the abstract base class that VM install types should > * subclass. > * </p> > * >- * @param installLocationOrDefinitionFile home location or since 3.4, a definition file >+ * @param installLocationOrDefinitionFile home location > * @return default javadoc location or <code>null</code> > * @since 2.1 > */ >- public URL getDefaultJavadocLocation(File installLocationOrDefinitionFile) { >+ public URL getDefaultJavadocLocation(File installLocation) { > return null; > } > > /** > * Returns a string of default VM arguments for a VM installed at the >- * given home location or definition file, or <code>null</code> if none. >+ * given home location, or <code>null</code> if none. > * The default implementation returns <code>null</code>, subclasses must override > * as appropriate. > * <p> >@@ -188,11 +182,11 @@ > * it has been added to the abstract base class that VM install types should > * subclass. > * </p> >- * @param installLocationOrDefinitionFile home location or definition file >+ * @param installLocation home location > * @return default VM arguments or <code>null</code> if none > * @since 3.4 > */ >- public String getDefaultVMArguments(File installLocationOrDefinitionFile) { >+ public String getDefaultVMArguments(File installLocation) { > return null; > } > } >Index: launching/org/eclipse/jdt/launching/IVMInstallType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/IVMInstallType.java,v >retrieving revision 1.16 >diff -u -r1.16 IVMInstallType.java >--- launching/org/eclipse/jdt/launching/IVMInstallType.java 10 Aug 2007 20:00:35 -0000 1.16 >+++ launching/org/eclipse/jdt/launching/IVMInstallType.java 13 Sep 2007 18:13:03 -0000 >@@ -88,20 +88,15 @@ > /** > * Validates the given location of a VM installation. > * <p> >- * Since 3.4, the given installLocation may be a file (rather than a home >- * directory). For example, the standard VM install type accepts execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * <p> > * For example, an implementation might check whether the VM executable > * is present. > * </p> >- * @param installLocationOrDefinitionFile the root directory of a potential installation for >- * this type of VM or since 3.4, a file describing an installation >+ * >+ * @param installLocation the root directory of a potential installation for >+ * this type of VM > * @return a status object describing whether the install location is valid > */ >- IStatus validateInstallLocation(File installLocationOrDefinitionFile); >+ IStatus validateInstallLocation(File installLocation); > > /** > * Tries to detect an installed VM that matches this VM install type. >@@ -120,19 +115,13 @@ > * at the given <code>installLocation</code>. > * The returned <code>LibraryLocation</code>s may not exist if the > * <code>installLocation</code> is not a valid install location. >- * <p> >- * Since 3.4, the given installLocation may be a file (rather than a home >- * directory). For example, the standard VM install type accepts execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * @param installLocationOrDefinitionFile home directory or since 3.4, a file >- * describing an installation >+ * >+ * @param installLocation home location > * @see LibraryLocation > * @see IVMInstallType#validateInstallLocation(File) > * > * @return default library locations based on the given <code>installLocation</code>. > * @since 2.0 > */ >- LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile); >+ LibraryLocation[] getDefaultLibraryLocations(File installLocation); > } >Index: launching/org/eclipse/jdt/launching/JavaRuntime.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java,v >retrieving revision 1.194 >diff -u -r1.194 JavaRuntime.java >--- launching/org/eclipse/jdt/launching/JavaRuntime.java 15 Aug 2007 16:01:00 -0000 1.194 >+++ launching/org/eclipse/jdt/launching/JavaRuntime.java 13 Sep 2007 18:13:04 -0000 >@@ -59,6 +59,8 @@ > import org.eclipse.jdt.internal.launching.CompositeId; > import org.eclipse.jdt.internal.launching.DefaultEntryResolver; > import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry; >+import org.eclipse.jdt.internal.launching.EEVMInstall; >+import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.internal.launching.JREContainerInitializer; > import org.eclipse.jdt.internal.launching.JavaSourceLookupUtil; > import org.eclipse.jdt.internal.launching.LaunchingMessages; >@@ -2654,5 +2656,44 @@ > } > } > } >+ >+ /** >+ * Creates a new VM based on the attributes specified in the given execution >+ * environment description file. The format of the file is defined by >+ * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >+ * >+ * @param eeFile VM definition file >+ * @param name name for the VM >+ * @param id id to assign to the new VM >+ * @return VM standin >+ * @exception CoreException if unable to create a VM from the given definition file >+ * @since 3.4 >+ */ >+ public static VMStandin createVMFromDefinitionFile(File eeFile, String name, String id) throws CoreException { >+ IStatus status = EEVMType.validateDefinitionFile(eeFile); >+ if (status.isOK()) { >+ VMStandin standin = new VMStandin(getVMInstallType(EEVMType.ID_EE_VM_TYPE), id); >+ standin.setName(name); >+ String home = EEVMType.getProperty(EEVMType.PROP_JAVA_HOME, eeFile); >+ standin.setInstallLocation(new File(home)); >+ standin.setLibraryLocations(EEVMType.getLibraryLocations(eeFile)); >+ standin.setVMArgs(EEVMType.getVMArguments(eeFile)); >+ standin.setJavadocLocation(EEVMType.getJavadocLocation(eeFile)); >+ standin.setAttribute(EEVMInstall.ATTR_EXECUTION_ENVIRONMENT_ID, EEVMType.getProperty(EEVMType.PROP_CLASS_LIB_LEVEL, eeFile)); >+ File exe = EEVMType.getExecutable(eeFile); >+ if (exe != null) { >+ try { >+ standin.setAttribute(EEVMInstall.ATTR_JAVA_EXE, exe.getCanonicalPath()); >+ } catch (IOException e) { >+ throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), >+ "Failed to create VM install", e)); >+ } >+ } >+ standin.setAttribute(EEVMInstall.ATTR_JAVA_VERSION, EEVMType.getJavaVersion(eeFile)); >+ return standin; >+ } else { >+ throw new CoreException(status); >+ } >+ } > > } >Index: launching/org/eclipse/jdt/launching/AbstractVMInstall.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractVMInstall.java,v >retrieving revision 1.30 >diff -u -r1.30 AbstractVMInstall.java >--- launching/org/eclipse/jdt/launching/AbstractVMInstall.java 16 May 2006 20:16:41 -0000 1.30 >+++ launching/org/eclipse/jdt/launching/AbstractVMInstall.java 13 Sep 2007 18:13:03 -0000 >@@ -55,6 +55,12 @@ > private LibraryLocation[] fSystemLibraryDescriptions; > private URL fJavadocLocation; > private String fVMArgs; >+ /** >+ * Map VM specific attributes that are persisted restored with a VM install. >+ * @since 3.4 >+ */ >+ private Map fAttributeMap = new HashMap(); >+ > // system properties are cached in user preferences prefixed with this key, followed > // by vm type, vm id, and system property name > private static final String PREF_VM_INSTALL_SYSTEM_PROPERTY = "PREF_VM_INSTALL_SYSTEM_PROPERTY"; //$NON-NLS-1$ >@@ -484,5 +490,56 @@ > throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin > .getUniqueIdentifier(), code, message, exception)); > } >+ >+ /** >+ * Sets a VM specific attribute. Attributes are persisted and restored with VM installs. >+ * Specifying a value of <code>null</code> as a value removes the attribute. Change >+ * notification is provided to {@link IVMInstallChangedListener} for VM attributes. >+ * >+ * @param key attribute key, cannot be <code>null</code> >+ * @param value attribute value or <code>null</code> to remove the attribute >+ * @since 3.4 >+ */ >+ public void setAttribute(String key, String value) { >+ String prevValue = (String) fAttributeMap.remove(key); >+ boolean notify = false; >+ if (value == null) { >+ if (prevValue != null && fNotify) { >+ notify = true; >+ } >+ } else { >+ fAttributeMap.put(key, value); >+ if (fNotify && (prevValue == null || !prevValue.equals(value))) { >+ notify = true; >+ } >+ } >+ if (notify) { >+ PropertyChangeEvent event = new PropertyChangeEvent(this, key, prevValue, value); >+ JavaRuntime.fireVMChanged(event); >+ } >+ } > >+ /** >+ * Returns a VM specific attribute associated with the given key or <code>null</code> >+ * if none. >+ * >+ * @param key attribute key, cannot be <code>null</code> >+ * @return attribute value, or <code>null</code> if none >+ * @since 3.4 >+ */ >+ public String getAttribute(String key) { >+ return (String) fAttributeMap.get(key); >+ } >+ >+ /** >+ * Returns a map of VM specific attributes stored with this VM install. Keys >+ * and values are strings. Modifying the map does not modify the attributes >+ * associated with this VM install. >+ * >+ * @return map of VM attributes >+ * @since 3.4 >+ */ >+ public Map getAttributes() { >+ return new HashMap(fAttributeMap); >+ } > } >Index: launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java,v >retrieving revision 1.2 >diff -u -r1.2 ExecutionEnvironmentAnalyzer.java >--- launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java 10 Aug 2007 20:00:35 -0000 1.2 >+++ launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java 13 Sep 2007 18:13:03 -0000 >@@ -18,6 +18,7 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jdt.internal.launching.EEVMInstall; > import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstall2; >@@ -72,8 +73,8 @@ > return new CompatibleEnvironment[0]; > IVMInstall2 vm2 = (IVMInstall2) vm; > List types = null; >- if (EEVMType.isEEInstall(vm.getInstallLocation())) { >- String eeId = EEVMType.getProperty(EEVMType.PROP_CLASS_LIB_LEVEL, vm.getInstallLocation()); >+ if (EEVMType.ID_EE_VM_TYPE.equals(vm.getVMInstallType().getId())) { >+ String eeId = ((EEVMInstall)vm).getAttribute(EEVMInstall.ATTR_EXECUTION_ENVIRONMENT_ID); > if (eeId != null) { > types = getTypes(eeId); > } >Index: launching/org/eclipse/jdt/internal/launching/EEVMInstall.java >=================================================================== >RCS file: launching/org/eclipse/jdt/internal/launching/EEVMInstall.java >diff -N launching/org/eclipse/jdt/internal/launching/EEVMInstall.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ launching/org/eclipse/jdt/internal/launching/EEVMInstall.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching; >+ >+import java.io.File; >+ >+import org.eclipse.jdt.launching.IVMInstallType; >+ >+/** >+ * A VM install created from an execution environment description file. >+ * >+ * @since 3.4 >+ */ >+public class EEVMInstall extends StandardVM { >+ >+ /** >+ * Attribute key for Java version property >+ */ >+ public static final String ATTR_JAVA_VERSION = "ATTR_JAVA_VERSION"; //$NON-NLS-1$ >+ >+ /** >+ * Attribute key for supported execution environment by this runtime >+ */ >+ public static final String ATTR_EXECUTION_ENVIRONMENT_ID = "ATTR_EXECUTION_ENVIRONMENT_ID"; //$NON-NLS-1$ >+ >+ /** >+ * Attribute key for Java executable used by this VM >+ */ >+ public static final String ATTR_JAVA_EXE = "ATTR_JAVA_EXE"; //$NON-NLS-1$ >+ >+ /** >+ * Constructs a VM install. >+ * >+ * @param type vm type >+ * @param id unique id >+ */ >+ EEVMInstall(IVMInstallType type, String id) { >+ super(type, id); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.StandardVM#getJavaVersion() >+ */ >+ public String getJavaVersion() { >+ return getAttribute(ATTR_JAVA_VERSION); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.StandardVM#getJavaExecutable() >+ */ >+ File getJavaExecutable() { >+ String exe = getAttribute(ATTR_JAVA_EXE); >+ if (exe != null) { >+ return new File(exe); >+ } >+ return null; >+ } >+ >+ >+ >+} >#P org.eclipse.jdt.debug.tests >Index: tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java,v >retrieving revision 1.3 >diff -u -r1.3 EEDefinitionTests.java >--- tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java 14 Aug 2007 20:23:35 -0000 1.3 >+++ tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java 13 Sep 2007 18:13:07 -0000 >@@ -12,13 +12,14 @@ > > import java.io.File; > >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; > import org.eclipse.jdt.debug.testplugin.JavaTestPlugin; > import org.eclipse.jdt.debug.tests.AbstractDebugTest; >-import org.eclipse.jdt.internal.launching.StandardVMType; >+import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstallType; > import org.eclipse.jdt.launching.JavaRuntime; >@@ -46,26 +47,34 @@ > } > > /** >- * Tests that the EE file is a valid install location >+ * Tests that the EE file is a valid file > */ >- public void testValidateInstallLocation() { >+ public void testValidateDefinitionFile() { > File file = getEEFile(); >- IVMInstallType vmType = getStandardVMInstallType(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- IStatus status = vmType.validateInstallLocation(file); >+ IStatus status = EEVMType.validateDefinitionFile(file); > assertTrue("Invalid install location", status.isOK()); > } > > /** >- * Tests default libraries for the EE file >+ * Tests that the EE install location validation returns an INFO status. > */ >- public void testDefaultLibraries() { >+ public void testValidateInstallLocation() { > File file = getEEFile(); >- IVMInstallType vmType = getStandardVMInstallType(); >+ IVMInstallType vmType = getVMInstallType(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- LibraryLocation[] libs = vmType.getDefaultLibraryLocations(file); >+ assertNotNull("Missing EE VM type", vmType); >+ IStatus status = vmType.validateInstallLocation(file); >+ assertTrue("Invalid install location", status.getSeverity() == IStatus.INFO); >+ } >+ >+ /** >+ * Tests libraries for the EE file >+ */ >+ public void testLibraries() { >+ File file = getEEFile(); >+ assertNotNull("Missing EE file", file); >+ LibraryLocation[] libs = EEVMType.getLibraryLocations(file); > String[] expected = new String[]{"end.jar", "classes.txt", "others.txt", "ext1.jar", "ext2.jar", "opt-ext.jar"}; > assertEquals("Wrong number of libraries", expected.length, libs.length); > for (int i = 0; i < expected.length; i++) { >@@ -87,15 +96,25 @@ > } > > /** >+ * Tests default libraries for an EE VM type are empty. >+ */ >+ public void testDefaultLibraries() { >+ File file = getEEFile(); >+ IVMInstallType vmType = getVMInstallType(); >+ assertNotNull("Missing EE file", file); >+ assertNotNull("Missing EE VM type", vmType); >+ LibraryLocation[] libs = vmType.getDefaultLibraryLocations(file); >+ assertEquals("Wrong number of libraries", 0, libs.length); >+ } >+ >+ /** > * Tests default VM arguments. All arguments from the EE file should get passed through in the > * same order to the command line. > */ >- public void testDefaultVMArguments() { >+ public void testVMArguments() { > File file = getEEFile(); >- StandardVMType vmType = (StandardVMType) getStandardVMInstallType(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- String defaultVMArguments = vmType.getDefaultVMArguments(file); >+ String defaultVMArguments = EEVMType.getVMArguments(file); > String[] expected = new String[] { > "-Dee.executable", > "-Dee.executable.console", >@@ -123,18 +142,15 @@ > /** > * Test compatible environments > */ >- public void testCompatibleEEs() { >+ public void testCompatibleEEs() throws CoreException { > IVMInstall install = null; >- StandardVMType vmType = (StandardVMType) getStandardVMInstallType(); >+ EEVMType vmType = (EEVMType) getVMInstallType(); > try { > File file = getEEFile(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- VMStandin vm = new VMStandin(vmType, "test-ee-file-id"); >- vm.setInstallLocation(file); >- vm.setName("test-ee-file"); >- vm.setVMArgs(vmType.getDefaultVMArguments(file)); >- install = vm.convertToRealVM(); >+ assertNotNull("Missing EE VM type", vmType); >+ VMStandin standin = JavaRuntime.createVMFromDefinitionFile(file, "test-ee-file", "test-ee-file-id"); >+ install = standin.convertToRealVM(); > > IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); > IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); >@@ -143,9 +159,9 @@ > IExecutionEnvironment env = envs[i]; > if (env.getId().equals("CDC-1.1/Foundation-1.1")) { > found11 = true; >- assertTrue("Should be strictly compatible with " + env.getId(), env.isStrictlyCompatible(vm)); >+ assertTrue("Should be strictly compatible with " + env.getId(), env.isStrictlyCompatible(install)); > } else if (env.getId().indexOf("jdt.debug.tests") < 0) { >- assertFalse("Should *not* be strictly compatible with " + env.getId(), env.isStrictlyCompatible(vm)); >+ assertFalse("Should *not* be strictly compatible with " + env.getId(), env.isStrictlyCompatible(install)); > } > } > assertTrue("Did not find foundation 1.1 environment", found11); >@@ -160,7 +176,7 @@ > return JavaTestPlugin.getDefault().getFileInPlugin(TEST_EE_FILE); > } > >- protected IVMInstallType getStandardVMInstallType() { >- return JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE); >+ protected IVMInstallType getVMInstallType() { >+ return JavaRuntime.getVMInstallType(EEVMType.ID_EE_VM_TYPE); > } > } >Index: testfiles/test-jre/bin/test-foundation11.ee >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/testfiles/test-jre/bin/test-foundation11.ee,v >retrieving revision 1.2 >diff -u -r1.2 test-foundation11.ee >--- testfiles/test-jre/bin/test-foundation11.ee 14 Aug 2007 19:26:56 -0000 1.2 >+++ testfiles/test-jre/bin/test-foundation11.ee 13 Sep 2007 18:13:07 -0000 >@@ -25,6 +25,7 @@ > -Dee.name=Eclipse JDT Test JRE Definition > -Dee.description=Foundation Specification v1.1 > -Dee.copyright=(c) Copyright IBM Corp. 2007 All Rights Reserved >+-Djava.home=.. > > # all args should get passed through to command line > -XspecialArg:123 >\ No newline at end of file >Index: testfiles/test-jre/bin/test-foundation11-win32.ee >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/testfiles/test-jre/bin/test-foundation11-win32.ee,v >retrieving revision 1.1 >diff -u -r1.1 test-foundation11-win32.ee >--- testfiles/test-jre/bin/test-foundation11-win32.ee 14 Aug 2007 19:26:56 -0000 1.1 >+++ testfiles/test-jre/bin/test-foundation11-win32.ee 13 Sep 2007 18:13:07 -0000 >@@ -25,6 +25,7 @@ > -Dee.name=Eclipse JDT Test JRE Definition > -Dee.description=Foundation Specification v1.1 > -Dee.copyright=(c) Copyright IBM Corp. 2007 All Rights Reserved >+-Djava.home=.. > > # all args should get passed through to command line > -XspecialArg:123 >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 201758
: 78364 |
79019
|
79587
|
79685