Attached project illustrates bug in Proguard up to 5.3.3 when using chained lambdas in Kotlin.
Bug leads to VerifyError when using Class.getDeclaredFields (which is very common operation in various libraries such as Jackson).
How to reproduce:
Which results in:
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
Location:
com/navixy/apiserver/resource/form/template/a.a()Lcom/navixy/apiserver/resource/form/template/FormTemplateStatsReadResponse; @177: iload
Reason:
Type uninitialized 142 (current frame, locals[12]) is not assignable to 'com/navixy/apiserver/resource/form/template/FormTemplateStatsReadResponse' (stack map, locals[12])
Current Frame:
bci: @177
flags: { }
locals: { 'com/navixy/apiserver/resource/form/template/a', 'java/util/Map',integer, '[Ljava/lang/Object;', '[Ljava/lang/Object;', 'java/util/Collection', integer, top, top, top, top, top, uninitialized 142, uninitialized 142 }
stack: { }
Stackmap Frame:
bci: @177
flags: { }
locals: { top, 'java/util/Map', integer, top, '[Ljava/lang/Object;', 'java/util/Collection', integer, top, top, top, top, top, 'com/navixy/apiserver/resource/form/template/FormTemplateStatsReadResponse', 'com/navixy/apiserver/resource/form/template/FormTemplateStatsReadResponse' }
stack: { }
Bytecode:
0x0000000: 2ab4 0017 b600 19c0 000a 4d2c 100a b800
0x0000010: 22b8 0023 1010 b800 263e 2c3a 04bb 000f
0x0000020: 591d b700 20c0 0011 3a05 1904 b900 2901
0x0000030: 003a 0619 06b9 002b 0100 9900 4919 06b9
0x0000040: 002c 0100 3a07 1905 1907 c000 163a 083a
0x0000050: 0c19 08b6 0027 c000 083a 0d19 0c19 0d19
0x0000060: 07c0 0016 3a08 3a0d 3a0c 1908 b600 28c0
0x0000070: 0009 3a0e 190c 190d 190e b900 2d03 0057
0x0000080: a7ff b319 054c 2ab4 0017 b600 1a3d bb00
0x0000090: 0659 b800 1cc0 0004 4e3a 0d3a 0c2d 3a04
0x00000a0: bb00 0c59 2dbe b700 1fc0 000d 3a05 0336
0x00000b0: 0615 0619 04be a200 3019 0415 0632 3a07
0x00000c0: 1905 1907 c000 083a 083a 0e19 0803 b800
0x00000d0: 1db8 0021 3a0f 190e 190f b900 2a02 0057
0x00000e0: 8406 01a7 ffce 1905 c000 103a 0e19 0c19
0x00000f0: 0d19 0ec0 000a b800 252b b800 241c b700
0x0000100: 1bb0
Stackmap Table:
full_frame(@51,{Object[#7],Top,Top,Top,Top,Object[#17],Object[#14]},{})
chop_frame(@131,1)
full_frame(@177,{Top,Object[#17],Integer,Top,Object[#4],Object[#13],Integer,Top,Top,Top,Top,Top,Object[#6],Object[#6]},{})
full_frame(@230,{Top,Object[#17],Integer,Top,Top,Object[#13],Top,Top,Top,Top,Top,Top,Object[#6],Object[#6]},{})
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at com.navixy.apiserver.Main.main(Unknown Source)
Sorry, instead of
package shade:shade proguard:proguard
you should do
mvn package shade:shade proguard:proguard
I'm running into the same problem. Only workaround I could find is to compile Kotlin with jvmTarget=1.6, but that's not a long-term solution.
Thanks for your report; sorry about the delay. I could indeed reproduce the problem. The preverification step can't handle the bytecode construct that is generated by the Kotlin compiler. It turns out that the problem is solved in DexGuard, our professional product for Android. Unfortunately, that is not an option for generic Java projects. I haven't found a quick fix yet. The current plan is to work toward ProGuard 6.0, with backported updates and new features.
Any updates on this?
This has become a blocker for us, as the previously mentioned workaround
jvmTarget=1.6no longer works on JDK 9.ProGuard 6.0 beta1 seems to have solved it. You can download its zip file from https://sourceforge.net/projects/proguard/files
Thanks, that's great news. We can't use a manually downloaded Jar file, but will update once a new proguard-gradle is available from Maven Central. (Would be great to have beta1 published there.)