On 26.11.2015 12:48, Jaroslav Bachorik wrote:
> On 25.11.2015 04:11, Mandy Chung wrote:
>>>> > On Nov 24, 2015, at 6:24 PM, David Holmes <david.holmes at oracle.com>
>> wrote:
>> >
>> > On 25/11/2015 10:06 AM, Mandy Chung wrote:
>> >>
>> >>> On Nov 24, 2015, at 3:45 PM, Peter Levart <peter.levart at 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.
>>>> Right - that’s what I was pointing out. In any case, I think it would
>> need to think through the cases that Mark bring up.
> I checked ProcessHandle.Info.arguments() and it indeed extract the
> arguments from command line. In addition to omitting the arguments set
> by the channels different than the command-line there is also a risk of
> truncated command line - an example of the command-line reported for a
> jtreg test in debug mode is in the attachment. The command-line seems to
... ok. now the attachment ...
> be restricted to 4096 characters on linux (PATH_MAX) so any arguments
> specified after this limit will be missed.
>> In the light of this - wouldn't it make sense to use the functionality
> available in RuntimeMXBean.getInputArguments() to fill the arguments
> array reported by ProcessHandle.Info.arguments() method (instead of
> extending j.l.Runtime with just another method)?
>> -JB-
>>>>>> Mandy
>>>
-------------- next part --------------
/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/images/jdk/bin/java -Dtest.class.path.prefix=/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/nb-jtreg/work/classes/java/lang/management/RuntimeMXBean:/home/jbachorik/src/java/jdk9-hs/jdk/test/java/lang/management/RuntimeMXBean -Dtest.src=/home/jbachorik/src/java/jdk9-hs/jdk/test/java/lang/management/RuntimeMXBean -Dtest.src.path=/home/jbachorik/src/java/jdk9-hs/jdk/test/java/lang/management/RuntimeMXBean -Dtest.classes=/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/nb-jtreg/work/classes/java/lang/management/RuntimeMXBean -Dtest.class.path=/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/nb-jtreg/work/classes/java/lang/management/RuntimeMXBean -Dtest.vm.opts=-Xbootclasspath/p:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.xml:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.naming:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.vm.ci:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.javadoc:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.zipfs:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.crypto.ec:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.xml.bind:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.scripting.nashorn:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.security.auth:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.policytool:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.snmp:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.naming.rmi:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.compiler:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.jfr:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.crypto.pkcs11:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.jcmd:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.desktop:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.jartool:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.management.cmm:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.sql.rowset:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.attach:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.hotspot.agent:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.sctp:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.prefs:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.base:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.transaction:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.management.resource:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.corba:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.xml.bind:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/java.annotations.common:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.dev:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-release/jdk/modules/jdk.xml.dom:/home/jbachorik/src/java/jdk9-hs/build/linux-x86_64-normal-server-relea