Debugger won't work with JMockit
Asked Answered
R

1

6

Hopefully an easy question here for someone.....

I'm using RAD 7.5.2, and am writing Junit tests. I was writing them just fine with JUnit 3, and then I wanted to mock up some function calls. So I loaded up jmockit 0.9.7 and Junit 4.6. I also include -javaagent:jmockit.jar as a VM argument.

When I "Run As Junit Test", it goes along with no problems at all (at least, none that I can see on the output). The output of Junit is good, and no errors are dumped to the console.

When I "Debug as Junit Test", it won't work. It dumps me out into:

InstrumentationImpl.class --> Source not found

...and when I hit continue....

NativeMethodAccessorImpl.class --> Source not found

...and when I hit continue...

The JUnit ends after this. It dumps the following to the console:


Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:160) Caused by: java.lang.UnsatisfiedLinkError: sun/instrument/InstrumentationImpl.redefineClasses0([Ljava/lang/instrument/ClassDefinition;)V at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:98) at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:197) at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:184) at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:116) at mockit.internal.RedefinitionEngine.setUpInternalStartupMock(RedefinitionEngine.java:53) at mockit.internal.Startup.loadInternalStartupMocks(Startup.java:123) at mockit.internal.Startup.initialize(Startup.java:110) at mockit.internal.Startup.premain(Startup.java:97) ... 5 more

Fatal error: processing of -javaagent failed


I can run both JUnit 3 and JUnit 4 on my tests with no problem, it's when I use the -javaagent:jmockit.jar (with the debugger; by themselves they're fine) that things get ugly, and I have to do that to use the jmockit stuff.

Thoughts?

Rite answered 13/5, 2009 at 20:2 Comment(1)
I had a different issue, which the binary doesn't actually align with source code.Angi
R
1

I regularly run JUnit tests that use JMockit (with and without the "-javaagent" JVM argument) in debug mode, and never had any issues.

Are you sure the classpath for the "Debug as Junit Test" configuration is identical to the one for "Run As Junit Test"? Since you got an UnsatisfiedLinkError, it may be that there is some jar file missing.

If that is not the cause of the error, then maybe it is something specific to RAD 7.5.2...

Responsible answered 2/7, 2009 at 14:39 Comment(1)
It's also happening with RAD 7.5.5; same symptoms as Jacob described.Palter

© 2022 - 2024 — McMap. All rights reserved.