2

Using jdk 1.8.0_51 source=1.7, target=1.7 Junit 4.6, ant 1.8.0

What is happening?
All the tests which were passing with 1.7 are now failing. I need to know the following:

  1. Why is this happening ?
  2. Is there an option like -XX:-UseSplitVerifier(java 1.7)
  3. How to find out the root cause of the problem ?
  4. What are the steps to be taken to resolve this issue ?

We have ant targets for build, deploy, test.
Build and deploy are working without problems but Junit tests are failing in all the modules.
I tried upgrading ant(1.8.9), junit 4.10.
Could this be because of any jar which is not compiled with java 1.8?
Should i ensure all jars which i use are compiled with java8 ? If it is then , it could be a bad sign :(

I tried running junit through command prompt and it worked.

java -cp ./target/package-test:./target/mycompany-common.jar:./lib/junit-4.6.jar org.junit.runner.JUnitCore com.mycompany.JunitTest

===================================================================================== 
          Tests:    1
        Batches:    1
        Threads:    1
           Host: remote


=====================================================================================
TEST                                                    RUN FAIL ERR SKIP    DURATION
JunitTest                                                1    1              0.068 sec
-------------------------------------------------------------------------------------
TOTAL                                                    1    1     
=====================================================================================
The following tests had failures or errors:
com.mycompany.JunitTest

The failures and errors can be seen in the following files:
/target/reports/junit/TEST-com.mycompany.JunitTest.txt

Results of first failed test:
Testsuite: com.mycompany.JunitTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.068 sec

Testcase: test took 0.018 sec
    Caused an ERROR
Expecting a stackmap frame at branch target 65
Exception Details:
  Location:
    com/mycompany/Identifier.equals(Ljava/lang/Object;)Z @26: ifne
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 033d 11ff ff3e 1215 1100 35b8 001b 2bc1
    0x0000010: 0002 1100 353d 1100 003e 9a00 271c 1100
    0x0000020: 35a0 0016 1d11 0000 a000 0f12 151c 1d04
    0x0000030: b800 4111 ffff 3e12 1511 0036 b800 1b03
    0x0000040: ac1d 9b00 0f12 151c 1d03 b800 4111 ffff
    0x0000050: 3e12 1511 0039 b800 1b2b c000 023a 0412
    0x0000060: 1511 003a b800 1b2a b400 2619 04b4 0026
    0x0000070: b600 43ac                              
  Stackmap Table:
    same_frame_extended(@89)

java.lang.VerifyError: Expecting a stackmap frame at branch target 65
Exception Details:
  Location:
    com/mycompany/Identifier.equals(Ljava/lang/Object;)Z @26: ifne
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 033d 11ff ff3e 1215 1100 35b8 001b 2bc1
    0x0000010: 0002 1100 353d 1100 003e 9a00 271c 1100
    0x0000020: 35a0 0016 1d11 0000 a000 0f12 151c 1d04
    0x0000030: b800 4111 ffff 3e12 1511 0036 b800 1b03
    0x0000040: ac1d 9b00 0f12 151c 1d03 b800 4111 ffff
    0x0000050: 3e12 1511 0039 b800 1b2b c000 023a 0412
    0x0000060: 1511 003a b800 1b2a b400 2619 04b4 0026
    0x0000070: b600 43ac                              
  Stackmap Table:
    same_frame_extended(@89)

    at com.mycompany.JunitTest.test(JunitTest.java:17)

sandeep kamath
  • 133
  • 2
  • 11
  • 1
    This could possibly be caused by some load-time bytecode transformation. Do you by any chance use Lombok or s.t. like this? To investigate you may run the Identifier.class through `javap -c` and see if there actually is an "ifne" instruction at offset 26. – Stephan Herrmann Aug 23 '15 at 21:35
  • Does this answer your question? [java.lang.VerifyError: Expecting a stackmap frame at branch target JDK 1.7](https://stackoverflow.com/questions/15122890/java-lang-verifyerror-expecting-a-stackmap-frame-at-branch-target-jdk-1-7) – Vadzim Apr 28 '20 at 04:51

3 Answers3

1

From Java 8, there is no equivalent for --usesplitverifier.

  1. You can use '-noverify' to stop java 8 from compiling code in strict byte code implementation mode.

  2. If using Eclipse, you can also do windows->preferences->compiler -> uncheck the option 'preserve unused local variables'

Rk R Bairi
  • 1,289
  • 7
  • 15
  • 39
0

I also faced the same challenge when migrating my application from 1.6 to 1.7, but I was able to fix it.

Approach 1: Either you can use -XX:-UseSplitVerifier argument to resolve this issue and you don't need to worry about to upgrade the library files.

Approach 2: I followed these steps to solve the issue:

  1. Identify and keep a list of external libraries consumed by your application.
  2. Once you identify the list, keep removing one by one external library files and plug in upgraded version library files which will help you to isolate the library which might causing the issue. In my case: j2ee.jar and openjpa-1.2.2 jar files created an issue and then I have upgraded these libraries which had resolved the migration issues.

It is bit of slow and painful process to figure out which library causing the issue and arrest it.

Laurel
  • 5,965
  • 14
  • 31
  • 57
SaravanaC
  • 81
  • 1
  • 3
0

I had a similar issue when upgrading from Java 1.7 to 1.8. I got the "Expecting a stackmap frame at branch target 12" error when running Parasoft Jtest unit test cases. The issue was resolved by adding the [-noverify] VM argument to the JRE definition in Eclipse.

John
  • 1
  • 2