This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcj/9866] static nested class refers to private member of outer class



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]