}
if (arguments == null) arguments = EMPTY_ARGUMENTS;
Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
MetaClassHelper.unwrap(arguments);
CachedConstructor constructor = (CachedConstructor) chooseMethod("<init>", constructors, argClasses);
if (constructor == null) {
constructor = (CachedConstructor) chooseMethod("<init>", constructors, argClasses);
}
if (constructor == null) {
throw new GroovyRuntimeException(
"Could not find matching constructor for: "
+ theClass.getName()
+ "(" + InvokerHelper.toTypeString(arguments) + ")");
}
List l = new ArrayList(constructors.toList());
Comparator comp = new Comparator() {
public int compare(Object arg0, Object arg1) {
CachedConstructor c0 = (CachedConstructor) arg0;
CachedConstructor c1 = (CachedConstructor) arg1;
String descriptor0 = BytecodeHelper.getMethodDescriptor(Void.TYPE, c0.getNativeParameterTypes());
String descriptor1 = BytecodeHelper.getMethodDescriptor(Void.TYPE, c1.getNativeParameterTypes());
return descriptor0.compareTo(descriptor1);
}
};
Collections.sort(l, comp);
int found = -1;