Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 350461

Summary: Selection of "Launch an Eclipse application" strips out double quotes for run configuration.
Product: [Eclipse Project] PDE Reporter: Allan <allan_chase>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: c.b.ainsley, curtis.windatt.public, gorazd.hribar.rajteric, kevin.pfarr, markus.kell.r, Vikas.Chandra, vroldanbet
Version: 4.0   
Target Milestone: 4.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 459310    
Bug Blocks:    
Attachments:
Description Flags
Fix
none
Fix 2 none

Description Allan CLA 2011-06-27 11:37:22 EDT
Build Identifier: I20110613-1736

When establishing a run configuration, I select "Launch an Eclipse application" to do so.  For my plugin, the VM arguments address environment variables that resolve to paths.  For example "${env_var:SomeVariable}\bin" might resolve to a path that contains spaces (hence the double quotes).  When I look at what's created in the run configuration, all double quote are stripped out.  In prior versions of Eclipse, this worked fine and preserved the double quotes. 

Reproducible: Always

Steps to Reproduce:
1.Select "Launch an Eclipse Application" (with VM arguments that contains double quotes around some environment variable)
2.Look at the newly created run configuration
3.Select "(x)=Arguments" tab and notice that the quotes are stripped out.
Comment 1 Curtis Windatt CLA 2011-06-27 15:38:15 EDT
Are you having any problems launching?  The launcher is supposed to remove any extra quotes and add them where necessary when passing arguments to the launched Eclipse.  I don't think there is a bug here (${env_var:SomeVariable does not require quotes in the launch config).

Can you please check if there is a problem with the arguments in your launched application?
Comment 2 Allan CLA 2011-06-27 16:22:01 EDT
(In reply to comment #1)
> Are you having any problems launching?  The launcher is supposed to remove any
> extra quotes and add them where necessary when passing arguments to the
> launched Eclipse.  I don't think there is a bug here (${env_var:SomeVariable
> does not require quotes in the launch config).
> Can you please check if there is a problem with the arguments in your launched
> application?

My application will no longer launch (until I go hand modify the run configuration to include the double quotes again).  Here is what I have in my launching VM Arguments (I merely changed a few names because of sensitivity):

-Xmx1024M -Xss256K
-Dosgi.locking=none
-Dorg.apache.commons.id.uuid.state.State=org.apache.commons.id.uuid.state.InMemoryStateImpl
-Djava.security.auth.login.config=C:\home\data\global\something\jaas.config
-Djava.library.path="${env_var:ARCGISHOME}\bin";"c:\h\bda\lib;c:\h\bcli\lib";"${env_var:F_IA32_REDIST11}bin\ia32"
-Dbdp.home=C:\h\BDA
-Dbdp.local_data=C:\h\data\local\BDA\data
-Dbdp.group_name=staff
-DrootDir=c:\h\BDA
-Dddp.analysis.trn.service.logLevel=OFF
-Dddp.analysis.trn.service.default=LOCAL
-Dddp.analysis.trn.service.numControllers=4
-Dddp.analysis.trn.service.portNumber=7130
-Dddp.analysis.trn.service.initTimeoutPeriod=30
-Dddp.analysis.trn.service.statusTimeoutPeriod=60
-Dddp.analysis.trn.service.statusCountThreshold=6
-Dddp.analysis.trn.service.epLaunchScript=\h\BDPCLI\bin\Run_Engine.bat
-Dddp.analysis.trn.service.parallelization.blockingAction=true
-Dddp.analysis.trn.service.parallelization.blockSize=500
-Dddp.analysis.trn.service.parallelization.blockByThreatType=false
-Dddp.analysis.trn.service.parallelization.blockOpAreaPosition=BEST
-Dddp.analysis.trn.service.baselinePath="${env_var:BASELINE_PATH}"
-Dddp.analysis.trn.service.baselineType="${env_var:BASELINE_TYPE}"
-Dsun.java2d.opengl=true

The result is basically the same (minus all the quotes).

I counted all the opening/closing double quotes and they all seem to make sense.  When I use Helios or any other previous version it worked fine.  I've been developing in 3.2 for a considerable time and it never complained about the double quotes before; I assumed that I was missing some setting/option?

On to your point: "I don't think there is a bug here (${env_var:SomeVariable
does not require quotes in the launch config)."
What if (in this example) SomeVariable (which is set at my OS level) was a path that contained whitespaces such as "c:\Program Files\Common\stuff\"?  When my launcher runs that (minus the quotes), I get a:

java.lang.NoClassDefFoundError: Files\Common
Caused by: java.lang.ClassNotFoundException: Files\Common
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Exception in thread "main" 

