-
Bug
-
Resolution: Duplicate
-
P1
-
None
-
7, 7u6
FULL PRODUCT VERSION :
C:\temp>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b130)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b02, mixed mode)
FULL OS VERSION :
Tested on Windows 7 64 bit
also tested on Windows XP (32 bit)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Nothing special. Plain vanilla. The systems have both JDK6 and JDK7 setup and easily switchable
A DESCRIPTION OF THE PROBLEM :
I can not escape the star (*) character to get it fed into a java program as is. It is ALWAYS expanded to a list of all the files in the current directory!
See the trivial sample program, and the results of calling it with naked star versus double-quoted stars on JDK6 vs. JDK7
C:\temp>cat echo.java
public class echo {
public static void main(String[] argv) throws Exception {
for (String s : argv) {
System.out.print(s);
System.out.print(' ');
}
System.out.println();
}
}
++++++++++++++++++++++++++++++++
C:\temp>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b130)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b02, mixed mode)
C:\temp>java -cp . echo *
echo.class echo.java
C:\temp>java -cp . echo "*"
echo.class echo.java
*** I switched JDKs here ****
C:\temp>java -version
java version "1.6.0_27-ea"
Java(TM) SE Runtime Environment (build 1.6.0_27-ea-b02)
Java HotSpot(TM) Client VM (build 20.2-b02, mixed mode, sharing)
C:\temp>java -cp . echo *
echo.class echo.java
C:\temp>java -cp . echo "*"
*
++++++++++++++++++++++++++++++++
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See description. It is trivial. Just have main print out its args. Then call main with "*" (literal double quotes). THen with a "naked" *.
Try it on JDK7 and JDK6. On 7 the quoted star will be replaced with the list of files!
I am running java from the plain Windows command interpreter (cmd.exe)
EXPECTED VERSUS ACTUAL BEHAVIOR :
See description.
echo * --> produce list of files in the current directory
echo "*" --> a plain star character should be passed to main()
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Source code provided by Bill Shannon:
public class echo {
public static void main(String[] argv) throws Exception {
for (String s : argv) {
System.out.print(s);
System.out.print(' ');
}
System.out.println();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I am an employee of Oracle and develop software for GlassFish. This is a big problem. We have monitoring commands that need to see a literal star character. It is impossible (or at least unknown to me) how to pass in a star character to a java program.
What I will have to do is some sort of ghastly hack like force users to use a token (e.g. ___STAR___) to represent the star character.
I ran this by Bill Shannon. He believes it should be a P1 bug.
I created this bug from the public site -- I didn't have the bugster URL handy...
C:\temp>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b130)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b02, mixed mode)
FULL OS VERSION :
Tested on Windows 7 64 bit
also tested on Windows XP (32 bit)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Nothing special. Plain vanilla. The systems have both JDK6 and JDK7 setup and easily switchable
A DESCRIPTION OF THE PROBLEM :
I can not escape the star (*) character to get it fed into a java program as is. It is ALWAYS expanded to a list of all the files in the current directory!
See the trivial sample program, and the results of calling it with naked star versus double-quoted stars on JDK6 vs. JDK7
C:\temp>cat echo.java
public class echo {
public static void main(String[] argv) throws Exception {
for (String s : argv) {
System.out.print(s);
System.out.print(' ');
}
System.out.println();
}
}
++++++++++++++++++++++++++++++++
C:\temp>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b130)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b02, mixed mode)
C:\temp>java -cp . echo *
echo.class echo.java
C:\temp>java -cp . echo "*"
echo.class echo.java
*** I switched JDKs here ****
C:\temp>java -version
java version "1.6.0_27-ea"
Java(TM) SE Runtime Environment (build 1.6.0_27-ea-b02)
Java HotSpot(TM) Client VM (build 20.2-b02, mixed mode, sharing)
C:\temp>java -cp . echo *
echo.class echo.java
C:\temp>java -cp . echo "*"
*
++++++++++++++++++++++++++++++++
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See description. It is trivial. Just have main print out its args. Then call main with "*" (literal double quotes). THen with a "naked" *.
Try it on JDK7 and JDK6. On 7 the quoted star will be replaced with the list of files!
I am running java from the plain Windows command interpreter (cmd.exe)
EXPECTED VERSUS ACTUAL BEHAVIOR :
See description.
echo * --> produce list of files in the current directory
echo "*" --> a plain star character should be passed to main()
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Source code provided by Bill Shannon:
public class echo {
public static void main(String[] argv) throws Exception {
for (String s : argv) {
System.out.print(s);
System.out.print(' ');
}
System.out.println();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I am an employee of Oracle and develop software for GlassFish. This is a big problem. We have monitoring commands that need to see a literal star character. It is impossible (or at least unknown to me) how to pass in a star character to a java program.
What I will have to do is some sort of ghastly hack like force users to use a token (e.g. ___STAR___) to represent the star character.
I ran this by Bill Shannon. He believes it should be a P1 bug.
I created this bug from the public site -- I didn't have the bugster URL handy...
- duplicates
-
JDK-7146424 Wildcard expansion for single entry classpath
- Closed
- relates to
-
JDK-7161292 strange java 7 behavior on windows ( star arg "*")
- Closed
-
JDK-7020954 Different Behavior in java.exe among windows editions and c libraries when "*" is set as an argument
- Closed