Bugs in new push

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sun Oct 24 03:39:11 PDT 2010


See comments below:

On 24/10/10 11:17, Maurizio Cimadamore wrote:
> Thanks for the report, I will look into that.
>
> Maurizio
>
> On 24/10/10 05:55, Ali Ebrahimi wrote:
>    
>> *Hi **Maurizio,*
>> *
>> *
>> *After new push the following test that already passed successfully, now
>> have a few compile error.*
>> *1)*
>> *
>>           final Runnable r1 =#
>>           {
>>               System.out.println("Start")
>>           };
>>           r1.run();
>>
>>       Error:Error:line (67)variable r1 might already have been assigned
>>      

This works now - I fixed this in the latest push
>> 2)
>>
>>           final Runnable r2 =#
>>           {
>>               int sum = 0;
>>               for (int i = 1; i<= 4; i++) {
>>                   sum += i;
>>               }
>>               out.println("Sum 4 = " + sum);
>>           }
>>           ;
>>           r2.run();
>>       Error:Error:line (76)local variable i cannot be referenced
>>       Error:Error:line (77)local variable sum cannot be referenced
>>      
I need to fix this - I cleaned up some code in the effectively final 
analysis, and I probably ended up messing up something, as the compiler 
now complains also for local variables declared *inside* the closure, 
which is obviously not intended.
>> 3)
>>
>>           final IntList11 il = new IntList11();
>>           out.println(il);
>>
>>
>>           il.forEach( #
>>           { i ->     return i+0;
>>           });
>>       Error:Error:line (181)unreported exception Exception; must be caught or
>> declared to be thrown
>>      

This doesn't seem a regression from the latest set of changes - I 
reverted the compiler back and tried to compile this:

interface Function<R,A,throws X> {
R f(A a) throws X;
}

class List<E> {
<throws X> E forEach(Function<E,E,X> a) throws X { return null; }
}

class Test {
{
         final List<Integer> il = new List<>();
         System.out.println(il);

         il.forEach( #(i)
         {   return i+0;
         });
}
}

Which fails in the same way. The current inference scheme goes nuts when 
it sees 'i + 0', causing exception types not to be inferred from the 
lambda body (see related warning).

Maurizio

>> I compiled the test with my build after getting latest changes.
>> I attached full test to my mail.
>>
>>
>> Best Regards
>> Ali Ebrahimi
>> *
>>
>>
>>
>>
>>
>>      
>
>    



More information about the lambda-dev mailing list