I can't see anything obvious and I've tried a few different variations with no luck.  Any suggestions would be appreciated.
Comment 3 Curtis Windatt CLA 2011-06-27 17:26:24 EDT
Sounds like a real bug then.  Would be a good thing to look at for 3.8, but I don't know if there will be enough committer time available.  A patch would be very appreciated.
Comment 4 Curtis Windatt CLA 2011-07-25 11:56:30 EDT
More related discussion at http://www.eclipse.org/forums/index.php/m/701802/
Comment 5 Chris Ainsley CLA 2012-05-15 11:22:41 EDT
I have encountered this bug myself when trying to run an Eclipse application when my JAVA_HOME environment variable is set to a folder with a space in the name.

My workaround will have to be to copy the JVM to a different folder and change JAVA_HOME. 

This is the command line that was generated incorrectly (should have double quotes around the JAVA_HOME path:


"C:\Program Files (x86)\Java\jdk1.6.0_27\bin\javaw.exe" -Dosgi.requiredJavaVersion=1.5 -DJAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_27 -Xms96m -Xmx700m -Dcom.ibm.icu.util.TimeZone.DefaultTimeZoneType=ICU -Declipse.pde.launch=true -Dfile.encoding=Cp1252 -classpath C:\eclipse37\plugins\org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -launcher C:\eclipse37\eclipse.exe -name Eclipse -showsplash 600 -product org.eclipse.platform.ide -data D:\projects\_workspaces\Calc/../runtime-EclipseApplication -configuration "file:D:/projects/_workspaces/Calc/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/" -dev "file:D:/projects/_workspaces/Calc/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties" -os win32 -ws win32 -arch x86 -nl en_US -consoleLog
Comment 6 Victor Roldan Betancort CLA 2014-03-28 15:29:17 EDT
I've also found this bug on Kepler SR1
Comment 7 Gorazd Hribar Rajteric CLA 2014-06-17 11:58:03 EDT
Same problem with Kepler SR2 on Mac OS X 10.9.3 (Mavericks)
Comment 8 Vikas Chandra CLA 2015-01-15 11:33:22 EST
Created attachment 249976 [details]
Fix

DebugPlugin.parseArguments removes quotes from within the arguments. I've removed call to that function now.  This is regression due to bug 321624 where duplicates was removed. There is another problem ( Bug 405539 - triaged to 4.5M5 now) due to the same fix. I have identified the problem and working for a fix.
Comment 9 Vikas Chandra CLA 2015-01-25 12:42:28 EST
Hi Markus,

This bug is due to DebugPlugin.parseArguments() stripping off double quotes (") in VM Arguments. This call was introduced sometime in PDE and all earlier cases where double quotes was working stopped working. Do you think backslash should be put before double quotes by user to solve this issue or do you recommend not using  DebugPlugin.parseArguments() for this [articular case. The only issue here is that things use to work earlier but not now.

Please let me know your suggestion/s on this one.

Thanks !
Comment 10 Vikas Chandra CLA 2015-01-27 06:40:23 EST
I have a solution but need feedback from Markus. Moving to 4.5M6
Comment 11 Vikas Chandra CLA 2015-02-06 06:16:18 EST
Markus, any comments?
Comment 12 Markus Keller CLA 2015-02-06 08:44:09 EST
Created attachment 250580 [details]
Fix 2

The scenario at hand is clicking "Launch and Eclipse application" in a *.product editor.

ProductFromConfigOperation#initializeProduct(IProduct) has the same problem. Its use of DebugPlugin.parseArguments(..) and later concatenation also mangles program arguments when the *.product file is created out of a launch configuration.

DebugPlugin.parseArguments(..) should only be used as the last step to parse a String into a String[] that serves as argument to Runtime.exec(..). But in LaunchAction.concatArgs(..), the variables in the arguments have not been substituted yet, so it's too early for parseArguments(..).

The patch from comment 8 would solve the specific problem with launch argument variables, but it would cause other problems. E.g. have these two arguments:
    -Done="| |"
    "-Dtwo=|  |"

A brute-force args.split("\\s+") and later concatenation with " " as joiner would mangle the two spaces into a single space. The right solution is to use a method that correctly parses and splits command line arguments without losing quotes. I've added such an API with bug 459310.

This patch makes use of the new API (which will only be available in the next I-build).
Comment 13 Vikas Chandra CLA 2015-02-09 07:52:00 EST
Thanks Markus,

Committed to 4.5 ( Mars) - master stream using
https://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit
/?id=c9b71feea86bb530e6a09112ef0cdd7c82e9b16b
Comment 14 Vikas Chandra CLA 2015-03-19 06:14:42 EDT
verified on 

Version: Mars (4.5)
Build id: I20150318-2000