Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 201758 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+4 lines)
Lines 23-28 Link Here
23
            class="org.eclipse.jdt.internal.launching.Standard11xVMType"
23
            class="org.eclipse.jdt.internal.launching.Standard11xVMType"
24
            id="org.eclipse.jdt.launching.Standard11xVMType">
24
            id="org.eclipse.jdt.launching.Standard11xVMType">
25
      </vmInstallType>
25
      </vmInstallType>
26
      <vmInstallType
27
            class="org.eclipse.jdt.internal.launching.EEVMType"
28
            id="org.eclipse.jdt.launching.EEVMType">
29
      </vmInstallType>
26
   </extension>
30
   </extension>
27
   <extension
31
   <extension
28
         point="org.eclipse.debug.core.launchConfigurationTypes">
32
         point="org.eclipse.debug.core.launchConfigurationTypes">
(-)launching/org/eclipse/jdt/internal/launching/StandardVM.java (-4 / +16 lines)
Lines 41-50 Link Here
41
        StandardVMType installType = (StandardVMType) getVMInstallType();
41
        StandardVMType installType = (StandardVMType) getVMInstallType();
42
        File installLocation = getInstallLocation();
42
        File installLocation = getInstallLocation();
43
        if (installLocation != null) {
43
        if (installLocation != null) {
44
        	if (EEVMType.isEEInstall(installLocation)) {
44
            File executable = getJavaExecutable();
45
        		return EEVMType.getJavaVersion(installLocation);
46
        	}
47
            File executable = StandardVMType.findJavaExecutable(installLocation);
48
            if (executable != null) {
45
            if (executable != null) {
49
                String vmVersion = installType.getVMVersion(installLocation, executable);
46
                String vmVersion = installType.getVMVersion(installLocation, executable);
50
                // strip off extra info
47
                // strip off extra info
Lines 64-67 Link Here
64
        }
61
        }
65
        return null;
62
        return null;
66
    }
63
    }
64
    
65
    /**
66
     * Returns the java executable for this VM or <code>null</code> if cannot be found
67
     * 
68
     * @return executable for this VM or <code>null</code> if none
69
     */
70
    File getJavaExecutable() {
71
    	File installLocation = getInstallLocation();
72
        if (installLocation != null) {
73
            return StandardVMType.findJavaExecutable(installLocation);
74
        }
75
        return null;
76
    }
77
    
78
    
67
}
79
}
(-)launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java (-2 / +8 lines)
Lines 171-181 Link Here
171
		
171
		
172
		// If no java command was specified, use default executable
172
		// If no java command was specified, use default executable
173
		if (command == null) {
173
		if (command == null) {
174
			File exe = StandardVMType.findJavaExecutable(fVMInstance.getInstallLocation());
174
			File exe = null;
175
			if (fVMInstance instanceof StandardVM) {
176
				exe = ((StandardVM)fVMInstance).getJavaExecutable();
177
			} else {
178
				exe = StandardVMType.findJavaExecutable(fVMInstance.getInstallLocation());
179
			}
175
			if (exe == null) {
180
			if (exe == null) {
176
				abort(MessageFormat.format(LaunchingMessages.StandardVMRunner_Unable_to_locate_executable_for__0__1, new String[]{fVMInstance.getName()}), null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); 
181
				abort(MessageFormat.format(LaunchingMessages.StandardVMRunner_Unable_to_locate_executable_for__0__1, new String[]{fVMInstance.getName()}), null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); 
182
			} else {
183
				return exe.getAbsolutePath();
177
			}
184
			}
178
			return exe.getAbsolutePath();
179
		}
185
		}
180
				
186
				
181
		// Build the path to the java executable.  First try 'bin', and if that
187
		// Build the path to the java executable.  First try 'bin', and if that
(-)launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java (-1 / +20 lines)
Lines 23-28 Link Here
23
import java.util.List;
23
import java.util.List;
24
import java.util.Map;
24
import java.util.Map;
25
import java.util.Set;
25
import java.util.Set;
26
import java.util.Map.Entry;
26
27
27
import javax.xml.parsers.DocumentBuilder;
28
import javax.xml.parsers.DocumentBuilder;
28
import javax.xml.parsers.DocumentBuilderFactory;
29
import javax.xml.parsers.DocumentBuilderFactory;
Lines 35-40 Link Here
35
import org.eclipse.core.runtime.Path;
36
import org.eclipse.core.runtime.Path;
36
import org.eclipse.core.runtime.Status;
37
import org.eclipse.core.runtime.Status;
37
import org.eclipse.debug.core.DebugPlugin;
38
import org.eclipse.debug.core.DebugPlugin;
39
import org.eclipse.jdt.launching.AbstractVMInstall;
38
import org.eclipse.jdt.launching.IVMInstall;
40
import org.eclipse.jdt.launching.IVMInstall;
39
import org.eclipse.jdt.launching.IVMInstall2;
41
import org.eclipse.jdt.launching.IVMInstall2;
40
import org.eclipse.jdt.launching.IVMInstallType;
42
import org.eclipse.jdt.launching.IVMInstallType;
Lines 130-136 Link Here
130
			}
132
			}
131
			vmList.add(vm);
133
			vmList.add(vm);
132
			File installLocation = vm.getInstallLocation();
134
			File installLocation = vm.getInstallLocation();
133
			if (installLocation == null || !vmInstallType.validateInstallLocation(installLocation).isOK()) {
135
			if (installLocation == null || vmInstallType.validateInstallLocation(installLocation).getSeverity() == IStatus.ERROR) {
134
				fInvalidVMList.add(vm);
136
				fInvalidVMList.add(vm);
135
			}
137
			}
136
			fVMList.add(vm);
138
			fVMList.add(vm);
Lines 344-349 Link Here
344
			}
346
			}
345
		}
347
		}
346
		
348
		
349
		// vm attributes
350
		if (vm instanceof AbstractVMInstall) {
351
			Map attributes = ((AbstractVMInstall)vm).getAttributes();
352
			if (!attributes.isEmpty()) {
353
				Element attrElement = doc.createElement("attributeMap"); //$NON-NLS-1$
354
				Iterator iterator = attributes.entrySet().iterator();
355
				while (iterator.hasNext()) {
356
					Entry entry = (Entry) iterator.next();
357
					Element entryElement = doc.createElement("entry"); //$NON-NLS-1$
358
					entryElement.setAttribute("key", (String)entry.getKey()); //$NON-NLS-1$
359
					entryElement.setAttribute("value", (String)entry.getValue()); //$NON-NLS-1$
360
					attrElement.appendChild(entryElement);
361
				}
362
				element.appendChild(attrElement);
363
			}
364
		}
