java/8432: Misleading error message for undeclared variable in inner class
jmr@ugcs.caltech.edu
jmr@ugcs.caltech.edu
Sat Nov 2 17:36:00 GMT 2002
>Number: 8432
>Category: java
>Synopsis: Misleading error message for undeclared variable in inner class
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Nov 02 17:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Jesse Rosenstock
>Release: 3.3 20021101 (experimental)
>Organization:
>Environment:
System: Linux churchill 2.4.3-12 #1 Fri Jun 8 15:05:56 EDT 2001 i686 unknown
Architecture: i686
<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/home/user/jmr/app/gcc --enable-languages=c++,java --enable-threads=posix --enable-shared --with-as=/home/user/jmr/app/binutils/bin/as --with-ld=/home/user/jmr/app/binutils/bin/ld : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured) : (reconfigured)
>Description:
If a variable isn't declared in an inner class, an error message is issued saying that the local variable must be declared final. It would be better to say that the variable is undeclared.
>How-To-Repeat:
; cat InnerStaticFinal.java
public class InnerStaticFinal {
private static final class Inner extends Base {
private Inner () {
super (foo);
}
}
}
; cat Base.java
public class Base {
public Base (Object o) {
}
}
; gcj Base.java InnerStaticFinal.java
InnerStaticFinal.java: In class `InnerStaticFinal$Inner':
InnerStaticFinal.java: In constructor `()':
InnerStaticFinal.java:4: error: Local variable `foo' can't be accessed from within the inner class `InnerStaticFinal$Inner' unless it is declared final.
super (foo);
^
1 error
; javac Base.java InnerStaticFinal.java
InnerStaticFinal.java:4: cannot resolve symbol
symbol : variable foo
location: class InnerStaticFinal.Inner
super (foo);
^
1 error
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="InnerStaticFinal.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="InnerStaticFinal.java"
cHVibGljIGNsYXNzIElubmVyU3RhdGljRmluYWwgewogICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwg
Y2xhc3MgSW5uZXIgZXh0ZW5kcyBCYXNlIHsKICAgICAgICBwcml2YXRlIElubmVyICgpIHsKICAg
ICAgICAgICAgc3VwZXIgKGZvbyk7CiAgICAgICAgfQogICAgfQp9Cg==
More information about the Gcc-bugs
mailing list