JVM flag for opening whole module at runtime in Java 17

Viewed 148

I'm looking for a way to open a whole module in Java 17 not a specific package and I'm looking for a JVM flag such as --add-opens. I do not have access to the module and thus cannot modify the module-info.java file so I need to do this as a JVM flag at runtime.

I'm trying to provide full reflective access to a third party serialization library into lots of different modules and I cannot pre-emptively know which packages the library will need access to thus I'd like to simply give it access to the whole module. Even better, I'd like the specific library to bypass all reflective access checks but I think this has been removed in Java 17 (the --illegal-access flag).

Is this possible in version 17? If not how would you go about giving a library access to everything? The library maintainers have not yet published a new version that properly supports the encapsulated module system and they probably can't do that since the nature of the functionality needs deep reflection to work.

0 Answers
Related