-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[24] Allow JDT to target Java 24 in compiler preferences
Fixes #1695
- Loading branch information
1 parent
102d06a
commit 1d01750
Showing
2 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ | |
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* 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, [email protected] - 89977 Make JDT .java agnostic | ||
|
@@ -78,7 +82,7 @@ public final class JavaModelUtil { | |
*/ | ||
public static final String VERSION_LATEST; | ||
static { | ||
VERSION_LATEST= JavaCore.VERSION_23; // make sure it is not inlined | ||
VERSION_LATEST= JavaCore.VERSION_24; // make sure it is not inlined | ||
} | ||
|
||
public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003; | ||
|
@@ -874,6 +878,10 @@ public static boolean is23OrHigher(String compliance) { | |
return !isVersionLessThan(compliance, JavaCore.VERSION_23); | ||
} | ||
|
||
public static boolean is24OrHigher(String compliance) { | ||
return !isVersionLessThan(compliance, JavaCore.VERSION_24); | ||
} | ||
|
||
/** | ||
* Checks if the given project or workspace has source compliance 1.2 or greater. | ||
* | ||
|
@@ -1080,6 +1088,17 @@ public static boolean is23OrHigher(IJavaProject project) { | |
return is23OrHigher(getSourceCompliance(project)); | ||
} | ||
|
||
/** | ||
* Checks if the given project or workspace has source compliance 24 or greater. | ||
* | ||
* @param project the project to test or <code>null</code> to test the workspace settings | ||
* @return <code>true</code> if the given project or workspace has source compliance 24 or | ||
* greater. | ||
*/ | ||
public static boolean is24OrHigher(IJavaProject project) { | ||
return is24OrHigher(getSourceCompliance(project)); | ||
} | ||
|
||
public static String getSourceCompliance(IJavaProject project) { | ||
return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE); | ||
} | ||
|
@@ -1130,6 +1149,8 @@ public static String getCompilerCompliance(IVMInstall2 vMInstall, String default | |
String version= vMInstall.getJavaVersion(); | ||
if (version == null) { | ||
return defaultCompliance; | ||
} else if (version.startsWith(JavaCore.VERSION_24)) { | ||
return JavaCore.VERSION_24; | ||
} else if (version.startsWith(JavaCore.VERSION_23)) { | ||
return JavaCore.VERSION_23; | ||
} else if (version.startsWith(JavaCore.VERSION_22)) { | ||
|
@@ -1180,7 +1201,9 @@ public static String getExecutionEnvironmentCompliance(IExecutionEnvironment exe | |
|
||
// fallback: | ||
String desc= executionEnvironment.getId(); | ||
if (desc.indexOf(JavaCore.VERSION_23) != -1) { | ||
if (desc.indexOf(JavaCore.VERSION_24) != -1) { | ||
return JavaCore.VERSION_24; | ||
} else if (desc.indexOf(JavaCore.VERSION_23) != -1) { | ||
return JavaCore.VERSION_23; | ||
} else if (desc.indexOf(JavaCore.VERSION_22) != -1) { | ||
return JavaCore.VERSION_22; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters