public static MetaConstructor getBestConstructorCandidate( final MetaClass[] arguments, final MetaClass decl, MetaConstructor[] constructors, final boolean classTarget) { if (constructors == null || constructors.length == 0) { return null; } MetaParameter[] parmTypes; MetaConstructor bestCandidate = null; int bestScore = 0; int score; boolean retry = false; do { for (final MetaConstructor meth : constructors) { if (classTarget && (meth.isStatic())) continue; final boolean isVarArgs = meth.isVarArgs(); if ((parmTypes = meth.getParameters()).length != arguments.length && !isVarArgs) { continue; } else if (arguments.length == 0 && parmTypes.length == 0) { bestCandidate = meth; break; } score = scoreMethods(arguments, parmTypes, isVarArgs); if (score != 0 && score > bestScore) { bestCandidate = meth; bestScore = score; } } if (!retry && bestCandidate == null && decl.isInterface()) { final MetaConstructor[] objMethods = Object_MetaClass.getConstructors(); final MetaConstructor[] nMethods = new MetaConstructor[constructors.length + objMethods.length]; System.arraycopy(constructors, 0, nMethods, 0, constructors.length); System.arraycopy(objMethods, 0, nMethods, constructors.length, objMethods.length); constructors = nMethods; retry = true; } else { break; } } while (true); return bestCandidate; }