java/2361: Cannot acces protected field of superclass in a different package
mark@klomp.org
mark@klomp.org
Fri Mar 23 07:06:00 GMT 2001
>Number: 2361
>Category: java
>Synopsis: Cannot acces protected field of superclass in a different package
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 23 07:06:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: mark@klomp.org
>Release: gcc version 3.0 20010323 (powerpc) and gcc version 3.1 20010323 (i586)
>Organization:
>Environment:
>Description:
Accessing a protected field from a superclass in a different package fails when you try to access it through a different instance. For example try the following:
package pkg;
public class C {
protected int p = 16;
}
class Test extends pkg.C {
void test() {
Test test = new Test();
int i = p; // this succeeds
int j = test.p; // this should also be possible
}
}
package pkg;
public class C {
protected int p = 16;
}
$ gcj -C Test.java pkg/C.java
Test.java: In class `Test':
Test.java: In method `Test.test()':
Test.java:5: Can't access protected field `Test.p' from `Test'.
int j = test.p;
^
1 error
Compiling first with jikes to class files and then compiling the class files to o files with gcj does work.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list