Feedback and comments on ARM proposal - resend

Howard Lovatt howard.lovatt at iee.org
Wed Mar 18 01:09:12 PDT 2009


Neal,

java 6 on a Mac catches your example - it says you can't assign to a
final variable.

Is the Mac javac correct?

Howard.

2009/3/18 Neal Gafter <neal at gafter.com>:
> On Tue, Mar 17, 2009 at 9:50 PM, Howard Lovatt <howard.lovatt at iee.org> wrote:
>>> Agreed, though there is one context in which it is possible to jump
>>> into the scope of a local variable declaration without "executing" the
>>> declaration: the switch statement.
>>
>> I thought this was only in C/C++ and Java had plugged this hole - I
>> guess I am wrong - do you have an example.
>
> Below, in the form of a puzzler.  What does the program print?  If you
> remove "final", does the answer change?
>
> import java.io.*;
> class T {
>    public static void main(String[] args) {
>        switch (args.length) {
>        case 0:
>            final int i = 0; // a constant variable
>            break;
>        case 1:
>            i = 1; // i is not definitely assigned here, so we assign to it
>            System.out.println(i); // i is constant, so prints 0? 1?
>            break;
>        }
>    }
> }
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>



More information about the coin-dev mailing list