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

Ron Pressler ron.pressler at oracle.com
Mon Sep 4 17:15:31 UTC 2023



> On 4 Sep 2023, at 17:07, Attila Kelemen <attila.kelemen85 at gmail.com> wrote:
> 
> So, the problem is that these people are unlikely to be very keen to modularize their app in the first place, and giving them an extra thing to point at (and people are very quick to find excuses), and my experience is that such an excuse potential will make my goal of convincing people a *lot* more difficult.

Let’s make this more concrete, then. How many JNI libraries are used by the application? (We may be able to offer a source repo soon with the change that you can try, if you don’t mind building the JDK, and test the experience).

The benefits from modules, most of which — maintainability and the possibility for robust security — stem from the integrity offered by strong encapsulation, are very powerful, but I admit they’re not easy for many to see. While writing a new modularised application is quite easy, modularising an existing large codebase is often not an easy task at all. Before the application can be modularised, its architecture has to be made modular — i.e. it must not make use of split packages and it must not have circular dependencies —and many codebases aren’t (the JDK wasn’t). The work required can easily dwarf the JNI flag to the point of making it insignificant. In such situations, maybe the codebase reaches a point where people realise they cannot easily move forward without modules (as the JDK had realised) or people understand the benefits they gain, which, admittedly, is not always easy because the benefits all involve future evolution or unknown vulnerabilities. But in other situations, modularising a large, existing, codebase may or may not be worth it. When you write new code, we suggest that you might as well modularise (even if you don’t understand the benefits) because it costs very little, and you may thank yourself for doing that later. Similarly, if you have a straightforward library, as that’s not hard, and will make life easier for you and your future users. But we’re not telling people that they should work to modularise all of their old applications, certainly not if they’re not happy to do it. The feature is there for new code and for those who really want it; in the future modularised applications may even enjoy other benefits. Modularising the JDK has helped the Java ecosystem a lot, but for old, large, complex applications your mileage may vary. In other words, we can’t and don’t tell people that the work required to modularised a large old application is always worth it.

— Ron




More information about the jdk-dev mailing list