Proguard 代码混淆后 WEB项目的运行

在代码进行Proguard 混淆之后,需要通过tomcat或者其他web服务进行启动,启动时报错如下:

Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 63
Exception Details:
  Location:
    org/jiucool/listener/DatabaseUpdateListener.cD()V @12: ifeq
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2ab4 0046 b600 4e4d 2cb8 00ae 9900 332c
    0x0000010: b800 7f4c 120a 2bb6 0073 b600 9f9a 002a
    0x0000020: b200 48bb 0030 59b7 00a2 120c b600 a32b
    0x0000030: b600 72b6 00a3 b600 a4b6 00ab a700 0bb2
    0x0000040: 0048 120b b600 abb1                    
 
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
	at java.lang.Class.getDeclaredFields(Class.java:1916)
	at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
	at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)
	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:89)
	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:63)
	at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:415)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:892)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5419)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 6 more

原因是项目启动时,JVM 会对字节码进行校验,校验不通过会导致该错误。
解决办法是是在启动时添加参数 :-Xverify:none 再启动即可。

Leave a Reply


正在读取数据……