Why java.lang.class.getDeclaredConstructors order not match
bkeh12 Mar 27, 2006 10:21 AM
public ConstructorInfoImpl[] getConstructors(ClassInfoImpl classInfo)
{ .....
Constructor[] constructors = getDeclaredConstructors(clazz);
.....
return infos;
}
protected Constructor[] getDeclaredConstructors(final Class clazz)
{
if (System.getSecurityManager() == null)
return clazz.getDeclaredConstructors(); //java.lang.class.getDeclaredConstructors()
else
{
.....
return clazz.getDeclaredConstructors(); //java.lang.class.getDeclaredConstructors()
.....
}
}
Because java.lang.class.getDeclaredConstructors() return constructors order does not match with declaredConstructors.
So Wrong arguments. new for target java.lang.reflect.Constructor expected=[int] actual=[org.jboss.test.kernel.config.support.TestMy].
Constructor[] constructors = {SimpleBean1(int),SimpleBean1(),SimpleBean1(org.jboss.test.kernel.config.support.TestMy)}.
javap -c -verbose SimpleBean1
public org.jboss.test.kernel.config.support.SimpleBean1(org.jboss.test.kernel.config.support.TestMy);
Code:
Stack=2, Locals=2, Args_size=2
.....
public org.jboss.test.kernel.config.support.SimpleBean1(int);
Code:
Stack=2, Locals=2, Args_size=2
.....
public org.jboss.test.kernel.config.support.SimpleBean1();
Code:
Stack=2, Locals=1, Args_size=1
.....
public class SimpleBean1 implements Serializable
{
// Constants -----------------------------------------------------
private static final long serialVersionUID = 3258126972906387766L;
// Attributes ----------------------------------------------------
/** Constructor used */
private String constructorUsed;
/** Constructor used */
private int constructorUsedInt;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
public SimpleBean1(TestMy t)
{
constructorUsed = "(TestMy t)";
}
public SimpleBean1(int i)
{
constructorUsed = "(int i)";
}
public SimpleBean1()
{
constructorUsed = "()";
}
// Public --------------------------------------------------------
public String getConstructorUsed()
{
return constructorUsed;
}
}
Can Constructor[] constructors order does match with declaredConstructors ?
<bean name="SimpleBean1" class="org.jboss.test.kernel.config.support.SimpleBean1"> <constructor> <parameter><inject bean="Test"/></parameter> </constructor> </bean>
So no use
<parameter class="..."><inject bean="Test"/></parameter>can work if constructors order does match with declaredConstructors that were right ?
ps my config is jvm 1.5_06