You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import com.expediagroup.beans.BeanUtils
data class BeanFrom(
val foo: String
)
data class BeanTo(
val foo: String = "bar"
)
val beanFrom = BeanFrom("bar")
val beanTo: BeanTo = BeanUtils().transformer.transform(beanFrom, BeanTo::class.java)
This throws:
com.expediagroup.transformer.error.InvalidBeanException: Constructor's parameters name have been removed from the compiled code. This caused a problems during the: BeanTo injection. Consider to use: @ConstructorArg annotation: https://github.com/ExpediaGroup/bull#different-field-names-defining-constructor-args or add the property: <parameters>true</parameters> to your maven-compiler configuration
at com.expediagroup.beans.transformer.TransformerImpl.handleInjectionException(TransformerImpl.java:201)
at com.expediagroup.beans.transformer.TransformerImpl.injectValues(TransformerImpl.java:164)
at com.expediagroup.beans.transformer.TransformerImpl.handleInjectionException(TransformerImpl.java:188)
at com.expediagroup.beans.transformer.TransformerImpl.injectValues(TransformerImpl.java:164)
at com.expediagroup.beans.transformer.TransformerImpl.injectValues(TransformerImpl.java:134)
at com.expediagroup.beans.transformer.TransformerImpl.transform(TransformerImpl.java:69)
at com.expediagroup.beans.transformer.AbstractBeanTransformer.transform(AbstractBeanTransformer.java:124)
at Line_4.<init>(Line_4.kts:1)
Caused by: com.expediagroup.transformer.error.InstanceCreationException
at com.expediagroup.transformer.utils.ClassUtils.getInstance(ClassUtils.java:548)
at com.expediagroup.beans.transformer.TransformerImpl.injectValues(TransformerImpl.java:162)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at com.expediagroup.transformer.utils.ClassUtils.getInstance(ClassUtils.java:546)
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method Line_2$BeanTo.<init>, parameter foo
at Line_2$BeanTo.<init>(Line_2.kts)
at Line_2$BeanTo.<init>(Line_2.kts:1)
The initial message is probably misleading. What happens here is that Kotlin creates an additional constructor with two more parameters (an int and a kotlin.jvm.internal.DefaultConstructorMarker), and BULL assumes that's the "all args" one.
That fails due to receiving the wrong number of arguments, and so BULL falls back to using the no args constructor and injecting fields.
But the no args constructor cannot be used, because the class expects a non-null value for its only field, and that yields the last exception you can see in the stack trace.
The text was updated successfully, but these errors were encountered:
Sample code:
This throws:
The initial message is probably misleading. What happens here is that Kotlin creates an additional constructor with two more parameters (an
int
and akotlin.jvm.internal.DefaultConstructorMarker
), and BULL assumes that's the "all args" one.That fails due to receiving the wrong number of arguments, and so BULL falls back to using the no args constructor and injecting fields.
But the no args constructor cannot be used, because the class expects a non-null value for its only field, and that yields the last exception you can see in the stack trace.
The text was updated successfully, but these errors were encountered: