Review request for 7198429: need checked categorization of caller-sensitive methods in the JDK

Mandy Chung mandy.chung at oracle.com
Tue Apr 2 22:25:08 UTC 2013


On 4/2/13 3:00 PM, Peter Levart wrote:
> Hi Mandy,
>
> There could be:
>
> public class SM1 extends SecurityManager {
>     @Override
>     public void checkMemberAccess(Class<?> clazz, int which) {...
>
> and:
>
> public class SM2 extends SM1 { ... // no checkMemberAccess override
>
> now if if you take SM2.class.getDeclaredMethod("checkMemberAccess", 
> ...) it will throw NoSuchMethodException, but the method is overriden in
> SM1. So I think it's better to use what John suggested (although not 
> using getDeclaredMethod, but getMethod instead):
>
> smgr.getClass().getMethod("checkMemberAccess", 
> ...).getDeclaringClass() == SecurityManager.class

Are you concerned the overhead of an exception thrown that we should avoid?

Mandy



More information about the core-libs-dev mailing list