On Wed, 27 May 2026 17:26:22 GMT, Alexander Matveev <[email protected]>
wrote:
>> test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java line 1248:
>>
>>> 1246:
>>> 1247: static Optional<Boolean> getConfigBooleanProperty(String
>>> propertyName) {
>>> 1248: return
>>> Optional.ofNullable(getConfigProperty(propertyName)).map(Boolean::valueOf);
>>
>> Should we use an alternative "String to Boolean" converter function to avoid
>> changes in test/jdk/tools/jpackage/run_tests.sh?
>>
>> Something like:
>>
>> static boolean toBoolean(String str) {
>> if (IS_TRUE.test(str)) {
>> return true;
>> } else if (IS_FALSE.test(str)) {
>> return false;
>> } else {
>> throw new IllegalArgumentException(String.format("Can't parse
>> boolean from [%s]", str));
>> }
>> }
>>
>> private final static Predicate<String> IS_TRUE =
>> Pattern.compile("^(?:y|Y|[y|Y]es|YES|[t|T]rue|TRUE|[1-9]\\d*|)$").asMatchPredicate();
>> private final static Predicate<String> IS_FALSE =
>> Pattern.compile("^(?:n|N|NO|No|no|[f|F]alse|FALSE|0)$").asMatchPredicate();
>
> I think change to run_tests.sh is more convenient, than proposed solution.
> Also, I think we should use `true` to set boolean properties, so we can just
> use `Boolean.getBoolean()` to read them. It is easy to understand, then for
> example -Djpackage.test.SQETest=5 (based on proposed code).
`Boolean.valueOf()` returns "false" for "1", "yes", "no", "ttrue", "off", "on"
string values. You think it is a good way to handle user input?
> It is easy to understand, then for example -Djpackage.test.SQETest=5 (based
> on proposed code)
Feel free to adjust the regexp to make it fail on the input you think is
misleading.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31265#discussion_r3312811411