Minor thoughts (Re: [External] : Re: JEP draft: Prepare to Restrict The Use of JNI

Ron Pressler ron.pressler at oracle.com
Mon Sep 4 09:48:47 UTC 2023



> On 3 Sep 2023, at 21:14, Simon Nash <simon at cjnash.com> wrote:
> You have not addressed my point that the end user of the application will see this scary warning when they are using a Java application that is doing nothing wrong (the application is just using a well written and well behaved JNI bridge to a well written and well behaved external C++ library).
> 
> What is the end user of the application supposed to do when they see the following?
> WARNING: A native method in org.baz.services.Controller has been bound
> WARNING: Controller::getData in module org.baz has been called by com.foo.Server in an unnamed module
> WARNING: Use --enable-native-access=org.baz to avoid a warning for native methods declared in org.baz
> WARNING: Native methods will be blocked in a future release unless native access is enabled
> The end user of my application doesn't know what a native method is or what --enable-native-access=org.baz means. They are being told to use --enable-native-access=org.baz but what can they do to obey this instruction? Only the developer of the application is able to make this change. The only thing the application end user can do is to stop using my application and use another similar application that is not written in Java and possibly even more dangerous but does not emit scary warning messages.

The end user of your application need not see the warning at all. If you, as the application author, pick a runtime based on a JDK version that has this warning for your application, then *you*, as the application author, will pass the flag to the Java runtime. Your application’s end user need not know about any Java flags; they need not even know your application is a Java application. These are all internal details of your application.

— Ron



More information about the jdk-dev mailing list