>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: [EMAIL PROTECTED] >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: