This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/13098] accepts invalid code referencing package only constructor
- From: "s28patel at student dot math dot uwaterloo dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Nov 2003 09:41:00 -0000
- Subject: [Bug java/13098] accepts invalid code referencing package only constructor
- References: <20031118055037.13098.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From s28patel at student dot math dot uwaterloo dot ca 2003-11-18 09:40 -------
Some more thoughts on this problem...
If a constructor has no access specifier, "... there is default access, which is
permitted only when the access occurs from within the package in which the type
is declared," so in this case access should not be permitted (section 6.6.1 in
the Java Language Specification 2nd ed. available at
http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html).
Sun's compiler and IBM's jikes compiler do not compile the code, yet gcj does
compile it.
gij throws an an IllegalAccessError when running the improperly compiled code,
but oddly both Microsoft's VM and Sun's VM run it without error (the constructor
is actually executed). It seems to me that this this is a problem with Sun's VM
and Microsoft's VM, and could possibly cause of incompatibilities.
For example what if someone developed a Java program with gcj that accidently
accesses a constructor with default access from outside the package (which is
technically illegal)? Then the bytecode would run fine on Sun's VM or
Microsoft's VM, but would fail if run with gij, and users might think gij has a bug.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13098