A lot of questions around the configuration of a reflective style library

Jochen Theodorou blackdrag at gmx.org
Sun Jul 10 10:04:55 UTC 2016


Hi,

since Alan suggested to make a new thread for this (coming from 
"Feedback on proposal for #ReflectiveAccessToNonExportedTypes"), I will 
do just this.

Let me rephrase the scenario from there a bit:
I am trying to figure out the configuration and implications of the 
configuration and what is different to from before using modules. Let us 
for simplicity assume we talk only about classes with public modifier 
and all modules are loaded with the same class loader.

We have a reflective library as module MyReflection, which uses classes 
generated at runtime to realize access similar to reflection. Let us 
also ignore where the information for classes and signatures come from. 
Then we have a Module M1, which has hidden API and wants to use 
MyReflection to access its own hidden API. The question here is about 
how to make the configuration and maybe what has to be done with regards 
to layers to enable this or if that is not possible. MethodHandles and 
service loader based solutions are to be ignored for this.

Part 2 would then be to have M2 working in the same way and the question 
would be if M1 and M2 suddenly gain access to each others hidden APIs. 
Of course this makes only sense if part 1 is possible. but my thought is 
based on the following:
To access the hidden API in M1 through M1, I have something like this: 
M1 calls into MyReflection, MyReflection calls into generated class 
(Layer in M1 I guess), generated class calls into M1. In short: 
M1->MyReflection->M1Accessor->M1. And for M2 I would of course have 
M2->MyReflection->M2Accessor->M2. Since MyReflection has access to 
M1Accessor and M2Accessor I see the following possible: 
M1->MyReflection->M2Accessor->M2


And I have a new Part 3, as another followup. Would a service loader or 
MethodHandles based logic change anything here? And while 
M1->MyReflection->M2Accessor->M2 itself would change I do not think that 
M1 accessing hidden API from M2 would change.


bye Jochen


More information about the jigsaw-dev mailing list