eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Projects with `:` in their name break JUnit test execution on MacOS (and probably all Unix/Linux OSes)

Open
#957 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

Steps to reproduce:
1. Create Java project with name "`foo:bar`"
2. Create JUnit test `some.JUnitTestClass` inside project
3. Right click JUnit test and select _Run As > JUnit Test_

Observe the following error in Console:
```
Class not found some.JUnitTestClass
java.lang.ClassNotFoundException: some.JUnitTestClass
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:766)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:490)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:513)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
```

The reason is that on these platforms the path separator jar is a colon `:`.

If you look into the generated command line call you can see that the `-classpath` is setup with these colons:
```
-classpath "/Users/.../workspace/foo:bar/bin:...
```

To the JVM these are separate classpath entries.

I think to continue supporting `:` in project names the classpath must be provided by a classpath jar.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with a Java project named `foo:bar` and inspect the generated JUnit command line, especially the `-classpath` value. Read the `RemoteTestRunner` path shown in the stack trace and trace where the classpath is assembled. Done means the named JUnit test runs successfully on Unix-like systems when the project name contains `:`.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.