Hi all,

I am looking for a solution to the following problem... I have an interface and an object that is supposed to serve as implementation, but does not implement the interface. n methods of the interface will be redirected to the object, but in case of default methods I would like to have the implementation provided by the interface. I am looking especially for a solution without me generating classes at runtime by hand.

Now there are several problems... I seem not to be able to invoke a default method by reflection. By MethodHandles I did something like this:

      MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, int.class).
      newInstance(interfaceClass, MethodHandles.Lookup.PRIVATE).
      unreflectSpecial(method, interfaceClass).
      bindTo(receiver);

where receiver is a dynamic proxy, method the Method of the default method, interfaceClass the Class of the interface with the default method.

But I am calling a private constructor here, which is bad, plus the above procedure does no longer work on JDK9.

So what am I supposed to do? change from a proxy to runtime generated classes and hope the best for classloaders and modules not getting in my way?

bye Jochen
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to