Ah, thanks, Martin.
One thing I've tried is just editing "org.jboss.resteasy.test.providers.priority.resource.ProviderPriorityFooParamConverterProviderAAA$Proxy$_$$_WeldClientProxy" to "org.jboss.resteasy.test.providers.priority.resource.ProviderPriorityFooParamConverterProviderAAA" and loading:
String o1Class = o1.getClass().getName();
o1Class = o1Class.substring(0, o1Class.indexOf("$"));
Class<?> o1Clazz = Thread.currentThread().getContextClassLoader().loadClass(o1Class);
Annotation o1as = o1Clazz.getAnnotations();
It works, but it's not very nice. After several years, though, I'm guessing that the naming convention of adding "$Proxy$_$$_WeldClientProxy" is likely to be around for a while. What do you think?
1 of 1 people found this helpful
Well, since Weld 2.3 all "proxy" constructs (i.e. client proxies and subclasses) are marked with SYNTHETIC modifier. So you use this check to be sure. And since Weld 3.0.1 special marker interfaces are part of the API (see also api/weld/src/main/java/org/jboss/weld/proxy at 3.0.SP1 · weld/api · GitHub ). Also it's not necessary to parse the name and load the class again. Instead, inspect the subclass via reflection (Weld is using subclassing for both client proxies and interception).
The fact that the proxy class is a subclass of the original class - that's fantastically useful. I never knew that. I feel much better about the solution. It's so much simpler and prettier - just
Class<?> clazz = o.getClass();
clazz = clazz.isSynthetic() ? clazz.getSuperClass() : clazz;
Priority priority = clazz.getAnnotation(Priority.class);