diff --git a/org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF index 19715ea903..ac21acaeef 100644 --- a/org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF @@ -38,10 +38,10 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.filebuffers;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", - org.eclipse.jdt.core;bundle-version="[3.32.0,4.0.0)", + org.eclipse.jdt.core;bundle-version="[3.39.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.13.400,4.0.0)", org.eclipse.jdt.debug;bundle-version="[3.20.0,4.0.0)", - org.eclipse.jdt.launching;bundle-version="[3.19.0,4.0.0)", + org.eclipse.jdt.launching;bundle-version="[3.23.0,4.0.0)", org.eclipse.jdt.ui;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)", diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java index c37422df14..4285301d45 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java @@ -463,11 +463,7 @@ protected void fillWithWorkspaceJREs() { */ protected void fillWithWorkspaceProfiles() { fEnvironments.clear(); - IExecutionEnvironment[] environments = JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments(); - for (int i = 0; i < environments.length; i++) { - fEnvironments.add(environments[i]); - } - + fEnvironments.addAll(JavaRuntime.getExecutionEnvironmentsManager().getSupportedExecutionEnvironments()); String[] names = new String[fEnvironments.size()]; Iterator iter = fEnvironments.iterator(); int i = 0; diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java index 2b345f3dd1..6feca84689 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java @@ -198,7 +198,7 @@ private void validateComplianceAndJRE(IVMInstall vmInstall) { fCompliance.setVisible(true); } else { - List allVersions = JavaCore.getAllVersions(); + List allVersions = JavaCore.getAllJavaProjectVersions(); String latest = allVersions.get(allVersions.size() - 1); String vmver = null; if (vmInstall instanceof AbstractVMInstall) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java index dd522b851d..5a8284e960 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java @@ -247,7 +247,7 @@ else if (segs >= 2) { } detectJavadocLocation(); if (s.isOK()) { - List allVersions = JavaCore.getAllVersions(); + List allVersions = JavaCore.getAllJavaProjectVersions(); String latest = allVersions.get(allVersions.size() - 1); IVMInstallType vmType = fVM.getVMInstallType(); if (vmType instanceof StandardVMType) { diff --git a/org.eclipse.jdt.launching/META-INF/MANIFEST.MF b/org.eclipse.jdt.launching/META-INF/MANIFEST.MF index ee0b20300b..d6931d5c0e 100644 --- a/org.eclipse.jdt.launching/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.launching/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.launching; singleton:=true -Bundle-Version: 3.22.100.qualifier +Bundle-Version: 3.23.0.qualifier Bundle-Activator: org.eclipse.jdt.internal.launching.LaunchingPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -15,7 +15,7 @@ Export-Package: org.eclipse.jdt.internal.launching;x-friends:="org.eclipse.jdt.d org.eclipse.jdt.launching.sourcelookup.advanced, org.eclipse.jdt.launching.sourcelookup.containers Require-Bundle: org.eclipse.core.resources;bundle-version="[3.14.0,4.0.0)", - org.eclipse.jdt.core;bundle-version="[3.34.0,4.0.0)", + org.eclipse.jdt.core;bundle-version="[3.39.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.17.0,4.0.0)", org.eclipse.jdt.debug;bundle-version="[3.21.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)", diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java index 2b037774f1..86be1b0542 100644 --- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java +++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java @@ -17,9 +17,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -89,6 +92,8 @@ public class EnvironmentsManager implements IExecutionEnvironmentsManager, IVMIn */ private TreeSet fEnvironments = null; + private List supportedEnvironments; + /** * List of access rule participants */ @@ -154,15 +159,18 @@ private EnvironmentsManager() { InstanceScope.INSTANCE.getNode(LaunchingPlugin.ID_PLUGIN).addPreferenceChangeListener(this); } - /* (non-Javadoc) - * @see org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager#getExecutionEnvironments() - */ @Override public synchronized IExecutionEnvironment[] getExecutionEnvironments() { initializeExtensions(); return fEnvironments.toArray(new IExecutionEnvironment[fEnvironments.size()]); } + @Override + public synchronized List getSupportedExecutionEnvironments() { + initializeExtensions(); + return supportedEnvironments; + } + /** * Returns all access rule participants that are not specific to an execution environment. * @@ -249,63 +257,74 @@ private String getExecutionEnvironmentCompliance(IExecutionEnvironment execution } private synchronized void initializeExtensions() { - if (fEnvironments == null) { - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchingPlugin.ID_PLUGIN, JavaRuntime.EXTENSION_POINT_EXECUTION_ENVIRONMENTS); - IConfigurationElement[] configs= extensionPoint.getConfigurationElements(); - fEnvironments = new TreeSet<>(new Comparator() { - @Override - public int compare(IExecutionEnvironment o1, IExecutionEnvironment o2) { - String compliance1 = getExecutionEnvironmentCompliance(o1); - String compliance2 = getExecutionEnvironmentCompliance(o2); - int result = JavaCore.compareJavaVersions(compliance1, compliance2); - if (result == 0) { - return o1.getId().compareTo(o2.getId()); - } - return result; - } - }); - fRuleParticipants = new LinkedHashSet<>(); - fEnvironmentsMap = new HashMap<>(configs.length); - fAnalyzers = new HashMap<>(configs.length); - for (int i = 0; i < configs.length; i++) { - IConfigurationElement element = configs[i]; - String name = element.getName(); - switch (name) { - case ENVIRONMENT_ELEMENT: - String id = element.getAttribute("id"); //$NON-NLS-1$ - if (id == null) { - LaunchingPlugin.log(NLS.bind("Execution environment must specify \"id\" attribute. Contributed by {0}.", new String[] { //$NON-NLS-1$ - element.getContributor().getName() })); - } else { - IExecutionEnvironment env = new ExecutionEnvironment(element); - fEnvironments.add(env); - fEnvironmentsMap.put(id, env); - } - break; - case ANALYZER_ELEMENT: - id = element.getAttribute("id"); //$NON-NLS-1$ - if (id == null) { - LaunchingPlugin.log(NLS.bind("Execution environment analyzer must specify \"id\" attribute. Contributed by {0}", new String[] { //$NON-NLS-1$ - element.getContributor().getName() })); - } else { - fAnalyzers.put(id, new Analyzer(element)); - } - break; - case RULE_PARTICIPANT_ELEMENT: - id = element.getAttribute("id"); //$NON-NLS-1$ - if (id == null) { - LaunchingPlugin.log(NLS.bind("Execution environment rule participant must specify \"id\" attribute. Contributed by {0}", new String[] { //$NON-NLS-1$ - element.getContributor().getName() })); - } else { - // use a linked hash set to avoid duplicate rule participants - fRuleParticipants.add(new AccessRuleParticipant(element)); - } - break; - default: - break; + if (fEnvironments != null) { + return; + } + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchingPlugin.ID_PLUGIN, JavaRuntime.EXTENSION_POINT_EXECUTION_ENVIRONMENTS); + IConfigurationElement[] configs = extensionPoint.getConfigurationElements(); + fEnvironments = new TreeSet<>(new Comparator() { + @Override + public int compare(IExecutionEnvironment o1, IExecutionEnvironment o2) { + String compliance1 = getExecutionEnvironmentCompliance(o1); + String compliance2 = getExecutionEnvironmentCompliance(o2); + int result = JavaCore.compareJavaVersions(compliance1, compliance2); + if (result == 0) { + return o1.getId().compareTo(o2.getId()); } + return result; + } + }); + fRuleParticipants = new LinkedHashSet<>(); + fEnvironmentsMap = new HashMap<>(configs.length); + fAnalyzers = new HashMap<>(configs.length); + for (int i = 0; i < configs.length; i++) { + IConfigurationElement element = configs[i]; + String name = element.getName(); + switch (name) { + case ENVIRONMENT_ELEMENT: + String id = element.getAttribute("id"); //$NON-NLS-1$ + if (id == null) { + LaunchingPlugin.log(NLS.bind("Execution environment must specify \"id\" attribute. Contributed by {0}.", new String[] { //$NON-NLS-1$ + element.getContributor().getName() })); + } else { + IExecutionEnvironment env = new ExecutionEnvironment(element); + fEnvironments.add(env); + fEnvironmentsMap.put(id, env); + } + break; + case ANALYZER_ELEMENT: + id = element.getAttribute("id"); //$NON-NLS-1$ + if (id == null) { + LaunchingPlugin.log(NLS.bind("Execution environment analyzer must specify \"id\" attribute. Contributed by {0}", new String[] { //$NON-NLS-1$ + element.getContributor().getName() })); + } else { + fAnalyzers.put(id, new Analyzer(element)); + } + break; + case RULE_PARTICIPANT_ELEMENT: + id = element.getAttribute("id"); //$NON-NLS-1$ + if (id == null) { + LaunchingPlugin.log(NLS.bind("Execution environment rule participant must specify \"id\" attribute. Contributed by {0}", new String[] { //$NON-NLS-1$ + element.getContributor().getName() })); + } else { + // use a linked hash set to avoid duplicate rule participants + fRuleParticipants.add(new AccessRuleParticipant(element)); + } + break; + default: + break; + } + } + + List filtered = new LinkedList<>(); + for (IExecutionEnvironment environment : fEnvironments) { + Map options = environment.getComplianceOptions(); + if (options != null && JavaCore.isSupportedJavaProjectVersion(options.get(JavaCore.COMPILER_COMPLIANCE))) { + filtered.add(environment); } } + Collections.reverse(filtered); + supportedEnvironments = Collections.unmodifiableList(filtered); } /** diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/environments/IExecutionEnvironmentsManager.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/environments/IExecutionEnvironmentsManager.java index 402f96f80e..65a27ecb85 100644 --- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/environments/IExecutionEnvironmentsManager.java +++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/environments/IExecutionEnvironmentsManager.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.jdt.launching.environments; +import java.util.List; + +import org.eclipse.jdt.core.JavaCore; /** * Manager for execution environments. The singleton manager is available @@ -32,6 +35,17 @@ public interface IExecutionEnvironmentsManager { */ public IExecutionEnvironment[] getExecutionEnvironments(); + /** + * Returns all execution environments supported by Java projects, reverse sorted by their id. + * + * @see IExecutionEnvironment#getId() + * @see JavaCore#isSupportedJavaProjectVersion(String) + * + * @return all registered execution environments sorted by their id + * @since 3.23 + */ + public List getSupportedExecutionEnvironments(); + /** * Returns the execution environment associated with the given * identifier or null if none. diff --git a/org.eclipse.jdt.launching/pom.xml b/org.eclipse.jdt.launching/pom.xml index 34b6e9b3a1..cb27f9031f 100644 --- a/org.eclipse.jdt.launching/pom.xml +++ b/org.eclipse.jdt.launching/pom.xml @@ -18,7 +18,7 @@ org.eclipse.jdt org.eclipse.jdt.launching - 3.22.100-SNAPSHOT + 3.23.0-SNAPSHOT eclipse-plugin