Closed Neiko2002 closed 8 years ago
Thank you for your input, we are working on addressing this issue.
Now you can define multiple types in AsmBuilder. Be sure to use the latest commit from master (acf2367).
You should pass main type (class or interface) as second argument and list of extra interfaces as third argument. As you can see in example below:
public interface A {
int a();
}
public interface B {
Integer b();
}
public interface C {
String c();
}
public void example() {
final DefiningClassLoader definingClassLoader = new DefiningClassLoader();
final A instance = new AsmBuilder<>(definingClassLoader, A.class, asList(B.class, C.class))
.method("a", value(42))
.method("b", value(43))
.method("c", value("44"))
.newInstance();
assertEquals(instance.a(), 42);
assertEquals(((B) instance).b(), Integer.valueOf(43));
assertEquals(((C) instance).c(), "44");
}
Thanks for the fast changes. Works for me so far.
Is it possible to define multiple types for the AsmBuilder? I've just started using codegen and was hoping to construct a new classes that implements two existing interfaces. But I can't find any methods for adding additional types to the AsmBuilder.