gcj/243: "protected" field access not restricted between packages

bryce@albatross.co.nz bryce@albatross.co.nz
Thu May 25 22:16:00 GMT 2000


>Number:         243
>Category:       gcj
>Synopsis:       "protected" field access not restricted between packages
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 25 22:16:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Bryce McKinlay
>Release:        unknown-1.0
>Organization:
>Environment:
gcc version 2.96 20000525 (experimental)
>Description:
A "protected" field in anything other than "this" should 
not be accessible to a class outside the current instance,
if it is declared in another package (even if the current
class is a subclass of the declaring class)

gcj incorrectly permits the following code:

// file: pkg1/A.java
package pkg1;
public class A 
{
  protected int i;
}

// file: pkg2/B.java
package pkg2;
public class B extends pkg1.A 
{
  public B(pkg1.A a)
  {
    int i = a.i;
  }  
}

Note that this code is still incorrectly accepted even if 
the "extends pkg1.A" is removed.
>How-To-Repeat:
Compile the above test case.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Java-prs mailing list