Current versions of java (8u20, 7u67) break gradle\groovy compiler and runtime compatibility:
:compileTestGroovy FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestGroovy'.
> Bad <init> method call from inside of a branch
Exception Details:
Location:
some/MyClass.<init>(Lsome/MyOtherClass;)V @71: invokespecial
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: b800 174d 04bd 0019 5903 2b53 5910 ff12
0x0000010: 05b8 001f 2a5f ab00 0000 0055 0000 0003
0x0000020: f20b c677 0000 0022 0000 9b75 0000 0037
0x0000030: 2cce be6d 0000 0040 5f5a 5903 3212 05b8
0x0000040: 0023 c000 055f 57b7 0026 a700 2b5f 5a57
0x0000050: b700 29a7 0022 5f5a 5903 3212 2bb8 0023
0x0000060: c000 2b5f 57b7 002e a700 0dbb 0030 5912
0x0000070: 32b7 0035 bf57 2ab6 0039 4e2d 2a5f b500
0x0000080: 3b2d 572c 123c 322a 123e b900 4403 0057
0x0000090: b1
Stackmap Table:
full_frame(@56,{UninitializedThis,Object[#74],Object[#76]},{Object[#78],UninitializedThis})
full_frame(@77,{UninitializedThis,Object[#74],Object[#76]},{Object[#78],UninitializedThis})
full_frame(@86,{UninitializedThis,Object[#74],Object[#76]},{Object[#78],UninitializedThis})
full_frame(@107,{UninitializedThis,Object[#74],Object[#76]},{Object[#78],UninitializedThis})
full_frame(@117,{Object[#2],Object[#74],Object[#76]},{Object[#78]})
People from ZeroTurnaround also noticed this behavior: http://zeroturnaround.com/forums/topic/verifyerror-bad-method-call-from-inside-of-a-branch/
The question is simple: while we wait for any solution in next versions of java, is there a workaround for this problem?
The most obvious way to deal with VerifyError is to use -noverify jvm option.
(Assuming gradle version >=1.12, and gradle wrapper as executable bin)
First of all, tell gradle to use the option for the compilation process (in your build.gradle):
compileGroovy {
groovyOptions.forkOptions.jvmArgs = ['-noverify']
}
For runtime, you should pass jvm option also:
Test task:
test {
jvmArgs '-noverify'
}
If you use application plugin:
applicationDefaultJvmArgs = ["-noverify"]
Or, by any other means.
That'll be all. Happy waiting for java release with fix:
This is a jdk bug & it has been fixed in latest jdk version 7 u72
It happens when Constructor
calls super.
Adding @CompileStatic
on Constructor
solves the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With