Allow BeanUtils#instantiateClass inlining with native

Closes gh-27072
This commit is contained in:
Juergen Hoeller 2021-11-10 15:20:56 +01:00
parent 54bd66755c
commit 2fba0bc272
1 changed files with 6 additions and 5 deletions

View File

@ -142,19 +142,20 @@ public abstract class BeanUtils {
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, "Specified class is an interface");
}
Constructor<T> ctor;
try {
return instantiateClass(clazz.getDeclaredConstructor());
ctor = clazz.getDeclaredConstructor();
}
catch (NoSuchMethodException ex) {
Constructor<T> ctor = findPrimaryConstructor(clazz);
if (ctor != null) {
return instantiateClass(ctor);
ctor = findPrimaryConstructor(clazz);
if (ctor == null) {
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
}
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
}
catch (LinkageError err) {
throw new BeanInstantiationException(clazz, "Unresolvable class definition", err);
}
return instantiateClass(ctor);
}
/**