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 163444 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-1 / +39 lines)
Lines 193-197 Link Here
193
      	 name= "%jreContainerMarkerProblemName">
193
      	 name= "%jreContainerMarkerProblemName">
194
      <super type="org.eclipse.core.resources.problemmarker"/>
194
      <super type="org.eclipse.core.resources.problemmarker"/>
195
      <persistent value="true"/>
195
      <persistent value="true"/>
196
   </extension>   
196
   </extension> 
197
   
198
      <extension
199
         point="org.eclipse.jdt.launching.executionEnvironments">
200
      <environment
201
            id="OSGi/Minimum-1.0"
202
            description="%environment.description.0"/>
203
      <environment
204
            id="OSGi/Minimum-1.1"
205
            description="%environment.description.1"/>
206
      <environment
207
            id="JRE-1.1"
208
            description="%environment.description.2"/>
209
      <environment
210
            id="J2SE-1.2"
211
            description="%environment.description.3"/>
212
      <environment
213
            id="J2SE-1.3"
214
            description="%environment.description.4"/>
215
      <environment
216
            id="J2SE-1.4"
217
            description="%environment.description.5"/>
218
      <environment
219
            id="J2SE-1.5"
220
            description="%environment.description.6"/>
221
      <environment
222
            id="CDC-1.0/Foundation-1.0"
223
            description="%environment.description.7"/>
224
      <environment
225
            id="CDC-1.1/Foundation-1.1"
226
            description="%environment.description.8"/>
227
      <environment
228
            id="JavaSE-1.6"
229
            description="%environment.description.9"/>
230
      <analyzer
231
            class="org.eclipse.jdt.internal.launching.environments.ExecutionEnvironmentAnalyzer"
232
            id="org.eclipse.pde.core.eeAnalyzer"/>
233
   </extension>
234
     
