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

Implied @Inject on a class with one parameterized constructor

    Details

    • Type: Feature Request
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.SP1
    • Fix Version/s: None
    • Component/s: Beans
    • Labels:
      None

      Description

      Currently, the specification states these limitations on what classes are beans. Namely it mentions that:

      It has an appropriate constructor - either
      * the class has a constructor with no parameters, or
      * the class declares a constructor annotated @Inject.

      This effectively means that a class which has single constructor that is parameterized and does not have @Inject annotation on it will not become a bean. In fact, it will blow the CDI up. Just like this class:

      @Dependent
      public class Foo {
        // no @Inject annotation and no other constructor present
        public Foo(Bar bar) {
        }
      }
      

      Could we loosen the limitation and in the above case automatically assume (effectively add) the @Inject annotation?

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                manovotn Matěj Novotný
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: