PicoContainer
  1. PicoContainer
  2. PICO-214

ImplementationHidingPicoContainer won't find non-null constructors

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1-1-beta-2
    • Fix Version/s: 1.2
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Environment:
      Win2K, Eclipse 3.1M1
    • Number of attachments :
      1

      Description

      /*

      • Compile and run this dode and an exception is thrown.
      • The failure description and a proposal for the bug cause is included in the comments of the source code.
        */
        import org.picocontainer.MutablePicoContainer;
        import org.picocontainer.alternatives.ImplementationHidingPicoContainer;

      public class PicoContainerBugTest {
      public static void main(String[] args)

      { final MutablePicoContainer pico = new ImplementationHidingPicoContainer(); pico.registerComponentImplementation(A.class); /* This is a workaround for the bug described further down. Normally * this method call should only be needed if specific requirements for * parameters exist, but not if PicoContainer shall resolve the * dependencies itself. However, with ImplementationHidingPicoContainer * this is currently the only way to register a class/interface such * that the automatic resolution works. */ pico.registerComponentImplementation(I1.class, B.class, null); /* The following registerComponentImplementation(Object, Class) of * ImplementationHidingPicoContainer is buggy, as it contains * "ComponentAdapter delegate = caf.createComponentAdapter(componentKey, * componentImplementation, new Parameter[0]);". Instead of "new * Parameter[0]" it should be "null" to have a behaviour consistent to * DefaultPicoContainer, i.e. if PicoContainer shall resolve * dependencies itself. */ pico.registerComponentImplementation(I2.class, C.class); /* The following verify() throws the exception, but is expected not to * throw: "org.picocontainer.PicoVerificationException: * [[org.picocontainer.PicoInitializationException: Either do the * specified parameters not match any of the following constructors: * [public PicoContainerBugTest$C(PicoContainerBugTest$A)] or the * constructors were not accessible for 'class * PicoContainerBugTest$C']]". * * I believe that the error comes this way: In method * getGreediestSatisfiableConstructor parameters are checked against * null and if parameters is not null it is assumed that specific * parameters have been given so that no automatic resolution takes * place. As now during registration instead of "null" falsly "new * Parameter[0]" was stored, this is now interpreted as if only the * nullary constructor shall be used, and if that doesn't exist, the * exception is thrown. */ pico.verify(); }

      public static interface I1 {
      }

      public static interface I2 {
      }

      public static class A {
      public A() {
      }
      }

      public static class B implements I1 {
      public B(final A a) {
      }
      }

      public static class C implements I2 {
      public C(final A a) {
      }
      }
      }

        Activity

        Hide
        Carsten Langer added a comment -

        Copy of the source file describing the bug.

        Show
        Carsten Langer added a comment - Copy of the source file describing the bug.
        Carsten Langer made changes -
        Field Original Value New Value
        Attachment PicoContainerBugTest.java [ 13116 ]
        Jörg Schaible made changes -
        Fix Version/s 1.2 [ 11330 ]
        Hide
        Mauro Talevi added a comment -

        Cannot reproduce bug in Pico 1.2 trunk.
        Issue has been added to org.picocontainer.alternatives.issues.Issue0214TestCase.

        Show
        Mauro Talevi added a comment - Cannot reproduce bug in Pico 1.2 trunk. Issue has been added to org.picocontainer.alternatives.issues.Issue0214TestCase.
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Cannot Reproduce [ 5 ]
        Hide
        Paul Hammant added a comment -

        Confirm, cannot repro. Carsten ??

        Show
        Paul Hammant added a comment - Confirm, cannot repro. Carsten ??
        Paul Hammant made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Carsten Langer
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1 hour
              1h
              Remaining:
              Remaining Estimate - 1 hour
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified