diff --git a/core/src/main/java/com/alibaba/fastjson2/util/KotlinUtils.java b/core/src/main/java/com/alibaba/fastjson2/util/KotlinUtils.java index 755973137508df874b276c3c9847e6cffcd20e98..54ac6976d3c2dfccf2e9ac4537c3da12eb4bf701 100644 --- a/core/src/main/java/com/alibaba/fastjson2/util/KotlinUtils.java +++ b/core/src/main/java/com/alibaba/fastjson2/util/KotlinUtils.java @@ -102,6 +102,13 @@ public class KotlinUtils { } catch (Throwable e) { // Ignore this exception } + } else if (creatorParams != 0 && beanInfo.createParameterNames == null) { + System.err.println("fastjson2 warning: class " + clazz.getName() + + " is a Kotlin class with constructor parameters, " + + "but kotlin-reflect is not on the classpath. " + + "Constructor parameter names cannot be resolved, " + + "which will cause deserialization to silently lose field values. " + + "Add org.jetbrains.kotlin:kotlin-reflect to your dependencies."); } beanInfo.creatorConstructor = creatorConstructor;