Is there really a jdk.proxy1 module?
Mandy Chung
mandy.chung at oracle.com
Tue Dec 8 16:20:11 UTC 2015
> On Dec 8, 2015, at 7:10 AM, Stephane Epardaud <stef at epardaud.fr> wrote:
>
> On 08/12/15 16:07, Peter Levart wrote:
>>
>>
>> Do you really have to addRead() ? Visibility of of classes
>> (Class.forName()) should only depend on class loader delegation.
>> Enumerating members, when you already have a java.lang.Class object
>> likewise. Looking-up annotations likewise.
>>
>> What exactly are you trying to do and what exception do you get?
>
> I have a scanner that can scan annotations of type X (by name) and
> member Y (by name) so it must use reflection to load the annotation and
> member. I got that when accessing the annotation's member Method:
>
>
> java.lang.IllegalAccessException: class
> com.redhat.ceylon.model.loader.impl.reflect.mirror.ReflectionAnnotation
> (in module com.redhat.ceylon.model) cannot access interface
> com.redhat.ceylon.compiler.java.metadata.Module (in module
> ceylon.language) because module ceylon.language does not export package
I believe your code is calling Class::getMethod on proxy class something like:
Method m = proxy.getClass().getMethod(“Y”);
m.invoke(proxy,….);
The above reflects on the generated proxy class but not the proxy interface X. If you did the following, it will get it to work.
Method m = X.class.getMethod(“Y”);
m.invoke(proxy,…);
When a proxy is generated to implement non-exported interface X in a named module M, such proxy class will be generated in a dynamic proxy [1]. If it were generated in module M, the proxy class would access any module-private types in M that should be avoided. IAE was thrown because it reflects on the proxy class that is generated in a dynamic module.
On the other hand, reflecting on a member of a proxy class that is a member of a proxy interface, it would be unexpected to the users as proxies are typically implementation-specific. I’ll want to look into this further and what it takes to do the access check on the proxy interface that the member belongs to.
Mandy
[1] The package and module membership of Proxy class is specified at:
http://cr.openjdk.java.net/~mr/jigsaw/spec/api/java/lang/reflect/Proxy.html#membership
More information about the jigsaw-dev
mailing list