hg: lambda/lambda/langtools: Bug fixes:

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Aug 30 01:35:12 PDT 2010


On 30/08/10 01:55, Howard Lovatt wrote:
> Hi Maurizio,
>
> Latest push is great progress. I particularly like that:
>
>        il.forEach( #( notUsed ) { throw new Exception(); } ); // Need
> to catch the checked exception!
>
> now works; but note that it has to be statement (i.e. ; required), any
> chance of eliminating the semi-colon?
>    
Not sure - the idea is that the body of a lambda can be either an 
expression (w/o terminating semi) or a statement (one or more, 
terminated by semi). In case of a method call, since a method call is an 
expression statement, you can have both the semi-terminated and the 
non-semi-terminated options; in the case of 'throw' which is a plain 
statement, I think your only option is to use a terminating semi-colon.
> The latest push has a regression:
>
> 88:    // Method References, syntax like Javadoc
> 89:    final ActionListener al4 = Main#print( ActionEvent );
> 90:    b1.addActionListener( al4 );
> 91:    b1.doClick();
>
> This compiles, but when run I get:
>
> Exception in thread "main" java.dyn.WrongMethodTypeException:
> (Ljava/dyn/MethodHandle;Ljava/awt/event/ActionEvent;)V cannot be
> called as (Ljava/dyn/MethodHandle;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
> 	at sun.dyn.FromGeneric$A2.invoke_I2(FromGeneric.java:533)
> 	at java.dyn.MethodHandle.invokeVarargs(MethodHandle.java:332)
> 	at com.sun.runtime.ProxyHelper$1.invoke(ProxyHelper.java:61)
> 	at $Proxy0.actionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2015)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2338)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
> 	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
> 	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
> 	at javax.swing.AbstractButton.doClick(AbstractButton.java:356)
> 	at lambdas.Main.lambdas(Main.java:91)
> 	at lambdas.Main.main(Main.java:22)
>    
Damn :-)
thanks again for the feedback!
> Note that:
>
>      // Method References, syntax like Javadoc
>      final ActionListener al4 = Main#print( ActionEvent );
>      b1.addActionListener( al4 );
> //    b1.doClick();
>      b1.removeActionListener( al4 );
>
> Now runs OK (thanks), i.e. the remove now works (the error above is
> caused when doClick runs).
>
>    
Maurizio
> Cheers,
>
>    -- Howard.
>    



More information about the lambda-dev mailing list