如何在 byte-buddy 中创建参数化 class?
How to create parametrized class in byte-buddy?
如何在byte-buddy中创建参数化class?
例如:
static public class SomeClass < T > {
T value;
}
Class<?> dynamicType = new ByteBuddy()
.subclass(Object.class)
.defineField("value", ???, Modifier.PUBLIC)
.make()
.load(Main.class.getClassLoader())
.getLoaded();
简单如:
new ByteBuddy().subclass(Object.class)
.typeVariable("T")
.defineField("value", TypeDescription.Generic.Builder.typeVariable("T").build(), Modifier.PUBLIC);
如何在byte-buddy中创建参数化class? 例如:
static public class SomeClass < T > {
T value;
}
Class<?> dynamicType = new ByteBuddy()
.subclass(Object.class)
.defineField("value", ???, Modifier.PUBLIC)
.make()
.load(Main.class.getClassLoader())
.getLoaded();
简单如:
new ByteBuddy().subclass(Object.class)
.typeVariable("T")
.defineField("value", TypeDescription.Generic.Builder.typeVariable("T").build(), Modifier.PUBLIC);