This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Method.invoke() on a non-public class from another package
- From: Andrew Haley <aph at gcc dot gnu dot org>
- To: Andrew Haley <aph at gcc dot gnu dot org>
- Cc: "Robert Lougher" <rob dot lougher at gmail dot com>, "Mark Wielaard" <mark at klomp dot org>, classpath at gnu dot org, java-patches at gcc dot gnu dot org
- Date: Tue, 10 Apr 2007 18:40:28 +0100
- Subject: Re: Method.invoke() on a non-public class from another package
- References: <1175899892.12305.55.camel@dijkstra.wildebeest.org> <1175982587.4504.37.camel@dijkstra.wildebeest.org> <1176029634.3239.0.camel@localhost.localdomain> <1176066768.4504.29.camel@dijkstra.wildebeest.org> <d58509a80704081441p7f0c6b0aqfbb14812b613cdf6@mail.gmail.com> <d58509a80704081500v23bb6688y23636b33b5d34b92@mail.gmail.com> <17945.26666.93912.441902@zebedee.pink> <d58509a80704081747r6a60fc13r37078db8710a2fca@mail.gmail.com> <d58509a80704081823j303aa772jf06b24b3382d7c38@mail.gmail.com> <17947.49382.769461.8563@zebedee.pink>
Andrew Haley writes:
> Robert Lougher writes:
>
> > Had a quick look, and in Classpath-0.93 java.util.AbstractMap contains
> > a class BasicMapEntry which implements getValue(). BasicMapEntry is
> > package-private. This isn't accessible outside the package.
> >
> > In CVS HEAD, this has changed and java.util.AbstractMap contains a
> > class SimpleEntry which implements getValue(). SimpleEntry is public.
> > Obviously, this is accessible...
>
> OK, thanks. I'm working on a gcj patch now.
Done.
Andrew.
2007-04-10 Andrew Haley <aph@redhat.com>
* java/lang/reflect/natMethod.cc (Method::invoke): In invoke also
check that the method's declaring class is accessible.
Index: natMethod.cc
===================================================================
*** natMethod.cc (revision 123473)
--- natMethod.cc (working copy)
***************
*** 173,182 ****
}
// Check accessibility, if required.
! if (! (Modifier::isPublic (meth->accflags) || this->isAccessible()))
{
Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$);
! if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags))
throw new IllegalAccessException;
}
--- 173,186 ----
}
// Check accessibility, if required.
! if (! ((Modifier::isPublic (meth->accflags)
! && Modifier::isPublic (declaringClass->accflags))
! || this->isAccessible()))
{
Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$);
! if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags)
! || ! _Jv_CheckAccess(caller, declaringClass,
! declaringClass->accflags))
throw new IllegalAccessException;
}