365
		
347
		return element;
366
		return element;
348
	}
367
	}
349
	
368
	
(-)launching/org/eclipse/jdt/internal/launching/EEVMType.java (-45 / +87 lines)
Lines 28-33 Link Here
28
import org.eclipse.core.runtime.IStatus;
28
import org.eclipse.core.runtime.IStatus;
29
import org.eclipse.core.runtime.Path;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.Status;
31
import org.eclipse.jdt.launching.AbstractVMInstallType;
32
import org.eclipse.jdt.launching.IVMInstall;
31
import org.eclipse.jdt.launching.LibraryLocation;
33
import org.eclipse.jdt.launching.LibraryLocation;
32
34
33
import com.ibm.icu.text.MessageFormat;
35
import com.ibm.icu.text.MessageFormat;
Lines 38-44 Link Here
38
 * 
40
 * 
39
 * @since 3.4
41
 * @since 3.4
40
 */
42
 */
41
public class EEVMType {
43
public class EEVMType extends AbstractVMInstallType {
44
	
45
	/**
46
	 * VM Type id
47
	 */
48
	public static final String ID_EE_VM_TYPE = "org.eclipse.jdt.launching.EEVMType"; //$NON-NLS-1$
42
	
49
	
43
	/**
50
	/**
44
	 * Map of {EE File -> {Map of {PropertyName -> PropertyValue}}
51
	 * Map of {EE File -> {Map of {PropertyName -> PropertyValue}}
Lines 58-112 Link Here
58
	public static final String PROP_CLASS_LIB_LEVEL = "-Dee.class.library.level";  //$NON-NLS-1$
65
	public static final String PROP_CLASS_LIB_LEVEL = "-Dee.class.library.level";  //$NON-NLS-1$
59
	public static final String PROP_EXECUTABLE = "-Dee.executable";  //$NON-NLS-1$
66
	public static final String PROP_EXECUTABLE = "-Dee.executable";  //$NON-NLS-1$
60
	public static final String PROP_EXECUTABLE_CONSOLE = "-Dee.executable.console";  //$NON-NLS-1$
67
	public static final String PROP_EXECUTABLE_CONSOLE = "-Dee.executable.console";  //$NON-NLS-1$
68
	public static final String PROP_JAVA_HOME = "-Djava.home";  //$NON-NLS-1$
61
	
69
	
62
	private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL};
70
	private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL, PROP_JAVA_HOME};
63
	
71
64
	/**
72
	/**
65
	 * Returns whether the given install location corresponds to an .ee file.
73
	 * Returns the library locations defined in the given definition file.
66
	 * 
74
	 * 
67
	 * @param installLocation
75
	 * @param eeFile definition file
68
	 * @return whether the given install location corresponds to an .ee file.
76
	 * @return library locations defined in the file or an empty collection if none
69
	 */
77
	 */
70
	public static boolean isEEInstall(File installLocation) {
78
	public static LibraryLocation[] getLibraryLocations(File eeFile) {
71
		if (installLocation.isFile()) {
72
			String name = installLocation.getName();
73
			if (name.endsWith(".ee")) { //$NON-NLS-1$
74
				return true;
75
			}
76
		}
77
		return false;
78
	}
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File)
82
	 */
83
	public static LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
84
		
79
		
85
		Map properties = getProperties(installLocation);
80
		Map properties = getProperties(eeFile);
86
		if (properties == null) {
81
		if (properties == null) {
87
			return new LibraryLocation[]{};
82
			return new LibraryLocation[]{};
88
		}
83
		}
89
		
84
		
90
		List allLibs = new ArrayList(); 
85
		List allLibs = new ArrayList(); 
91
		
86
		
92
		String dirs = getProperty(PROP_ENDORSED_DIRS, installLocation);
87
		String dirs = getProperty(PROP_ENDORSED_DIRS, eeFile);
93
		if (dirs != null) {
88
		if (dirs != null) {
94
			// Add all endorsed libraries - they are first, as they replace
89
			// Add all endorsed libraries - they are first, as they replace
95
			allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation)));
90
			allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile)));
96
		}
91
		}
97
		
92
		
98
		// next is the bootpath libraries
93
		// next is the bootpath libraries
99
		dirs = getProperty(PROP_BOOT_CLASS_PATH, installLocation);
94
		dirs = getProperty(PROP_BOOT_CLASS_PATH, eeFile);
100
		if (dirs != null) {
95
		if (dirs != null) {
101
			String[] bootpath = resolvePaths(dirs, installLocation);
96
			String[] bootpath = resolvePaths(dirs, eeFile);
102
			List boot = new ArrayList(bootpath.length);
97
			List boot = new ArrayList(bootpath.length);
103
			URL url = getDefaultJavadocLocation(installLocation);
98
			URL url = getJavadocLocation(eeFile);
104
			for (int i = 0; i < bootpath.length; i++) {
99
			for (int i = 0; i < bootpath.length; i++) {
105
				IPath path = new Path(bootpath[i]);
100
				IPath path = new Path(bootpath[i]);
106
				File lib = path.toFile(); 
101
				File lib = path.toFile(); 
107
				if (lib.exists() && lib.isFile()) {
102
				if (lib.exists() && lib.isFile()) {
108
					LibraryLocation libraryLocation = new LibraryLocation(path,
103
					LibraryLocation libraryLocation = new LibraryLocation(path,
109
									getDefaultSourceLocation(installLocation),
104
									getDefaultSourceLocation(eeFile),
110
									Path.EMPTY,
105
									Path.EMPTY,
111
									url);
106
									url);
112
					boot.add(libraryLocation);
107
					boot.add(libraryLocation);
Lines 116-124 Link Here
116
		}
111
		}
117
				
112
				
118
		// Add all extension libraries
113
		// Add all extension libraries
119
		dirs = getProperty(PROP_EXTENSION_DIRS, installLocation);
114
		dirs = getProperty(PROP_EXTENSION_DIRS, eeFile);
120
		if (dirs != null) {
115
		if (dirs != null) {
121
			allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation)));
116
			allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile)));
122
		}
117
		}
123
		
118
		
124
		
119
		
Lines 135-158 Link Here
135
		return (LibraryLocation[])allLibs.toArray(new LibraryLocation[allLibs.size()]);
