java/5943: incorrect "Can't reassign a value to the final variable" error
shroff@transeda.com
shroff@transeda.com
Wed Mar 13 11:56:00 GMT 2002
>Number: 5943
>Category: java
>Synopsis: incorrect "Can't reassign a value to the final variable" error
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 13 11:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Saurin Shroff
>Release: GNU Java version 3.0.1 (sparc-sun-solaris2.8)
>Organization:
>Environment:
Sun/Solaris
>Description:
I get incorrect "Can't reassign a value to the final variable"
error for following core. Sun Java 1.1, 1.2 and 1.3 allows it.
//file: bug1.java
public abstract class bug1 {
public static final String m_os_name = System.getProperty("os.name");
public static final boolean m_unix_os;
static {
String ntos = "Windows NT";
if (m_os_name.equals(ntos)) {
m_unix_os = false;
} else {
m_unix_os = true;
}
}
}
Here is the log:
shroff@bert> gcj -v -C bug1.java
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.1/specs
Configured with: ../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld --enable-libgcj
Thread model: posix
gcc version 3.0.1
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.1/jc1 bug1.java -quiet -dumpbase bug1.java -g1 -version -fencoding=UTF-8 -fsyntax-only -femit-class-files -o /dev/null
GNU Java version 3.0.1 (sparc-sun-solaris2.8)
compiled by GNU C version 3.0.1.
bug1.java: In class `bug1':
bug1.java: In method `<clinit>()':
bug1.java:10: Can't reassign a value to the final variable `m_unix_os'.
m_unix_os = true;
^
1 error
>How-To-Repeat:
See the example in the report.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list