I want to ignore the instrumentation for methods which are abstract to source class and target object but if it is abstract method for source alone then i would like to call the equivalent method on target object. Currently i am using this
adapter = new ByteBuddy().subclass(source.class)
.method(ElementMatchers.isAbstract())
.intercept(MethodCall.invokeSelf().on(target).withAllArguments()).make()
.load(clazz.getClassLoader(),ClassLoadingStrategy.Default.INJECTION).getLoaded().newInstance()
but getting these kind of exceptions The abstract methods which does not have implementation neither in source class nor in target object is failing with below error.
Cannot invoke public abstract java.lang.Object java.sql.Wrapper.unwrap(java.lang.Class) throws java.sql.SQLException on public static volatile java.lang.Class com.demo.Source$ByteBuddy$f7N2VK0l.invocationTarget$fl948k0
Can I achieve any one of the below scenario if the method is abstract in both cases?
- Ignore instrumentation for abstract methods which does not have implementation in both source and target.
- Redirect unmatched method to a default method.