130
		return (LibraryLocation[])allLibs.toArray(new LibraryLocation[allLibs.size()]);
136
	}
131
	}
137
	
132
	
138
	/* (non-Javadoc)
133
139
	 * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File)
134
	/**
135
	 * Returns the javadoc location specified in the definition file or <code>null</code>
136
	 * if none.
137
	 * 
138
	 * @param eeFile definition file
139
	 * @return javadoc location specified in the definition file or <code>null</code> if none
140
	 */
140
	 */
141
	public static URL getDefaultJavadocLocation(File installLocation) {
141
	public static URL getJavadocLocation(File eeFile) {
142
		String version = getProperty(PROP_LANGUAGE_LEVEL, installLocation);
142
		String version = getProperty(PROP_LANGUAGE_LEVEL, eeFile);
143
		if (version != null) {
143
		if (version != null) {
144
			return StandardVMType.getDefaultJavadocLocation(version);
144
			return StandardVMType.getDefaultJavadocLocation(version);
145
		}
145
		}
146
		return null;
146
		return null;
147
	}
147
	}
148
	
148
	
149
	/* (non-Javadoc)
149
	/**
150
	 * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File)
150
	 * Returns VM arguments defined in the given definition file or <code>null</code> if none.
151
	 * 
152
	 * @param eeFile definition file
153
	 * @return VM arguments or <code>null</code> if none
151
	 */
154
	 */
152
	public static String getDefaultVMArguments(File installLocation) {
155
	public static String getVMArguments(File eeFile) {
153
		Map properties = getProperties(installLocation);
156
		Map properties = getProperties(eeFile);
154
		if (properties != null) {
157
		if (properties != null) {
155
			List args = (List) fgArguments.get(installLocation);
158
			List args = (List) fgArguments.get(eeFile);
156
			StringBuffer buf = new StringBuffer();
159
			StringBuffer buf = new StringBuffer();
157
			Iterator iterator = args.iterator();
160
			Iterator iterator = args.iterator();
158
			while (iterator.hasNext()) {
161
			while (iterator.hasNext()) {
Lines 185-204 Link Here
185
		return Path.EMPTY;
188
		return Path.EMPTY;
186
	}
189
	}
187
190
188
	/* (non-Javadoc)
191
	/**
189
	 * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File)
192
	 * Returns a status indicating if the given definition file is valid.
193
	 * 
194
	 * @param eeFile definition file
195
	 * @return status indicating if the given definition file is valid
190
	 */
196
	 */
191
	public static IStatus validateInstallLocation(File installLocation) {
197
	public static IStatus validateDefinitionFile(File eeFile) {
192
		Map properties = getProperties(installLocation);
198
		Map properties = getProperties(eeFile);
193
		if (properties == null) {
199
		if (properties == null) {
194
			return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{installLocation.getName()} ));
200
			return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{eeFile.getName()} ));
195
		}
201
		}
196
		// validate required properties
202
		// validate required properties
197
		for (int i = 0; i < REQUIRED_PROPERTIES.length; i++) {
203
		for (int i = 0; i < REQUIRED_PROPERTIES.length; i++) {
198
			String key = REQUIRED_PROPERTIES[i];
204
			String key = REQUIRED_PROPERTIES[i];
199
			String property = (String) properties.get(key);
205
			String property = (String) properties.get(key);
200
			if (property == null) {
206
			if (property == null) {
201
				return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{installLocation.getName(), key} ));
207
				return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{eeFile.getName(), key} ));
202
			}
208
			}
203
		}
209
		}
204
		return Status.OK_STATUS;
210
		return Status.OK_STATUS;
Lines 209-215 Link Here
209
	 * is considered first.
215
	 * is considered first.
210
	 * 
216
	 * 
211
	 * @param installLocation ee file
217
	 * @param installLocation ee file
212
	 * @return standard executable
218
	 * @return standard executable or <code>null</code> if none
213
	 */
219
	 */
214
	public static File getExecutable(File installLocation) { 
220
	public static File getExecutable(File installLocation) { 
215
		String property = getProperty(PROP_EXECUTABLE, installLocation);
221
		String property = getProperty(PROP_EXECUTABLE, installLocation);
Lines 320-323 Link Here
320
		}
326
		}
321
		return null;
327
		return null;
322
	}
328
	}
329
330
	/* (non-Javadoc)
331
	 * @see org.eclipse.jdt.launching.AbstractVMInstallType#doCreateVMInstall(java.lang.String)
332
	 */
333
	protected IVMInstall doCreateVMInstall(String id) {
334
		return new EEVMInstall(this, id);
335
	}
336
337
	/* (non-Javadoc)
338
	 * @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation()
339
	 */
340
	public File detectInstallLocation() {
341
		return null;
342
	}
343
344
	/* (non-Javadoc)
345
	 * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File)
346
	 */
347
	public LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile) {
348
		return new LibraryLocation[0];
349
	}
350
351
	/* (non-Javadoc)
352
	 * @see org.eclipse.jdt.launching.IVMInstallType#getName()
353
	 */
354
	public String getName() {
355
		// TODO:
356
		return "Execution Environment Description";
357
	}
358
359
	/* (non-Javadoc)
360
	 * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File)
361
	 */
362
	public IStatus validateInstallLocation(File installLocationOrDefinitionFile) {
363
		return new Status(IStatus.INFO, LaunchingPlugin.getUniqueIdentifier(), "Unable to validate install location.");
364
	}
323
}
365
}
(-)launching/org/eclipse/jdt/internal/launching/StandardVMType.java (-31 / +7 lines)
Lines 79-87 Link Here
79
	 * <code>null</code>.
79
	 * <code>null</code>.
80
	 */
80
	 */
