From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4994 invoked by alias); 26 Feb 2003 17:56:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 4962 invoked by uid 71); 26 Feb 2003 17:56:00 -0000 Resent-Date: 26 Feb 2003 17:56:00 -0000 Resent-Message-ID: <20030226175600.4961.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, java-prs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, brian_252@yahoo.com Received: (qmail 30937 invoked by uid 48); 26 Feb 2003 17:52:15 -0000 Message-Id: <20030226175215.30936.qmail@sources.redhat.com> Date: Wed, 26 Feb 2003 17:56:00 -0000 From: brian_252@yahoo.com Reply-To: brian_252@yahoo.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: java/9866: static nested class refers to private member of outer class X-SW-Source: 2003-02/txt/msg01388.txt.bz2 List-Id: >Number: 9866 >Category: java >Synopsis: static nested class refers to private member of outer class >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: support >Submitter-Id: net >Arrival-Date: Wed Feb 26 17:56:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Brian DeRocher >Release: gcj-3.2, gij-3.2 >Organization: >Environment: GNU/Debian Linux (woody mostly) >Description: This bug comes from compiling ant-1.5.1, specifically ProjectHelperImpl.java. They create a nested static class. In the nested class, they make an explicit reference to the outer class. And finally they refer to a private member of the outer class. Here's a simplification of the code: public class PHI { public static void main( String args[] ) { PHI phi = new PHI(); RH rh = new RH( phi ); rh.setLocator( "TheHound" ); } private String locator; static class RH { PHI phi; public RH( PHI phi ) { this.phi = phi; } public void setLocator( String locator ) { phi.locator = locator; } } } brian@mahogany:Personal/Workshop/Test/ :) gcj -C PHI.java brian@mahogany:Personal/Workshop/Test/ :) gij PHI Exception in thread "main" java.lang.IllegalAccessError at 0x40174218: java.lang.Throwable.Throwable() (/usr/lib/libgcj.so.2) at 0x4016a7c4: java.lang.Error.Error() (/usr/lib/libgcj.so.2) at 0x4016c908: java.lang.LinkageError.LinkageError() (/usr/lib/libgcj.so.2) at 0x4016b6a4: java.lang.IncompatibleClassChangeError.IncompatibleClassChangeError() (/usr/lib/libgcj.so.2) at 0x4016b404: java.lang.IllegalAccessError.IllegalAccessError() (/usr/lib/libgcj.so.2) at 0x40149d5a: _Jv_ResolvePoolEntry(java.lang.Class, int) (/usr/lib/libgcj.so.2) at 0x401516f0: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.2) at 0x40152703: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.2) at 0x4014e671: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/libgcj.so.2) at 0x4023b114: ?? (??:0) at 0x4023b25f: ffi_call_SYSV (/usr/lib/libgcj.so.2) at 0x4023b227: ffi_raw_call (/usr/lib/libgcj.so.2) at 0x4014e8db: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.2) at 0x40152703: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.2) at 0x4014e671: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/libgcj.so.2) at 0x4023b114: ?? (??:0) at 0x4015565f: gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.2) at 0x4015fb63: java.lang.Thread.run_(java.lang.Object) (/usr/lib/libgcj.so.2) at 0x4023a6a4: ?? (??:0) at 0x403dff76: GC_start_routine (/usr/lib/libgcjgc.so.1) at 0x403f7fa5: ?? (??:0) at 0x4050c8ea: __clone (/lib/libc.so.6) In my personal opinion, i don't think this is a bug. The inner class does have access to the private members of the outer class, but this is through an implicit reference. Static classes don't have the implicit reference. The question is, what is the definied behavior of an explicit reference. So why do i report it? Because obviously other compilers have compiled and executed ProjectHelperImpl successfully. A related PR is 9369. Just hypothetically here, if the compiler does generate a function void setLocator( String Locator ) { this.Locator = Locator } in the outer class PHI, does this function become accessible to the public (or to subclasses)? I hope not, since this would change the definition of the class. >How-To-Repeat: gcj -C PHI.java gij PHI >Fix: If the outer data member is protected, there's no error. >Release-Note: >Audit-Trail: >Unformatted: