Allow BeanUtils#instantiateClass inlining with native
Closes gh-27072
This commit is contained in:
parent
54bd66755c
commit
2fba0bc272
|
|
@ -142,19 +142,20 @@ public abstract class BeanUtils {
|
||||||
if (clazz.isInterface()) {
|
if (clazz.isInterface()) {
|
||||||
throw new BeanInstantiationException(clazz, "Specified class is an interface");
|
throw new BeanInstantiationException(clazz, "Specified class is an interface");
|
||||||
}
|
}
|
||||||
|
Constructor<T> ctor;
|
||||||
try {
|
try {
|
||||||
return instantiateClass(clazz.getDeclaredConstructor());
|
ctor = clazz.getDeclaredConstructor();
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException ex) {
|
catch (NoSuchMethodException ex) {
|
||||||
Constructor<T> ctor = findPrimaryConstructor(clazz);
|
ctor = findPrimaryConstructor(clazz);
|
||||||
if (ctor != null) {
|
if (ctor == null) {
|
||||||
return instantiateClass(ctor);
|
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
|
||||||
}
|
}
|
||||||
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
|
|
||||||
}
|
}
|
||||||
catch (LinkageError err) {
|
catch (LinkageError err) {
|
||||||
throw new BeanInstantiationException(clazz, "Unresolvable class definition", err);
|
throw new BeanInstantiationException(clazz, "Unresolvable class definition", err);
|
||||||
}
|
}
|
||||||
|
return instantiateClass(ctor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue