}
Constructor cns = getBestConstructorCandidate(parms, cls, false);
if (cns == null)
throw new CompileException("unable to find constructor for: " + cls.getName(), expr, start);
for (int i = 0; i < parms.length; i++) {
//noinspection unchecked
parms[i] = convert(parms[i], cns.getParameterTypes()[i]);
}
if (cnsRes.length > 1) {
return PropertyAccessor.get(cnsRes[1], cns.newInstance(parms), factory, thisValue, pCtx);
}
else {
return cns.newInstance(parms);
}
}
else {
Constructor<?> cns = Class.forName(typeDescr.getClassName(), true, pCtx.getParserConfiguration().getClassLoader())
.getConstructor(EMPTYCLS);
if (cnsRes.length > 1) {
return PropertyAccessor.get(cnsRes[1], cns.newInstance(), factory, thisValue, pCtx);
}
else {
return cns.newInstance();
}
}
}
}
catch (CompileException e) {
throw e;
}
catch (ClassNotFoundException e) {
throw new CompileException("unable to resolve class: " + e.getMessage(), expr, start, e);
}
catch (NoSuchMethodException e) {
throw new CompileException("cannot resolve constructor: " + e.getMessage(), expr, start, e);
}
catch (Exception e) {
throw new CompileException("could not instantiate class: " + e.getMessage(), expr, start, e);
}
}