Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-221

Throw definition error if the set of decorated types of a decorator is empty

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.1.PRD
    • Component/s: Decorators
    • Labels:
      None

      Description

      I propose the following addition to section 8.1:
      "If the set of decorated types of a decorator is empty, the container automatically detects the problem and treats it as a definition error."

      This would be helpful in cases where the developer is not aware that a decorator and decorated bean must share the same interface, and thinks that a decorator can be defined simply by extending the decorated class (as in the following example).

      public class MyBean {
          public Object foo() {...}
      }
      
      @Decorator
      public class MyDecorator extends MyBean {
          @Inject @Delegate MyBean delegate;
          public Object foo() {...}
      }
      

      Even though the spec does explicitly state that "superclasses are not decorated types of the decorator", throwing an error would probably save some people's debugging time.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  pmuir Pete Muir
                  Reporter:
                  luksa Marko Luksa
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: