Commit 72c301dc authored by Skylot's avatar Skylot

core: print error on failed method decode

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