81
	public static File findJavaExecutable(File vmInstallLocation) {
81
	public static File findJavaExecutable(File vmInstallLocation) {
82
		if (EEVMType.isEEInstall(vmInstallLocation)) {
83
			return EEVMType.getExecutable(vmInstallLocation);
84
		}
85
		// Try each candidate in order.  The first one found wins.  Thus, the order
82
		// Try each candidate in order.  The first one found wins.  Thus, the order
86
		// of fgCandidateJavaLocations and fgCandidateJavaFiles is significant.
83
		// of fgCandidateJavaLocations and fgCandidateJavaFiles is significant.
87
		for (int i = 0; i < fgCandidateJavaFiles.length; i++) {
84
		for (int i = 0; i < fgCandidateJavaFiles.length; i++) {
Lines 282-291 Link Here
282
	 * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(File)
279
	 * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(File)
283
	 */
280
	 */
284
	public LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
281
	public LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
285
		if (EEVMType.isEEInstall(installLocation)) {
286
			return EEVMType.getDefaultLibraryLocations(installLocation);
287
		}
288
289
		// Determine the java executable that corresponds to the specified install location
282
		// Determine the java executable that corresponds to the specified install location
290
		// and use this to generate library information.  If no java executable was found, 
283
		// and use this to generate library information.  If no java executable was found, 
291
		// the 'standard' libraries will be returned.
284
		// the 'standard' libraries will be returned.
Lines 446-454 Link Here
446
	 * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File)
439
	 * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File)
447
	 */
440
	 */
448
	public IStatus validateInstallLocation(File javaHome) {
441
	public IStatus validateInstallLocation(File javaHome) {
449
		if (EEVMType.isEEInstall(javaHome)) {
450
			return EEVMType.validateInstallLocation(javaHome);
451
		}
452
		IStatus status = null;
442
		IStatus status = null;
453
		if (Platform.getOS().equals(Constants.OS_MACOSX)) {
443
		if (Platform.getOS().equals(Constants.OS_MACOSX)) {
454
			status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_Standard_VM_not_supported_on_MacOS__1, null); 
444
			status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_Standard_VM_not_supported_on_MacOS__1, null); 
Lines 602-630 Link Here
602
	 * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File)
592
	 * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File)
603
	 */
593
	 */
604
	public URL getDefaultJavadocLocation(File installLocation) {
594
	public URL getDefaultJavadocLocation(File installLocation) {
605
		if (EEVMType.isEEInstall(installLocation)) {
595
		File javaExecutable = findJavaExecutable(installLocation);
606
			return EEVMType.getDefaultJavadocLocation(installLocation);
596
		if (javaExecutable != null) {
607
		} else {
597
			LibraryInfo libInfo = getLibraryInfo(installLocation, javaExecutable);
608
			File javaExecutable = findJavaExecutable(installLocation);
598
			if (libInfo != null) {
609
			if (javaExecutable != null) {
599
				String version = libInfo.getVersion();
610
				LibraryInfo libInfo = getLibraryInfo(installLocation, javaExecutable);
600
				return getDefaultJavadocLocation(version);
611
				if (libInfo != null) {
612
					String version = libInfo.getVersion();
613
					return getDefaultJavadocLocation(version);
614
				}
615
			}
601
			}
616
			return null;
617
		}
602
		}
618
	}
603
		return null;
619
620
	/* (non-Javadoc)
621
	 * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File)
622
	 */
623
	public String getDefaultVMArguments(File installLocation) {
624
		if (EEVMType.isEEInstall(installLocation)) {
625
			return EEVMType.getDefaultVMArguments(installLocation);
626
		}
627
		return super.getDefaultVMArguments(installLocation);
628
	}
604
	}
629
605
630
	/**
606
	/**
(-)launching/org/eclipse/jdt/launching/IVMInstall.java (-15 / +4 lines)
Lines 68-95 Link Here
68
	void setName(String name);
68
	void setName(String name);
69
	/**
69
	/**
70
	 * Returns the root directory of the install location of this VM.
70
	 * Returns the root directory of the install location of this VM.
71
	 * <p>
71
	 * 
72
	 * Since 3.4, this may also be a file describing a VM install.
73
	 * For example, the standard VM installs support execution
74
	 * environment description files, as described by
75
	 * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>.
76
	 * </p>
77
	 * @return the root directory of this VM installation. May
72
	 * @return the root directory of this VM installation. May
78
	 * 			return <code>null</code>.
73
	 * 			return <code>null</code>.
79
	 */
74
	 */
80
	File getInstallLocation();
75
	File getInstallLocation();
81
	/**
76
	/**
82
	 * Sets the root directory of the install location of this VM.
77
	 * Sets the root directory of the install location of this VM.
83
	 * <p>
78
	 * 
84
	 * Since 3.4, this may also be a file describing a VM install.
79
	 * @param installLocation the root directory of this VM installation
85
	 * For example, the standard VM installs support execution
86
	 * environment description files, as described by
87
	 * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>.
88
	 * </p>
89
	 * @param installLocationOrDefinitionFile the root directory or definition file for
90
	 * 	this VM installation
91
	 */
80
	 */
92
	void setInstallLocation(File installLocationOrDefinitionFile);
81
	void setInstallLocation(File installLocation);
93
		
82
		
94
	/**
83
	/**
95
	 * Returns the VM type of this VM.
84
	 * Returns the VM type of this VM.
(-)launching/org/eclipse/jdt/launching/VMStandin.java (-1 / +20 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.launching;
11
package org.eclipse.jdt.launching;
12
12
13
import java.util.Iterator;
14
import java.util.Map;
15
import java.util.Map.Entry;
16
13
17
14
18
15
/**
19
/**
Lines 93-98 Link Here
93
			setVMArguments(realVM.getVMArguments());
97
			setVMArguments(realVM.getVMArguments());
94
			fJavaVersion = null;
98
			fJavaVersion = null;
95
		}
99
		}
100
		if (realVM instanceof AbstractVMInstall) {
101
			AbstractVMInstall vm2 = (AbstractVMInstall) realVM;
102
			Map attributes = vm2.getAttributes();
103
			Iterator iterator = attributes.entrySet().iterator();
104
			while (iterator.hasNext()) {
105
				Entry entry = (Entry) iterator.next();
106
				setAttribute((String)entry.getKey(), (String)entry.getValue());
107
			}
108
		}
96
	}
109
	}
97
	
110
	
98
	/**
111
	/**
Lines 126-132 Link Here
126
		}
139
		}
127
		
140
		
128
		if (realVM instanceof AbstractVMInstall) {
141
		if (realVM instanceof AbstractVMInstall) {
129
			 ((AbstractVMInstall)realVM).setNotify(true);
142
			AbstractVMInstall avm = (AbstractVMInstall) realVM;
143
			Iterator iterator = getAttributes().entrySet().iterator();
144
			while (iterator.hasNext()) {
145
				Entry entry = (Entry) iterator.next();
146
				avm.setAttribute((String)entry.getKey(), (String)entry.getValue());
147
			}
148
			avm.setNotify(true);
130
		}		
149
		}		
131
		if (!notify) {
150
		if (!notify) {
132
			JavaRuntime.fireVMAdded(realVM);
151
			JavaRuntime.fireVMAdded(realVM);
(-)launching/org/eclipse/jdt/launching/AbstractVMInstallType.java (-11 / +5 lines)
Lines 157-185 Link Here
157
	 * implementation returns <code>null</code>, subclasses must override as
157
	 * implementation returns <code>null</code>, subclasses must override as
158
	 * appropriate.
158
	 * appropriate.
159
	 * <p>
159
	 * <p>
160
	 * Since 3.4, the argument may also be a file describing a VM install.
161
	 * For example, the standard VM installs support execution
162
	 * environment description files, as described by
163
	 * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>.
164
	 * </p>
165
	 * <p>
166
	 * Note, this method would ideally be added to <code>IVMInstallType</code>,
160
	 * Note, this method would ideally be added to <code>IVMInstallType</code>,
167
	 * but it would have been a breaking API change between 2.0 and 2.1. Thus,
161
	 * but it would have been a breaking API change between 2.0 and 2.1. Thus,
168
	 * it has been added to the abstract base class that VM install types should
162
	 * it has been added to the abstract base class that VM install types should
169
	 * subclass.
163
	 * subclass.
170
	 * </p>
164
	 * </p>
171
	 * 
165
	 * 
172
	 * @param installLocationOrDefinitionFile home location or since 3.4, a definition file
166
	 * @param installLocationOrDefinitionFile home location
173
	 * @return default javadoc location or <code>null</code>
167
	 * @return default javadoc location or <code>null</code>
174
	 * @since 2.1
168
	 * @since 2.1
175
	 */
169
	 */
176
	public URL getDefaultJavadocLocation(File installLocationOrDefinitionFile) {
170
	public URL getDefaultJavadocLocation(File installLocation) {
177
		return null;		
171
		return null;		
178
	}
172
	}
179
	
173
	
180
	/**
174
	/**
181
	 * Returns a string of default VM arguments for a VM installed at the
175
	 * Returns a string of default VM arguments for a VM installed at the
182
	 * given home location or definition file, or <code>null</code> if none.
176
	 * given home location, or <code>null</code> if none.
183
	 * The default implementation returns <code>null</code>, subclasses must override
177
	 * The default implementation returns <code>null</code>, subclasses must override
184
	 * as appropriate.
178
	 * as appropriate.
185
	 * <p>
179
	 * <p>
Lines 188-198 Link Here
188
	 * it has been added to the abstract base class that VM install types should
182
	 * it has been added to the abstract base class that VM install types should
189
	 * subclass.
183
	 * subclass.
190
	 * </p>
184
	 * </p>
191
	 * @param installLocationOrDefinitionFile home location or definition file
185
	 * @param installLocation home location
192
	 * @return default VM arguments or <code>null</code> if none
186
	 * @return default VM arguments or <code>null</code> if none
193
	 * @since 3.4
187
	 * @since 3.4
194
	 */
188
	 */
195
	public String getDefaultVMArguments(File installLocationOrDefinitionFile) {
189
	public String getDefaultVMArguments(File installLocation) {
196
		return null;
190
		return null;
197
	}
191
	}
198
}
192
}
(-)launching/org/eclipse/jdt/launching/IVMInstallType.java (-18 / +7 lines)
Lines 88-107 Link Here
88
	/**
88
	/**
89
	 * Validates the given location of a VM installation.
89
	 * Validates the given location of a VM installation.
90
	 * <p>
90
	 * <p>
91
	 * Since 3.4, the given installLocation may be a file (rather than a home
92
	 * directory). For example, the standard VM install type accepts execution
93
	 * environment description files, as described by
94
	 * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>.
95
	 * </p> 
96
	 * <p>
97
	 * For example, an implementation might check whether the VM executable 
91
	 * For example, an implementation might check whether the VM executable 
98
	 * is present.
92
	 * is present.
99
	 * </p>
93
	 * </p>
100
	 * @param installLocationOrDefinitionFile the root directory of a potential installation for
94
	 * 
101
	 *   this type of VM or since 3.4, a file describing an installation
95
	 * @param installLocation the root directory of a potential installation for
96
	 *   this type of VM
102
	 * @return a status object describing whether the install location is valid
97
	 * @return a status object describing whether the install location is valid
103
	 */
