JDK-4766029 : (process) Runtime.exec incorrect test for empty command
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-10-21
  • Updated: 2002-11-22
  • Resolved: 2002-11-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Description

Name: gm110360			Date: 10/21/2002


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) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b08 VERIFIED IN: mantis
2004-06-14

EVALUATION This looks like a bad check. -- iag@sfbay 2002-10-21
2002-10-21