{"record":{"id":"f78d108dd27bd00c","repo":"chinabugotech/hutool","slug":"no-constructor-provided","errorCode":null,"errorMessage":"No constructor provided","messagePattern":"No constructor provided","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hutool-aop/src/main/java/cn/hutool/aop/proxy/CglibProxyFactory.java","lineNumber":61,"sourceCode":"\t\tClass<?>[] parameterTypes;\n\t\tObject[] values;\n\t\tIllegalArgumentException finalException = null;\n\t\tfor (final Constructor<?> constructor : constructors) {\n\t\t\tparameterTypes = constructor.getParameterTypes();\n\t\t\tvalues = ClassUtil.getDefaultValues(parameterTypes);\n\n\t\t\ttry {\n\t\t\t\treturn (T) enhancer.create(parameterTypes, values);\n\t\t\t} catch (final IllegalArgumentException e) {\n\t\t\t\t//ignore\n\t\t\t\tfinalException = e;\n\t\t\t}\n\t\t}\n\t\tif (null != finalException) {\n\t\t\tthrow finalException;\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"No constructor provided\");\n\t}\n}\n","sourceCodeStart":43,"sourceCodeEnd":64,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-aop/src/main/java/cn/hutool/aop/proxy/CglibProxyFactory.java#L43-L64","documentation":"Thrown by CglibProxyFactory.create only when the target class exposes zero constructors to ReflectUtil.getConstructors AND no IllegalArgumentException was captured during iteration. In the normal failure case (all constructors rejected by enhancer.create) the LAST IllegalArgumentException is rethrown instead, so this literal message specifically indicates an empty constructor set -- i.e. the target is not a normal instantiable class (array, interface, primitive, or a synthetic type with no declared constructors).","triggerScenarios":"Calling SimpleAspect<T>.proxy (or ProxyUtil) on an array type, a primitive wrapper with no accessible constructor, an interface (should use JDK dynamic proxy instead), or a JVM-generated/synthetic class whose getDeclaredConstructors returns nothing. Also reachable if ReflectUtil.getConstructors filters out all constructors of the target.","commonSituations":"Accidentally proxying a Class object, an array, or an interface instead of a concrete class; passing a lambda/synthetic proxy; reflective environments that hide constructors.","solutions":["Ensure the target is a concrete, non-final class with at least one constructor.","For interfaces, use a JDK dynamic proxy (ProxyUtil / Proxy.newProxyInstance) instead of cglib.","Do not proxy arrays, primitives, or synthetic proxy classes.","If the class genuinely has constructors but they are filtered, review ReflectUtil.getConstructors behavior / access rules."],"exampleFix":"// before\nSomeInterface proxy = new SimpleAspect<>(someImpl).proxy();\n// or passing an array / interface -> No constructor provided\n\n// after -- proxy a concrete class with cglib, or use JDK proxy for interfaces\nConcreteImpl impl = new ConcreteImpl();\nConcreteImpl proxy = ProxyUtil.proxy(impl, new Aspect() { /*...*/ });","handlingStrategy":"type-guard","validationCode":"// Reject non-instantiable targets before proxying\nClass<?> c = target.getClass();\nif (c.isArray() || c.isInterface() || c.isPrimitive() || c.isEnum()\n    || java.lang.reflect.Modifier.isAbstract(c.getModifiers())) {\n    throw new IllegalArgumentException(\"cannot cglib-proxy \" + c);\n}\nif (c.getDeclaredConstructors().length == 0) {\n    throw new IllegalArgumentException(\"no constructors on \" + c);\n}","typeGuard":"static boolean isCglibProxyable(Object target) {\n    if (target == null) return false;\n    Class<?> c = target.getClass();\n    return !c.isInterface() && !c.isArray() && !c.isPrimitive()\n        && !Modifier.isFinal(c.getModifiers())\n        && c.getDeclaredConstructors().length > 0;\n}","tryCatchPattern":"try {\n    return ProxyUtil.proxy(target, aspect);\n} catch (IllegalArgumentException e) {\n    if (\"No constructor provided\".equals(e.getMessage())) {\n        // target is interface/array/primitive/synthetic -> switch to JDK dynamic proxy\n    }\n    throw e;\n}","preventionTips":["Proxy concrete non-final classes only with cglib.","Use JDK dynamic proxies for interface targets.","Never pass arrays, primitives, enums, or abstract classes to the cglib factory."],"tags":["aop","cglib","proxy","reflection"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}