Also remember that that java launcher is not the only launcher used with the 
JVM. There are lots of apps that use the invocation API to start the JVM, and 
there is no standardized way to propagate the command line or even the 
Main-Class to the JVM. This is currently an outage in serviceability tools such 
as jps and jcmd. 

https://bugs.openjdk.java.net/browse/JDK-6174973: 
<https://bugs.openjdk.java.net/browse/JDK-6174973:> "Process names don't appear 
in jps output when JNI is used to launch”
https://bugs.openjdk.java.net/browse/JDK-6456333: 
<https://bugs.openjdk.java.net/browse/JDK-6456333:> "Incorrect jar name handle 
by jps in case java -jar.”
https://bugs.openjdk.java.net/browse/JDK-7012002: 
<https://bugs.openjdk.java.net/browse/JDK-7012002:> "JPS output is wrong”

Thanks,
/Staffan

> On 25 nov. 2015, at 03:53, Roger Riggs <roger.ri...@oracle.com> wrote:
> 
> Hi,
> 
> The ProcessHandle.current().info().arguments() has the operating system's view
> of the command and arguments.  Which may differ from what is passed to main[] 
> args.
> Perhaps for current() it should be special cased to exactly and always match 
> main(args)
> but that's a different question.
> 
> If the desired set of arguments is different from what is typed on the command
> line or is passed to main, the perhaps it should remain in RuntimeMXBean.
> A method on Runtime to return the arguments would be understood to be
> more general and match either main(args) or the true command line as typed.
> 
> Roger
> 
> 
> On 11/24/15 9:24 PM, David Holmes wrote:
>> On 25/11/2015 10:06 AM, Mandy Chung wrote:
>>> 
>>>> On Nov 24, 2015, at 3:45 PM, Peter Levart <peter.lev...@gmail.com> wrote:
>>>> 
>>>> 
>>>> 
>>>> On 11/24/2015 05:49 PM, Jaroslav Bachorik wrote:
>>>>> Hi,
>>>>> 
>>>>> while working on an issue to clean up a code in java.base module using 
>>>>> reflection to access RuntimeMXBean (from java.management module) in order 
>>>>> to get hold of the VM arguments (yes, this won't work with module 
>>>>> boundaries in place) it was pointed out that this functionality should be 
>>>>> available in java.base without going through JMX.
>>>> 
>>>> Isn't the following JDK9 API already providing that:
>>>> 
>>>> ProcessHandle.current().info().arguments();
>>> 
>>> This is what I also start going after.
>>> 
>>> The launcher does some job on the command-line before passing to the VM, 
>>> e.g. @argfile support that expands the options specified in the file, add 
>>> -Djava.class.path and some system properties passing to the VM, take out -J 
>>> if they are JDK tool launchers etc.
>> 
>> I haven't looked at the two APIs but the command-line is potentially very 
>> different from the "VM arguments". The VM can get its arguments from the 
>> command-line, the launcher, options file and environment variables.
>> 
>> David
>> 
>>> Mandy
>>> 
> 

Reply via email to