Bug 217994 - [patch][launching] Run/Debug honors JRE VM args before Launcher VM args
Summary: [patch][launching] Run/Debug honors JRE VM args before Launcher VM args
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows NT
: P3 normal with 1 vote (vote)
Target Milestone: 4.3 M1   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, contributed, helpwanted
: 138623 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-02-06 08:44 EST by Takeshi Toyohara CLA
Modified: 2012-07-04 11:40 EDT (History)
6 users (show)

See Also:


Attachments
Patch for org.eclipse.jdt.launching.AbstractVMRunner (937 bytes, patch)
2012-06-11 10:49 EDT, Pascal Gruen CLA
no flags Details | Diff
updated patch (1.39 KB, patch)
2012-06-11 11:48 EDT, Michael Rennie CLA
Michael_Rennie: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Takeshi Toyohara CLA 2008-02-06 08:44:20 EST
Build ID: v3.2.1 M20060921-0945

Steps To Reproduce:
1. Set a JRE level VM args via Preferences (e.g. -Dvm.test.arg=jre or -Xmx1024)
2. Create a simple java app that prints out the VM args you specified (e.g. System.getProperty("vm.test.arg"))
3. Create a launch configuration for this class and set VM args here (e.g. -Dvm.test.arg=launch or -Xmx128)
4. Execute the launcher.  You will see that the JRE-level args are used, instead of the launch configuration args.


More information:
Filing this as a bug b/c the behavior is counterintuitive.  The launchers should act as overrides, so their args should be specified first when invoking a VM.  Tested and reproducible in both 3.2 and 3.3 builds.
Comment 1 Tillmann Seidel CLA 2009-09-02 04:12:53 EDT
This is a duplicate of <a href="show_bug.cgi?id=138623">138623</a>.

The behaviour is still reproducible on 3.4.2 (M20090211-1700).

IMO a fix for this bug would be quite important. I just spent an hour searching why my launch config parameter is ignored until I stumbled upon the JRE level VM argument which I set months ago and totally forgot about. Giving the launch config arguments preference over the VM level ones would be far more intuitive and less error-prone.
Comment 2 Darin Wright CLA 2009-09-02 10:29:44 EDT
All arguments are passed to the command line. The JRE args are appened to the launch config args, and passed as is without any duplicate handling. The end result is likely VM dependent.

For example, here "-Dmy.arg" is specifed in the config as "config" and in the JRE page as "VM".

C:\jdk1.5.0_13\bin\javaw.exe -Dmy.arg=config -Dmy.arg=VM -Dfile.encoding=Cp1252 -classpath C:\eclipse-dev\keep-trying\Junk\bin Args

The relevant code is in org.eclipse.jdt.launching.AbstractVMRunner, in the method combineVmArgs(...).

Patches/contributions welcome :-)
Comment 3 Pascal Gruen CLA 2012-06-11 10:49:49 EDT
Created attachment 217158 [details]
Patch for org.eclipse.jdt.launching.AbstractVMRunner

The plugin version I used is org.eclipse.jdt.launching_3.6.1.v20111006_r372.jar, but the patch works for me for other versions, too.

I created a test class that tries to allocate an int buffer using

int buf[] = new int[64 * 1024 * 1024];

When having -Xmx32m as default VM arguments, I get an OutOfMemory exception. Setting -Xmx128m as launcher arguments, the allocation works fine, launcher arguments take precedence now.
Comment 4 Michael Rennie CLA 2012-06-11 11:13:58 EDT
*** Bug 138623 has been marked as a duplicate of this bug. ***
Comment 5 Michael Rennie CLA 2012-06-11 11:48:37 EDT
Created attachment 217166 [details]
updated patch

The original patch would not apply to git, so I created this one that does. Also corrected the license header to properly attribute the fix to Pascal.
Comment 6 Michael Rennie CLA 2012-07-04 11:40:20 EDT
Pushed patch to master: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=204323c43b663ffa955236e09de25fae120111c7

Thanks for the fix Pascal!