This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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 java/13098] accepts invalid code referencing package only constructor


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


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