It is necessary to describe the structure of this class
class A{
private List<A> listA;
}
tried the solution: Byte-buddy: generate classes with cyclic types
but it will lead to an error
java.lang.ExceptionInInitializerError Caused by: java.lang.IllegalStateException: Cannot resolve declared type of a latent type description:...
You can use TargetType
as a reference for the currently generated type:
new ByteBuddy()
.subclass(Object.class)
.name("A")
.defineField("listA",
TypeDescription.Generic.Builder.parameterizedType(
List.class, TargetType.class).build(),
Visibility.PRIVATE)
.make()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With