Illegal native access from module even with --enable-native-access=[module]
Paul Sandoz
paul.sandoz at oracle.com
Tue Aug 17 20:58:03 UTC 2021
Hi,
Try placing "--enable-native-access=com.brcolow.vulkan” before “—module …” otherwise it becomes part of the string args passed to the application:
@@ -29,11 +29,11 @@
<arguments>
<argument>--add-modules</argument>
<argument>jdk.incubator.foreign</argument>
+ <argument>--enable-native-access=com.brcolow.vulkan</argument>
<argument>--module-path</argument>
<modulepath/>
<argument>--module</argument>
<argument>com.brcolow.vulkan/com.brcolow.vulkan.Vulkan</argument>
- <argument>--enable-native-access=com.brcolow.vulkan</argument>
</arguments>
</configuration>
</plugin>
Paul.
> On Aug 17, 2021, at 1:26 PM, Michael Ennen <mike.ennen at gmail.com> wrote:
>
> I am once again messing around with Project Panama. This time exploring
> Vulkan.
>
> You can find the project here:
>
> https://github.com/brcolow/java-vulkan
>
> You can use jextract on Vulkan API headers by running `jextract.ps1` in
> Powershell (Windows).
>
> Then use `maven-exec-plugin` by running:
>
> "mvn exec:exec"
>
> which is running java with the following arguments:
>
> [C:\Program Files\Java\jdk-17-panama\bin\java.exe, --add-modules,
> jdk.incubator.foreign, --module-path,
> C:\Users\mikee\dev\java-vulkan\target\classes, --module,
> com.brcolow.vulkan/com.brcolow.vulkan.Vulkan,
> --enable-native-access=com.brcolow.vulkan]
>
> (I have tried with and without --add-modules jdk.incubator.foreign which
> shouldn't be necessary given my module-info.java).
>
> The JDK version is the latest EA "17-panama+3-167", I get the error:
>
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at com.brcolow.vulkan at 0.0.1-SNAPSHOT
> /com.brcolow.vulkan.constants$48.<clinit>(constants$48.java:15)
>
> at com.brcolow.vulkan at 0.0.1-SNAPSHOT
> /com.brcolow.vulkan.vulkan_h_14.vkCreateInstance(vulkan_h_14.java:694)
>
> at com.brcolow.vulkan at 0.0.1-SNAPSHOT
> /com.brcolow.vulkan.Vulkan.main(Vulkan.java:34)
>
> Caused by: java.lang.IllegalCallerException: Illegal native access from
> module: com.brcolow.vulkan
>
> at
> java.base/jdk.internal.reflect.Reflection.ensureNativeAccess(Reflection.java:113)
>
> at
> jdk.incubator.foreign/jdk.incubator.foreign.CLinker.getInstance(CLinker.java:129)
>
> at com.brcolow.vulkan at 0.0.1-SNAPSHOT
> /com.brcolow.vulkan.RuntimeHelper.<clinit>(RuntimeHelper.java:27)
> ... 3 more
>
> Thank you.
> --
> Michael Ennen
More information about the panama-dev
mailing list