Having Fun with Java Reflection and Modules

(blog.ptidej.net)

3 points | by yann-gael 12 hours ago ago

1 comments

  • yann-gael 12 hours ago

    Java modules offer strong(er) encapsulation and put the onus on the Java programs to explicitly declare, at compile-time and run-time, whether they need special access to APIs (i.e., packages and their classes) hidden in some specific modules. These special accesses can be declared at both compile and run times and, of course, must be documented along with the programs. However, at run time, you may still want to hide some APIs that are not (yet) in a module, and conversely, you may still want to access hidden APIs and inform the program users that they forgot to allow this access. You can do both in pure Java by having some fun with reflection!