java/9685: Illegal access to package-private method is allowed
rmathew@hotmail.com
rmathew@hotmail.com
Thu Feb 13 06:16:00 GMT 2003
>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:
More information about the Java-prs
mailing list