This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug libgcj/9866] static nested class refers to private member of outer class
- From: "pmladek at suse dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 9 Nov 2006 14:16:23 -0000
- Subject: [Bug libgcj/9866] static nested class refers to private member of outer class
- References: <bug-9866-4218@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from pmladek at suse dot cz 2006-11-09 14:16 -------
I still see the problem with gcj (GCC) 4.1.2 20061018 (prerelease) (SUSE
Linux).
It makes problems also with OpenOffice.org when the internally used hsqldb is
compiled and used with gcj/gij.
Note that it is really a bug. The java documentation says at
http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html:
--- cut ---
A nested class is a member of its enclosing class and, as such, has access to
other members of the enclosing class, even if they are declared private.
--- cut ---
There is another definition in the "Java Language Specification" at
http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6.1:
--- cut ---
Otherwise, if the member or constructor is declared private, then access is
permitted if and only if it occurs within the body of the top level class
(§7.6) that encloses the declaration of the member or constructor.
--- cut ---
Note that also C++ works this way. The OPOSITE problem is even mentioned in the
"Frequently reported non-bugs" at http://gcc.gnu.org/bugs.html#nonbugs_cxx:
--- cut ---
Nested classes can access private members and types of the containing class.
Defect report 45 clarifies that nested classes are members of the class
they are nested in, and so are granted access to private members of that class.
--- cut ---
--
pmladek at suse dot cz changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pmladek at suse dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9866