This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug java/16839] New: Final vars in switch generate compile error in anonymous class.


This valid java code generates a compile error.

public class finaltest {
    public void main(String args[]) {
        System.out.println("got to main");
        switch(23) {
        case 1:
            final String s = "x";
            break;
        case 2:
            new Runnable() {
                public void run() {
                    System.out.println("run");
                }
            };
            break;
        }
    }
}
 

C:\> \app\gcj\gcc-3.5\bin\gcj finaltest.java
finaltest.java: In class `finaltest':
finaltest.java: In method `finaltest.main(java.lang.String[])':
finaltest.java:13: error: Variable `s' may not have been initialized.
                          };
     ^
  1 error

C:\> gcj --version
gcj (GCC) 3.5.0 20040629 (experimental)
Copyright (C) 2004 Free Software Foundation, Inc.

-- 
           Summary: Final vars in switch generate compile error in anonymous
                    class.
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: beandz at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org
  GCC host triplet: Win2K


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16839


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]