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

Reply via email to