"All problems in computer science can be solved by another level of
indirection"... "except for the problem of too many layers of indirection".

What about (untested):

Consumer proxy = Proxy.newProxyInstance(...);
Consumer myConsumer = proxy::accept;

If you keep the proxy inaccessible, nobody will ever call andThen on it.

Or am I missing something obvious?

Cheers,
Alessio

On Mon, Oct 6, 2014 at 6:06 PM, Jochen Theodorou <blackd...@gmx.org> wrote:

> Hi,
>
> I find this a little odd and I wonder how you are supposed to do it right.
> Or if that is a bug.
>
> So I have a class implementing InvocationHandler and I used Proxy to
> create a an proxied instance of Consumer. This is a functional interface
> and I want to use its accept method for my purposes, while still keeping
> the old andThen method as it is.
>
> going by the usual signature for the InvocationHandler implementation main
> method (public Object invoke(Object proxy, Method method, Object[] args)
> throws Throwable)
>
> I can do neither method.invoke on this, since that leads to that method
> (overflow then) again, nor can I take the proxy object, since it obviously
> has nothing to do with functional interface.
>
> Now... is that really on purpose? Are you indeed forced to split up your
> code into a java7+ and pre java7 case to be able to use 
> MethodHandleProxies#asInterfaceInstance
> where it is available instead? Shouldn't Proxy and InvocationHandler then
> be marked deprecated in Java8? And how do you use MethodHandleProxies to
> implement multiple interfaces?
>
> bye Jochen
>
> --
> Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
> blog: http://blackdragsview.blogspot.com/
> german groovy discussion newsgroup: de.comp.lang.misc
> For Groovy programming sources visit http://groovy-lang.org
>
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev@openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to