This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Tom Tromey writes:
 > > // p1/T151221am3c.java 
 > > package p1;
 > > abstract class T151221am3a {
 > >     abstract void m(); // note non-public accessibility
 > > }
 > > interface T151221am3b {
 > >     void m() throws Exception;
 > > }
 > > public abstract class T151221am3c extends T151221am3a implements T151221am3b {
 > >     // inherits 2 versions of m()
 > > }
 > 
 > > // T151221am3d.java
 > > abstract class T151221am3d extends p1.T151221am3c {
 > >     // a concrete subclass of c will necessarily have an implementation of m
 > >     // that does not throw, in order to implement a.m; but only b.m was
 > >     // inherited here because of accessibility. Since b.m throws, the catch
 > >     // clause is reachable
 > >     {
 > >         try {
 > >             m();
 > >         } catch (Exception e) {
 > >         }
 > >     }
 > > }
 > 
 > Andrew> m() in p1.T151221am3a can't implement m() in p1.T151221am3b
 > Andrew> because it is non-public.
 > 
 > Actually, T151221am3b.m() is implicitly public because it is declared
 > in an interface.

Yes, I know that.  The "it" is T151221am3a.m() in p1.  :-)

 > I think the code above, while twisted, is legal.

Okay.  I suppose it must be, given that it's a test case, older
versions of javac reject it, and newer versions allow it.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]