Bug 547874 - Unit Test Launcher creates corrupt classpath
Summary: Unit Test Launcher creates corrupt classpath
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.11   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 385738
  Show dependency tree
 
Reported: 2019-06-03 10:25 EDT by Stefan Lehmann CLA
Modified: 2023-11-17 12:34 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Lehmann CLA 2019-06-03 10:25:45 EDT
The created classpath is not wrapped in " chars when too long for adding it via commandline (when it gets externalized into a file).

This leads to errors when the classpath locations contain spaces.

Our analysis shows that the error is originated in:
*org.eclipse.jdt.internal.launching.ClasspathShortener*

private File createClassPathArgumentFile(String classpath) throws CoreException {
		try {
			String timeStamp = getLaunchTimeStamp();
			File classPathFile = new File(processTempFilesDir, String.format(LAUNCH_TEMP_FILE_PREFIX
					+ "%s-classpath-arg-%s.txt", getLaunchConfigurationName(), timeStamp)); //$NON-NLS-1$

			byte[] bytes = ("-classpath " + classpath).getBytes(StandardCharsets.UTF_8); //$NON-NLS-1$

			Files.write(classPathFile.toPath(), bytes);
			return classPathFile;
		} catch (IOException e) {
			throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IStatus.ERROR, "Cannot create classpath argument file", e)); //$NON-NLS-1$
		}
	}

Also we found Bug #385738 which introduced the problem.

In former versions of Eclipse IDE classpath location with spaces worked fine.
Can you please fix this regression?

Best regards, Stefan
Comment 1 Roman Fischer CLA 2019-06-03 11:43:58 EDT
Also the Backslashs in the classpath (used in Windowsmachine as name-separator) musst inside the Argument File duplicated: classpath.replace("\\","\\\\")
 https://docs.oracle.com/javase/9/tools/java.htm#JSWOR-GUID-4856361B-8BFD-4964-AE84-121F5F6CF111
-> Because backslash (\) is an escape character, a backslash character must be escaped with another backslash character.

For Test: on Windows: eclipse use the Argument File, if the normal commandline is longer than ClasspathShortener.getMaxCommandLineLength(): 32767 (ARG_MAX_WINDOWS) - 2048
Comment 2 Sarika Sinha CLA 2019-06-03 11:59:40 EDT
@Cédric,
Can you look into this?
Comment 3 Andrey Loskutov CLA 2019-12-06 11:44:12 EST
Is this still reproducible after the fix for bug 552037 / using 4.14 RC2?
Comment 4 Eclipse Genie CLA 2021-11-26 12:09:55 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2023-11-17 12:34:53 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.