Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Logging JNI calls with AspectJ

Hi,

Is is possible to create a pointcut that intercepts native methods that
invoke non-java code through JNI?

I'd like to be able to put a logging aspect into an existing piece of code
that does lots of native invocations. Here's my aspect:

public aspect LogNativeAspect {

    private Logger LOGGER = Logger.getLogger("LogNativeAspect");

    pointcut traceMethods()
        : execution(*  *.*(..)) && !within(LogNativeAspect);

    before() : traceMethods() {

        Signature signature = thisJoinPointStaticPart.getSignature();

        if (Modifier.isNative(signature.getModifiers())) {
	      LOGGER.debug("Calling: " + signature.toLongString());
        }
    }
}

If I remove the conditional check on Modifier.isNative, then all other
method calls get logged. However, native methods don't get intercepted. Is
this supported?

Cheers,
Manish


--------------------------------------------------------------------------------
The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express
written permission of the sender. If you are not the intended recipient, please
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to 
http://www.drkw.com/disc/email/ or contact the sender. 3167
--------------------------------------------------------------------------------



Back to the top