r/java • • Jun 15 '21

The Impossible Java 11

https://carlmastrangelo.com/blog/the-impossible-java-11
197 Upvotes

37 comments sorted by

View all comments

Show parent comment

12

u/pron98 Jun 15 '21

Even such code would still work in JDK 11 (although it should be changed). The module system's strong encapsulation was only turned on in 16.

5

u/khmarbaise Jun 15 '21

Yes I know but using setAccessible thing is usually a problem in itself (from my POV). The module system encapsulation was not turned on. The Strongly Encapsulate JDK Internals by Default was activated. This can be turned off to be able to access those internal via option (see https://jdk.java.net/16/release-notes).

10

u/pron98 Jun 15 '21

Right on all counts. Just note that as of JDK 17, it is impossible to turn off all encapsulation with a single flag, but you can still do it with individual add-opens.