197
</plugin>
235
</plugin>
(-)plugin.properties (+11 lines)
Lines 42-44 Link Here
42
classpathVariableSourceContainerType.description= Workspace folder, local directory, or archive referenced by a variable path
42
classpathVariableSourceContainerType.description= Workspace folder, local directory, or archive referenced by a variable path
43
classpathContainerSourceContainerType.name= Java Library
43
classpathContainerSourceContainerType.name= Java Library
44
classpathContainerSourceContainerType.description= A collection of binary archives with attached source
44
classpathContainerSourceContainerType.description= A collection of binary archives with attached source
45
46
environment.description.0 = Minimum environment to run the OSGi framework 1.0
47
environment.description.1 = Minimum environment to run the OSGi framework 1.1
48
environment.description.2 = Java Runtime Environment 1.1
49
environment.description.3 = Java 2 Platform, Standard Edition 1.2
50
environment.description.4 = Java 2 Platform, Standard Edition 1.3
51
environment.description.5 = Java 2 Platform, Standard Edition 1.4
52
environment.description.6 = Java 2 Platform, Standard Edition 5.0
53
environment.description.7 = CDC 1.0, Foundation 1.0
54
environment.description.8 = CDC 1.1, Foundation 1.1
55
environment.description.9 = Java Platform, Standard Edition 6.0
(-)launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java (+151 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 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.environments;
12
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.StringTokenizer;
18
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.jdt.launching.IVMInstall;
22
import org.eclipse.jdt.launching.IVMInstall2;
23
import org.eclipse.jdt.launching.IVMInstall3;
24
import org.eclipse.jdt.launching.JavaRuntime;
25
import org.eclipse.jdt.launching.environments.CompatibleEnvironment;
26
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
27
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentAnalyzerDelegate;
28
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
29
30
public class ExecutionEnvironmentAnalyzer implements IExecutionEnvironmentAnalyzerDelegate {
31
	
32
	private static final String JavaSE_1_6 = "JavaSE-1.6"; //$NON-NLS-1$
33
	private static final String J2SE_1_5 = "J2SE-1.5"; //$NON-NLS-1$
34
	private static final String J2SE_1_4 = "J2SE-1.4"; //$NON-NLS-1$
35
	private static final String J2SE_1_3 = "J2SE-1.3"; //$NON-NLS-1$
36
	private static final String J2SE_1_2 = "J2SE-1.2"; //$NON-NLS-1$
37
	private static final String JRE_1_1 = "JRE-1.1"; //$NON-NLS-1$
38
	
39
	private static final String CDC_FOUNDATION_1_1 = "CDC-1.1/Foundation-1.1"; //$NON-NLS-1$
40
	private static final String CDC_FOUNDATION_1_0 = "CDC-1.0/Foundation-1.0"; //$NON-NLS-1$
41
	
42
	private static final String OSGI_MINIMUM_1_0 = "OSGi/Minimum-1.0"; //$NON-NLS-1$
43
	private static final String OSGI_MINIMUM_1_1 = "OSGi/Minimum-1.1"; //$NON-NLS-1$
44
	
45
	private static final String JAVA_SPEC_VERSION = "java.specification.version"; //$NON-NLS-1$
46
	private static final String JAVA_SPEC_NAME = "java.specification.name"; //$NON-NLS-1$
47
	private static final String JAVA_VERSION = "java.version"; //$NON-NLS-1$
48
	
49
	private static final String[] VM_PROPERTIES = {JAVA_SPEC_NAME, JAVA_SPEC_VERSION, JAVA_VERSION};
50
	private static final String FOUNDATION = "foundation"; //$NON-NLS-1$
51
	private static final Map mappings = new HashMap();
52
53
	static {
54
		// table where the key is the EE and the value is an array of EEs that it is a super-set of
55
		mappings.put(CDC_FOUNDATION_1_0, new String[] {OSGI_MINIMUM_1_0});
56
		mappings.put(CDC_FOUNDATION_1_1, new String[] {CDC_FOUNDATION_1_0, OSGI_MINIMUM_1_1});
57
		mappings.put(OSGI_MINIMUM_1_1, new String[] {OSGI_MINIMUM_1_0});
58
		mappings.put(J2SE_1_2, new String[] {JRE_1_1});
59
		mappings.put(J2SE_1_3, new String[] {J2SE_1_2, CDC_FOUNDATION_1_0, OSGI_MINIMUM_1_0});
60
		mappings.put(J2SE_1_4, new String[] {J2SE_1_3, CDC_FOUNDATION_1_1, OSGI_MINIMUM_1_1});
61
		mappings.put(J2SE_1_5, new String[] {J2SE_1_4});
62
		mappings.put(JavaSE_1_6, new String[] {J2SE_1_5});
63
	}
64
	public CompatibleEnvironment[] analyze(IVMInstall vm, IProgressMonitor monitor) throws CoreException {
65
		ArrayList result = new ArrayList();
66
		if (!(vm instanceof IVMInstall2))
67
			return new CompatibleEnvironment[0];
68
		IVMInstall2 vm2 = (IVMInstall2) vm;
69
		
70
		List types = null;
71
		String javaVersion = vm2.getJavaVersion();
72
		if (javaVersion == null) {
73
			// We have a contributed VM type. Check to see if its a foundation VM, if we can.
74
			if ((vm instanceof IVMInstall3) && isFoundation1_0((IVMInstall3) vm)) 
75
				types = getTypes(CDC_FOUNDATION_1_0);
76
			else if ((vm instanceof IVMInstall3) && isFoundation1_1((IVMInstall3) vm)) 
77
				types = getTypes(CDC_FOUNDATION_1_1);
78
		} else {
79
			if (javaVersion.startsWith("1.6")) //$NON-NLS-1$
80
				types = getTypes(JavaSE_1_6);
81
			else if (javaVersion.startsWith("1.5")) //$NON-NLS-1$
82
				types = getTypes(J2SE_1_5);
83
			else if (javaVersion.startsWith("1.4")) //$NON-NLS-1$
84
				types = getTypes(J2SE_1_4);
85
			else if (javaVersion.startsWith("1.3")) //$NON-NLS-1$
86
				types = getTypes(J2SE_1_3);
87
			else if (javaVersion.startsWith("1.2")) //$NON-NLS-1$
88
				types = getTypes(J2SE_1_2);
89
			else if (javaVersion.startsWith("1.1")) { //$NON-NLS-1$
90
				if ((vm instanceof IVMInstall3) && isFoundation1_1((IVMInstall3) vm))
91
					types = getTypes(CDC_FOUNDATION_1_1);
92
				else
93
					types = getTypes(JRE_1_1);
94
			} else if (javaVersion.startsWith("1.0")) { //$NON-NLS-1$
95
				if ((vm instanceof IVMInstall3) && isFoundation1_0((IVMInstall3) vm)) 
96
					types = getTypes(CDC_FOUNDATION_1_0);
97
			}
98
		}
99
100
		if (types != null) {
101
			for (int i=0; i < types.size(); i++)
102
				addEnvironment(result, (String) types.get(i), i ==0);
103
		}
104
		return (CompatibleEnvironment[])result.toArray(new CompatibleEnvironment[result.size()]);
105
	}
106
107
	/*
108
	 * Check a couple of known system properties for the word "foundation".
109
	 */
110
	private boolean isFoundation(Map properties) {
111
		for (int i=0; i < VM_PROPERTIES.length; i++) {
112
			String value = (String) properties.get(VM_PROPERTIES[i]);
113
			if (value == null)
114
				continue;
115
			for (StringTokenizer tokenizer = new StringTokenizer(value); tokenizer.hasMoreTokens(); )
116
				if (FOUNDATION.equalsIgnoreCase(tokenizer.nextToken()))
117
					return true;
118
		}
119
		return false;
120
	}
121
122
	private boolean isFoundation1_0(IVMInstall3 vm) throws CoreException {
123
		Map map = vm.evaluateSystemProperties(VM_PROPERTIES, null);
124
		return isFoundation(map) ? "1.0".equals(map.get(JAVA_SPEC_VERSION)) : false; //$NON-NLS-1$
125
	}
126
127
	private boolean isFoundation1_1(IVMInstall3 vm) throws CoreException {
128
		Map map = vm.evaluateSystemProperties(VM_PROPERTIES, null);
129
		return isFoundation(map) ? "1.1".equals(map.get(JAVA_SPEC_VERSION)) : false; //$NON-NLS-1$
130
	}
131
132
	private void addEnvironment(ArrayList result, String id, boolean strict) {
133
		IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
134
		IExecutionEnvironment env = manager.getEnvironment(id);
135
		if (env != null)
136
			result.add(new CompatibleEnvironment(env, strict));
137
	}
138
	
139
	// first entry in the list is the perfect match
140
	private List getTypes(String type) {
141
		List result = new ArrayList();
142
		result.add(type);
143
		String[] values = (String[]) mappings.get(type);
144
		if (values != null) {
145
			for (int i=0; i<values.length; i++)
146
				result.addAll(getTypes(values[i]));
147
		}
148
		return result;
149
	}
150
151
}

Return to bug 163444