public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: brian_252@yahoo.com
To: gcc-gnats@gcc.gnu.org
Subject: java/9866: static nested class refers to private member of outer class
Date: Wed, 26 Feb 2003 17:56:00 -0000 [thread overview]
Message-ID: <20030226175215.30936.qmail@sources.redhat.com> (raw)
>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:
reply other threads:[~2003-02-26 17:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030226175215.30936.qmail@sources.redhat.com \
--to=brian_252@yahoo.com \
--cc=gcc-gnats@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).