This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
java/9685: Illegal access to package-private method is allowed
- From: rmathew at hotmail dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 13 Feb 2003 06:14:55 -0000
- Subject: java/9685: Illegal access to package-private method is allowed
- Reply-to: rmathew at hotmail dot com
>Number: 9685
>Category: java
>Synopsis: Illegal access to package-private method is allowed
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Thu Feb 13 06:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: rmathew@hotmail.com
>Release: 3.3
>Organization:
>Environment:
>Description:
GCJ 3.3 seems to allow a class to access the package-private
methods of a different class even though this is not
permitted by the JLS.
Here's a simple testcase:
------------------- File: foo/Bar.java --------------------
package foo;
public class Bar {
static void snafu( ) { }
}
---------------------------- 8< ----------------------------
------------------- File: ChkAcc.java ----------------------
public class ChkAcc {
public void checkAccess( ) { foo.Bar.snafu( ); }
}
---------------------------- 8< ----------------------------
GCJ wrongly allows ChkAcc.java to compile successfully.
Note that this works with non-static methods as well.
It also works if a class in a named package accesses
package-private methods in the anonymous "default"
package.
Ranjit.
>How-To-Repeat:
gcj -C foo/Bar.java
gcj -C ChkAcc.java
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: