Cleanup (warnings; formatting)

master
Roman Shevchenko 7 years ago
parent 2393cd9aa8
commit 95aa1ae2f0
  1. 23
      src/org/jetbrains/java/decompiler/main/ClassWriter.java
  2. 4
      src/org/jetbrains/java/decompiler/main/Fernflower.java
  3. 4
      src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java
  4. 31
      src/org/jetbrains/java/decompiler/main/rels/MethodProcessorRunnable.java

@ -1,6 +1,4 @@
/* // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package org.jetbrains.java.decompiler.main; package org.jetbrains.java.decompiler.main;
import org.jetbrains.java.decompiler.code.CodeConstants; import org.jetbrains.java.decompiler.code.CodeConstants;
@ -517,10 +515,9 @@ public class ClassWriter {
try { try {
buffer.append(root.toJava(indent, tracer)); buffer.append(root.toJava(indent, tracer));
} }
catch (Throwable ex) { catch (Throwable t) {
DecompilerContext.getLogger().writeMessage("Method " + mt.getName() + " " + mt.getDescriptor() + " couldn't be written.", String message = "Method " + mt.getName() + " " + mt.getDescriptor() + " couldn't be written.";
IFernflowerLogger.Severity.WARN, DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN, t);
ex);
methodWrapper.decompiledWithErrors = true; methodWrapper.decompiledWithErrors = true;
} }
} }
@ -805,7 +802,6 @@ public class ClassWriter {
buffer.append(';'); buffer.append(';');
buffer.appendLineSeparator(); buffer.appendLineSeparator();
tracer.incrementCurrentSourceLine();
} }
else { else {
if (!clinit && !dinit) { if (!clinit && !dinit) {
@ -831,11 +827,9 @@ public class ClassWriter {
tracer.setCurrentSourceLine(codeTracer.getCurrentSourceLine()); tracer.setCurrentSourceLine(codeTracer.getCurrentSourceLine());
tracer.addTracer(codeTracer); tracer.addTracer(codeTracer);
} }
catch (Throwable ex) { catch (Throwable t) {
DecompilerContext.getLogger() String message = "Method " + mt.getName() + " " + mt.getDescriptor() + " couldn't be written.";
.writeMessage("Method " + mt.getName() + " " + mt.getDescriptor() + " couldn't be written.", DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN, t);
IFernflowerLogger.Severity.WARN,
ex);
methodWrapper.decompiledWithErrors = true; methodWrapper.decompiledWithErrors = true;
} }
} }
@ -850,8 +844,9 @@ public class ClassWriter {
tracer.addMapping(root.getDummyExit().bytecode); tracer.addMapping(root.getDummyExit().bytecode);
} }
buffer.appendIndent(indent).append('}').appendLineSeparator(); buffer.appendIndent(indent).append('}').appendLineSeparator();
tracer.incrementCurrentSourceLine();
} }
tracer.incrementCurrentSourceLine();
} }
finally { finally {
DecompilerContext.setProperty(DecompilerContext.CURRENT_METHOD_WRAPPER, outerWrapper); DecompilerContext.setProperty(DecompilerContext.CURRENT_METHOD_WRAPPER, outerWrapper);

@ -114,8 +114,8 @@ public class Fernflower implements IDecompiledData {
classProcessor.writeClass(cl, buffer); classProcessor.writeClass(cl, buffer);
return buffer.toString(); return buffer.toString();
} }
catch (Throwable ex) { catch (Throwable t) {
DecompilerContext.getLogger().writeMessage("Class " + cl.qualifiedName + " couldn't be fully decompiled.", ex); DecompilerContext.getLogger().writeMessage("Class " + cl.qualifiedName + " couldn't be fully decompiled.", t);
return null; return null;
} }
} }

@ -122,9 +122,9 @@ public class ClassWrapper {
} }
} }
} }
catch (Throwable ex) { catch (Throwable t) {
String message = "Method " + mt.getName() + " " + mt.getDescriptor() + " couldn't be decompiled."; String message = "Method " + mt.getName() + " " + mt.getDescriptor() + " couldn't be decompiled.";
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN, ex); DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN, t);
isError = true; isError = true;
} }

@ -129,39 +129,26 @@ public class MethodProcessorRunnable implements Runnable {
SequenceHelper.condenseSequences(root); SequenceHelper.condenseSequences(root);
while (true) { StackVarsProcessor stackProc = new StackVarsProcessor();
StackVarsProcessor stackProc = new StackVarsProcessor();
stackProc.simplifyStackVars(root, mt, cl);
do {
stackProc.simplifyStackVars(root, mt, cl);
varProc.setVarVersions(root); varProc.setVarVersions(root);
if (!new PPandMMHelper().findPPandMM(root)) {
break;
}
} }
while (new PPandMMHelper().findPPandMM(root));
while (true) { while (true) {
LabelHelper.cleanUpEdges(root); LabelHelper.cleanUpEdges(root);
while (true) { do {
MergeHelper.enhanceLoops(root); MergeHelper.enhanceLoops(root);
if (LoopExtractHelper.extractLoops(root)) {
continue;
}
if (!IfHelper.mergeAllIfs(root)) {
break;
}
} }
while (LoopExtractHelper.extractLoops(root) || IfHelper.mergeAllIfs(root));
if (DecompilerContext.getOption(IFernflowerPreferences.IDEA_NOT_NULL_ANNOTATION)) { if (DecompilerContext.getOption(IFernflowerPreferences.IDEA_NOT_NULL_ANNOTATION)) {
if (IdeaNotNullHelper.removeHardcodedChecks(root, mt)) { if (IdeaNotNullHelper.removeHardcodedChecks(root, mt)) {
SequenceHelper.condenseSequences(root); SequenceHelper.condenseSequences(root);
StackVarsProcessor stackProc = new StackVarsProcessor();
stackProc.simplifyStackVars(root, mt, cl); stackProc.simplifyStackVars(root, mt, cl);
varProc.setVarVersions(root); varProc.setVarVersions(root);
} }
} }
@ -178,9 +165,9 @@ public class MethodProcessorRunnable implements Runnable {
} }
// FIXME: !! // FIXME: !!
// if(!EliminateLoopsHelper.eliminateLoops(root)) { //if(!EliminateLoopsHelper.eliminateLoops(root)) {
// break; // break;
// } //}
} }
ExitHelper.removeRedundantReturns(root); ExitHelper.removeRedundantReturns(root);

Loading…
Cancel
Save