Request for feedback on annotation processing API changes made in JDK 9

Alex Buckley alex.buckley at
Fri Apr 7 21:15:25 UTC 2017

On 4/7/2017 3:15 AM, Dawid Weiss wrote:
> In short, the problem seems to be that we use Apache Velocity as a
> template processor and pass those TypeElement instances for dynamic
> introspection. When Velocity tries to access a property accessor
> method (like getQualifiedName) it does so on the target class (not on
> the interface) and consequently fails with cross-module access check.

Basically the same issue as "Using 
java.awt.Toolkit.getDefaultToolkit().getScreenSize() reflectively causes 
InaccessibleObjectException" [1].

The fact that Velocity gets IllegalAccessException, not 
InaccessibleObjectException, is probably because Velocity has found 
'public' members (in this case, a nested type) and expects them to be 
universally accessible.

> I didn't dig deeper yet but I wonder how this kind of situation can be
> worked around if the processor is used in the wild (where we have no
> control and can't add --add-exports). Provide package-local wrapper
> classes that call the target via the interface methods (TypeElement)?
> Nothing else comes to my mind at the moment.

Please report a bug to Velocity. They've dealt with this kind of thing 
over the years [2][3].



More information about the compiler-dev mailing list