Let's say I have a native method called "doSomething()" and there is other code written by other people that calls it, which I cannot change. Let's also assume I cannot change the native C code either, so I'm stuck with the name of the native method. How would I "wrap" the call to the native nethod "doSomething()" so that it checked for a security permission first? Normally (if I could change the name) I'd do:
The above would break only code that uses reflection where it looks for and executes any method flagged as native, but that's a small price. HOWEVER, I cannot change the C code, so I'm unable to do the above. Also, I cannot change the code of the calling classes. What's the solution here? I'm stumped. [ January 23, 2004: Message edited by: Robert Paris ]
OK, here's what you do. Make exactly the change you show above. Implement the Java_package_doSomething0() function in C. Have it call the existing Java_package_doSomething() function, forwarding all the arguments, and Bob's your uncle!