From mboxrd@z Thu Jan 1 00:00:00 1970 From: bryce@albatross.co.nz To: gcc-gnats@gcc.gnu.org Subject: java/1958: Incorrect error message attempting to access non-final local from local class Date: Sun, 01 Apr 2001 00:00:00 -0000 Message-id: <20010213065256.12481.qmail@sourceware.cygnus.com> X-SW-Source: 2001-q1/msg01193.html List-Id: >Number: 1958 >Category: java >Synopsis: Incorrect error message attempting to access non-final local from local class >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Feb 12 22:56:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Bryce McKinlay >Release: gcc version 2.97 20010207 (experimental) >Organization: >Environment: >Description: The code below is illegal because x is non final in Local2.a(). gcj reports: $ gcj -c Local2.java Local2.java: In class `Local2$I': Local2.java: In method `Local2$I.b()': Local2.java:8: Undefined variable `x'. int b() {return x;}; ^ 1 error but the correct error (as reported by javac) is: Local2.java:8: local variable x is accessed from within inner class; needs to be declared final >How-To-Repeat: public class Local2 { void a() { int x; class I { int b() {return x;}; } } } >Fix: >Release-Note: >Audit-Trail: >Unformatted: