United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6459832 : RuntimeMXBean.getInputArguments() doesn't handle arguments with spaces properly

Details
Type:
Bug
Submit Date:
2006-08-14
Status:
Closed
Updated Date:
2014-02-27
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
core-svc
OS:
windows_xp
Sub-Component:
java.lang.management
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports

Sub Tasks

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

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
This routine isn't properly returning arguments with spaces in them. This is a problem for us when trying to parse -javaagent flags with spaces for file paths.





STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
>javac -target 1.5 EchoArgs.java

>java -D"value=one two three" EchoArgs

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
-Dvalue=one two three
one two three
ACTUAL -
-Dvalue=one
two
three
one two three

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class EchoArgs {
    public static void main(String args[]) {
        for (String str: java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments()) {
            System.out.println(str);
        }
        System.out.println(System.getProperty("value"));
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
assume that arguments start with a - and hope that no other values do (i.e., there isn't anything reliable)

                                    

Comments
SUGGESTED FIX

HS now returns an array of VM arguments instead of a string concatenating all arguments.

Also changed SDK to use the new HS entry point.
                                     
2006-12-05
EVALUATION

The VM concatenates all arguments into one string to pass to java.lang.management assuming whitespace is the separator which is incorrect.

Will fix it in JDK7.
                                     
2006-11-03



Hardware and Software, Engineered to Work Together