core: print error on failed method decode
This commit is contained in:
@@ -180,14 +180,19 @@ public class MethodGen {
|
||||
|
||||
public void addFallbackMethodCode(CodeWriter code) {
|
||||
if (mth.getInstructions() == null) {
|
||||
// load original instructions
|
||||
try {
|
||||
mth.load();
|
||||
DepthTraversal.visit(new FallbackModeVisitor(), mth);
|
||||
} catch (DecodeException e) {
|
||||
LOG.error("Error reload instructions in fallback mode:", e);
|
||||
code.startLine("// Can't loadFile method instructions: " + e.getMessage());
|
||||
return;
|
||||
JadxErrorAttr errorAttr = mth.get(AType.JADX_ERROR);
|
||||
if (errorAttr == null
|
||||
|| errorAttr.getCause() == null
|
||||
|| !errorAttr.getCause().getClass().equals(DecodeException.class)) {
|
||||
// load original instructions
|
||||
try {
|
||||
mth.load();
|
||||
DepthTraversal.visit(new FallbackModeVisitor(), mth);
|
||||
} catch (DecodeException e) {
|
||||
LOG.error("Error reload instructions in fallback mode:", e);
|
||||
code.startLine("// Can't load method instructions: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
InsnNode[] insnArr = mth.getInstructions();
|
||||
|
||||
@@ -222,8 +222,8 @@ public class ClassNode extends LineAttrNode implements ILoadable {
|
||||
for (MethodNode mth : getMethods()) {
|
||||
try {
|
||||
mth.load();
|
||||
} catch (DecodeException e) {
|
||||
LOG.error("Method load error", e);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Method load error:", e);
|
||||
mth.addAttr(new JadxErrorAttr(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,8 @@ public class ClassModifier extends AbstractVisitor {
|
||||
// remove public empty constructors
|
||||
if (af.isConstructor()
|
||||
&& af.isPublic()
|
||||
&& mth.getArguments(false).isEmpty()) {
|
||||
&& mth.getArguments(false).isEmpty()
|
||||
&& !mth.contains(AType.JADX_ERROR)) {
|
||||
List<BlockNode> bb = mth.getBasicBlocks();
|
||||
if (bb == null || bb.isEmpty() || allBlocksEmpty(bb)) {
|
||||
mth.add(AFlag.DONT_GENERATE);
|
||||
|
||||
Reference in New Issue
Block a user