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

Interface default methods are treated inconsistently by AnnotatedType and WithAnnotations

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 3.0.5.Final
    • Fix Version/s: 3.1.0.Final
    • Component/s: Extensions
    • Labels:
      None
    • Environment:

      Linux, OpenLiberty

    • Steps to Reproduce:
      Hide

      I have a class `MyBean` which implements an interface `MyInterface` and `MyInterface` declares a default method `myMethod()` which is annotated `@MyAnnotation`.

      If I observe the `ProcessAnnotatedType` event for `MyBean`, I can call `getAnnotatedType().getMethods()` and see the default method inherited from `MyInterface`.

      However, if I observe the `ProcessAnnotatedType` event but constrain it using `@WithAnnotations(MyAnnotation.class)`, my observer method is not called.

      Show
      I have a class `MyBean` which implements an interface `MyInterface` and `MyInterface` declares a default method `myMethod()` which is annotated `@MyAnnotation`. If I observe the `ProcessAnnotatedType` event for `MyBean`, I can call `getAnnotatedType().getMethods()` and see the default method inherited from `MyInterface`. However, if I observe the `ProcessAnnotatedType` event but constrain it using `@WithAnnotations(MyAnnotation.class)`, my observer method is not called.

      Description

      AnnotatedType.getMethods() returns default methods inherited from interfaces, but @WithAnnotations does not consider annotations on these methods when selecting types for the ProcessAnnotatedType event.

      The Javadoc for WithAnnotations seems to say it should be consistent with spec section 11.4. Alternative Metadata Sources which includes the description of AnnotatedType.getMethods().

      Section 11.4 only talks about methods from the class and its superclasses and makes no mention of default methods from interfaces.

      I'm not sure whether default methods inherited from interfaces should be included here, but I would expect AnnotatedType.getMethods() and WithAnnotations to be consistent.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mkouba Martin Kouba
                  Reporter:
                  azquelt Andrew Rouse
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: