[foreign-memaccess+abi] RFR: 8310659: The jar tool should support allowing access to restricted methods from executable jars [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Jun 27 14:20:30 UTC 2023
On Tue, 27 Jun 2023 14:05:12 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Add `Enable-Native-Access` jar attribute. `Enable-Native-Access: true` is equal to passing `--enable-native-access=ALL-UNNAMED` on the command line when running an executable jar (using `-jar <jar file>`).
>>
>> Question: right now I've implemented this to check if the attribute value is exactly `true`, otherwise it is ignored. Should we only allow `true` or `false`, and throw an error on other values?
>>
>> Reviewer note: I've factored some of a test code for analyzing output to `TestEnableNativeAccessBase` for the enable native access tests.
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>
> missed changes
src/java.base/share/classes/sun/launcher/LauncherHelper.java line 600:
> 598: addExportsOrOpens(opens, true);
> 599: }
> 600: if (Boolean.parseBoolean(mainAttrs.getValue(ENABLE_NATIVE_ACCESS))) {
>From a design perspective there are two options here:
* `false` means "ignore" (which is what is being implemented here)
* `false` means `no native access`.
The latter seems a bit odd - but I'd like to remind the behavior of what happens when `--enable-native-access foo` is specified, and access to restricted method occurs in a module other than `foo`. In that case we throw an exception (e.g. we validate strictly, because a command line option was found).
Jar could do a similar thing:
* if no manifest attribute is specified, do the current warning behavior
* if attribute is set to `true`, do not warn
* if attribute is set to `false`, access to restricted methods in this jar are simply not allowed and must fail with exception
-------------
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/843#discussion_r1243828426
More information about the panama-dev
mailing list