Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4766029
Votes 1
Synopsis (process) Runtime.exec incorrect test for empty command
Category java:classes_lang
Reported Against 1.4.1
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs 4789681
Submit Date 21-OCT-2002
Description




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

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
The exec(String command, String envp[], File dir) method of
the Runtime class tests for empty command using:

        if (command == "")

IMO, this test should be done using:

        if (command.length() == 0)




STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the following line of Java code:

Runtime.getRuntime().exec(new String());



EXPECTED VERSUS ACTUAL BEHAVIOR :
It should throw an IllegalArgumentException, but it throws
an IndexOutOfBoundsException instead.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.IndexOutOfBoundsException
	at java.lang.Runtime.exec(Runtime.java:547)
	at java.lang.Runtime.exec(Runtime.java:428)
	at java.lang.Runtime.exec(Runtime.java:364)
	at java.lang.Runtime.exec(Runtime.java:326)
	at CodeSnippet_3.run(CodeSnippet_3.java:3)
	at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain1.eval
(ScrapbookMain1.java:14)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at
org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.evalLoop
(ScrapbookMain.java:48)
	at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.main
(ScrapbookMain.java:29)


REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 166038) 
======================================================================
Work Around
N/A
Evaluation
This looks like a bad check.

--  xxxxx@xxxxx  2002-10-21
Comments
  
  Include a link with my name & email   

Submitted On 22-OCT-2002
ptatavujava
Actually, the test should be done using:
        if (command.trim().length() == 0)



PLEASE NOTE: JDK6 is formerly known as Project Mustang