Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24] Allow JDT to target Java 24 in compiler preferences #1713

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
* Jesper S Møller - Bug 529432 - Allow JDT UI to target Java 10
Expand Down Expand Up @@ -701,10 +705,8 @@ private void validateComplianceStatus() {
}
}

@SuppressWarnings("unused")
protected boolean isBetaVersion(String compliance) {
return false;
// return JavaCore.VERSION_23.equals(compliance);
return JavaCore.VERSION_24.equals(compliance);
}

private String addsExportToSystemModule() {
Expand Down