Commit 395cae43 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

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

parent eb77aa51
...@@ -51,7 +51,8 @@ public class ExtractFieldInit extends AbstractVisitor { ...@@ -51,7 +51,8 @@ public class ExtractFieldInit extends AbstractVisitor {
MethodNode clinit = cls.getClassInitMth(); MethodNode clinit = cls.getClassInitMth();
if (clinit == null if (clinit == null
|| !clinit.getAccessFlags().isStatic() || !clinit.getAccessFlags().isStatic()
|| clinit.isNoCode()) { || clinit.isNoCode()
|| clinit.getBasicBlocks() == null) {
return; return;
} }
...@@ -235,7 +236,7 @@ public class ExtractFieldInit extends AbstractVisitor { ...@@ -235,7 +236,7 @@ public class ExtractFieldInit extends AbstractVisitor {
} }
private static List<InsnNode> getFieldAssigns(MethodNode mth, FieldNode field, InsnType putInsn) { private static List<InsnNode> getFieldAssigns(MethodNode mth, FieldNode field, InsnType putInsn) {
if (mth.isNoCode()) { if (mth.isNoCode() || mth.getBasicBlocks() == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<InsnNode> assignInsns = new ArrayList<>(); List<InsnNode> assignInsns = new ArrayList<>();
......
...@@ -218,7 +218,7 @@ public class ReSugarCode extends AbstractVisitor { ...@@ -218,7 +218,7 @@ public class ReSugarCode extends AbstractVisitor {
private static void initClsEnumMap(ClassNode enumCls) { private static void initClsEnumMap(ClassNode enumCls) {
MethodNode clsInitMth = enumCls.getClassInitMth(); MethodNode clsInitMth = enumCls.getClassInitMth();
if (clsInitMth == null || clsInitMth.isNoCode()) { if (clsInitMth == null || clsInitMth.isNoCode() || clsInitMth.getBasicBlocks() == null) {
return; return;
} }
EnumMapAttr mapAttr = new EnumMapAttr(); EnumMapAttr mapAttr = new EnumMapAttr();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment