[weld-issues] [JBoss JIRA] (WELD-1131) Weld Proxies (for instance created by Producer-Method) loose Annotations put ontop of Methods of source class

P Huber (JIRA) jira-events at lists.jboss.org
Wed May 9 11:47:18 EDT 2012


    [ https://issues.jboss.org/browse/WELD-1131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12691479#comment-12691479 ] 

P Huber edited comment on WELD-1131 at 5/9/12 11:46 AM:
--------------------------------------------------------

This is the original Annotation which has Retention "Runtime" from the begining (but good you've asked...I admittetly forgot that in the past on several occasions ;-)

@Target({ METHOD, FIELD })
@Retention(RUNTIME)
@Documented
public @interface PredicateDef {
	String value();
}

And the use of it is
        @PredicateDef("...")
	public String getFirstName() {
		return firstName;
	}

And I found a workaround in the meantime which works for me

I had used this, which *does NOT* work: 
    final BeanInfo bi = Introspector.getBeanInfo(selectedCustomer.getClass());

and replaced it with this *working* version:
    final BeanInfo bi = Introspector.getBeanInfo(selectedCustomer.getClass().getSuperClass());

---
Arquillian: I'm not yet into Arquillian, but I can try to do a simple sample with standalone WELD CDI. It guess it should be possible to reproduce the issue, though I cannot promise.
 

                
      was (Author: huberp):
    This is the original Annotation which has Retention "Runtime" from the begining (but good you've asked...I admittetly forgot that in the past on several occasions ;-)

@Target({ METHOD, FIELD })
@Retention(RUNTIME)
@Documented
public @interface PredicateDef {
	String value();
}

And the use of it is
        @PredicateDef("...")
	public String getFirstName() {
		return firstName;
	}

And I found a workaround in the meantime which works for me

I had used this, which *does NOT* work: 
    final BeanInfo bi = Introspector.getBeanInfo(selectedCustomer.getClass());

and replaced it with this *working* version:
    final BeanInfo bi = Introspector.getBeanInfo(selectedCustomer.getClass().getSuperClass());

---
Arquillian: I'm not yet into Arquillian, but I can try to do a simple sample with standalone WELD CDI. It guess it should be possible to mimik the issue, though I cannot promise.
 

                  
> Weld Proxies (for instance created by Producer-Method) loose Annotations put ontop of Methods of source class
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: WELD-1131
>                 URL: https://issues.jboss.org/browse/WELD-1131
>             Project: Weld
>          Issue Type: Bug
>          Components: Reflection layer
>         Environment: glassfish 3.1.2
>            Reporter: P Huber
>
> I have project specific Annotations ontop of public Methods of a class.
> class Customer {
>         @MyProjectSpecificAnnotation
> 	public String getFirstName() {
> 		return firstName;
> 	}
> }
> When producing Objects of such an annotated class, like with
> class Example {
>      @Produce
>      Customer producerField;
> }
> Then at the Injection Side the Annotations "MyProjectSpecificAnnotation" is no longer available, because WELD injects a byte-code created proxy.
> class InjectionSide {
>      @Inject
>      Customer injectField; // here we get the WELD-Proxy of unpronouncable name...and no Annotations
> }
> I've used BeanIntrospector to reflect the injected Instance of class Customer. I get a set of PropertyDescriptors with a write/read Method each.
> But as allready said, none of them has the "MyProjectSpecificAnnotation".
> Could be due to the fact, that when subclassing a class, the Annotations of the super class are not available at sub class directly - But in Case of a "transparent" WELD proxy I'd expect they should be there. Probably you have to simply copy annotations during on-the-fly byte-code creation of the Proxy. The Problem is btw also true for javas built in Dynamic Proxy: using it you also loose Annotations.
> Hope you can fix that

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list