98
	 */
104
	IStatus validateInstallLocation(File installLocationOrDefinitionFile);
99
	IStatus validateInstallLocation(File installLocation);
105
	
100
	
106
	/**
101
	/**
107
	 * Tries to detect an installed VM that matches this VM install type.
102
	 * Tries to detect an installed VM that matches this VM install type.
Lines 120-138 Link Here
120
	 * at the given <code>installLocation</code>.
115
	 * at the given <code>installLocation</code>.
121
	 * The returned <code>LibraryLocation</code>s may not exist if the
116
	 * The returned <code>LibraryLocation</code>s may not exist if the
122
	 * <code>installLocation</code> is not a valid install location.
117
	 * <code>installLocation</code> is not a valid install location.
123
	 * <p>
118
	 * 
124
	 * Since 3.4, the given installLocation may be a file (rather than a home
119
	 * @param installLocation home location
125
	 * directory). For example, the standard VM install type accepts execution
126
	 * environment description files, as described by
127
	 * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>.
128
	 * </p> 
129
	 * @param installLocationOrDefinitionFile home directory or since 3.4, a file
130
	 * 	describing an installation
131
	 * @see LibraryLocation
120
	 * @see LibraryLocation
132
	 * @see IVMInstallType#validateInstallLocation(File)
121
	 * @see IVMInstallType#validateInstallLocation(File)
133
	 * 
122
	 * 
134
	 * @return default library locations based on the given <code>installLocation</code>.
123
	 * @return default library locations based on the given <code>installLocation</code>.
135
	 * @since 2.0
124
	 * @since 2.0
136
	 */
125
	 */
137
	LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile);	
126
	LibraryLocation[] getDefaultLibraryLocations(File installLocation);	
