diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java index e9a9c63201a..77fa8e20313 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java @@ -515,7 +515,14 @@ private static Object newInstance(Class cls) { } catch (Throwable t) { try { Constructor[] constructors = cls.getDeclaredConstructors(); - if (constructors != null && constructors.length == 0) { + /** + * From Javadoc java.lang.Class#getDeclaredConstructors + * This method returns an array of Constructor objects reflecting all the constructors + * declared by the class represented by this Class object. + * This method returns an array of length 0, + * if this Class object represents an interface, a primitive type, an array class, or void. + */ + if (constructors.length == 0) { throw new RuntimeException("Illegal constructor: " + cls.getName()); } Constructor constructor = constructors[0];