Instrumentation.redefineModule -- extraPackages argument?

Remi Forax forax at univ-mlv.fr
Sat Mar 11 13:56:06 UTC 2017


Hi Mickael,
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

----- Mail original -----
> De: "Michael Rasmussen" <michael.rasmussen at zeroturnaround.com>
> À: "jigsaw-dev" <jigsaw-dev at openjdk.java.net>
> Envoyé: Samedi 11 Mars 2017 14:31:08
> Objet: Re: Instrumentation.redefineModule -- extraPackages argument?

> Looking a bit closer in the source, and not just the public API, I did find
> addPackage in the private API part of Module (and the corresponding
> native JVM_AddModulePackage).
> So the capability for dynamically evolving a named module is present,
> supported, and utilized by Proxy!
> 
> Adding a new package isn't just for use-cases of development, modules that
> dynamically expand have other use cases as well, for instance classes
> dynamically created at runtime based on factors that cannot be determined
> at compile time (well, proxy is a good example of that, and as mentioned
> already does exactly this!).
> 
> Also, as Jochen pointed out, setting up a new classloader with new layers
> and modules etc, is a non-trivial task, just for adding a new package --
> especially considering the functionality is present, just not public.
> 
> sure, from JRebel's point of view, a method being non-public isn't exactly
> an obstacle for us; but "normal" frameworks don't have that luxury.
> 
> /Michael


More information about the jigsaw-dev mailing list