java/1261: "protected" field access not restricted between packages

bryce@albatross.co.nz bryce@albatross.co.nz
Wed Dec 20 12:23:00 GMT 2000


>Number:         1261
>Category:       java
>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:   Wed Dec 20 12:18:25 PST 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:

Formerly PR gcj/243

>Unformatted:



More information about the Gcc-prs mailing list