PicoContainer

PicoContainer finds the greediest constructor, even if it is protected or private

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.1
  • Component/s: PicoContainer (Java)
  • Labels:
    None
  • Number of attachments :
    0

Description

Currently we have a class that has protected constructors (used mostly for testing purposes), however, Pico tries to instantiate that object using those constructors, instead of the less greedy (but still public) other constructors.

A work around it to register it with params to indicate to use the noarg constructor:

internalContainer.registerComponentImplementation(
UpgradeManager.class,
UpgradeManagerImpl.class,
Collections.EMPTY_LIST);

The problem appears to be that ConstructorInjectionComponentAdapter.getGreediestSatisifableConstructor() can return a constructor which then barfs in InstantiatingComponentAdapter.newInstance().

I think that this could be solved by making allowNonPublicClasses protected in InstantiatingComponentAdapter ?

On another note - is Satisifable the correct spelling?

Issue Links

Activity

Hide
Joerg Schaible added a comment -

Hi Scott,

I fixed it in your proposed way setting "allowNonPublicClasses" to protected and using it in CICA.

Regards,
Jörg

Show
Joerg Schaible added a comment - Hi Scott, I fixed it in your proposed way setting "allowNonPublicClasses" to protected and using it in CICA. Regards, Jörg
Hide
Joerg Schaible added a comment -

Already fixed.

Show
Joerg Schaible added a comment - Already fixed.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: