Instrumentation.redefineModule -- extraPackages argument?

Michael Rasmussen michael.rasmussen at
Sat Mar 11 15:12:05 UTC 2017

> i do not think you can use addPackage() directly because Module.getResourceAsStream() will not work on the resources associated with a package added by addPackage.
> The code of Module.getResourceAsStream() currently supposes that only proxies can add private packages, and proxies can not add new resources.
> Rémi

Yes, you are correct that the current implementation doesn't update
the classloader's mapping of package -> module.

But I did a quick and dirty test/hack, calling addPackage on the
Module, and then registering the package in the classloader.
After that, Class.forName successfully loaded the class, it was
defined in to the correct module, and it could access non-exported
members of that module!


More information about the jigsaw-dev mailing list