138
}
127
}
(-)launching/org/eclipse/jdt/launching/JavaRuntime.java (+41 lines)
Lines 59-64 Link Here
59
import org.eclipse.jdt.internal.launching.CompositeId;
59
import org.eclipse.jdt.internal.launching.CompositeId;
60
import org.eclipse.jdt.internal.launching.DefaultEntryResolver;
60
import org.eclipse.jdt.internal.launching.DefaultEntryResolver;
61
import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry;
61
import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry;
62
import org.eclipse.jdt.internal.launching.EEVMInstall;
63
import org.eclipse.jdt.internal.launching.EEVMType;
62
import org.eclipse.jdt.internal.launching.JREContainerInitializer;
64
import org.eclipse.jdt.internal.launching.JREContainerInitializer;
63
import org.eclipse.jdt.internal.launching.JavaSourceLookupUtil;
65
import org.eclipse.jdt.internal.launching.JavaSourceLookupUtil;
64
import org.eclipse.jdt.internal.launching.LaunchingMessages;
66
import org.eclipse.jdt.internal.launching.LaunchingMessages;
Lines 2654-2658 Link Here
2654
            }
2656
            }
2655
        }		
2657
        }		
2656
	}
2658
	}
2659
	
2660
	/**
2661
	 * Creates a new VM based on the attributes specified in the given execution 
2662
	 * environment description file. The format of the file is defined by
2663
	 * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>.
2664
	 * 
2665
	 * @param eeFile VM definition file
2666
	 * @param name name for the VM
2667
	 * @param id id to assign to the new VM
2668
	 * @return VM standin 
2669
	 * @exception CoreException if unable to create a VM from the given definition file
2670
	 * @since 3.4
2671
	 */
2672
	public static VMStandin createVMFromDefinitionFile(File eeFile, String name, String id) throws CoreException {
2673
		IStatus status = EEVMType.validateDefinitionFile(eeFile);
2674
		if (status.isOK()) {
2675
			VMStandin standin = new VMStandin(getVMInstallType(EEVMType.ID_EE_VM_TYPE), id);
2676
			standin.setName(name);
2677
			String home = EEVMType.getProperty(EEVMType.PROP_JAVA_HOME, eeFile);
2678
			standin.setInstallLocation(new File(home));
2679
			standin.setLibraryLocations(EEVMType.getLibraryLocations(eeFile));
2680
			standin.setVMArgs(EEVMType.getVMArguments(eeFile));
2681
			standin.setJavadocLocation(EEVMType.getJavadocLocation(eeFile));
2682
			standin.setAttribute(EEVMInstall.ATTR_EXECUTION_ENVIRONMENT_ID, EEVMType.getProperty(EEVMType.PROP_CLASS_LIB_LEVEL, eeFile));
2683
			File exe = EEVMType.getExecutable(eeFile);
2684
			if (exe != null) {
2685
				try {
2686
					standin.setAttribute(EEVMInstall.ATTR_JAVA_EXE, exe.getCanonicalPath());
2687
				} catch (IOException e) {
2688
					throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(),
2689
							"Failed to create VM install", e));
2690
				}
2691
			}
2692
			standin.setAttribute(EEVMInstall.ATTR_JAVA_VERSION, EEVMType.getJavaVersion(eeFile));
2693
			return standin;
2694
		} else {
2695
			throw new CoreException(status);
2696
		}
2697
	}
2657
2698
2658
}
2699
}
(-)launching/org/eclipse/jdt/launching/AbstractVMInstall.java (+57 lines)
Lines 55-60 Link Here
55
	private LibraryLocation[] fSystemLibraryDescriptions;
55
	private LibraryLocation[] fSystemLibraryDescriptions;
56
	private URL fJavadocLocation;
56
	private URL fJavadocLocation;
57
	private String fVMArgs;
57
	private String fVMArgs;
58
	/**
59
	 * Map VM specific attributes that are persisted restored with a VM install.
60
	 * @since 3.4
61
	 */
62
	private Map fAttributeMap = new HashMap();
63
	
58
	// system properties are cached in user preferences prefixed with this key, followed
64
	// system properties are cached in user preferences prefixed with this key, followed
59
	// by vm type, vm id, and system property name
65
	// by vm type, vm id, and system property name
60
	private static final String PREF_VM_INSTALL_SYSTEM_PROPERTY = "PREF_VM_INSTALL_SYSTEM_PROPERTY"; //$NON-NLS-1$
66
	private static final String PREF_VM_INSTALL_SYSTEM_PROPERTY = "PREF_VM_INSTALL_SYSTEM_PROPERTY"; //$NON-NLS-1$
Lines 484-488 Link Here
484
		throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin
490
		throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin
485
				.getUniqueIdentifier(), code, message, exception));
491
				.getUniqueIdentifier(), code, message, exception));
486
	}	
492
	}	
493
	
494
	/**
495
	 * Sets a VM specific attribute. Attributes are persisted and restored with VM installs.
496
	 * Specifying a value of <code>null</code> as a value removes the attribute. Change
497
	 * notification is provided to {@link IVMInstallChangedListener} for VM attributes.
498
	 * 
499
	 * @param key attribute key, cannot be <code>null</code>
500
	 * @param value attribute value or <code>null</code> to remove the attribute
501
	 * @since 3.4
502
	 */
503
	public void setAttribute(String key, String value) {
504
		String prevValue = (String) fAttributeMap.remove(key);
505
		boolean notify = false;
506
		if (value == null) {
507
			if (prevValue != null && fNotify) {
508
				notify = true;
509
			}
510
		} else {
511
			fAttributeMap.put(key, value);
512
			if (fNotify && (prevValue == null || !prevValue.equals(value))) {
513
				notify = true;
514
			}
515
		}
516
		if (notify) {
517
			PropertyChangeEvent event = new PropertyChangeEvent(this, key, prevValue, value);
518
			JavaRuntime.fireVMChanged(event);
519
		}
520
	}
487
    
521
    
522
	/**
523
	 * Returns a VM specific attribute associated with the given key or <code>null</code> 
524
	 * if none.
525
	 * 
526
	 * @param key attribute key, cannot be <code>null</code>
527
	 * @return attribute value, or <code>null</code> if none
528
	 * @since 3.4
529
	 */
530
	public String getAttribute(String key) {
531
		return (String) fAttributeMap.get(key);
532
	}
533
	
534
	/**
535
	 * Returns a map of VM specific attributes stored with this VM install. Keys
536
	 * and values are strings. Modifying the map does not modify the attributes
537
	 * associated with this VM install.
538
	 * 
539
	 * @return map of VM attributes
540
	 * @since 3.4
541
	 */
542
	public Map getAttributes() {
543
		return new HashMap(fAttributeMap);
544
	}
