module readability and exceptions in api
Michał Zegan
webczat_200 at poczta.onet.pl
Sat Oct 13 14:12:30 UTC 2018
W dniu 13.10.2018 o 09:24, Alan Bateman pisze:
> On 13/10/2018 00:40, Michał Zegan wrote:
>> :
>>
>> Oh actually one question I forgot about: if I generate bytecode
>> accessing classes in modules that I don't read, and I call
>> Module.addReads on myself, I can then read the module with classes I
>> want to access, however my module's class loader probably will not
>> delegate to the other module's class loader for class loading, so how to
>> solve this situation? Creating my own class loader that loads the
>> bytecode would require to have separate module for the bytecode.
> Right, the class loader delegation must respect the readability graph.
> There aren't any APIs for dynamically augmenting the delegation graph so
> it would require that bring your own class loaders (and specify a
> mapping function to defineModules) if you want to do that.
hmm so it is not a good idea to, say, generate a bytecode/class to be
defined as part of currently loaded module X by means of
MethodHandles.Lookup.defineClass or something like that if this bytecode
would have to access module Y that is currently not readable by X,
because I have no control over class loader of X and cannot augment it's
delegation? So may be better to make my own module Z that reads Y and X
and that contains my class, and open some packages to it or export them
to it or do whatever? Then I probably have no use for Module.addReads
either, just addExports/maybe addOpens...
>
> -Alan
More information about the jigsaw-dev
mailing list