RFR: 8340081: Test java/foreign/TestLinker.java failed failed: missing permission java.lang.foreign.native.threshold.power.fill
Per Minborg
pminborg at openjdk.org
Fri Sep 13 06:56:08 UTC 2024
On Fri, 13 Sep 2024 06:49:41 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> Yes, the 2-arg GetIntegerAction.privilegedGetProperty would be better here, and it would retain the existing behavior for when the property value can't be parsed as a number.
>
> I think we need the try block anyhow as we have to deal with a String. But might be slightly better. We could revisit this later.
It would look like this:
static int powerOfPropertyOr(String name, int defaultPower) {
final String property = GetPropertyAction.privilegedGetProperty(PROPERTY_PATH + name, Integer.toString(defaultPower));
try {
return 1 << Math.clamp(Integer.parseInt(property), 0, Integer.SIZE - 2);
} catch (NumberFormatException _) {
// ignore
}
return defaultPower;
}
```
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20983#discussion_r1758281092
More information about the core-libs-dev
mailing list