This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/16839] New: Final vars in switch generate compile error in anonymous class.
- From: "beandz at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jul 2004 22:24:57 -0000
- Subject: [Bug java/16839] New: Final vars in switch generate compile error in anonymous class.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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