Browse Source

Allow BeanUtils#instantiateClass inlining with native

Closes gh-27072
pull/27554/head
Juergen Hoeller 4 years ago
parent
commit
2fba0bc272
  1. 11
      spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

11
spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

@ -142,19 +142,20 @@ public abstract class BeanUtils { @@ -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);
}
/**

Loading…
Cancel
Save