Question

is it possible to support this solution using cglib?

interface I { 
void foo(); 
void boo(); 
}

abstract class B implements I { 
  foo();
}

abstract class C implements I { 
  boo();
}

abstract class D extends B {

}

The code

D d = new D();
d.foo();
d.boo();
Was it helpful?

Solution

Yes, that is no problem for CgLib. I have even tried to do it and it was a no problem for me. I use cglib-nodep-2.1_3.jar.

If you want to d.boo(); to do nothing I see no problem here.

If you would like to implement something like Java8 default methods there is a little more tricky with passing a state of an object.

The only different is that you need to create an object by Enhancer. If you want to change how "new D();" behaves you should try AspectJ. I think its possible to make it work with AspectJ, but eclipse compliator will always give you problem. its should be possible to ignore compiler errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top