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

Bug 70955

Summary: Empty string as a program argument not accepted.
Product: [Eclipse Project] JDT Reporter: Paul Smith <paul.smith>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows NT   
Whiteboard:

Description Paul Smith CLA 2004-07-28 03:29:24 EDT
I have a collegue who cannot debug (or run) with an empty string argument 
(i.e. "").

Here's a simple proof of case program:
// START
public class Test {
    public static void main(String[] args) {
        System.out.println("There are " + args.length + " arguments.");
        for (int i = 0; i < args.length; i++) {
            System.out.println("arg " + (1 + i) + "=[" + args[i] + "]");
        }
    }
}
// END

In Run -> Debug... -> Arguments [Tab], enter the following in 'Program 
Arguments':

The output from the program in debug or run is as follows.

There are 3 arguments.
arg 1=[word1]
arg 2=[part1 part2]
arg 3=[word2]

However, running the program from the command line gives:

There are 4 arguments.
arg 1=[word1]
arg 2=[]
arg 3=[part1 part2]
arg 4=[word2]

The JRE for the project being used is 1.4.2_05

This is a minor inconvenience but is a difference to how Java command line 
performs so I thing it needs to be resolved.

Please excuse me if I have missed an option. I have trawled the Web and looked 
in the bug database without success.
Comment 1 Paul Smith CLA 2004-07-28 03:32:11 EDT
Sorry, I missed out the parameters entered:

word1 "" "part1 part2" word2
Comment 2 Darin Wright CLA 2004-07-28 15:01:37 EDT
Fixed in ExecutionArguments. Added 2 tests to LaunchConfigurationArgumentTests.
Comment 3 Darin Wright CLA 2004-07-28 15:01:49 EDT
Please verify, Jared.
Comment 4 Paul Smith CLA 2004-07-29 07:25:46 EDT
I have downloaded the latest nightly build and found that it now works - thanks 
very much for the fast resolution.
Comment 5 Jared Burns CLA 2004-07-29 12:23:55 EDT
Only committers verify bugs. Thanks for double-checking, though.
Comment 6 Jared Burns CLA 2004-08-02 14:02:48 EDT
(marking fixed)
Comment 7 Jared Burns CLA 2004-08-19 13:30:48 EDT
Reopening. The implementation doesn't look for an empty string (""), it just looks for an empty buffer at 
one point in the parsing process. If you just pass in a *single* double-quote ("), the "parse buffer" also 
happens to be empty, so we incorrectly add the second double-quote to the arguments.
Comment 8 Jared Burns CLA 2004-10-28 15:00:10 EDT
Fixed in ExecutionArguments with an explicit check for an empty string argument.

Please verify, DW.
Comment 9 Darin Wright CLA 2004-10-29 10:27:40 EDT
Verified. (However, external tools now has the same bug - I will file a new 
bug to consolidate the support).