DATACMNS-1170 - Fallback to default constructor discovery for Kotlin classes without primary constructor.
We now fall back to default preferred constructor discovery if a Kotlin class has no primary constructor and no preferred constructor is resolved. Previously, primary constructor resolution yielded no result (returned null) which caused the subsequent Java constructor lookup to fail. Original pull request: #244.
This commit is contained in:
committed by
Oliver Gierke
parent
93c65c02fe
commit
041c18bef9
@@ -166,6 +166,11 @@ public interface PreferredConstructorDiscoverer<T, P extends PersistentProperty<
|
||||
|
||||
KFunction<T> primaryConstructor = KClasses
|
||||
.getPrimaryConstructor(JvmClassMappingKt.getKotlinClass(type.getType()));
|
||||
|
||||
if (primaryConstructor == null) {
|
||||
return DEFAULT.discover(type, entity);
|
||||
}
|
||||
|
||||
Constructor<T> javaConstructor = ReflectJvmMapping.getJavaConstructor(primaryConstructor);
|
||||
|
||||
return javaConstructor != null ? buildPreferredConstructor(javaConstructor, type, entity) : null;
|
||||
|
||||
Reference in New Issue
Block a user