Skip to content

Commit

Permalink
fix: hide debug type inference logs
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Dec 3, 2018
1 parent 95f9ab0 commit d553157
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand Down Expand Up @@ -67,7 +68,7 @@ private void setBestType(SSAVar ssaVar) {
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 {
Expand All @@ -85,7 +86,7 @@ private void calculateFromBounds(SSAVar ssaVar) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
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;
Expand Down Expand Up @@ -81,7 +81,7 @@ private TypeUpdateResult updateTypeChecked(TypeUpdateInfo updateInfo, InsnArg ar
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;
Expand Down Expand Up @@ -153,7 +153,6 @@ private boolean inBounds(Set<ITypeBound> bounds, ArgType candidateType) {
return true;
}

@Nullable
private boolean checkBound(ArgType candidateType, ITypeBound bound, ArgType boundType) {
TypeCompareEnum compareResult = comparator.compareTypes(candidateType, boundType);
switch (compareResult) {
Expand All @@ -166,9 +165,7 @@ private boolean checkBound(ArgType candidateType, ITypeBound bound, ArgType boun

case NARROW:
if (bound.getBound() == BoundEnum.ASSIGN) {
if (boundType.isTypeKnown() || !checkAssignForUnknown(boundType, candidateType)) {
return false;
}
return !boundType.isTypeKnown() && checkAssignForUnknown(boundType, candidateType);
}
return true;

Expand Down

0 comments on commit d553157

Please sign in to comment.