Skip to content

Commit

Permalink
Fix failures in InstanceMainMethodsTests on Java 24
Browse files Browse the repository at this point in the history
+ initialize project java24 "Two_Four"
+ create extension for EE JavaSE-24

See eclipse-jdt#553
  • Loading branch information
stephan-herrmann committed Nov 3, 2024
1 parent 271ea8f commit 8a3ca83
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 1 deletion.
5 changes: 5 additions & 0 deletions org.eclipse.jdt.debug.tests/java24/Main1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Main1 {
public static void main() {
System.out.println("test");
}
}
7 changes: 7 additions & 0 deletions org.eclipse.jdt.debug.tests/java24/Main2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Main2 {

void main() {
System.out.println("test");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/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.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
Expand Down Expand Up @@ -66,6 +70,7 @@ public class JavaProjectHelper {
public static final String JAVA_SE_16_EE_NAME = "JavaSE-16";
public static final String JAVA_SE_21_EE_NAME = "JavaSE-21";
public static final String JAVA_SE_23_EE_NAME = "JavaSE-23";
public static final String JAVA_SE_24_EE_NAME = "JavaSE-24";

/**
* path to the test src for 'testprograms'
Expand Down Expand Up @@ -100,6 +105,10 @@ public class JavaProjectHelper {
* path to the 23 test source
*/
public static final IPath TEST_23_SRC_DIR = new Path("java23");
/**
* path to the 24 test source
*/
public static final IPath TEST_24_SRC_DIR = new Path("java24");

/**
* path to the compiler error java file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/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.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
Expand Down Expand Up @@ -181,6 +185,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
public static final String ONESIX_PROJECT_NAME = "One_Six";
public static final String TWENTYONE_PROJECT_NAME = "Two_One";
public static final String TWENTYTHREE_PROJECT_NAME = "Two_Three";
public static final String TWENTYFOUR_PROJECT_NAME = "Two_Four";
public static final String BOUND_JRE_PROJECT_NAME = "BoundJRE";
public static final String CLONE_SUFFIX = "Clone";

Expand Down Expand Up @@ -240,6 +245,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
private static boolean loaded16_ = false;
private static boolean loaded21 = false;
private static boolean loaded23 = false;
private static boolean loaded24 = false;
private static boolean loadedEE = false;
private static boolean loadedJRE = false;
private static boolean loadedMulti = false;
Expand Down Expand Up @@ -653,6 +659,40 @@ synchronized void assert23Project() {
}
}

/**
* Creates the Java 24 compliant project
*/
synchronized void assert24Project() {
IJavaProject jp = null;
ArrayList<ILaunchConfiguration> cfgs = new ArrayList<>(1);
try {
if (!loaded24) {
jp = createProject(TWENTYFOUR_PROJECT_NAME, JavaProjectHelper.TEST_24_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_24_EE_NAME, false);
jp.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
jp.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_24);
jp.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_24);
cfgs.add(createLaunchConfiguration(jp, "Main1"));
cfgs.add(createLaunchConfiguration(jp, "Main2"));
cfgs.add(createLaunchConfiguration(jp, "Main21"));
loaded24 = true;
waitForBuild();
assertNoErrorMarkersExist(jp.getProject());
}
} catch (Exception e) {
try {
if (jp != null) {
jp.getProject().delete(true, true, null);
for (int i = 0; i < cfgs.size(); i++) {
cfgs.get(i).delete();
}
}
} catch (CoreException ce) {
// ignore
}
handleProjectCreationException(e, TWENTYFOUR_PROJECT_NAME, jp);
}
}

/**
* Creates the 'BoundJRE' project used for the JRE testing
*/
Expand Down Expand Up @@ -959,6 +999,16 @@ protected IJavaProject get23Project() {
return getJavaProject(TWENTYTHREE_PROJECT_NAME);
}

/**
* Returns the 'Two_Four' project, used for Java 24 tests.
*
* @return the test project
*/
protected IJavaProject get24Project() {
assert24Project();
return getJavaProject(TWENTYFOUR_PROJECT_NAME);
}

/**
* Returns the 'BoundJRE' project
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/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.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
Expand All @@ -26,7 +30,7 @@ public InstanceMainMethodsTests(String name) {

@Override
protected IJavaProject getProjectContext() {
return super.get23Project();
return super.get24Project();
}

public void testStaticMainWithoutArgs() throws Exception {
Expand Down
5 changes: 5 additions & 0 deletions org.eclipse.jdt.launching/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/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.
#
# SPDX-License-Identifier: EPL-2.0
#
Expand Down Expand Up @@ -85,6 +89,7 @@ environment.description.24 = Java Platform, Standard Edition 20
environment.description.25 = Java Platform, Standard Edition 21
environment.description.26 = Java Platform, Standard Edition 22
environment.description.27 = Java Platform, Standard Edition 23
environment.description.28 = Java Platform, Standard Edition 24

classpathVariableInitializer.deprecated = Use the JRE System Library instead

Expand Down
9 changes: 9 additions & 0 deletions org.eclipse.jdt.launching/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/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.
SPDX-License-Identifier: EPL-2.0
Expand Down Expand Up @@ -393,6 +397,11 @@
id="JavaSE-23"
compliance="23">
</environment>
<environment
description="%environment.description.28"
id="JavaSE-24"
compliance="24">
</environment>
<analyzer
class="org.eclipse.jdt.internal.launching.environments.ExecutionEnvironmentAnalyzer"
id="org.eclipse.jdt.launching.eeAnalyzer"/>
Expand Down

0 comments on commit 8a3ca83

Please sign in to comment.