Details
-
Type: New Feature
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.2-RC2
-
Fix Version/s: 1.3
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Number of attachments :
Description
I have a class with two constructors, a no-args one and one with two arguments.
I pass is one of the arguments as a constant Parameter. The other argument is not satisfiable at this point. I expected Pico to use my default constructor but instead it tried to use the other one and throw an exception.
I can see the problem is in this bit of code:
// filter out all constructors that will definately not match
for (int i = 0; i < allConstructors.length; i++) {
Constructor constructor = allConstructors[i];
if ((parameters == null || constructor.getParameterTypes().length == parameters.length) && (allowNonPublicClasses || (constructor.getModifiers() & Modifier.PUBLIC) != 0))
}
Because I pass in one parameter the 0 args constructor is not even considered.
Activity
Field | Original Value | New Value |
---|---|---|
Type | Bug [ 1 ] | New Feature [ 2 ] |
Fix Version/s | 1.3 [ 11331 ] | |
Assignee | Joerg Schaible [ joehni ] |
Assignee | Joerg Schaible [ joehni ] | Michael Rimov [ rimovm ] |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
This is by design. If you specify the number of parameters, you specify the arity of the ctor. Nevertheless with the changes planned in
PICO-160I also have in mind, that the given parameters should be used to satisfy any ctor that has up-to the number of provided parameters and independent of their sequence.