lambda and MethodHandles in current prototype
Peter Levart
peter.levart at gmail.com
Sun Nov 20 13:19:34 PST 2011
On Sunday, November 20, 2011 08:35:59 PM Brian Goetz wrote:
> Ignore everything having to do with the compilation strategy (and any
> consequent performance considerations) for the time being. It is
> completely temporary, just enough to make things work while the language
> runtime is catching up with the compiler.
>
> The final specification will allow great latitude to the language
> runtime to construct the instance however it wants: dynamically spun
> inner classes, wrapper classes around method handles, dynamic proxies,
> method handle proxies, or other as yet unknown mechanisms. And to
> change it as often as it feels like. So the behavior of your test
> program will be completely implementation-dependent, and could even
> change from run to run.
>
> You seem to be imploying that it is beneficial to specify the behavior
> more tightly. Why is this good? Is is simply that you want to know
> whether an object is the result of a lambda expression (and if so, what
> would you do with this information?), or something more?
No, I was just wondering whether the implementation philosophy has changed sice last time I checked.
And now that I have checked, ...
... I found your presentation at: http://www.wiki.jvmlangsummit.com/images/1/1e/2011_Goetz_Lambda.pdf
and I can see what the philosophy is.
Just a question: Is current prototype already using this "MetaFactory" to construct converted objects? Is this "MetaFactory" pluggable if one wants to experiment with different strategies? Just curious.
Regards, Peter
>
> On 11/20/2011 1:58 PM, Peter Levart wrote:
> > I tried the prototype in binary distribution and was surprised that the following code:
> >
> > import java.lang.invoke.MethodHandleProxies;
> > import java.util.functions.IntOperator;
> >
> > public class Test
> > {
> > static int sum(int a, int b)
> > {
> > return a + b;
> > }
> >
> > public static void main(String[] args)
> > {
> > IntOperator sum1 = (a, b) -> a + b;
> > IntOperator sum2 = Test#sum;
> >
> > System.out.println(MethodHandleProxies.isWrapperInstance(sum1));
> > System.out.println(MethodHandleProxies.isWrapperInstance(sum2));
> > }
> > }
> >
> >
> > prints:
> >
> > false
> > false
> >
> >
> > Has the compilation strategy changed? Aren't MethodHandles used any more or are they still, but the conversion to functional interfaces doesn't use MethodHandleProxies.asInterfaceInstance()? Are there any plans for the above code to print true/true (or at least false/true)?
> >
> > Regards,
> >
> > Peter
> >
>
More information about the lambda-dev
mailing list