Illegal native access from module even with --enable-native-access=[module]

Michael Ennen mike.ennen at gmail.com
Tue Aug 17 20:26:31 UTC 2021


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