Bug 211045 - [jar exporter] program arguments are ignored
Summary: [jar exporter] program arguments are ignored
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Benno Baumgartner CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-11-27 06:10 EST by Martin Aeschlimann CLA
Modified: 2008-04-30 09:26 EDT (History)
1 user (show)

See Also:


Attachments
patch for org.eclipse.jdt.ui, show info for launchconfigs with arguments (8.00 KB, patch)
2007-12-05 14:49 EST, Ferenc Hechler CLA
no flags Details | Diff
patch2 for org.eclipse.jdt.ui, show info for launchconfigs with arguments (7.91 KB, patch)
2007-12-06 12:03 EST, Ferenc Hechler CLA
no flags Details | Diff
patch3 for org.eclipse.jdt.ui, show info for launchconfigs with arguments (7.76 KB, patch)
2007-12-08 09:58 EST, Ferenc Hechler CLA
no flags Details | Diff
fix (7.54 KB, patch)
2007-12-10 04:18 EST, Benno Baumgartner CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2007-11-27 06:10:41 EST
20071127

- create a project with JUnit 3.8.1 code (from the smoke test)
- create a Java application launch configuration for 'junit.textui.TestRunner'
  add 'junit.samples.VectorTest' as program argument on the second tab page

- create a runnable JAR from this launch configuration
- run the created JAR
  The command says that arguments must be specified.

It seems that the program arguments 'junit.samples.VectorTest' are not used.
Comment 1 Benno Baumgartner CLA 2007-11-29 12:25:34 EST
We should fix this, its a new feature. 

Ferenc? Is this possible? Can the manifest contain main class arguments? Can you have a look at this until end of next week?
Comment 2 Ferenc Hechler CLA 2007-11-29 14:46:03 EST
The requested feature is not supported by standard jars.
There is no Attribute in the manifest to specify the application args.
The arguments have to be entered in the command line:

  java -jar xxx.jar [app_arg1] [app_arg2] [app_arg3] ...

The feature could be implemented using a special boot-stub loader inside the jar which parses a custom manifest attribute and is executed instead of the Main-Class and then calls the main methode of the real Main-Class.
But this might have side effects.

Is this feature really needed?
What about conflicts, if there are args in the launch-config and also args in the command-line?



Comment 3 Benno Baumgartner CLA 2007-11-29 16:00:30 EST
Thanks Ferenc, no special class loader, no parsing, please. We should show a warning if program arguments are used. The solution for the user would be to do what VectorTest already does: add a main method like

	public static void main (String[] args) {
		junit.textui.TestRunner.run (new TestSuite(VectorTest.class));
	}

and create a runnable jar which runs this main method.

Martin? Would that be acceptable?
Comment 4 Martin Aeschlimann CLA 2007-11-30 04:35:27 EST
I agree with Benno's comment 3: When we detect program and VM arguments in the launch configuration, we can warn the user in the wizard:
'Note: Program and VM arguments will not be part of the runnable JAR. Arguments can be passed on the command line when launching the JAR'
Comment 5 Ferenc Hechler CLA 2007-12-04 02:37:58 EST
I will add an patch till friday,
feri
Comment 6 Ferenc Hechler CLA 2007-12-05 14:49:53 EST
Created attachment 84562 [details]
patch for org.eclipse.jdt.ui, show info for launchconfigs with arguments
Comment 7 Benno Baumgartner CLA 2007-12-06 04:04:48 EST
(In reply to comment #6)
> Created an attachment (id=84562) [details]
> patch for org.eclipse.jdt.ui, show info for launchconfigs with arguments
> 

Patch is not good:
1. Open the create runnable jar wizard for the first time
Is:
 Wizard shows error 'no launch configuration selected'
Should:
 Wizards must never open with an error message, see http://www.eclipse.org/articles/Article-UI-Guidelines/Contents.html#Wizards

2. 'no launch configuration selected' should start with an uppercase
3. Remove the 'Note: ' part of the message, the info icon already indicates that this is a note
4. Change the severity from info to warning
Comment 8 Ferenc Hechler CLA 2007-12-06 12:03:36 EST
Created attachment 84643 [details]
patch2 for org.eclipse.jdt.ui, show info for launchconfigs with arguments

removed error message for missing launch-config, set priority to warning, removed "note: " prefix.
Comment 9 Benno Baumgartner CLA 2007-12-07 06:28:56 EST
(In reply to comment #8)
> Created an attachment (id=84643) [details]
> patch2 for org.eclipse.jdt.ui, show info for launchconfigs with arguments
> 
> removed error message for missing launch-config, set priority to warning,
> removed "note: " prefix.

-The formatting is incorrect, enable format edited lines.
-Remove unnecessary parenthesis.
-Remove unnecessary local variables.
-Something like:
private String getLaunchConfigurationAttibute(String attributeName, 
                                                       String defaultValue) {
	String result = defaultValue; 
	try {
	    result = fLaunchConfiguration.getAttribute(...); 
	} catch (CoreException e) {
	    JavaPlugin.log(e);
	}
	return result;
}
Is easier to read if:
private String getLaunchConfigurationAttibute(String attributeName, 
                                                       String defaultValue) {
	try {
	    return fLaunchConfiguration.getAttribute(...); 
	} catch (CoreException e) {
	    JavaPlugin.log(e);
            return defaultValue;
	}
}
It's also faster (less assignments, less values on stack)
Comment 10 Ferenc Hechler CLA 2007-12-08 09:58:40 EST
Created attachment 84806 [details]
patch3 for org.eclipse.jdt.ui, show info for launchconfigs with arguments

reformated code
Comment 11 Benno Baumgartner CLA 2007-12-10 04:18:05 EST
Created attachment 84851 [details]
fix
Comment 12 Benno Baumgartner CLA 2007-12-10 04:19:11 EST
fixed > I20071204-1547