488
}
545
}
(-)launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java (-2 / +3 lines)
Lines 18-23 Link Here
18
18
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.jdt.internal.launching.EEVMInstall;
21
import org.eclipse.jdt.internal.launching.EEVMType;
22
import org.eclipse.jdt.internal.launching.EEVMType;
22
import org.eclipse.jdt.launching.IVMInstall;
23
import org.eclipse.jdt.launching.IVMInstall;
23
import org.eclipse.jdt.launching.IVMInstall2;
24
import org.eclipse.jdt.launching.IVMInstall2;
Lines 72-79 Link Here
72
			return new CompatibleEnvironment[0];
73
			return new CompatibleEnvironment[0];
73
		IVMInstall2 vm2 = (IVMInstall2) vm;
74
		IVMInstall2 vm2 = (IVMInstall2) vm;
74
		List types = null;
75
		List types = null;
75
		if (EEVMType.isEEInstall(vm.getInstallLocation())) {
76
		if (EEVMType.ID_EE_VM_TYPE.equals(vm.getVMInstallType().getId())) {
76
			String eeId = EEVMType.getProperty(EEVMType.PROP_CLASS_LIB_LEVEL, vm.getInstallLocation());
77
			String eeId = ((EEVMInstall)vm).getAttribute(EEVMInstall.ATTR_EXECUTION_ENVIRONMENT_ID);
77
			if (eeId != null) {
78
			if (eeId != null) {
78
				types = getTypes(eeId);
79
				types = getTypes(eeId);
79
			}
80
			}
(-)launching/org/eclipse/jdt/internal/launching/EEVMInstall.java (+69 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.launching;
12
13
import java.io.File;
14
15
import org.eclipse.jdt.launching.IVMInstallType;
16
17
/**
18
 * A VM install created from an execution environment description file.
19
 * 
20
 * @since 3.4
21
 */
22
public class EEVMInstall extends StandardVM {
23
	
24
	/**
25
	 * Attribute key for Java version property
26
	 */
27
	public static final String ATTR_JAVA_VERSION = "ATTR_JAVA_VERSION"; //$NON-NLS-1$
28
	
29
	/**
30
	 * Attribute key for supported execution environment by this runtime
31
	 */
32
	public static final String ATTR_EXECUTION_ENVIRONMENT_ID = "ATTR_EXECUTION_ENVIRONMENT_ID"; //$NON-NLS-1$
33
	
34
	/**
35
	 * Attribute key for Java executable used by this VM
36
	 */
37
	public static final String ATTR_JAVA_EXE = "ATTR_JAVA_EXE"; //$NON-NLS-1$
38
39
	/**
40
	 * Constructs a VM install.
41
	 * 
42
	 * @param type vm type
43
	 * @param id unique id
44
	 */
45
	EEVMInstall(IVMInstallType type, String id) {
46
		super(type, id);
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.jdt.internal.launching.StandardVM#getJavaVersion()
51
	 */
52
	public String getJavaVersion() {
53
    	return getAttribute(ATTR_JAVA_VERSION);
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.jdt.internal.launching.StandardVM#getJavaExecutable()
58
	 */
59
	File getJavaExecutable() {
60
		String exe = getAttribute(ATTR_JAVA_EXE);
61
		if (exe != null) {
62
			return new File(exe);
63
		}
64
		return null;
65
	}
66
	
67
	
68
69
}
(-)tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java (-27 / +43 lines)
Lines 12-24 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
14
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Path;
18
import org.eclipse.core.runtime.Path;
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.jdt.debug.testplugin.JavaTestPlugin;
20
import org.eclipse.jdt.debug.testplugin.JavaTestPlugin;
20
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
21
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
21
import org.eclipse.jdt.internal.launching.StandardVMType;
22
import org.eclipse.jdt.internal.launching.EEVMType;
22
import org.eclipse.jdt.launching.IVMInstall;
23
import org.eclipse.jdt.launching.IVMInstall;
23
import org.eclipse.jdt.launching.IVMInstallType;
24
import org.eclipse.jdt.launching.IVMInstallType;
24
import org.eclipse.jdt.launching.JavaRuntime;
25
import org.eclipse.jdt.launching.JavaRuntime;
Lines 46-71 Link Here
46
	}
47
	}
47
	
48
	
48
	/**
49
	/**
49
	 * Tests that the EE file is a valid install location
50
	 * Tests that the EE file is a valid file
50
	 */
51
	 */
51
	public void testValidateInstallLocation() {
52
	public void testValidateDefinitionFile() {
52
		File file = getEEFile();
53
		File file = getEEFile();
53
		IVMInstallType vmType = getStandardVMInstallType();
54
		assertNotNull("Missing EE file", file);
54
		assertNotNull("Missing EE file", file);
55
		assertNotNull("Missing standard VM type", vmType);
55
		IStatus status = EEVMType.validateDefinitionFile(file);
56
		IStatus status = vmType.validateInstallLocation(file);
57
		assertTrue("Invalid install location", status.isOK());
56
		assertTrue("Invalid install location", status.isOK());
58
	}
57
	}
59
	
58
	
60
	/**
59
	/**
61
	 * Tests default libraries for the EE file
60
	 * Tests that the EE install location validation returns an INFO status.
62
	 */
61
	 */
63
	public void testDefaultLibraries() {
62
	public void testValidateInstallLocation() {
64
		File file = getEEFile();
63
		File file = getEEFile();
65
		IVMInstallType vmType = getStandardVMInstallType();
64
		IVMInstallType vmType = getVMInstallType();
66
		assertNotNull("Missing EE file", file);
65
		assertNotNull("Missing EE file", file);
67
		assertNotNull("Missing standard VM type", vmType);
66
		assertNotNull("Missing EE VM type", vmType);
68
		LibraryLocation[] libs = vmType.getDefaultLibraryLocations(file);
67
		IStatus status = vmType.validateInstallLocation(file);
68
		assertTrue("Invalid install location", status.getSeverity() == IStatus.INFO);
69
	}	
70
	
71
	/**
72
	 * Tests libraries for the EE file
73
	 */
74
	public void testLibraries() {
75
		File file = getEEFile();
76
		assertNotNull("Missing EE file", file);
77
		LibraryLocation[] libs = EEVMType.getLibraryLocations(file);
69
		String[] expected = new String[]{"end.jar", "classes.txt", "others.txt", "ext1.jar", "ext2.jar", "opt-ext.jar"};
78
		String[] expected = new String[]{"end.jar", "classes.txt", "others.txt", "ext1.jar", "ext2.jar", "opt-ext.jar"};
70
		assertEquals("Wrong number of libraries", expected.length, libs.length);
79
		assertEquals("Wrong number of libraries", expected.length, libs.length);
71
		for (int i = 0; i < expected.length; i++) {
80
		for (int i = 0; i < expected.length; i++) {
Lines 87-101 Link Here
87
	}
96
	}
88
	
97
	
89
	/**
98
	/**
99
	 * Tests default libraries for an EE VM type are empty.
100
	 */
101
	public void testDefaultLibraries() {
102
		File file = getEEFile();
103
		IVMInstallType vmType = getVMInstallType();
104
		assertNotNull("Missing EE file", file);
105
		assertNotNull("Missing EE VM type", vmType);
106
		LibraryLocation[] libs = vmType.getDefaultLibraryLocations(file);
107
		assertEquals("Wrong number of libraries", 0, libs.length);
108
	}	
109
	
110
	/**
90
	 * Tests default VM arguments. All arguments from the EE file should get passed through in the
111
	 * Tests default VM arguments. All arguments from the EE file should get passed through in the
91
	 * same order to the command line.
112
	 * same order to the command line.
92
	 */
113
	 */
93
	public void testDefaultVMArguments() {
114
	public void testVMArguments() {
94
		File file = getEEFile();
115
		File file = getEEFile();
95
		StandardVMType vmType = (StandardVMType) getStandardVMInstallType();
96
		assertNotNull("Missing EE file", file);
116
		assertNotNull("Missing EE file", file);
97
		assertNotNull("Missing standard VM type", vmType);
117
		String defaultVMArguments = EEVMType.getVMArguments(file);
98
		String defaultVMArguments = vmType.getDefaultVMArguments(file);
99
		String[] expected = new String[] {
118
		String[] expected = new String[] {
100
				"-Dee.executable",
119
				"-Dee.executable",
101
				"-Dee.executable.console",
120
				"-Dee.executable.console",
Lines 123-140 Link Here
123
	/**
142
	/**
124
	 * Test compatible environments
143
	 * Test compatible environments
125
	 */
144
	 */
126
	public void testCompatibleEEs() {
145
	public void testCompatibleEEs() throws CoreException {
127
		IVMInstall install = null;
146
		IVMInstall install = null;
128
		StandardVMType vmType = (StandardVMType) getStandardVMInstallType();
147
		EEVMType vmType = (EEVMType) getVMInstallType();
129
		try {
148
		try {
130
			File file = getEEFile();
149
			File file = getEEFile();
131
			assertNotNull("Missing EE file", file);
150
			assertNotNull("Missing EE file", file);
132
			assertNotNull("Missing standard VM type", vmType);
151
			assertNotNull("Missing EE VM type", vmType);
133
			VMStandin vm = new VMStandin(vmType, "test-ee-file-id");
152
			VMStandin standin = JavaRuntime.createVMFromDefinitionFile(file, "test-ee-file", "test-ee-file-id");
134
			vm.setInstallLocation(file);
153
			install = standin.convertToRealVM();
135
			vm.setName("test-ee-file");
136
			vm.setVMArgs(vmType.getDefaultVMArguments(file));
137
			install = vm.convertToRealVM();
138
			
154
			
139
			IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
155
			IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
140
			IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
156
			IExecutionEnvironment[] envs = manager.getExecutionEnvironments();
Lines 143-151 Link Here
143
				IExecutionEnvironment env = envs[i];
159
				IExecutionEnvironment env = envs[i];
144
				if (env.getId().equals("CDC-1.1/Foundation-1.1")) {
160
				if (env.getId().equals("CDC-1.1/Foundation-1.1")) {
145
					found11 = true;
161
					found11 = true;
146
					assertTrue("Should be strictly compatible with " + env.getId(), env.isStrictlyCompatible(vm));
162
					assertTrue("Should be strictly compatible with " + env.getId(), env.isStrictlyCompatible(install));
147
				} else if (env.getId().indexOf("jdt.debug.tests") < 0) {
163
				} else if (env.getId().indexOf("jdt.debug.tests") < 0) {
148
					assertFalse("Should *not* be strictly compatible with " + env.getId(), env.isStrictlyCompatible(vm));
164
					assertFalse("Should *not* be strictly compatible with " + env.getId(), env.isStrictlyCompatible(install));
149
				}
165
				}
150
			}
166
			}
151
			assertTrue("Did not find foundation 1.1 environment", found11);
167
			assertTrue("Did not find foundation 1.1 environment", found11);
Lines 160-166 Link Here
160
		return JavaTestPlugin.getDefault().getFileInPlugin(TEST_EE_FILE);
176
		return JavaTestPlugin.getDefault().getFileInPlugin(TEST_EE_FILE);
161
	}
177
	}
162
	
178
	
163
	protected IVMInstallType getStandardVMInstallType() {
179
	protected IVMInstallType getVMInstallType() {
164
		return JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
180
		return JavaRuntime.getVMInstallType(EEVMType.ID_EE_VM_TYPE);
165
	}
181
	}
166
}
182
}
(-)testfiles/test-jre/bin/test-foundation11.ee (+1 lines)
Lines 25-30 Link Here
25
-Dee.name=Eclipse JDT Test JRE Definition
25
-Dee.name=Eclipse JDT Test JRE Definition
26
-Dee.description=Foundation Specification v1.1
26
-Dee.description=Foundation Specification v1.1
27
-Dee.copyright=(c) Copyright IBM Corp. 2007  All Rights Reserved
27
-Dee.copyright=(c) Copyright IBM Corp. 2007  All Rights Reserved
28
-Djava.home=..
28
29
29
# all args should get passed through to command line
30
# all args should get passed through to command line
30
-XspecialArg:123
31
-XspecialArg:123
(-)testfiles/test-jre/bin/test-foundation11-win32.ee (+1 lines)
Lines 25-30 Link Here
25
-Dee.name=Eclipse JDT Test JRE Definition
25
-Dee.name=Eclipse JDT Test JRE Definition
26
-Dee.description=Foundation Specification v1.1
26
-Dee.description=Foundation Specification v1.1
27
-Dee.copyright=(c) Copyright IBM Corp. 2007  All Rights Reserved
27
-Dee.copyright=(c) Copyright IBM Corp. 2007  All Rights Reserved
28
-Djava.home=..
28
29
29
# all args should get passed through to command line
30
# all args should get passed through to command line
30
-XspecialArg:123
31
-XspecialArg:123

Return to bug 201758