I'm trying to use jMockit to stub out a call to netscape.javascript.JSObject which is unfortunately an abstract class with a few native methods in it, both of which don't play well with jMockit. Is there any way for me to stub this out, either with jMockit, or using plain java (I'd prefer not having to introduce a new library if possible)? The code I'm trying to inject the mock in looks something like the following (don't ask):
JSObject win = JSObject.getWindow(this);
String someVal = (String) win.call("foo", new String[] {""});
Unfortunately I can't modify the code in question (once again, don't ask), so the only way I can do any sort of unit testing on it is if I can figure out how to stub out or otherwise eliminate the calls to JSObject. My current mock implementation returns a new instance of itself for the call to getWindow, and returns a constant string for the call to call but of course it fails at runtime complaining about
class redefinition failed: attempted to change method modifiers
which from my research I've discovered means it's attempting to mock a native method.
Edit: Due to the target platform I need to use JDK 1.5 to build/test so any solution must be viable on 1.5.