Skip to content

Set default VM for execution environment in LongClassPathTests#880

Merged
iloveeclipse merged 1 commit intoeclipse-jdt:masterfrom
trancexpress:gh851
Feb 26, 2026
Merged

Set default VM for execution environment in LongClassPathTests#880
iloveeclipse merged 1 commit intoeclipse-jdt:masterfrom
trancexpress:gh851

Conversation

@trancexpress
Copy link
Contributor

Fixes: #851

@trancexpress
Copy link
Contributor Author

Looking at #851 (comment), it seems test snippets are compiled with one Java version and ran on another version.

When I run the tests locally, they fail, but I don't see the unexpected class versions errors.

While the change here fixes the tests when I run them locally, I think we should understand why tests are compiled with one Java version and ran on another...

Copy link
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Well, the tests pass now on my Windows notebook but need ~50 seconds to finish (before, they just hung).

@iloveeclipse iloveeclipse marked this pull request as ready for review February 26, 2026 12:31
@trancexpress
Copy link
Contributor Author

I'm not sure, on my laptop (installed Java 8, 11, 17, 21, 25) it seems Java 21 is used for compilation of the project. Despite Java 1.6 and Java 9 on the classpath. But for debugging the test snippet, Java 8 resp. Java 11 is used... I.e. for running, the best match is used. But not for compiling.

My workspace default compliance level is Java 21... Maybe that is why. But this doesn't help fix testVeryLongClasspathWithClasspathOnlyJar (Java 1.6 on classpath):

diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
index 2bd6ca7e0..daa87df58 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Optional;
 
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -109,6 +110,9 @@ public class LongClassPathTests extends AbstractDebugTest {
                }
                // Given
                javaProject = createJavaProjectClone("test ä VeryLongClasspathWithClasspathOnlyJar", CLASSPATH_PROJECT_CONTENT_PATH.toString(), JavaProjectHelper.JAVA_SE_1_6_EE_NAME, true);
+               javaProject.setOption(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED);
+               javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
+               javaProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
                launchConfiguration = createLaunchConfigurationStopInMain(javaProject, MAIN_TYPE_NAME);
                int minClasspathLength = 300000;
                setLongClasspath(javaProject, minClasspathLength);

@trancexpress
Copy link
Contributor Author

OK, this also fixes the tests:

diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
index 2bd6ca7e0..88bb29320 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
@@ -109,6 +109,9 @@ public class LongClassPathTests extends AbstractDebugTest {
                }
                // Given
                javaProject = createJavaProjectClone("test ä VeryLongClasspathWithClasspathOnlyJar", CLASSPATH_PROJECT_CONTENT_PATH.toString(), JavaProjectHelper.JAVA_SE_1_6_EE_NAME, true);
+               javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
+               javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
+               javaProject.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
                launchConfiguration = createLaunchConfigurationStopInMain(javaProject, MAIN_TYPE_NAME);
                int minClasspathLength = 300000;
                setLongClasspath(javaProject, minClasspathLength);
@@ -144,6 +147,9 @@ public class LongClassPathTests extends AbstractDebugTest {
                        return;
                }
                javaProject = createJavaProjectClone("testVeryLongClasspathWithArgumentFile", CLASSPATH_PROJECT_CONTENT_PATH.toString(), JavaProjectHelper.JAVA_SE_9_EE_NAME, true);
+               javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_11);
+               javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_11);
+               javaProject.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_11);
                launchConfiguration = createLaunchConfigurationStopInMain(javaProject, MAIN_TYPE_NAME);
                assumeTrue(isArgumentFileSupported(launchConfiguration));
                int minClasspathLength = 300000;

@iloveeclipse which one do you prefer? If you prefer setting source and target (which IMO is simpler to understand), we can keep the refactoring of the other test, or drop it.

@iloveeclipse
Copy link
Member

which one do you prefer?

Interestingly, the second "explicit options" patch takes now ~80 seconds (but passes), so some ~30 - 40 secs added now on top. Let use the first version.

@iloveeclipse
Copy link
Member

Do you also observe extra time added with second patch version?

@trancexpress
Copy link
Contributor Author

Do you also observe extra time added with second patch version?

No, with both changes it takes about 30 seconds to run each test method.

The many classpath entries are added ater the new settings, I'm not sure why the test would take much longer... If the new settings cause a recompile, it should be a short one. The test project has almost nothing, other than the many entries added programmatically.

@iloveeclipse
Copy link
Member

I'm not sure why the test would take much longer...

I guess the older VM picked before (Java 11 in my case) was slower?

@iloveeclipse
Copy link
Member

Looking on assertions, I see that some are written like assumptions???
Could you please check whether that small change would work on Linux with / without the patch?
On Windows it doesn't change anything, so if it would also work on Linux, could you please add it to the main fix?

diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
index 226b33e..b6f17ec 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/launching/LongClassPathTests.java
@@ -13,7 +13,6 @@
  *******************************************************************************/
 package org.eclipse.jdt.debug.tests.launching;
 
-import static org.junit.Assume.assumeFalse;
 import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
@@ -158,7 +157,7 @@
 		}
 		javaProject = createJavaProjectClone("testVeryLongClasspathWithArgumentFile", CLASSPATH_PROJECT_CONTENT_PATH.toString(), JavaProjectHelper.JAVA_SE_9_EE_NAME, true);
 		launchConfiguration = createLaunchConfigurationStopInMain(javaProject, MAIN_TYPE_NAME);
-		assumeTrue(isArgumentFileSupported(launchConfiguration));
+		assertTrue(isArgumentFileSupported(launchConfiguration));
 		int minClasspathLength = 300000;
 
 		// Given
@@ -193,7 +192,7 @@
 		// Given
 		javaProject = createJavaProjectClone("testVeryLongClasspath", CLASSPATH_PROJECT_CONTENT_PATH.toString(), JavaProjectHelper.JAVA_SE_1_6_EE_NAME, true);
 		launchConfiguration = createLaunchConfigurationStopInMain(javaProject, MAIN_TYPE_NAME);
-		assumeFalse(isArgumentFileSupported(launchConfiguration));
+		assertFalse(isArgumentFileSupported(launchConfiguration));
 		int minClasspathLength = 300000;
 		setLongClasspath(javaProject, minClasspathLength);
 		waitForBuild();

@trancexpress
Copy link
Contributor Author

Looking on assertions, I see that some are written like assumptions???

Maybe it was necessary, at some point in the past.

Could you please check whether that small change would work on Linux with / without the patch? On Windows it doesn't change anything, so if it would also work on Linux, could you please add it to the main fix?

Tests still pass also with those changes.

@iloveeclipse iloveeclipse merged commit ffa9eaa into eclipse-jdt:master Feb 26, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] LongClassPathTests failure on Windows

2 participants