fix: handle NPE for methods with removed instructions (#342) (PR #583)

This commit is contained in:
Ahmed Ashour
2019-04-12 17:12:38 +02:00
committed by skylot
parent eb77aa51b2
commit 395cae439e
2 changed files with 4 additions and 3 deletions
@@ -51,7 +51,8 @@ public class ExtractFieldInit extends AbstractVisitor {
MethodNode clinit = cls.getClassInitMth();
if (clinit == null
|| !clinit.getAccessFlags().isStatic()
|| clinit.isNoCode()) {
|| clinit.isNoCode()
|| clinit.getBasicBlocks() == null) {
return;
}
@@ -235,7 +236,7 @@ public class ExtractFieldInit extends AbstractVisitor {
}
private static List<InsnNode> getFieldAssigns(MethodNode mth, FieldNode field, InsnType putInsn) {
if (mth.isNoCode()) {
if (mth.isNoCode() || mth.getBasicBlocks() == null) {
return Collections.emptyList();
}
List<InsnNode> assignInsns = new ArrayList<>();
@@ -218,7 +218,7 @@ public class ReSugarCode extends AbstractVisitor {
private static void initClsEnumMap(ClassNode enumCls) {
MethodNode clsInitMth = enumCls.getClassInitMth();
if (clsInitMth == null || clsInitMth.isNoCode()) {
if (clsInitMth == null || clsInitMth.isNoCode() || clsInitMth.getBasicBlocks() == null) {
return;
}
EnumMapAttr mapAttr = new EnumMapAttr();