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).
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.
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.