Bug 470613: [1.9] support 1.9 as compiler compliance level and add JCP disclaimer
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
index c3544a0..1b2b17c 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Matt Chapman, mpchapman@gmail.com - 89977 Make JDT .java agnostic
@@ -71,7 +75,7 @@
*/
public static final String VERSION_LATEST;
static {
- VERSION_LATEST= JavaCore.VERSION_1_8; // make sure it is not inlined
+ VERSION_LATEST= JavaCore.VERSION_1_9; // make sure it is not inlined
}
/**
@@ -771,6 +775,10 @@
return !isVersionLessThan(compliance, JavaCore.VERSION_1_8);
}
+ public static boolean is19OrHigher(String compliance) {
+ return !isVersionLessThan(compliance, JavaCore.VERSION_1_9);
+ }
+
/**
* Checks if the given project or workspace has source compliance 1.5 or greater.
*
@@ -835,6 +843,8 @@
String version= vMInstall.getJavaVersion();
if (version == null) {
return defaultCompliance;
+ } else if (version.startsWith(JavaCore.VERSION_1_9)) {
+ return JavaCore.VERSION_1_9;
} else if (version.startsWith(JavaCore.VERSION_1_8)) {
return JavaCore.VERSION_1_8;
} else if (version.startsWith(JavaCore.VERSION_1_7)) {
@@ -865,7 +875,9 @@
// fallback:
String desc= executionEnvironment.getId();
- if (desc.indexOf(JavaCore.VERSION_1_8) != -1) {
+ if (desc.indexOf(JavaCore.VERSION_1_9) != -1) {
+ return JavaCore.VERSION_1_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;
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 897b454..8085d15 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
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -121,6 +125,7 @@
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_1_9= JavaCore.VERSION_1_9;
private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$
private static final String ERROR= JavaCore.ERROR;
@@ -261,15 +266,56 @@
private Composite createComplianceTabContent(Composite folder) {
- String[] values3456= new String[] { VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8 };
- String[] values3456Labels= new String[] {
+ final String[] complianceVersions= new String[] { VERSION_1_3, VERSION_1_4,
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9 };
+ 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_version19,
};
+
+ 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 };
+ 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,
+ };
+ if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) {
+ targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14);
+ targetLabels= append(targetLabels, ComplianceConfigurationBlock.VERSION_JSR14);
+ }
+ if (ComplianceConfigurationBlock.VERSION_1_9.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) {
+ //TODO(BETA_JAVA9) at the moment, runtime doesn't support a new class file version
+ targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_1_9);
+ targetLabels= append(targetLabels, PreferencesMessages.ComplianceConfigurationBlock_version19);
+ }
+
+ String[] sourceVersions= new String[] { VERSION_1_3, VERSION_1_4,
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_1_9 };
+ String[] sourceLabels= new String[] {
+ PreferencesMessages.ComplianceConfigurationBlock_version13,
+ PreferencesMessages.ComplianceConfigurationBlock_version14,
+ PreferencesMessages.ComplianceConfigurationBlock_version15,
+ PreferencesMessages.ComplianceConfigurationBlock_version16,
+ PreferencesMessages.ComplianceConfigurationBlock_version17,
+ PreferencesMessages.ComplianceConfigurationBlock_version18,
+ };
+ if (ComplianceConfigurationBlock.VERSION_1_9.equals(getValue(PREF_SOURCE_COMPATIBILITY))) {
+ //TODO(BETA_JAVA9) at the moment, there's no new Java language feature
+ sourceVersions= append(sourceVersions, ComplianceConfigurationBlock.VERSION_1_9);
+ sourceLabels= append(sourceLabels, PreferencesMessages.ComplianceConfigurationBlock_version19);
+ }
final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
Composite composite= sc1.getBody();
@@ -320,7 +366,7 @@
String label= PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
- addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);
+ addComboBox(group, label, PREF_COMPLIANCE, complianceVersions, complianceLabels, 0);
label= PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0);
@@ -333,30 +379,11 @@
int indent= LayoutUtil.getIndent();
- String[] versions= 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 };
- String[] versionsLabels= 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
- };
-
- boolean showJsr14= ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM));
- if (showJsr14) {
- versions= append(versions, ComplianceConfigurationBlock.VERSION_JSR14);
- versionsLabels= append(versionsLabels, ComplianceConfigurationBlock.VERSION_JSR14);
- }
-
label= PreferencesMessages.ComplianceConfigurationBlock_codegen_targetplatform_label;
- addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent);
+ addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, targetVersions, targetLabels, indent);
label= PreferencesMessages.ComplianceConfigurationBlock_source_compatibility_label;
- addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent);
+ addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, sourceVersions, sourceLabels, indent);
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
@@ -609,11 +636,12 @@
}
}
-// String source= getValue(PREF_SOURCE_COMPATIBILITY);
-// if (VERSION_1_8.equals(source)) {
-// 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;
-// }
+ //TODO: Remove once Java SE 9 has been shipped:
+ String selectedCompliance= getValue(PREF_COMPLIANCE);
+ if (VERSION_1_9.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 ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null);
@@ -656,6 +684,10 @@
// target must not be smaller than source
if (!VERSION_1_3.equals(source) && JavaModelUtil.isVersionLessThan(target, source)) {
+ if (VERSION_1_9.equals(source) && VERSION_1_8.equals(target)) {
+ // TODO(BETA_JAVA9): not clear yet whether there will be a 1.9 class file version. Allow mismatch for now:
+ return status;
+ }
status.setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_source);
return status;
}
@@ -851,32 +883,13 @@
}
} else {
- //TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel);
- if (VERSION_1_4.equals(complianceLevel)) {
- assertAsId= WARNING;
- enumAsId= WARNING;
- source= VERSION_1_3;
- target= VERSION_1_2;
- } else if (VERSION_1_5.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_5;
- target= VERSION_1_5;
- } else if (VERSION_1_6.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_6;
- target= VERSION_1_6;
- } else if (VERSION_1_7.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_7;
- target= VERSION_1_7;
- } else if (VERSION_1_8.equals(complianceLevel)) {
- assertAsId= ERROR;
- enumAsId= ERROR;
- source= VERSION_1_8;
- target= VERSION_1_8;
+ HashMap<String, String> options= new HashMap<String, String>();
+ JavaModelUtil.setComplianceOptions(options, complianceLevel);
+ if (complianceLevel.equals(options.get(JavaCore.COMPILER_COMPLIANCE))) {
+ source= options.get(JavaCore.COMPILER_SOURCE);
+ target= options.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM);
+ assertAsId= options.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
+ enumAsId= options.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER);
} else {
assertAsId= IGNORE;
enumAsId= IGNORE;
@@ -913,38 +926,16 @@
* @return {@link #DEFAULT_CONF} or {@link #USER_CONF}
*/
private String getCurrentCompliance() {
- Object complianceLevel= getValue(PREF_COMPLIANCE);
- //TODO: use JavaModelUtil.setComplianceOptions(new HashMap(), complianceLevel);
- if ((VERSION_1_3.equals(complianceLevel)
- && IGNORE.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && IGNORE.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_3.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_1.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_4.equals(complianceLevel)
- && WARNING.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && WARNING.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_3.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_2.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_5.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_5.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_5.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_6.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_6.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_6.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_7.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_7.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_7.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))
- || (VERSION_1_8.equals(complianceLevel)
- && ERROR.equals(getValue(PREF_PB_ASSERT_AS_IDENTIFIER))
- && ERROR.equals(getValue(PREF_PB_ENUM_AS_IDENTIFIER))
- && VERSION_1_8.equals(getValue(PREF_SOURCE_COMPATIBILITY))
- && VERSION_1_8.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)))) {
+ String complianceLevel= getValue(PREF_COMPLIANCE);
+
+ HashMap<String, String> defaultOptions= new HashMap<String, String>();
+ JavaModelUtil.setComplianceOptions(defaultOptions, complianceLevel);
+
+ if (complianceLevel.equals(defaultOptions.get(JavaCore.COMPILER_COMPLIANCE))
+ && getValue(PREF_SOURCE_COMPATIBILITY).equals(defaultOptions.get(JavaCore.COMPILER_SOURCE))
+ && getValue(PREF_CODEGEN_TARGET_PLATFORM).equals(defaultOptions.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM))
+ && getValue(PREF_PB_ASSERT_AS_IDENTIFIER).equals(defaultOptions.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER))
+ && getValue(PREF_PB_ENUM_AS_IDENTIFIER).equals(defaultOptions.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER))) {
return DEFAULT_CONF;
}
return USER_CONF;
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 62abd83..e2759f6 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
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
@@ -790,6 +794,7 @@
public static String ComplianceConfigurationBlock_version16;
public static String ComplianceConfigurationBlock_version17;
public static String ComplianceConfigurationBlock_version18;
+ public static String ComplianceConfigurationBlock_version19;
public static String ComplianceConfigurationBlock_versionCLDC11;
public static String ComplianceConfigurationBlock_src_greater_compliance;
public static String ComplianceConfigurationBlock_classfile_greater_compliance;
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 9de665c..5c46e71 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
@@ -544,6 +544,7 @@
ComplianceConfigurationBlock_version16=1.6
ComplianceConfigurationBlock_version17=1.7
ComplianceConfigurationBlock_version18=1.8
+ComplianceConfigurationBlock_version19=1.9 (BETA)
ComplianceConfigurationBlock_versionCLDC11=CLDC 1.1
ComplianceConfigurationBlock_needsbuild_title=Compiler Settings Changed