Commit 99d98140 authored by Skylot's avatar Skylot

don't use concatenation in logger, fix other small code style issues

parent 141398ae
...@@ -18,7 +18,7 @@ public class JadxCLI { ...@@ -18,7 +18,7 @@ public class JadxCLI {
processAndSave(jadxArgs); processAndSave(jadxArgs);
} }
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("jadx error: " + e.getMessage(), e); LOG.error("jadx error: {}", e.getMessage(), e);
System.exit(1); System.exit(1);
} }
} }
...@@ -56,7 +56,7 @@ public class JadxCLI { ...@@ -56,7 +56,7 @@ public class JadxCLI {
} else { } else {
outDirName = name + "-jadx-out"; outDirName = name + "-jadx-out";
} }
LOG.info("output directory: " + outDirName); LOG.info("output directory: {}", outDirName);
outputDir = new File(outDirName); outputDir = new File(outDirName);
jadxArgs.setOutputDir(outputDir); jadxArgs.setOutputDir(outputDir);
} }
......
...@@ -2,6 +2,8 @@ package jadx.api; ...@@ -2,6 +2,8 @@ package jadx.api;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
public final class JavaPackage implements JavaNode, Comparable<JavaPackage> { public final class JavaPackage implements JavaNode, Comparable<JavaPackage> {
private final String name; private final String name;
private final List<JavaClass> classes; private final List<JavaClass> classes;
...@@ -32,7 +34,7 @@ public final class JavaPackage implements JavaNode, Comparable<JavaPackage> { ...@@ -32,7 +34,7 @@ public final class JavaPackage implements JavaNode, Comparable<JavaPackage> {
} }
@Override @Override
public int compareTo(JavaPackage o) { public int compareTo(@NotNull JavaPackage o) {
return name.compareTo(o.name); return name.compareTo(o.name);
} }
......
...@@ -42,7 +42,7 @@ public final class ResourcesLoader { ...@@ -42,7 +42,7 @@ public final class ResourcesLoader {
return list; return list;
} }
public static interface ResourceDecoder { public interface ResourceDecoder {
Object decode(long size, InputStream is) throws IOException; Object decode(long size, InputStream is) throws IOException;
} }
...@@ -72,7 +72,7 @@ public final class ResourcesLoader { ...@@ -72,7 +72,7 @@ public final class ResourcesLoader {
inputStream.close(); inputStream.close();
} }
} catch (Exception e) { } catch (Exception e) {
LOG.debug("Error close zip file: " + zipRef, e); LOG.debug("Error close zip file: {}", zipRef, e);
} }
} }
} }
...@@ -130,7 +130,7 @@ public final class ResourcesLoader { ...@@ -130,7 +130,7 @@ public final class ResourcesLoader {
try { try {
zip.close(); zip.close();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Zip file close error: " + file.getAbsolutePath(), e); LOG.error("Zip file close error: {}", file.getAbsolutePath(), e);
} }
} }
} }
......
...@@ -153,12 +153,8 @@ public class MethodGen { ...@@ -153,12 +153,8 @@ public class MethodGen {
if (mth.contains(AType.JADX_ERROR) if (mth.contains(AType.JADX_ERROR)
|| mth.contains(AFlag.INCONSISTENT_CODE) || mth.contains(AFlag.INCONSISTENT_CODE)
|| mth.getRegion() == null) { || mth.getRegion() == null) {
code.startLine("throw new UnsupportedOperationException(\"Method not decompiled: ")
.add(mth.toString())
.add("\");");
if (mth.contains(AType.JADX_ERROR)) {
JadxErrorAttr err = mth.get(AType.JADX_ERROR); JadxErrorAttr err = mth.get(AType.JADX_ERROR);
if (err != null) {
code.startLine("/* JADX: method processing error */"); code.startLine("/* JADX: method processing error */");
Throwable cause = err.getCause(); Throwable cause = err.getCause();
if (cause != null) { if (cause != null) {
...@@ -171,6 +167,10 @@ public class MethodGen { ...@@ -171,6 +167,10 @@ public class MethodGen {
code.startLine("/*"); code.startLine("/*");
addFallbackMethodCode(code); addFallbackMethodCode(code);
code.startLine("*/"); code.startLine("*/");
code.startLine("throw new UnsupportedOperationException(\"Method not decompiled: ")
.add(mth.toString())
.add("\");");
} else { } else {
RegionGen regionGen = new RegionGen(this); RegionGen regionGen = new RegionGen(this);
regionGen.makeRegion(code, mth.getRegion()); regionGen.makeRegion(code, mth.getRegion());
......
...@@ -257,7 +257,7 @@ public class RegionGen extends InsnGen { ...@@ -257,7 +257,7 @@ public class RegionGen extends InsnGen {
} else if (k instanceof Integer) { } else if (k instanceof Integer) {
code.add(TypeGen.literalToString((Integer) k, arg.getType())); code.add(TypeGen.literalToString((Integer) k, arg.getType()));
} else { } else {
throw new JadxRuntimeException("Unexpected key in switch: " + (k != null ? k.getClass() : k)); throw new JadxRuntimeException("Unexpected key in switch: " + (k != null ? k.getClass() : null));
} }
code.add(':'); code.add(':');
} }
......
...@@ -63,7 +63,7 @@ public class TypeGen { ...@@ -63,7 +63,7 @@ public class TypeGen {
case OBJECT: case OBJECT:
case ARRAY: case ARRAY:
if (lit != 0) { if (lit != 0) {
LOG.warn("Wrong object literal: " + lit + " for type: " + type); LOG.warn("Wrong object literal: {} for type: {}", lit, type);
return Long.toString(lit); return Long.toString(lit);
} }
return "null"; return "null";
......
...@@ -94,17 +94,17 @@ public class CheckRegions extends AbstractVisitor { ...@@ -94,17 +94,17 @@ public class CheckRegions extends AbstractVisitor {
} }
private void printRegion(MethodNode mth) { private void printRegion(MethodNode mth) {
LOG.debug("|" + mth.toString()); LOG.debug("|{}", mth.toString());
printRegion(mth, mth.getRegion(), "| "); printRegion(mth, mth.getRegion(), "| ");
} }
private void printRegion(MethodNode mth, IRegion region, String indent) { private void printRegion(MethodNode mth, IRegion region, String indent) {
LOG.debug(indent + region); LOG.debug("{}{}", indent, region);
for (IContainer container : region.getSubBlocks()) { for (IContainer container : region.getSubBlocks()) {
if (container instanceof IRegion) { if (container instanceof IRegion) {
printRegion(mth, (IRegion) container, indent + " "); printRegion(mth, (IRegion) container, indent + " ");
} else { } else {
LOG.debug(indent + " " + container); LOG.debug("{} {}", indent, container);
} }
} }
} }
......
...@@ -40,7 +40,7 @@ public class ErrorsCounter { ...@@ -40,7 +40,7 @@ public class ErrorsCounter {
if (e.getClass() == JadxOverflowException.class) { if (e.getClass() == JadxOverflowException.class) {
// don't print full stack trace // don't print full stack trace
e = new JadxOverflowException(e.getMessage()); e = new JadxOverflowException(e.getMessage());
LOG.error(msg + ", message: " + e.getMessage()); LOG.error("{}, message: {}", msg, e.getMessage());
} else { } else {
LOG.error(msg, e); LOG.error(msg, e);
} }
......
...@@ -273,7 +273,7 @@ public class ResTableParser extends CommonBinaryParser { ...@@ -273,7 +273,7 @@ public class ResTableParser extends CommonBinaryParser {
if ((b1 & 0x80) == 0) { if ((b1 & 0x80) == 0) {
str = new String(new char[]{(char) b1, (char) b2}); str = new String(new char[]{(char) b1, (char) b2});
} else { } else {
LOG.warn("TODO: parse locale: 0x" + Integer.toHexString(b1) + Integer.toHexString(b1)); LOG.warn("TODO: parse locale: 0x{}{}", Integer.toHexString(b1), Integer.toHexString(b2));
} }
} }
return str; return str;
......
...@@ -92,7 +92,7 @@ public class ValuesParser extends ParserConstants { ...@@ -92,7 +92,7 @@ public class ValuesParser extends ParserConstants {
return decodeComplex(data, true); return decodeComplex(data, true);
default: default:
LOG.warn("Unknown data type: 0x" + Integer.toHexString(dataType) + " " + data); LOG.warn("Unknown data type: 0x{} {}", Integer.toHexString(dataType), data);
return " ?0x" + Integer.toHexString(dataType) + " " + data; return " ?0x" + Integer.toHexString(dataType) + " " + data;
} }
} }
......
...@@ -29,7 +29,7 @@ public class TestVariablesDefinitions extends IntegrationTest { ...@@ -29,7 +29,7 @@ public class TestVariablesDefinitions extends IntegrationTest {
DepthTraversal.visit(pass, cls); DepthTraversal.visit(pass, cls);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Decode exception: " + cls, e); LOG.error("Decode exception: {}", cls, e);
} }
} }
} }
......
...@@ -38,7 +38,7 @@ public class JadxGUI { ...@@ -38,7 +38,7 @@ public class JadxGUI {
} }
}); });
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("Error: " + e.getMessage()); LOG.error("Error: {}", e.getMessage());
System.exit(1); System.exit(1);
} }
} }
......
...@@ -31,9 +31,9 @@ public class JadxWrapper { ...@@ -31,9 +31,9 @@ public class JadxWrapper {
try { try {
this.decompiler.loadFile(file); this.decompiler.loadFile(file);
} catch (DecodeException e) { } catch (DecodeException e) {
LOG.error("Error decode file: " + file, e); LOG.error("Error decode file: {}", file, e);
} catch (JadxException e) { } catch (JadxException e) {
LOG.error("Error open file: " + file, e); LOG.error("Error open file: {}", file, e);
} }
} }
......
...@@ -150,7 +150,7 @@ class ContentArea extends RSyntaxTextArea { ...@@ -150,7 +150,7 @@ class ContentArea extends RSyntaxTextArea {
try { try {
setCaretPosition(getLineStartOffset(line)); setCaretPosition(getLineStartOffset(line));
} catch (BadLocationException e) { } catch (BadLocationException e) {
LOG.debug("Can't scroll to " + line, e); LOG.debug("Can't scroll to {}", line, e);
} }
} }
......
...@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory; ...@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
class SearchBar extends JToolBar { class SearchBar extends JToolBar {
private static final long serialVersionUID = 1836871286618633003L; private static final long serialVersionUID = 1836871286618633003L;
private static final Logger LOG = LoggerFactory.getLogger(SearchDialog.class); private static final Logger LOG = LoggerFactory.getLogger(SearchBar.class);
private static final Color COLOR_BG_ERROR = new Color(0xFFDFDE); private static final Color COLOR_BG_ERROR = new Color(0xFFDFDE);
private static final Color COLOR_BG_WARN = new Color(0xFFFDD9); private static final Color COLOR_BG_WARN = new Color(0xFFFDD9);
......
...@@ -20,7 +20,7 @@ import static java.awt.Desktop.Action; ...@@ -20,7 +20,7 @@ import static java.awt.Desktop.Action;
public class Link extends JLabel implements MouseListener { public class Link extends JLabel implements MouseListener {
private static final long serialVersionUID = 3655322136444908178L; private static final long serialVersionUID = 3655322136444908178L;
private static final Logger LOG = LoggerFactory.getLogger(JLabel.class); private static final Logger LOG = LoggerFactory.getLogger(Link.class);
private String url; private String url;
......
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