From 5cc92505d7b88fa3cd60e5a25806791f8864d217 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 19 Jun 2024 11:45:41 +0200 Subject: [PATCH] Drop support for older Java versions - Don't propose compilation targets below 1.8 JLS - don't show old EE's in wizards Requires https://github.com/eclipse-jdt/eclipse.jdt.debug/pull/452 Requires https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2606 See https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1465 --- .../internal/corext/util/JavaModelUtil.java | 32 +-- .../JavadocSpecificsWizardPage.java | 4 +- .../ComplianceConfigurationBlock.java | 207 +++--------------- .../ui/preferences/PreferencesMessages.java | 24 -- .../PreferencesMessages.properties | 25 --- .../wizards/NewJavaProjectWizardPageOne.java | 7 +- 6 files changed, 47 insertions(+), 252 deletions(-) diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java index 7f4619e7bf9..6548b85ab08 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java @@ -1143,28 +1143,20 @@ public static String getCompilerCompliance(IVMInstall2 vMInstall, String default return JavaCore.VERSION_9; } else if (version.startsWith(JavaCore.VERSION_1_8)) { return JavaCore.VERSION_1_8; - } else if (version.startsWith(JavaCore.VERSION_1_7)) { - return JavaCore.VERSION_1_7; - } else if (version.startsWith(JavaCore.VERSION_1_6)) { - return JavaCore.VERSION_1_6; - } else if (version.startsWith(JavaCore.VERSION_1_5)) { - return JavaCore.VERSION_1_5; - } else if (version.startsWith(JavaCore.VERSION_1_4)) { - return JavaCore.VERSION_1_4; - } else if (version.startsWith(JavaCore.VERSION_1_3) - || version.startsWith(JavaCore.VERSION_1_2) - || version.startsWith(JavaCore.VERSION_1_1)) { - return JavaCore.VERSION_1_3; } - return JavaCore.isSupportedJavaVersion(version) ? defaultCompliance : JavaModelUtil.VERSION_LATEST; + return JavaCore.isSupportedJavaProjectVersion(version) ? defaultCompliance : JavaModelUtil.VERSION_LATEST; } public static String getExecutionEnvironmentCompliance(IExecutionEnvironment executionEnvironment) { Map complianceOptions= executionEnvironment.getComplianceOptions(); if (complianceOptions != null) { String compliance= complianceOptions.get(JavaCore.COMPILER_COMPLIANCE); - if (compliance != null) - return compliance; + if (compliance != null) { + if(JavaCore.isSupportedJavaProjectVersion(compliance)) { + return compliance; + } + return JavaCore.getFirstSupportedJavaVersion(); + } } // fallback: @@ -1199,16 +1191,8 @@ public static String getExecutionEnvironmentCompliance(IExecutionEnvironment exe return JavaCore.VERSION_9; } else if (desc.indexOf(JavaCore.VERSION_1_8) != -1) { return JavaCore.VERSION_1_8; - } else if (desc.indexOf(JavaCore.VERSION_1_7) != -1) { - return JavaCore.VERSION_1_7; - } else if (desc.indexOf(JavaCore.VERSION_1_6) != -1) { - return JavaCore.VERSION_1_6; - } else if (desc.indexOf(JavaCore.VERSION_1_5) != -1) { - return JavaCore.VERSION_1_5; - } else if (desc.indexOf(JavaCore.VERSION_1_4) != -1) { - return JavaCore.VERSION_1_4; } - return JavaCore.VERSION_1_3; + return JavaCore.getFirstSupportedJavaVersion(); } /** diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java index 159898e9941..4b1b8fe1ff7 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocSpecificsWizardPage.java @@ -18,7 +18,6 @@ import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.eclipse.swt.SWT; @@ -154,8 +153,7 @@ private void createExtraOptionsGroup(Composite composite) { fSourceCombo= createCombo(inner, SWT.NONE, fStore.getSource(), createGridData(1)); List versions= new ArrayList<>(); versions.add("-"); //$NON-NLS-1$ - versions.addAll(JavaCore.getAllVersions()); - versions.removeAll(Arrays.asList(JavaCore.VERSION_CLDC_1_1, JavaCore.VERSION_1_1, JavaCore.VERSION_1_2)); + versions.addAll(JavaCore.getAllJavaProjectVersions()); fSourceCombo.setItems(versions.toArray(new String[versions.size()])); fSourceCombo.setText(fStore.getSource()); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java index 062a3fd81be..415f7315ed2 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java @@ -14,9 +14,21 @@ *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; +import static org.eclipse.jdt.core.JavaCore.DISABLED; +import static org.eclipse.jdt.core.JavaCore.DO_NOT_GENERATE; +import static org.eclipse.jdt.core.JavaCore.ENABLED; +import static org.eclipse.jdt.core.JavaCore.ERROR; +import static org.eclipse.jdt.core.JavaCore.GENERATE; +import static org.eclipse.jdt.core.JavaCore.IGNORE; +import static org.eclipse.jdt.core.JavaCore.INFO; +import static org.eclipse.jdt.core.JavaCore.OPTIMIZE_OUT; +import static org.eclipse.jdt.core.JavaCore.PRESERVE; +import static org.eclipse.jdt.core.JavaCore.WARNING; + import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.List; @@ -80,7 +92,6 @@ import org.eclipse.jdt.internal.ui.wizards.buildpaths.LibrariesWorkbookPage; import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; - /** * Configuration block for the 'Java Compiler' page. */ @@ -126,47 +137,8 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { private static final Key PREF_CODEGEN_UNUSED_LOCAL= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL); private static final Key PREF_CODEGEN_METHOD_PARAMETERS_ATTR= getJDTCoreKey(JavaCore.COMPILER_CODEGEN_METHOD_PARAMETERS_ATTR); - // values - private static final String GENERATE= JavaCore.GENERATE; - private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE; - - private static final String PRESERVE= JavaCore.PRESERVE; - private static final String OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT; - - private static final String VERSION_CLDC_1_1= JavaCore.VERSION_CLDC_1_1; - private static final String VERSION_1_1= JavaCore.VERSION_1_1; - private static final String VERSION_1_2= JavaCore.VERSION_1_2; - private static final String VERSION_1_3= JavaCore.VERSION_1_3; - - private static final String VERSION_1_4= JavaCore.VERSION_1_4; - private static final String VERSION_1_5= JavaCore.VERSION_1_5; - private static final String VERSION_1_6= JavaCore.VERSION_1_6; - private static final String VERSION_1_7= JavaCore.VERSION_1_7; - private static final String VERSION_1_8= JavaCore.VERSION_1_8; - private static final String VERSION_9= JavaCore.VERSION_9; - private static final String VERSION_10= JavaCore.VERSION_10; - private static final String VERSION_11= JavaCore.VERSION_11; - private static final String VERSION_12 = JavaCore.VERSION_12; - private static final String VERSION_13 = JavaCore.VERSION_13; - private static final String VERSION_14 = JavaCore.VERSION_14; - private static final String VERSION_15 = JavaCore.VERSION_15; - private static final String VERSION_16 = JavaCore.VERSION_16; - private static final String VERSION_17 = JavaCore.VERSION_17; - private static final String VERSION_18 = JavaCore.VERSION_18; - private static final String VERSION_19 = JavaCore.VERSION_19; - private static final String VERSION_20 = JavaCore.VERSION_20; - private static final String VERSION_21 = JavaCore.VERSION_21; - private static final String VERSION_22 = JavaCore.VERSION_22; - private static final String VERSION_LATEST = JavaCore.latestSupportedJavaVersion(); - private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$ - - private static final String ERROR= JavaCore.ERROR; - private static final String WARNING= JavaCore.WARNING; - private static final String INFO= JavaCore.INFO; - private static final String IGNORE= JavaCore.IGNORE; - private static final String ENABLED= JavaCore.ENABLED; - private static final String DISABLED= JavaCore.DISABLED; + private static final String VERSION_LATEST = JavaCore.latestSupportedJavaVersion(); private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$ private static final String USER_CONF= "user"; //$NON-NLS-1$ @@ -313,88 +285,16 @@ public void enablePreferenceContent(boolean enable) { private Composite createComplianceTabContent(Composite folder) { - final String[] complianceVersions= new String[] { VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_21, VERSION_22 }; - final String[] complianceLabels= new String[] { - PreferencesMessages.ComplianceConfigurationBlock_version13, - PreferencesMessages.ComplianceConfigurationBlock_version14, - PreferencesMessages.ComplianceConfigurationBlock_version15, - PreferencesMessages.ComplianceConfigurationBlock_version16, - PreferencesMessages.ComplianceConfigurationBlock_version17, - PreferencesMessages.ComplianceConfigurationBlock_version18, - PreferencesMessages.ComplianceConfigurationBlock_version9, - PreferencesMessages.ComplianceConfigurationBlock_version10, - PreferencesMessages.ComplianceConfigurationBlock_version_11, - PreferencesMessages.ComplianceConfigurationBlock_version_12, - PreferencesMessages.ComplianceConfigurationBlock_version_13, - PreferencesMessages.ComplianceConfigurationBlock_version_14, - PreferencesMessages.ComplianceConfigurationBlock_version_15, - PreferencesMessages.ComplianceConfigurationBlock_version_16, - PreferencesMessages.ComplianceConfigurationBlock_version_17, - PreferencesMessages.ComplianceConfigurationBlock_version_18, - PreferencesMessages.ComplianceConfigurationBlock_version_19, - PreferencesMessages.ComplianceConfigurationBlock_version_20, - PreferencesMessages.ComplianceConfigurationBlock_version_21, - PreferencesMessages.ComplianceConfigurationBlock_version_22 - }; + ArrayList allJavaProjectVersions = new ArrayList<>(JavaCore.getAllJavaProjectVersions()); + Collections.reverse(allJavaProjectVersions); + final String[] complianceVersions= allJavaProjectVersions.toArray(String[]::new); + final String[] complianceLabels= complianceVersions; - String[] targetVersions= new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_21, VERSION_22 }; - String[] targetLabels= new String[] { - PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11, - PreferencesMessages.ComplianceConfigurationBlock_version11, - PreferencesMessages.ComplianceConfigurationBlock_version12, - PreferencesMessages.ComplianceConfigurationBlock_version13, - PreferencesMessages.ComplianceConfigurationBlock_version14, - PreferencesMessages.ComplianceConfigurationBlock_version15, - PreferencesMessages.ComplianceConfigurationBlock_version16, - PreferencesMessages.ComplianceConfigurationBlock_version17, - PreferencesMessages.ComplianceConfigurationBlock_version18, - PreferencesMessages.ComplianceConfigurationBlock_version9, - PreferencesMessages.ComplianceConfigurationBlock_version10, - PreferencesMessages.ComplianceConfigurationBlock_version_11, - PreferencesMessages.ComplianceConfigurationBlock_version_12, - PreferencesMessages.ComplianceConfigurationBlock_version_13, - PreferencesMessages.ComplianceConfigurationBlock_version_14, - PreferencesMessages.ComplianceConfigurationBlock_version_15, - PreferencesMessages.ComplianceConfigurationBlock_version_16, - PreferencesMessages.ComplianceConfigurationBlock_version_17, - PreferencesMessages.ComplianceConfigurationBlock_version_18, - PreferencesMessages.ComplianceConfigurationBlock_version_19, - PreferencesMessages.ComplianceConfigurationBlock_version_20, - PreferencesMessages.ComplianceConfigurationBlock_version_21, - PreferencesMessages.ComplianceConfigurationBlock_version_22 + final String[] targetVersions= complianceVersions; + final String[] targetLabels= targetVersions; - }; - if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) { - targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14); - targetLabels= append(targetLabels, ComplianceConfigurationBlock.VERSION_JSR14); - } - - String[] sourceVersions= new String[] { VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17, VERSION_18, VERSION_19, VERSION_20, VERSION_21, VERSION_22 }; - String[] sourceLabels= new String[] { - PreferencesMessages.ComplianceConfigurationBlock_version13, - PreferencesMessages.ComplianceConfigurationBlock_version14, - PreferencesMessages.ComplianceConfigurationBlock_version15, - PreferencesMessages.ComplianceConfigurationBlock_version16, - PreferencesMessages.ComplianceConfigurationBlock_version17, - PreferencesMessages.ComplianceConfigurationBlock_version18, - PreferencesMessages.ComplianceConfigurationBlock_version9, - PreferencesMessages.ComplianceConfigurationBlock_version10, - PreferencesMessages.ComplianceConfigurationBlock_version_11, - PreferencesMessages.ComplianceConfigurationBlock_version_12, - PreferencesMessages.ComplianceConfigurationBlock_version_13, - PreferencesMessages.ComplianceConfigurationBlock_version_14, - PreferencesMessages.ComplianceConfigurationBlock_version_15, - PreferencesMessages.ComplianceConfigurationBlock_version_16, - PreferencesMessages.ComplianceConfigurationBlock_version_17, - PreferencesMessages.ComplianceConfigurationBlock_version_18, - PreferencesMessages.ComplianceConfigurationBlock_version_19, - PreferencesMessages.ComplianceConfigurationBlock_version_20, - PreferencesMessages.ComplianceConfigurationBlock_version_21, - PreferencesMessages.ComplianceConfigurationBlock_version_22 - }; + final String[] sourceVersions= complianceVersions; + final String[] sourceLabels= sourceVersions; final ScrolledPageContent sc1 = new ScrolledPageContent(folder); Composite composite= sc1.getBody(); @@ -542,7 +442,8 @@ public void widgetSelected(SelectionEvent e) { fJRE50InfoText= new Link(infoComposite, SWT.WRAP); fJRE50InfoText.setFont(composite.getFont()); // set a text: not the real one, just for layouting - fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, new String[] { getVersionLabel(VERSION_1_3), getVersionLabel(VERSION_1_3) })); + String versionLabel= getVersionLabel(JavaCore.getFirstSupportedJavaVersion()); + fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, new String[] { versionLabel, versionLabel })); fJRE50InfoText.setVisible(false); fJRE50InfoText.addSelectionListener(new SelectionListener() { @Override @@ -591,13 +492,6 @@ private void initializeReleaseCheckBox(boolean useProjectSpecificSettings) { } } - private static String[] append(String[] versions, String version) { - String[] result= new String[versions.length + 1]; - System.arraycopy(versions, 0, result, 0, versions.length); - result[versions.length]= version; - return result; - } - protected final void openBuildPathPropertyPage() { if (getPreferenceContainer() != null) { Map data= new HashMap<>(); @@ -668,16 +562,6 @@ protected void validateSettings(Key changedKey, String oldValue, String newValue updateAssertEnumAsIdentifierEnableState(); fComplianceStatus= validateCompliance(); } else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey)) { - if (VERSION_CLDC_1_1.equals(newValue) && !oldValue.equals(newValue)) { - String compliance= getValue(PREF_COMPLIANCE); - String source= getValue(PREF_SOURCE_COMPATIBILITY); - if (!JavaModelUtil.isVersionLessThan(compliance, VERSION_1_5)) { - setValue(PREF_COMPLIANCE, VERSION_1_4); - } - if (!VERSION_1_3.equals(source)) { - setValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_3); - } - } updateControls(); updateInlineJSREnableState(); updateStoreMethodParamNamesEnableState(); @@ -853,14 +737,6 @@ private void validateComplianceStatus() { } } - //TODO: Comment once Java SE 22 has been shipped: -// String selectedCompliance= getValue(PREF_COMPLIANCE); -// if (VERSION_22.equals(selectedCompliance)) { -// fJRE50InfoText.setText( -// "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."); //$NON-NLS-1$ -// isVisible= true; -// } - fJRE50InfoText.setVisible(isVisible); fJRE50InfoImage.setImage(isVisible ? image : null); fJRE50InfoImage.getParent().layout(); @@ -946,7 +822,7 @@ private void updateReleaseOptionStatus() { private boolean isJREVersionUnsupportedAndGreater(String version, String compilerCompliance) { boolean isJREUnsupportedAndGreater= false; String versionStr= version; - if (!JavaCore.isSupportedJavaVersion(versionStr)) { + if (!JavaCore.isSupportedJavaProjectVersion(versionStr)) { try { versionStr= getJREVersionString(versionStr); int jreVersion= Integer.parseInt(versionStr); @@ -985,10 +861,6 @@ private IStatus validateCompliance() { String source= getValue(PREF_SOURCE_COMPATIBILITY); String target= getValue(PREF_CODEGEN_TARGET_PLATFORM); - if (ComplianceConfigurationBlock.VERSION_JSR14.equals(target)) { - target= source; - } - // compliance must not be smaller than source or target if (JavaModelUtil.isVersionLessThan(compliance, source)) { status.setError(PreferencesMessages.ComplianceConfigurationBlock_src_greater_compliance); @@ -1000,15 +872,8 @@ private IStatus validateCompliance() { return status; } - if (VERSION_CLDC_1_1.equals(target)) { - if (!VERSION_1_3.equals(source) || !JavaModelUtil.isVersionLessThan(compliance, VERSION_1_5)) { - status.setError(PreferencesMessages.ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14); - return status; - } - } - // target must not be smaller than source - if (!VERSION_1_3.equals(source) && JavaModelUtil.isVersionLessThan(target, source)) { + if (JavaModelUtil.isVersionLessThan(target, source)) { status.setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_source); return status; } @@ -1119,12 +984,10 @@ private void updatePreviewControls() { private void updateAssertEnumAsIdentifierEnableState() { if (checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF)) { - String compatibility= getValue(PREF_SOURCE_COMPATIBILITY); - - boolean isLessThan14= VERSION_1_3.equals(compatibility); + final boolean isLessThan14= false; updateRememberedComplianceOption(PREF_PB_ASSERT_AS_IDENTIFIER, IDX_ASSERT_AS_IDENTIFIER, isLessThan14, ERROR); - boolean isLessThan15= isLessThan14 || VERSION_1_4.equals(compatibility); + final boolean isLessThan15= false; updateRememberedComplianceOption(PREF_PB_ENUM_AS_IDENTIFIER, IDX_ENUM_AS_IDENTIFIER, isLessThan15, ERROR); } } @@ -1178,14 +1041,12 @@ private void updateRememberedComplianceOption(Key prefKey, int idx, boolean enab } private void updateInlineJSREnableState() { - String target= getValue(PREF_CODEGEN_TARGET_PLATFORM); - - boolean enabled= JavaModelUtil.isVersionLessThan(target, VERSION_1_5); + final boolean lessThan15= false; Button checkBox= getCheckBox(PREF_CODEGEN_INLINE_JSR_BYTECODE); boolean wasCheckBoxEnabled= checkBox.isEnabled(); - checkBox.setEnabled(enabled); + checkBox.setEnabled(lessThan15); - if (!enabled) { + if (!lessThan15) { String val= getValue(PREF_CODEGEN_INLINE_JSR_BYTECODE); if (wasCheckBoxEnabled) fRememberedUserCompliance[IDX_INLINE_JSR_BYTECODE]= val; @@ -1307,10 +1168,10 @@ private void updateComplianceDefaultSettings(boolean rememberOld, String oldComp } else { enablePreview= DISABLED; reportPreview= WARNING; - assertAsId= IGNORE; - enumAsId= IGNORE; - source= VERSION_1_3; - target= VERSION_1_1; + assertAsId= ERROR; + enumAsId= ERROR; + source= JavaCore.getFirstSupportedJavaVersion(); + target= JavaCore.getFirstSupportedJavaVersion(); } } } else { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java index 4e9f8a1d863..0f6ebf27b78 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java @@ -536,11 +536,6 @@ private PreferencesMessages() { public static String ComplianceConfigurationBlock_warning; public static String ComplianceConfigurationBlock_info; public static String ComplianceConfigurationBlock_ignore; - public static String ComplianceConfigurationBlock_version11; - public static String ComplianceConfigurationBlock_version12; - public static String ComplianceConfigurationBlock_version13; - public static String ComplianceConfigurationBlock_version14; - public static String ComplianceConfigurationBlock_version15; public static String ComplianceConfigurationBlock_needsbuild_title; public static String ComplianceConfigurationBlock_needsfullbuild_message; public static String ComplianceConfigurationBlock_needsprojectbuild_message; @@ -548,7 +543,6 @@ private PreferencesMessages() { public static String ComplianceConfigurationBlock_line_number_attr_label; public static String ComplianceConfigurationBlock_source_file_attr_label; public static String ComplianceConfigurationBlock_codegen_unused_local_label; - public static String ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14; public static String ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label; public static String ComplianceConfigurationBlock_codegen_method_parameters_attr; public static String ComplianceConfigurationBlock_compiler_compliance_label; @@ -848,24 +842,6 @@ private PreferencesMessages() { public static String JavaBasePreferencePage_do_not_hide_dialog_message; public static String CodeAssistConfigurationBlock_matchCamelCase_label; public static String CodeAssistConfigurationBlock_matchSubword_label; - public static String ComplianceConfigurationBlock_version16; - public static String ComplianceConfigurationBlock_version17; - public static String ComplianceConfigurationBlock_version18; - public static String ComplianceConfigurationBlock_version9; - public static String ComplianceConfigurationBlock_version10; - public static String ComplianceConfigurationBlock_version_11; - public static String ComplianceConfigurationBlock_version_12; - public static String ComplianceConfigurationBlock_version_13; - public static String ComplianceConfigurationBlock_version_14; - public static String ComplianceConfigurationBlock_version_15; - public static String ComplianceConfigurationBlock_version_16; - public static String ComplianceConfigurationBlock_version_17; - public static String ComplianceConfigurationBlock_version_18; - public static String ComplianceConfigurationBlock_version_19; - public static String ComplianceConfigurationBlock_version_20; - public static String ComplianceConfigurationBlock_version_21; - public static String ComplianceConfigurationBlock_version_22; - public static String ComplianceConfigurationBlock_versionCLDC11; public static String ComplianceConfigurationBlock_src_greater_compliance; public static String ComplianceConfigurationBlock_classfile_greater_compliance; public static String ComplianceConfigurationBlock_classfile_greater_source; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties index 89b533e38ab..6ecb2d448f6 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties @@ -596,30 +596,6 @@ ComplianceConfigurationBlock_warning=Warning ComplianceConfigurationBlock_info=Info ComplianceConfigurationBlock_ignore=Ignore -ComplianceConfigurationBlock_version11=1.1 -ComplianceConfigurationBlock_version12=1.2 -ComplianceConfigurationBlock_version13=1.3 -ComplianceConfigurationBlock_version14=1.4 -ComplianceConfigurationBlock_version15=1.5 -ComplianceConfigurationBlock_version16=1.6 -ComplianceConfigurationBlock_version17=1.7 -ComplianceConfigurationBlock_version18=1.8 -ComplianceConfigurationBlock_version9=9 -ComplianceConfigurationBlock_version10=10 -ComplianceConfigurationBlock_version_11=11 -ComplianceConfigurationBlock_version_12=12 -ComplianceConfigurationBlock_version_13=13 -ComplianceConfigurationBlock_version_14=14 -ComplianceConfigurationBlock_version_15=15 -ComplianceConfigurationBlock_version_16=16 -ComplianceConfigurationBlock_version_17=17 -ComplianceConfigurationBlock_version_18=18 -ComplianceConfigurationBlock_version_19=19 -ComplianceConfigurationBlock_version_20=20 -ComplianceConfigurationBlock_version_21=21 -ComplianceConfigurationBlock_version_22=22 -ComplianceConfigurationBlock_versionCLDC11=CLDC 1.1 - ComplianceConfigurationBlock_needsbuild_title=Compiler Settings Changed ComplianceConfigurationBlock_needsfullbuild_message=The compiler settings have changed. Rebuild to apply these changes? ComplianceConfigurationBlock_needsprojectbuild_message=The compiler settings have changed. Rebuild the project to apply the changes? @@ -647,7 +623,6 @@ ComplianceConfigurationBlock_classfile_greater_compliance=Classfile compatibilit ComplianceConfigurationBlock_classfile_greater_source=Classfile compatibility must be equal or greater than source compatibility. ComplianceConfigurationBlock_jrecompliance_info=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). Configure... -ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14=CLDC 1.1 requires source level 1.3 and compliance 1.4 or less ComplianceConfigurationBlock_jrecompliance_info_project=When selecting {0} compliance, make sure to have a compatible JRE installed and activated (currently {1}). Configure the ''Installed JREs'' and ''Execution Environments'', or change the JRE on the ''Java Build Path''. ComplianceConfigurationBlock_jrecompliance_backwardcompatibility_info=The system libraries from the selected release {0} will be used with ''--release'' compiler option using current JRE {1}. ComplianceConfigurationBlock_jrecompliance_backwardcompatibility_warning=The system libraries from the selected release {0} will be used with ''--release'' compiler option using current JRE {1}. When using --release, it is recommended to use a JRE version 12 or greater. diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java index 32687af0236..72be0e6deda 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java @@ -474,8 +474,8 @@ private void initializeJvmFields () { fInstalledJVMs= getWorkspaceJREs(); Arrays.sort(fInstalledJVMs, (i0, i1) -> { if (i1 instanceof IVMInstall2 && i0 instanceof IVMInstall2) { - String cc0= JavaModelUtil.getCompilerCompliance((IVMInstall2) i0, JavaCore.VERSION_1_4); - String cc1= JavaModelUtil.getCompilerCompliance((IVMInstall2) i1, JavaCore.VERSION_1_4); + String cc0= JavaModelUtil.getCompilerCompliance((IVMInstall2) i0, JavaCore.getFirstSupportedJavaVersion()); + String cc1= JavaModelUtil.getCompilerCompliance((IVMInstall2) i1, JavaCore.getFirstSupportedJavaVersion()); int result= JavaCore.compareJavaVersions(cc1, cc0); if (result != 0) return result; @@ -483,7 +483,8 @@ private void initializeJvmFields () { return Policy.getComparator().compare(i0.getName(), i1.getName()); }); - fInstalledEEs= JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments(); + List environments= JavaRuntime.getExecutionEnvironmentsManager().getSupportedExecutionEnvironments(); + fInstalledEEs= environments.toArray(IExecutionEnvironment[]::new); } public Control createControl(Composite composite) {