United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4672990 : Command line argument outcome is strange when passed asterisk(*)

Details
Type:
Bug
Submit Date:
2002-04-23
Status:
Closed
Updated Date:
2009-07-21
Project Name:
JDK
Resolved Date:
2009-07-21
Component:
docs
OS:
windows_xp
Sub-Component:
guides
CPU:
x86
Priority:
P4
Resolution:
Not an Issue
Affected Versions:
1.4.0
Fixed Versions:

Related Reports
Relates:
Relates:
Relates:
Relates:

Sub Tasks

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

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
                                     
2002-04-25
WORK AROUND

A simple work around besides putting in quotes "*" would be to use 
bash or ksh shell on windows all should be ok.
                                     
2004-06-11
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
                                     
2006-03-15



Hardware and Software, Engineered to Work Together