[Patch] PR java/9685: Fix Catching Illegal Access to Package-Private Fields/Members

Ranjit Mathew rmathew@gmail.com
Thu Apr 22 13:16:00 GMT 2004


Andrew Haley wrote:
> Ranjit Mathew writes:
>  > 
>  >   15.12.2.1-accessibility-method-3 PASSED
>  >   15.12.2.1-accessibility-method-5 PASSED
                                        ^^^^^^
Sorry, I should clarify that these are remanants
from my botched attempt to cut-paste the testcase
names from the log diffs - these cases really FAIL
with the patched GCJ, as could be made out from
the context.


> Javac says:
> 
> ./p1/T151221am3c.java:8: m() in p1.T151221am3a cannot implement m() in p1.T151221am3b; attempting to assign weaker access privileges; was public
> public abstract class T151221am3c extends T151221am3a implements T151221am3b {
>                 ^
> 1 error

Huh? With Sun's JDK 1.4.2.03 on Linux, this compiles
just fine (I compiled T151221am3d.java, just to clarify).

Perhaps you're using an older/buggier JDK?


> What does the patched gcj say?

----------------------------- 8< -----------------------------
$ ~/gcc/bin/gcj -C T151221am3d.java
T151221am3d.java: In class `T151221am3d':
T151221am3d.java: In method `instinit$(T151221am3d)':
T151221am3d.java:9: error: Can't access package-private method `p1.T151221am3a.m' from `T151221am3d'.
            m();
               ^
1 error
----------------------------- 8< -----------------------------

Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT gmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/



More information about the Java-patches mailing list