Not able to start application using obfuscated jar

Hi Jack,

I ran into an issue of not able to initialize main class with the following error:
Error: Unable to initialize main class com.cepheid.testsupporttool.core.TSTApplication
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 32
Exception Details:
Location:
com/cepheid/testsupporttool/core/TSTApplication.main([Ljava/lang/String;)V @2: getstatic
Reason:
Expected stackmap frame at this location.

I have the following obfuscation rules applied:
dontskipnonpubliclibraryclassmembers
dontshrink
dontoptimize
dontpreverify
dontnote
dontwarn

// Keep - Native method names. Keep all native class/method names.
keepclasseswithmembernames includedescriptorclasses: true, 'class * { \
    native <methods>; \
}'

// Keep - main class entry
keep 'public class com.mycorp.testsupporttool.core.TSTApplication {  \
    public static void main(java.lang.String[]);  \
}'

In my case, the main class is in a jar with internal libs obfuscated and external jars not obfuscated.

Did I miss any necessary configurations?

Thanks in advance,
Jingkun

Let me remove the config of dontpreverify and try launching the app again

Hi Jack,

Different error(s) are running into after removing dontpreverify rule:

12:33:22.343 [main] ERROR com.mycorp.startup - unable to start ConfigService
java.lang.NullPointerException: Cannot invoke “com.mycorp.c.i.b.s.a(com.mycorp.c.i.b.e)” because “” is null
at com.mycorp.c.h.e.i(Unknown Source) ~[nexus-3.3.11-RELEASE.jar:11]
at com.mycorp.c.h.e.b(Unknown Source) [nexus-3.3.11-RELEASE.jar:11]
at com.mycorp.c.h.t.b(Unknown Source) [nexus-3.3.11-RELEASE.jar:11]
at com.mycorp.gxcore.e.b.A.b(Unknown Source) [gxcore-3.3.13-RELEASE.jar:3.3.13-RELEASE]
at com.mycorp.myApp.core.TSTApplication.main(Unknown Source) [myApp.jar:?]

What might be the issue?

Thanks,
Jingkun

Hi @jhuOnProguard.

Can you try the following steps and let me know if the ‘java.lang.VerifyError’ goes away?

  1. Ensure that your ProGuard configuration includes the -dontpreverify option, as you’ve already done.

  2. Use a more refined -keep option:

-keep class com.cepheid.testsupporttool.core.TSTApplication {
    public static void main(java.lang.String[]);
}
  1. Check your JDK version
  • Ensure you’re using JDK 8 or later.
  1. Upgrade to the latest version of ProGuard.

  2. Clean and rebuild.

Please let me know if anything is unclear.

Kind Regards,

Jack

Hi Jack,

Yes. It worked. I apologize for my late reply.

Thanks a lot for your help.