0

I am getting the following trace when running junit:

java.lang.VerifyError: Expecting a stackmap frame at branch target 56
Exception Details:

Reason:
Expected stackmap frame at this location.

Bytecode:

0000000: 2a12 b703 bd00 0312 b9b8 00bf 12c1 b800
0000010: c74c 2b01 4d01 4e2c 12e8 b800 ec12 ed12
0000020: eeb8 00f1 b800 f53a 0419 04b2 00f7 a600
0000030: 0ab2 00cb 4ea7 0009 1904 c000 f84e 2da5
0000040: 0004 b112 1f03 bd00 21b8 0023 2a12 1fb8
0000050: 0029 c000 1fb5 002d 2a12 2fb8 0029 c000
0000060: 2fb5 0031 b800 33b8 0037 2a4d 014e 2c12
0000070: fab8 00fc 12fd 12fe b801 00b8 0102 3a04
0000080: 1904 b201 04a6 000b 2cb4 0031 4ea7 0009
0000090: 1904 c001 054e 2db9 003b 0200 572a 1240
00000a0: 014d 014e 2c13 0107 b801 0913 010a 1301
00000b0: 0bb8 010d b801 0f3a 0419 04b2 0111 a600
00000c0: 0ab2 0042 4ea7 0009 1904 c001 134e 2db8
00000d0: 0048 c000 40b5 004b 2a4d 014e 2c13 0114
00000e0: b801 1613 0117 1301 18b8 011a b801 1c3a
00000f0: 0419 04b2 011e a600 0b2c b400 314e a700
0000100: 0919 04c0 0105 4e2d b900 4d01 00b8 0037
0000110: 2a4d 014e 2c13 011f b801 2113 0122 1301
0000120: 23b8 0125 b801 273a 0419 04b2 0129 a600
0000130: 0b2c b400 4b4e a700 0919 04c0 012a 4e2d
0000140: b900 3b02 0057 a700 444c 2b4d 013a 042c
0000150: 01a5 0009 2c3a 04a7 000b 1301 2cb8 012e
0000160: 3a04 1904 1301 2f03 bd00 0313 0130 b801
0000170: 3213 0133 b801 353a 0519 05b2 0137 a600
0000180: 0c2c b601 3b01 4ea7 0003 2a4d 014e 2c13
0000190: 013c b801 3e13 013f 1301 40b8 0142 b801
00001a0: 443a 0419 04b2 0146 a600 0b2c b400 4b4e
00001b0: a700 0919 04c0 012a 4e2d b900 5601 00b8
00001c0: 0037 125a b900 3b02 0057 2a12 5c4d 014e
00001d0: 013a 042c 01a5 0009 2c3a 04a7 000b 1301
00001e0: 48b8 014a 3a04 1904 1301 4b03 bd00 0313
00001f0: 014c b801 4e13 0150 b801 523a 0519 05b2
0000200: 0154 a600 0b2c b601 564e a700 0919 05c0
0000210: 00f8 4e2d c000 5cb5 0062 2a12 64b8 0066
0000220: c000 64b5 0067 a700 cc4c 2b4d 013a 042c
0000230: 01a5 0009 2c3a 04a7 000b 1301 58b8 015a
0000240: 3a04 1904 1301 5b03 bd00 0313 015c b801
0000250: 5e13 015f b801 613a 0519 05b2 0163 a600
0000260: 0c2c b601 6501 4ea7 0003 a700 884c 2b4d
0000270: 013a 042c 01a5 0009 2c3a 04a7 000b 1301
0000280: 67b8 0169 3a04 1904 1301 6a03 bd00 0313
0000290: 016b b801 6d13 016e b801 703a 0519 05b2
00002a0: 0172 a600 0c2c b601 7401 4ea7 0003 a700
00002b0: 444c 2b4d 013a 042c 01a5 0009 2c3a 04a7
00002c0: 000b 1301 76b8 0178 3a04 1904 1301 7903
00002d0: bd00 0313 017a b801 7c13 017d b801 7f3a
00002e0: 0519 05b2 0181 a600 0c2c b601 8301 4ea7
00002f0: 0003 2a12 7201 4d01 4e2c 1301 84b8 0186
0000300: 1301 8713 0188 b801 8ab8 018c 3a04 1904
0000310: b201 8ea6 000a b200 424e a700 0919 04c0
0000320: 0113 4e2d b800 74c0 0072 b500 752a 1277
0000330: 014d 014e 2c13 018f b801 9113 0192 1301
0000340: 93b8 0195 b801 973a 0419 04b2 0199 a600
0000350: 0ab2 0042 4ea7 0009 1904 c001 134e 2db8
0000360: 0074 c000 77b5 0079 b1                 
Exception Handler Table:
bci [216, 326] => handler: 329
bci [458, 550] => handler: 553
bci [458, 550] => handler: 621
bci [458, 550] => handler: 689
Stackmap Table:
same_locals_1_stack_item_extended(@89,Object[#82])
same_frame(@94)
same_locals_1_stack_item_frame(@141,Object[#106])
same_locals_1_stack_item_frame(@149,Object[#109])
same_locals_1_stack_item_frame(@157,Object[#112])
same_frame(@162)

at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
at java.lang.Class.privateGetPublicMethods(Class.java:2733)
at java.lang.Class.getMethods(Class.java:1472)
at       org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegate Impl.getTestMethods(PowerMockJUnit44RunnerDelegateImpl.java:93)
at  org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.<init>(PowerMockJUnit44RunnerDelegateImpl.java:69)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.<init>(PowerMockJUnit47RunnerDelegateImpl.java:42)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.<init>(PowerMockJUnit49RunnerDelegateImpl.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:143)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:39)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:217)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:59)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:32)
at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:33)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

I have tried doing the following:

  • Adding "-XX:-UseSplitVerifier" JVM argument (did not work).
  • I am using JDK7 and cannot shift to JDK6.
  • Gone through a lot of posts regarding this on SO, but could not find anything that would remove this error, in my case.

My class looks like this:

@RunWith(PowerMockRunner.class)
@PrepareForTest({SecureTokenFactory.class})
@PowerMockIgnore({"javax.net.ssl.*","javax.management.*"})
public class ServiceInvokerTest {
...
ASR4
  • 545
  • 1
  • 8
  • 24
  • That messge usually means either: a) the class file is corrupt, b) there's a profiler involved which is changing the class file on the fly (and not doing it correctly), or c) the class file is generate on the fly, again, incorrectly. Does the PowerMock framework generate class files on the fly? – Dave C Feb 23 '17 at 20:53
  • I don't know that, but I tried removing the following two line: @PrepareForTest({SecureTokenFactory.class}) @PowerMockIgnore({"javax.net.ssl.*","javax.management.*"}) And now I am getting the "org.mockito.exceptions.misusing.MissingMethodInvocationException", saying that the "when() requires an argument which has to be a method on call on a mock" – ASR4 Feb 23 '17 at 23:00

1 Answers1

0

I got this working using "-XX:-UseSplitVerifier".

But not by going to:

Preferences -> Choosing the JRE -> Edit -> adding "-XX:-UseSplitVerifier" to "Default VM arguments", as mentioned in lot of places.

I got it working by:

Run Configurations -> Arguments -> adding "-XX:-UseSplitVerifier" to "VM arguments"

ASR4
  • 545
  • 1
  • 8
  • 24
  • Good temporary workaround. See my comment on what this does, here: http://stackoverflow.com/questions/15253173/how-safe-is-it-to-use-xx-usesplitverifier/19383468#19383468 – Dave C Mar 22 '17 at 19:06