java - JMockIt fails with AgentInitializationException: Agent JAR loaded but agent failed to initialize -
i developing plugin eclipse kepler. adding @runwith(jmockit.class) test class causes following error:
jmockit: reinitializing under custom class loader org.eclipse.osgi.internal.baseadaptor.defaultclassloader@b7ccec1[com.mypackage.myclass:2.3.9.201508161221(id=1)] java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ sun.instrument.instrumentationimpl.loadclassandstartagent(instrumentationimpl.java:382) @ sun.instrument.instrumentationimpl.loadclassandcallagentmain(instrumentationimpl.java:407) caused by: java.lang.verifyerror @ sun.instrument.instrumentationimpl.redefineclasses0(native method) @ sun.instrument.instrumentationimpl.redefineclasses(instrumentationimpl.java:170) @ mockit.internal.startup.startup.redefinemethods(startup.java:242) @ mockit.internal.startup.startup.redefinemethods(startup.java:236) @ mockit.internal.mockups.mockclasssetup.applyclassmodifications(mockclasssetup.java:134) @ mockit.internal.mockups.mockclasssetup.redefinemethodsinclasshierarchy(mockclasssetup.java:91) @ mockit.internal.mockups.mockclasssetup.redefinemethods(mockclasssetup.java:76) @ mockit.mockup.redefinemethods(mockup.java:240) @ mockit.mockup.redefineclassorimplementinterface(mockup.java:222) @ mockit.mockup.<init>(mockup.java:131) @ mockit.integration.junit4.internal.runnotifierdecorator.<init>(runnotifierdecorator.java:21) @ mockit.internal.startup.jmockitinitialization.loadinternalstartupmocksforjunitintegration(jmockitinitialization.java:42) @ mockit.internal.startup.jmockitinitialization.initialize(jmockitinitialization.java:27) @ mockit.internal.startup.startup.applystartupmocks(startup.java:72) @ mockit.internal.startup.startup.reapplystartupmocks(startup.java:124) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ mockit.internal.util.methodreflection.invoke(methodreflection.java:94) @ mockit.internal.util.methodreflection.invoke(methodreflection.java:159) @ mockit.internal.startup.startup.reinitializejmockitundercustomclassloader(startup.java:118) @ mockit.internal.startup.startup.agentmain(startup.java:101) ... 6 more java.lang.illegalstateexception: com.sun.tools.attach.agentinitializationexception: agent jar loaded agent failed initialize @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.apache.maven.surefire.junit4.junit4provider.execute(junit4provider.java:262) @ org.apache.maven.surefire.junit4.junit4provider.executetestset(junit4provider.java:153) @ org.apache.maven.surefire.junit4.junit4provider.invoke(junit4provider.java:124) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ java.lang.reflect.method.invoke(method.java:606) @ org.apache.maven.surefire.util.reflectionutils.invokemethodwitharray2(reflectionutils.java:208) @ org.apache.maven.surefire.booter.providerfactory$providerproxy.invoke(providerfactory.java:156) @ org.apache.maven.surefire.booter.providerfactory.invokeprovider(providerfactory.java:82) @ org.eclipse.tycho.surefire.osgibooter.osgisurefirebooter.run(osgisurefirebooter.java:91) @ org.eclipse.tycho.surefire.osgibooter.abstractuitestapplication$1.run(abstractuitestapplication.java:35) @ org.eclipse.swt.widgets.runnablelock.run(runnablelock.java:35) @ org.eclipse.swt.widgets.synchronizer.runasyncmessages(synchronizer.java:135) @ org.eclipse.swt.widgets.display.runasyncmessages(display.java:4145) @ org.eclipse.swt.widgets.display.readanddispatch(display.java:3762) @ org.eclipse.e4.ui.internal.workbench.swt.partrenderingengine$9.run(partrenderingengine.java:1113) @ org.eclipse.core.databinding.observable.realm.runwithdefault(realm.java:332) @ org.eclipse.e4.ui.internal.workbench.swt.partrenderingengine.run(partrenderingengine.java:997) @ org.eclipse.e4.ui.internal.workbench.e4workbench.createandrunui(e4workbench.java:140) @ org.eclipse.ui.internal.workbench$5.run(workbench.java:611) @ org.eclipse.core.databinding.observable.realm.runwithdefault(realm.java:332) @ org.eclipse.ui.internal.workbench.createandrunworkbench(workbench.java:567) @ org.eclipse.ui.platformui.createandrunworkbench(platformui.java:150) @ org.eclipse.ui.internal.ide.application.ideapplication.start(ideapplication.java:124) @ org.eclipse.tycho.surefire.osgibooter.uitestapplication.runapplication(uitestapplication.java:31) @ org.eclipse.tycho.surefire.osgibooter.abstractuitestapplication.run(abstractuitestapplication.java:120) @ org.eclipse.tycho.surefire.osgibooter.uitestapplication.start(uitestapplication.java:37) @ org.eclipse.equinox.internal.app.eclipseapphandle.run(eclipseapphandle.java:196) @ org.eclipse.core.runtime.internal.adaptor.eclipseapplauncher.runapplication(eclipseapplauncher.java:110) @ org.eclipse.core.runtime.internal.adaptor.eclipseapplauncher.start(eclipseapplauncher.java:79) @ org.eclipse.core.runtime.adaptor.eclipsestarter.run(eclipsestarter.java:354) @ org.eclipse.core.runtime.adaptor.eclipsestarter.run(eclipsestarter.java:181) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ java.lang.reflect.method.invoke(method.java:606) @ org.eclipse.equinox.launcher.main.invokeframework(main.java:636) @ org.eclipse.equinox.launcher.main.basicrun(main.java:591) @ org.eclipse.equinox.launcher.main.run(main.java:1450) @ org.eclipse.equinox.launcher.main.main(main.java:1426) caused by: com.sun.tools.attach.agentinitializationexception: agent jar loaded agent failed initialize ... 39 more
am doing wrong or jmockit bug? using version jmockit 1.18, junit 4.12
i expect @runwith(jmockit.class)
should have taken care of problem.
in case, jmockit tutorial here, there notes should check, in case these resolve issue. in particular, these 2 seem relevant:
- (note eclipse users: when specifying order of jars in >classpath, make sure use "order , export" tab of "java build >path" window. also, make sure eclipse project uses jre jdk >installation instead of "plain" jre, since latter lacks >"attach" native library.)
- in other situations (like running on jdk implementations other >the oracle jdks), may need pass "-javaagent:path>/jmockit.jar" jvm initialization parameter. can done in >the "run/debug configuration" both eclipse , intellij idea, or >build tools such ant , maven.
Comments
Post a Comment