Revision1: Corrected: RFR 8059557 (XL): Validate JVM Command-Line Flag Arguments

Gerard Ziemski gerard.ziemski at
Wed May 27 13:18:32 UTC 2015

On 5/26/2015 7:43 PM, David Holmes wrote:
>>> In globals.hpp, looking at all the "stack parameters" I expect to see a
>>> constraint function specified somewhere, but there isn't one. So now 
>>> I'm
>>> a bit confused about how constraint functions are specified and 
>>> used. If
>>> there has to be a relationship maintained between A, B and C, is the
>>> constraint function specified for all of them or none of them and 
>>> simply
>>> executed as post argument processing step? Can you elaborate on when
>>> constraint functions may be used, and must be used, and how they are
>>> processed?
>> Constraints were not meant as a framework that imposes restrictions 
>> as to when and how to be used. It’s a helper framework that makes it 
>> easy for a developer to implement the kind of a constraint that a 
>> particular flag(s) demands. The decision as to what goes into it is 
>> left to the engineer responsible for a particular flag. The process 
>> of implementing constraints and ranges is still ongoing for many of 
>> the flags, and there are 3 subtasks tracking the issue. This webrev 
>> covers the introduction of the range/constraint framework and a 
>> subset of ranges/constraints implemented for those flags for which I 
>> was able to find existing ad hoc code or comments describing them.
> That's not really answering the question. Let me assume from this that 
> the stack parameters have not been updated yet - fine. Now lets 
> suppose that I want to update them using a constraint function. How do 
> I do that? Do I specify the constraint function on each argument 
> involved in the constraint? When will the constraint function be 
> executed?

Constraints are not methods and should not be used to set values - they 
are read-only value verification functions.

Constraints are called whenever the flag in question changes its value 
(via CommandLineFlags::*AtPut  for those flags set by external tools 
like jcmd), and also a final check is run 
(CommandLineFlags::check_all_ranges_and_constraints()) right after 
Arguments::apply_ergo(), at which point it is assumed that all flags 
have their final values set.

There is Arguments::post_final_range_and_constraint_check() method 
provided for any custom code that can assume that all range and 
constraints checks have been performed at that point and set any 
dependent values. Setting values of the flags themselves, however, 
should be performed before 
CommandLineFlags::check_all_ranges_and_constraints() is called.



More information about the hotspot-dev mailing list