Proxy classes and reflection (IllegalAccessException)

Alan Bateman Alan.Bateman at oracle.com
Fri Apr 8 15:22:21 UTC 2016


On 08/04/2016 15:01, Dawid Weiss wrote:
> :
>
> This jar contains:
> javax.annotation.Priority
> javax.ws.rs.* (subpackages and classes)
>
> So it's definitely not consistent. I added the following to command
> line to make it all run:
>
> -Xpatch:java.annotations.common=[...]/jaxrs-api-3.0.10.Final.jar
> -XaddExports:java.annotations.common/javax.ws.rs=ALL-UNNAMED
> -XaddExports:java.annotations.common/javax.ws.rs.client=ALL-UNNAMED
> ... (other subpackages from javax.ws.rs.*)
The javax.annotation package should be renamed to javax.anarchy :-)

Hopefully we will have builds soon that implement the new policy for the 
root modules when the initial class is on the class path. That will mean 
that java.annotations.common will not be resolved by default and should 
help here.


> :
> The interface is available outside of the module -- it is used (and is
> visible) to all classes. The proxy class created for this interface
> isn't (or rather: the reflective call to the proxy's constructor
> fails, like explained in the javadoc you pointed to).
The interface is visible but its package isn't exported by the module to 
everyone that potentially reads the module. This is subtle but 
-XaddExports exports packages to specific targets. The "ALL-UNNAMED" 
token is all unnamed modules, it's not all modules.

-Alan.


More information about the jigsaw-dev mailing list