JDK-4672990 : Command line argument outcome is strange when passed asterisk(*)
  • Type: Bug
  • Component: docs
  • Sub-Component: guides
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2002-04-23
  • Updated: 2009-07-21
  • Resolved: 2009-07-21
Related Reports
Relates :  
Relates :  
Relates :  
Description
Name: rmT116609			Date: 04/23/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION : Windows XP

A DESCRIPTION OF THE PROBLEM :
If the argument * is given, the outcome of the argument-array is strange.
trye args.length and you'll be suprised.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile given source
2. Use 1 argument: okay (The outcome should be 1 and that's good)
3. Use 2 arguments : okay * (The outcome should be 2 but is something weird)


EXPECTED VERSUS ACTUAL BEHAVIOR :
See reproducing steps.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Test
{
	public static void main( String[] args )
	{

		System.out.println("Len: " + args.length);
		System.out.println("args: " + args);
		System.out.println("args[ 0 ]: " + args[ 0 ]);
		System.out.println("args[ 1 ]: " + args[ 1 ]);
	}

}// end of class: Test
---------- END SOURCE ----------
Output:


C:\> java Test okay *
Len: 562
args: [Ljava.lang.String;@765291
args[ 0 ]: okay
args[ 1 ]: 132003

Workaround:

C:\> java Test okay "*"
Len: 2
args: [Ljava.lang.String;@eee36c
args[ 0 ]: okay
args[ 1 ]: *

I think the work around is no good since I'm not able to test if the end user used quotations are not.

According to the doc's, the arguments passed via the command line are strings.
(see : http://java.sun.com/docs/books/tutorial/essential/attributes/cmdLineArgs.html
)

There is no mentioning the quotation or the issue with the asterisk.


(Review ID: 145719) 
======================================================================

Comments
EVALUATION The special treatment of "*" on Windows was added by 4342394 Compilation of Multiple java files filed Later, even more confusing special treatment of "*" was added by 6268383 Class-path wildcards, jplan feature 082 This bug should probably be closed as a dup of 5036373 Tool doc for 'java' should document Windows-specific command arg processing
15-03-2006

WORK AROUND A simple work around besides putting in quotes "*" would be to use bash or ksh shell on windows all should be ok.
11-06-2004

EVALUATION Eval 5 years ago was right on target. Will ask doc team to look into adding some wording about this. A simple work around besides putting in quotes "*" would be to use bash or ksh shell on windows all should be ok. ###@###.### 2002-04-25
25-04-2002