From d553157bb31fb552b0f5506d773db7ad70536596 Mon Sep 17 00:00:00 2001 From: Skylot Date: Mon, 3 Dec 2018 12:36:06 +0300 Subject: [PATCH] fix: hide debug type inference logs --- .../dex/visitors/typeinference/TypeInferenceVisitor.java | 5 +++-- .../jadx/core/dex/visitors/typeinference/TypeUpdate.java | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java b/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java index 9de242932..5207dd3fc 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java @@ -10,6 +10,7 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import jadx.core.Consts; import jadx.core.dex.instructions.IndexInsnNode; import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.LiteralArg; @@ -67,7 +68,7 @@ public final class TypeInferenceVisitor extends AbstractVisitor { if (assignArg.isTypeImmutable()) { ArgType initType = assignArg.getInitType(); TypeUpdateResult result = typeUpdate.apply(ssaVar, initType); - if (result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) { + if (Consts.DEBUG && result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) { LOG.debug("Initial immutable type set rejected: {} -> {}", ssaVar, initType); } } else { @@ -85,7 +86,7 @@ public final class TypeInferenceVisitor extends AbstractVisitor { if (bestTypeOpt.isPresent()) { ArgType candidateType = bestTypeOpt.get(); TypeUpdateResult result = typeUpdate.apply(ssaVar, candidateType); - if (result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) { + if (Consts.DEBUG && result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) { if (ssaVar.getTypeInfo().getType().equals(candidateType)) { LOG.warn("Same type rejected: {} -> {}, bounds: {}", ssaVar, candidateType, bounds); } else { diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java b/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java index 6dbbdaa14..f7e8f974c 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java @@ -7,10 +7,10 @@ import java.util.Objects; import java.util.Set; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import jadx.core.Consts; import jadx.core.dex.instructions.InsnType; import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.InsnArg; @@ -81,7 +81,7 @@ public final class TypeUpdate { private TypeUpdateResult updateTypeForSsaVar(TypeUpdateInfo updateInfo, SSAVar ssaVar, ArgType candidateType) { TypeInfo typeInfo = ssaVar.getTypeInfo(); if (!inBounds(typeInfo.getBounds(), candidateType)) { - if (LOG.isDebugEnabled()) { + if (Consts.DEBUG && LOG.isDebugEnabled()) { LOG.debug("Reject type '{}' for {} by bounds: {}", candidateType, ssaVar, typeInfo.getBounds()); } return REJECT; @@ -153,7 +153,6 @@ public final class TypeUpdate { return true; } - @Nullable private boolean checkBound(ArgType candidateType, ITypeBound bound, ArgType boundType) { TypeCompareEnum compareResult = comparator.compareTypes(candidateType, boundType); switch (compareResult) { @@ -166,9 +165,7 @@ public final class TypeUpdate { case NARROW: if (bound.getBound() == BoundEnum.ASSIGN) { - if (boundType.isTypeKnown() || !checkAssignForUnknown(boundType, candidateType)) { - return false; - } + return !boundType.isTypeKnown() && checkAssignForUnknown(boundType, candidateType); } return true;