Latest build c572fa185d05 limitations
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Sat Sep 11 05:22:50 PDT 2010
The problem has nothing to do with try/catch - it is caused by using
'int' as explicit type - if you replace it with Integer it works...
Thanks for the report.
Maurizio
On 11/09/10 06:18, Howard Lovatt wrote:
> Hi,
>
> Using my usual source:
>
> 143: final IntList11 il = new IntList11();
> 144: out.println( il );
> 145: il.forEach( #( int i ) { 2 * i } ); // No exception; no try
> block - needs type parameter
> 146: out.println( il );
>
> Gives:
>
> Exception in thread "main" java.lang.VerifyError: Bad local variable
> type in method lambdas.Main$9.call(Ljava/lang/Integer;)Ljava/lang/Integer;
> at offset 1
> at lambdas.Main.exceptionTransparency(Main.java:145)
> at lambdas.Main.main(Main.java:24)
>
> But:
>
> try {
> il.forEach( #( int i ) {
> if ( i< 4 ) { throw new Exception(); }
> return i * i;
> } ); // Need to catch the checked exception!
> } catch ( final Throwable notUsed ) {
> out.println( "Exception caught 1" );
> }
> out.println( il );
>
> Works!
>
> And:
>
> il.forEach( #( i ) { 2 * i } );
>
> Requires a try catch block (as before) and:
>
> il.forEach( #( Integer i ) { 2 * i } );
>
> Works.
>
> Great to see such regular updates into the repository,
>
> -- Howard.
>
>
More information about the lambda-dev
mailing list