From d7a5b66ad8a4137b74f551d05a498c5743b08f76 Mon Sep 17 00:00:00 2001 From: Noopur Gupta Date: Wed, 19 Jun 2024 15:00:58 +0530 Subject: [PATCH] Drop support for older Java versions https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1465 --- .../ComplianceConfigurationBlock.java | 72 +++---------------- .../ui/preferences/PreferencesMessages.java | 8 --- .../PreferencesMessages.properties | 8 --- 3 files changed, 11 insertions(+), 77 deletions(-) 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..b29d6dd6e36 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 @@ -133,15 +133,6 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { 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; @@ -313,14 +304,8 @@ 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[] complianceVersions= new String[] { 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, @@ -338,17 +323,8 @@ private Composite createComplianceTabContent(Composite folder) { PreferencesMessages.ComplianceConfigurationBlock_version_22 }; - 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[] targetVersions= new String[] { 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, @@ -371,14 +347,8 @@ private Composite createComplianceTabContent(Composite folder) { 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[] sourceVersions= new String[] {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, @@ -542,7 +512,7 @@ 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) })); + fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, new String[] { getVersionLabel(VERSION_1_8), getVersionLabel(VERSION_1_8) })); fJRE50InfoText.setVisible(false); fJRE50InfoText.addSelectionListener(new SelectionListener() { @Override @@ -668,16 +638,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(); @@ -1000,15 +960,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 +1072,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); + boolean isLessThan14= false; updateRememberedComplianceOption(PREF_PB_ASSERT_AS_IDENTIFIER, IDX_ASSERT_AS_IDENTIFIER, isLessThan14, ERROR); - boolean isLessThan15= isLessThan14 || VERSION_1_4.equals(compatibility); + boolean isLessThan15= false; updateRememberedComplianceOption(PREF_PB_ENUM_AS_IDENTIFIER, IDX_ENUM_AS_IDENTIFIER, isLessThan15, ERROR); } } @@ -1178,9 +1129,8 @@ 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); + boolean isTargetLessThan15= false; + boolean enabled= isTargetLessThan15; Button checkBox= getCheckBox(PREF_CODEGEN_INLINE_JSR_BYTECODE); boolean wasCheckBoxEnabled= checkBox.isEnabled(); checkBox.setEnabled(enabled); @@ -1309,8 +1259,8 @@ private void updateComplianceDefaultSettings(boolean rememberOld, String oldComp reportPreview= WARNING; assertAsId= IGNORE; enumAsId= IGNORE; - source= VERSION_1_3; - target= VERSION_1_1; + source= VERSION_1_8; + target= VERSION_1_8; } } } 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..e7af0785850 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; @@ -848,8 +843,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; @@ -865,7 +858,6 @@ private PreferencesMessages() { 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..b93c4995917 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,13 +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 @@ -618,7 +611,6 @@ 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?