chore: resolve some warnings reported by IntelliJ Idea
This commit is contained in:
@@ -69,9 +69,9 @@ import jadx.core.xmlgen.ResourcesSaver;
|
||||
public final class JadxDecompiler implements Closeable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxDecompiler.class);
|
||||
|
||||
private JadxArgs args;
|
||||
private JadxPluginManager pluginManager = new JadxPluginManager();
|
||||
private List<ILoadResult> loadedInputs = new ArrayList<>();
|
||||
private final JadxArgs args;
|
||||
private final JadxPluginManager pluginManager = new JadxPluginManager();
|
||||
private final List<ILoadResult> loadedInputs = new ArrayList<>();
|
||||
|
||||
private RootNode root;
|
||||
private List<JavaClass> classes;
|
||||
|
||||
@@ -133,8 +133,11 @@ public class AnnotationGen {
|
||||
public EncodedValue getAnnotationDefaultValue(String name) {
|
||||
IAnnotation an = cls.getAnnotation(Consts.DALVIK_ANNOTATION_DEFAULT);
|
||||
if (an != null) {
|
||||
IAnnotation defAnnotation = (IAnnotation) an.getDefaultValue().getValue();
|
||||
return defAnnotation.getValues().get(name);
|
||||
EncodedValue defValue = an.getDefaultValue();
|
||||
if (defValue != null) {
|
||||
IAnnotation defAnnotation = (IAnnotation) defValue.getValue();
|
||||
return defAnnotation.getValues().get(name);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -234,11 +234,8 @@ public class ClassGen {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param clsCode
|
||||
* @param printClassName allows to print the original class name as comment (e.g. for inlined
|
||||
* classes)
|
||||
* @throws CodegenException
|
||||
*/
|
||||
public void addClassBody(CodeWriter clsCode, boolean printClassName) throws CodegenException {
|
||||
clsCode.add('{');
|
||||
|
||||
@@ -14,6 +14,7 @@ import jadx.api.ICodeInfo;
|
||||
import jadx.api.impl.SimpleCodeInfo;
|
||||
import jadx.core.dex.attributes.nodes.LineAttrNode;
|
||||
import jadx.core.utils.StringUtils;
|
||||
import jadx.core.utils.Utils;
|
||||
|
||||
public class CodeWriter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CodeWriter.class);
|
||||
@@ -153,17 +154,12 @@ public class CodeWriter {
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringRepeatCanBeUsed")
|
||||
private void updateIndent() {
|
||||
int curIndent = indent;
|
||||
if (curIndent < INDENT_CACHE.length) {
|
||||
this.indentStr = INDENT_CACHE[curIndent];
|
||||
} else {
|
||||
StringBuilder s = new StringBuilder(curIndent * INDENT_STR.length());
|
||||
for (int i = 0; i < curIndent; i++) {
|
||||
s.append(INDENT_STR);
|
||||
}
|
||||
this.indentStr = s.toString();
|
||||
this.indentStr = Utils.strRepeat(INDENT_STR, curIndent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ public class Deobfuscator {
|
||||
|
||||
public String getPkgAlias(ClassNode cls) {
|
||||
ClassInfo classInfo = cls.getClassInfo();
|
||||
PackageNode pkg = null;
|
||||
PackageNode pkg;
|
||||
DeobfClsInfo deobfClsInfo = clsMap.get(classInfo);
|
||||
if (deobfClsInfo != null) {
|
||||
pkg = deobfClsInfo.getPkg();
|
||||
@@ -420,9 +420,6 @@ public class Deobfuscator {
|
||||
/**
|
||||
* Generate a prefix for a class name that bases on certain class properties, certain
|
||||
* extended superclasses or implemented interfaces.
|
||||
*
|
||||
* @param cls
|
||||
* @return
|
||||
*/
|
||||
private String makeClsPrefix(ClassNode cls) {
|
||||
if (cls.isEnum()) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import jadx.core.dex.info.MethodInfo;
|
||||
|
||||
class OverridedMethodsNode {
|
||||
|
||||
private Set<MethodInfo> methods;
|
||||
private final Set<MethodInfo> methods;
|
||||
|
||||
public OverridedMethodsNode(Set<MethodInfo> methodsSet) {
|
||||
methods = methodsSet;
|
||||
|
||||
@@ -454,6 +454,7 @@ public class InsnNode extends LineAttrNode {
|
||||
/**
|
||||
* Compare instruction only by identity.
|
||||
*/
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
|
||||
@@ -434,6 +434,7 @@ public class RootNode {
|
||||
return appPackage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassNode getAppResClass() {
|
||||
return appResClass;
|
||||
}
|
||||
|
||||
@@ -259,6 +259,7 @@ public class SignatureParser {
|
||||
* <p/>
|
||||
* Example: "<T:Ljava/lang/Exception;:Ljava/lang/Object;>"
|
||||
*/
|
||||
@SuppressWarnings("ConditionalBreakInInfiniteLoop")
|
||||
public List<ArgType> consumeGenericTypeParameters() {
|
||||
if (!lookAhead('<')) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class OverrideMethodVisitor extends AbstractVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: Simplified version of method from {@link ModVisitor#isFieldVisibleInMethod}
|
||||
* NOTE: Simplified version of method from ModVisitor.isFieldVisibleInMethod
|
||||
*/
|
||||
private boolean isMethodVisibleInCls(MethodNode superMth, ClassNode cls) {
|
||||
AccessInfo accessFlags = superMth.getAccessFlags();
|
||||
|
||||
@@ -38,12 +38,9 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
|
||||
Map<BlockNode, TryCatchBlock> tryBlocksMap = new HashMap<>(2);
|
||||
searchTryCatchDominators(mth, tryBlocksMap);
|
||||
|
||||
IRegionIterativeVisitor visitor = new IRegionIterativeVisitor() {
|
||||
@Override
|
||||
public boolean visitRegion(MethodNode mth, IRegion region) {
|
||||
boolean changed = checkAndWrap(mth, tryBlocksMap, region);
|
||||
return changed && !tryBlocksMap.isEmpty();
|
||||
}
|
||||
IRegionIterativeVisitor visitor = (regionMth, region) -> {
|
||||
boolean changed = checkAndWrap(regionMth, tryBlocksMap, region);
|
||||
return changed && !tryBlocksMap.isEmpty();
|
||||
};
|
||||
DepthRegionTraversal.traverseIncludingExcHandlers(mth, visitor);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public class RegionMaker {
|
||||
|
||||
private final MethodNode mth;
|
||||
private final int regionsLimit;
|
||||
private final BitSet processedBlocks;
|
||||
private int regionsCount;
|
||||
private BitSet processedBlocks;
|
||||
|
||||
public RegionMaker(MethodNode mth) {
|
||||
this.mth = mth;
|
||||
|
||||
@@ -34,12 +34,13 @@ final class RegionStack {
|
||||
exits = new HashSet<>(4);
|
||||
}
|
||||
|
||||
private State(State c) {
|
||||
exits = new HashSet<>(c.exits);
|
||||
private State(State c, IRegion region) {
|
||||
this.exits = new HashSet<>(c.exits);
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public State copy() {
|
||||
return new State(this);
|
||||
public State copyWith(IRegion region) {
|
||||
return new State(this, region);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,8 +65,7 @@ final class RegionStack {
|
||||
if (stack.size() > REGIONS_STACK_LIMIT) {
|
||||
throw new JadxOverflowException("Regions stack size limit reached");
|
||||
}
|
||||
curState = curState.copy();
|
||||
curState.region = region;
|
||||
curState = curState.copyWith(region);
|
||||
if (DEBUG) {
|
||||
LOG.debug("Stack push: {}: {}", size(), curState);
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import jadx.core.utils.Utils;
|
||||
|
||||
public abstract class AbstractTypeConstraint implements ITypeConstraint {
|
||||
|
||||
protected InsnNode insn;
|
||||
protected List<SSAVar> relatedVars;
|
||||
protected final InsnNode insn;
|
||||
protected final List<SSAVar> relatedVars;
|
||||
|
||||
public AbstractTypeConstraint(InsnNode insn, InsnArg arg) {
|
||||
this.insn = insn;
|
||||
|
||||
@@ -17,7 +17,7 @@ import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
public class TypeSearchState {
|
||||
|
||||
private Map<SSAVar, TypeSearchVarInfo> varInfoMap;
|
||||
private final Map<SSAVar, TypeSearchVarInfo> varInfoMap;
|
||||
|
||||
public TypeSearchState(MethodNode mth) {
|
||||
List<SSAVar> vars = mth.getSVars();
|
||||
|
||||
@@ -25,8 +25,8 @@ public class ExportGradleProject {
|
||||
|
||||
private final RootNode root;
|
||||
private final File outDir;
|
||||
private File srcOutDir;
|
||||
private File resOutDir;
|
||||
private final File srcOutDir;
|
||||
private final File resOutDir;
|
||||
|
||||
public ExportGradleProject(RootNode root, File outDir) {
|
||||
this.root = root;
|
||||
|
||||
@@ -160,6 +160,7 @@ public class DebugChecks {
|
||||
InsnNode parentInsn = useArg.getParentInsn();
|
||||
if (parentInsn != null && parentInsn == usedInPhi) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
@@ -168,5 +169,4 @@ public class DebugChecks {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class EncodedValueUtils {
|
||||
case ENCODED_DOUBLE:
|
||||
return InsnArg.lit(Double.doubleToLongBits((Double) value), ArgType.DOUBLE);
|
||||
case ENCODED_STRING:
|
||||
// noinspection RedundantCast
|
||||
return (String) value;
|
||||
|
||||
case ENCODED_TYPE:
|
||||
|
||||
@@ -88,8 +88,8 @@ public final class ImmutableList<E> implements List<E>, RandomAccess {
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new Iterator<E>() {
|
||||
private final int len = arr.length;
|
||||
private int index = 0;
|
||||
private int len = arr.length;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ExtDataInput extends DataInputDelegate {
|
||||
@SuppressWarnings("InnerAssignment")
|
||||
public final int skipBytes(int n) throws IOException {
|
||||
int total = 0;
|
||||
int cur = 0;
|
||||
int cur;
|
||||
|
||||
while ((total < n) && ((cur = super.skipBytes(n - total)) > 0)) {
|
||||
total += cur;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
|
||||
private int namespaceDepth = 0;
|
||||
private int[] resourceIds;
|
||||
|
||||
private RootNode rootNode;
|
||||
private final RootNode rootNode;
|
||||
private String appPackageName;
|
||||
|
||||
public BinaryXMLParser(RootNode rootNode) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ResourcesSaver implements Runnable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResourcesSaver.class);
|
||||
|
||||
private final ResourceFile resourceFile;
|
||||
private File outDir;
|
||||
private final File outDir;
|
||||
|
||||
public ResourcesSaver(File outDir, ResourceFile resourceFile) {
|
||||
this.resourceFile = resourceFile;
|
||||
|
||||
Reference in New Issue
Block a user