java.lang.AbstractMethodError分析及解决思路

今天运行程序,出现了java.lang.AbstractMethodError。查阅JDK文档,解释如下:

public class AbstractMethodError
extends IncompatibleClassChangeError

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

经简单分析,发现是由于代码混淆导致的异常。

排查后发现,某个类(PageRoot)实现了接口IPageRoot,但是没有实现方法getChildCount,同时父类ViewArray实现了接口B中同名方法getChildCount,

导致在非加密时,调用类PageRoot中getChildCount方法时会去找父类ViewArray的getChildCount方法,不会报错。

而混淆后,由于接口IPageRoot和ViewArray是2个,虽然方法同名,但是混淆后的方法是2个不同的名称。调用类PageRoot中getChildCount方法,

实际是调用接口IPageRoot中的getChildCount方法,而接口IPageRoot的getChildCount方法在类PageRoot中没有具体实现,是抽象的,所以出现了AbstractMethodError异常。

 

简单的类引用如下图:

  • 10
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值