Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1144

Superclass of processed AnnotationType is ignored

    XMLWordPrintable

Details

    • Hide

      1. Deploy sample app to JBoss 6.1.0.Final (upgraded to Weld 1.1.8.Final)
      2. Hit http://localhost:8080/cdi-testWeb
      3. Note NullPointerException
      4. Modify code where indicated (CdiExtension.java) to use 'processedFields.add( annotatedField );'
      5. Redeploy and note it works

      Show
      1. Deploy sample app to JBoss 6.1.0.Final (upgraded to Weld 1.1.8.Final) 2. Hit http://localhost:8080/cdi-testWeb 3. Note NullPointerException 4. Modify code where indicated (CdiExtension.java) to use 'processedFields.add( annotatedField );' 5. Redeploy and note it works
    • Compatibility/Configuration
    • Workaround Exists
    • Hide

      I have managed to hack around this problem by using reflection to set the AnnotatedField's 'type' and manipulate its 'annotationMap' rather than recreating it. However that's pretty nasty.

      Show
      I have managed to hack around this problem by using reflection to set the AnnotatedField's 'type' and manipulate its 'annotationMap' rather than recreating it. However that's pretty nasty.

    Description

      This issue has been raised a couple times (WELD-705 and WELD-1062) and marked as 'resolved' both times, but still appears broken in 1.1.8.Final?

      The documentation for ProcessAnnotatedType says it allows "an extension class [to] process the annotations of a bean class before the container builds its metamodel". However this appears very brittle. For example, any attempt to touch the AnnotatedFields of an AnnotatedType breaks superclass injection?

      I attach a sample that uses processAnnotationType. All it does is recreate each AnnotatedField and put it back into a new Set. This is sufficient to break superclass injection (CdiTest1.mConfigurationTest1 is null). Note that putting the same AnnotatedField (not a recreated version) back into the new Set works fine.

      Of course for a real use case I would do something more useful to each AnnotatedField that simply recreating it. For example I would change its type (like Solder's @Exact does) or add additional annotations. But I wanted to keep the test case simple.

      My code is very similar to that in the CDI Reference Guide: http://docs.jboss.org/weld/reference/latest/en-US/html/extend.html#d0e5057

      Attachments

        Activity

          People

            marko.luksa@gmail.com Marko Luksa (Inactive)
            kennardconsulting Richard Kennard (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: