3 Replies Latest reply on Oct 25, 2016 10:51 AM by Laird Nelson

    Accessing class annotation on a Weld-made proxy?

    Laird Nelson Apprentice

      (This is tangentially related to WELD-1131 and this forum thread.)


      When Weld hands me a bean instance, and I want to inspect that instance's class for a class-level annotation, I cannot, because the class of the instance that Weld hands me is a proxy.


      While I can think of lots of non-portable hacks to discover my class-level annotation, is there a sanctioned way to arrange things such that a call of Class#getAnnotation(Class) on the proxy class will work properly?


      The CDI 2.0 EDR2 Javadocs index includes the word "proxy" only 10 times, and only in connection with the UnproxyableResolutionException class, so I am beginning to fear that this may not be possible.


      For comparison purposes, HK2 (another JSR-330 framework with features comparable to CDI) allows this use case explicitly: you can always test an instance to see if it is an instanceof ProxyCtl.  I mention this because this is the mindset I'm approaching the problem with in case that helps.