Open code review for 8061999 Enhance VM option parsing to allow options to be specified
Daniel D. Daugherty
daniel.daugherty at oracle.com
Thu Jun 25 16:36:51 UTC 2015
Dmitry,
Thanks for the reminder about one of the prime motivators for
this changeset.
Just one more example to show how things work today:
$ cat DumpMyProperty.java
public class DumpMyProperty {
public static void main(String[] args) {
System.out.println("my.property=" +
System.getProperty("my.property"));
}
}
$ cat flags.input.java_property
-Dmy.property="This is my special property."
$ java -showversion DumpMyProperty
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b69)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b69, mixed mode)
my.property=null
$ java -showversion -Dmy.property="This is my special property."
DumpMyProperty
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b69)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b69, mixed mode)
my.property=This is my special property.
$ java -XX:+PrintVMOptions -XX:Flags=flags.input.java_property
DumpMyProperty
VM option '-Dmy.property=This is my special property.'
Unrecognized VM option 'Dmy.property=This is my special property.'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This example shows that '-Dmy.property="This is my special property."'
option is not supported by the '-XX:Flags' option. The '-XX:Flags' option
is designed for '-XX:' options which is why it assumes that the contents
of the file includes '-XX:' options without the leading '-XX:'.
Why is this important? Passing in Java properties is one of primary ways
that folks pass "sensitive" information into their Java application stacks.
Dan
On 6/24/15 12:10 PM, Dmitry Dmitriev wrote:
> Hello Dan,
> I just want to add following: new VM Options file feature allow to
> define property inside option file.
>
> Thanks,
> Dmitry
>
> On 24.06.2015 19:19, Daniel D. Daugherty wrote:
>> On 6/23/15 10:43 PM, John Rose wrote:
>>> On Jun 23, 2015, at 7:50 PM, David Holmes <david.holmes at oracle.com>
>>> wrote:
>>>> On 24/06/2015 3:43 AM, Ron Durbin wrote:
>>>>> David,
>>>>>
>>>>> The '-XX:Flags' option was considered during the research phase
>>>>> of this project and was rejected because of its limitations. The
>>>>> '-XX:Flags' option only works for boolean flag options and it
>>>>> uses a different syntax for the options than the command line.
>>>>> For example, '-XX:+UseSerialGC' would be specified as '+UseSerialGC'
>>>>> in the '-XX:Flags' option file.
>>>> I'm a little surprised the Flags option wasn't extended to cover
>>>> these additional requirements. But presumably it should now be
>>>> deprecated as we (again presumably) don't want to have two
>>>> mechanisms for doing this.
>>> I thought the Flags option used to handle any command line options,
>>> and like David I'm surprised the right answer is to get rid of it
>>> and make a new option that does what I think the Flags option should
>>> be doing.
>>>
>>> — John
>>
>> Greetings,
>>
>> Ron is out of the office until next week so I'll provide a little
>> bit of background...
>>
>> Ron has a detailed write-up documenting all the research that he
>> did on the various command line option mechanisms. We had planned
>> to attach that write-up to the bug report, but we dropped the ball
>> (Sorry Mary!) After Ron returns, we'll make a final editing pass
>> on the document and attach it to the bug report.
>>
>> I fleshed out the '-XX:Flags' test cases that Ron posted earlier
>> in the thread:
>>
>> $ more flags.input.*::::::::::::::
>> flags.input.boolean
>> ::::::::::::::
>> +UseSerialGC
>> ::::::::::::::
>> flags.input.ccstr
>> ::::::::::::::
>> ErrorFile=my_error_file
>> ::::::::::::::
>> flags.input.uintx
>> ::::::::::::::
>> MinRAMFraction=8
>>
>> $ java -XX:+PrintVMOptions -XX:Flags=flags.input.boolean -version
>> VM option '+UseSerialGC'
>> VM option '+PrintVMOptions'
>> VM option 'Flags=flags.input.boolean'
>> java version "1.9.0-ea"
>> Java(TM) SE Runtime Environment (build 1.9.0-ea-b69)
>> Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b69, mixed mode)
>>
>> $ java -XX:+PrintVMOptions -XX:Flags=flags.input.ccstr -version
>> VM option 'ErrorFile=my_error_file'
>> VM option '+PrintVMOptions'
>> VM option 'Flags=flags.input.ccstr'
>> java version "1.9.0-ea"
>> Java(TM) SE Runtime Environment (build 1.9.0-ea-b69)
>> Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b69, mixed mode)
>>
>> $ java -XX:+PrintVMOptions -XX:Flags=flags.input.uintx -version
>> VM option 'MinRAMFraction=8'
>> VM option '+PrintVMOptions'
>> VM option 'Flags=flags.input.uintx'
>> java version "1.9.0-ea"
>> Java(TM) SE Runtime Environment (build 1.9.0-ea-b69)
>> Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b69, mixed mode)
>>
>>
>> It looks like the '-XX:Flags' option does work for 'bool', 'uintx'
>> and 'ccstr' options. Clearly Ron and I didn't remember the exact
>> reason that he ruled out using the '-XX:Flags' option. This part
>> of the review thread will have to be resolved after Ron returns.
>>
>> Dan
>
More information about the hotspot-runtime-dev
mailing list