在一个web项目,扰码后运行发现tomcat回复500,而且给出了java.lang.ClassFormatError的错误。然后给了某个类某行(1042),而那个类也就大概一百行,根本无法定位。
如果不进行扰码,是没有问题。这说明不是代码逻辑问题,而在于扰码问题。代码有异常捕获,没有捕获到这个异常。在代码中加入log,看看代码的执行情况,发现语句在user.getPhone(),而且返回的500异常多了信息:
java.lang.ClassFormatError: LVTT entry for … in class file … does not match any LVT entry.
这个报错,和跟踪到user.getPhone()是符合。在网上查找解决方法:
参考2:https://sourceforge.net/p/proguard/bugs/462/
看来这是ProGuard的一个bug,还有bug号(见参考2)。在参考1中给出:Add !code/allocation/variable is workaround for proguard bug when -dontobfuscate is set to your –optimizations,即在proguard的配置文件中增加:
-optimizations !code/allocation/variable
或者在图形工具中给出:
问题解决。
相关链接:开发日志