From 3a676e5f1f8d2f66e83167ac8cd9d7e176e8f81d Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Mon, 4 Sep 2023 21:30:28 -0400 Subject: [PATCH] Remove redundant initializers In most of these cases, the initializer is redundant because some other assignment to the same location appears after the initialization but before any use. In a few cases involving fields, the explicit initialization value is identical to what would be used implicitly. --- .../java/translator/jdt/JDTJava2CAstTranslator.java | 4 ++-- .../cast/java/translator/Java2IRTranslator.java | 2 +- .../cast/js/nodejs/NodejsRequiredSourceModule.java | 2 +- .../callgraph/fieldbased/flowgraph/FlowGraph.java | 3 +-- .../extraction/CorrelatedPairExtractionPolicy.java | 8 ++++---- .../java/com/ibm/wala/cast/js/test/CAstDumper.java | 3 +-- .../wala/cast/js/test/TestForInBodyExtraction.java | 4 ++-- .../wala/cast/loader/CAstAbstractModuleLoader.java | 3 +-- .../java/com/ibm/wala/cast/util/SourceBuffer.java | 4 ++-- .../arraybounds/hypergraph/weight/NormalOrder.java | 2 +- .../arraybounds/hypergraph/weight/Weight.java | 2 +- .../ExceptionTransferFunctionProvider.java | 3 +-- .../wala/analysis/reflection/CloneInterpreter.java | 2 +- .../reflection/FactoryBypassInterpreter.java | 2 +- .../reflection/ReflectiveInvocationInterpreter.java | 4 ++-- .../wala/analysis/typeInference/TypeInference.java | 2 +- .../com/ibm/wala/classLoader/BytecodeClass.java | 6 +++--- .../com/ibm/wala/classLoader/ClassLoaderImpl.java | 2 +- .../com/ibm/wala/classLoader/ShrikeCTMethod.java | 2 +- .../com/ibm/wala/classLoader/ShrikeIRFactory.java | 2 +- .../com/ibm/wala/core/util/shrike/ShrikeUtil.java | 2 +- .../com/ibm/wala/core/util/strings/StringStuff.java | 2 +- .../ibm/wala/dataflow/IFDS/TabulationSolver.java | 2 +- .../demandpa/alg/ContextSensitiveStateMachine.java | 2 +- .../wala/demandpa/alg/DemandRefinementPointsTo.java | 13 ++++++------- .../demandpa/flowgraph/AbstractDemandFlowGraph.java | 2 +- .../com/ibm/wala/examples/drivers/PDFSlice.java | 2 +- .../wala/ipa/callgraph/impl/AbstractRootMethod.java | 4 ++-- .../propagation/PropagationCallGraphBuilder.java | 2 +- .../ipa/callgraph/propagation/PropagationGraph.java | 2 +- .../callgraph/propagation/PropagationSystem.java | 3 +-- .../propagation/rta/TypeBasedPointerAnalysis.java | 2 +- .../ipa/summaries/BypassMethodTargetSelector.java | 4 ++-- .../wala/ipa/summaries/XMLMethodSummaryReader.java | 2 +- .../com/ibm/wala/properties/WalaProperties.java | 4 ++-- core/src/main/java/com/ibm/wala/ssa/SSABuilder.java | 2 +- core/src/main/java/com/ibm/wala/ssa/SSACFG.java | 2 +- .../com/ibm/wala/dalvik/classLoader/DexIMethod.java | 2 +- .../com/ibm/wala/dalvik/classLoader/DexUtil.java | 2 +- .../parameters/AndroidModelParameterManager.java | 2 +- .../structure/AbstractAndroidModel.java | 8 ++++---- .../java/com/ibm/wala/dalvik/ssa/DexSSABuilder.java | 2 +- .../main/java/com/ibm/wala/ide/util/JdtUtil.java | 2 +- .../java/org/scandroid/model/AppModelMethod.java | 6 +++--- .../prefixtransfer/PrefixTransferGraph.java | 2 +- .../main/java/org/scandroid/util/DexDotUtil.java | 2 +- .../main/java/org/scandroid/util/EntryPoints.java | 7 +++---- .../shrike/shrikeBT/shrikeCT/ClassInstrumenter.java | 2 +- .../ibm/wala/util/collections/ImmutableStack.java | 4 ++-- .../com/ibm/wala/util/collections/SparseVector.java | 2 +- .../com/ibm/wala/util/graph/GraphIntegrity.java | 10 +++++----- .../ibm/wala/util/intset/BasicNaturalRelation.java | 2 +- .../java/com/ibm/wala/util/intset/BitVector.java | 4 +--- .../com/ibm/wala/util/intset/BitVectorBase.java | 2 +- .../ibm/wala/util/intset/FixedSizeBitVector.java | 2 +- .../com/ibm/wala/util/intset/MutableMapping.java | 2 +- .../main/java/com/ibm/wala/util/viz/DotUtil.java | 2 +- 57 files changed, 86 insertions(+), 95 deletions(-) diff --git a/cast/java/ecj/src/main/java/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java b/cast/java/ecj/src/main/java/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java index b3a7728f82..e31e656d39 100644 --- a/cast/java/ecj/src/main/java/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java +++ b/cast/java/ecj/src/main/java/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java @@ -186,7 +186,7 @@ // possible) public abstract class JDTJava2CAstTranslator { - protected boolean dump = false; + protected boolean dump; protected final CAst fFactory = new CAstImpl(); @@ -1083,7 +1083,7 @@ private ProcedureEntity( } if (fDecl != null) { - int i = 0; // index to start filling up with real params + int i; // index to start filling up with real params if ((fModifiers & Modifier.STATIC) != 0) { fParameterNames = new String[fDecl.parameters().size()]; i = 0; diff --git a/cast/java/src/main/java/com/ibm/wala/cast/java/translator/Java2IRTranslator.java b/cast/java/src/main/java/com/ibm/wala/cast/java/translator/Java2IRTranslator.java index 90ce1e0e01..8dc688e223 100644 --- a/cast/java/src/main/java/com/ibm/wala/cast/java/translator/Java2IRTranslator.java +++ b/cast/java/src/main/java/com/ibm/wala/cast/java/translator/Java2IRTranslator.java @@ -31,7 +31,7 @@ public class Java2IRTranslator { protected final SetOfClasses exclusions; - CAstRewriterFactory castRewriterFactory = null; + CAstRewriterFactory castRewriterFactory; public Java2IRTranslator(JavaSourceLoaderImpl srcLoader, SetOfClasses exclusions) { this(srcLoader, null, exclusions); diff --git a/cast/js/nodejs/src/main/java/com/ibm/wala/cast/js/nodejs/NodejsRequiredSourceModule.java b/cast/js/nodejs/src/main/java/com/ibm/wala/cast/js/nodejs/NodejsRequiredSourceModule.java index 13ecbdbea2..f13fa9e65a 100644 --- a/cast/js/nodejs/src/main/java/com/ibm/wala/cast/js/nodejs/NodejsRequiredSourceModule.java +++ b/cast/js/nodejs/src/main/java/com/ibm/wala/cast/js/nodejs/NodejsRequiredSourceModule.java @@ -70,7 +70,7 @@ public InputStream getInputStream() { Assertions.UNREACHABLE(e.getMessage()); } - String wrapperSource = null; + final String wrapperSource; String ext = FilenameUtils.getExtension(getFile().toString()).toLowerCase(); switch (ext) { case "js": diff --git a/cast/js/src/main/java/com/ibm/wala/cast/js/callgraph/fieldbased/flowgraph/FlowGraph.java b/cast/js/src/main/java/com/ibm/wala/cast/js/callgraph/fieldbased/flowgraph/FlowGraph.java index db3e4031c0..a50b6bfd44 100644 --- a/cast/js/src/main/java/com/ibm/wala/cast/js/callgraph/fieldbased/flowgraph/FlowGraph.java +++ b/cast/js/src/main/java/com/ibm/wala/cast/js/callgraph/fieldbased/flowgraph/FlowGraph.java @@ -185,8 +185,7 @@ public PointerAnalysis getPointerAnalysis( private final Map, PrototypeFieldVertex> proto = HashMapFactory.make(); - private GraphReachability pointerAnalysis = - computeClosure(graph, monitor, ObjectVertex.class); + private GraphReachability pointerAnalysis; private final ExtensionGraph dataflow = new ExtensionGraph<>(graph); diff --git a/cast/js/src/main/java/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/CorrelatedPairExtractionPolicy.java b/cast/js/src/main/java/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/CorrelatedPairExtractionPolicy.java index 46dd732066..f2df452472 100644 --- a/cast/js/src/main/java/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/CorrelatedPairExtractionPolicy.java +++ b/cast/js/src/main/java/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/CorrelatedPairExtractionPolicy.java @@ -96,7 +96,7 @@ private boolean addCorrelation( if (!entity.getPosition().getURL().toString().equals(startPos.getURL().toString())) return true; Set startNodes = findNodesAtPos(CAstNode.OBJECT_REF, startPos, entity); - Set endNodes = null; + final Set endNodes; if (corr instanceof ReadWriteCorrelation) { endNodes = findNodesAtPos(CAstNode.ASSIGN, endPos, entity); } else if (corr instanceof EscapeCorrelation) { @@ -207,9 +207,9 @@ private static void filterNames(Set nodes, String indexName) { String parmName, List locals) { ChildPos pos = startNode; - CAstNode block = null; - int start = -1, end = 0; - int start_inner = -1, end_inner = -1; + CAstNode block; + int start, end; + int start_inner, end_inner = -1; do { if (pos != startNode && pos.getParentPos() instanceof ChildPos) diff --git a/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/CAstDumper.java b/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/CAstDumper.java index d0732df59b..7aa2933404 100644 --- a/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/CAstDumper.java +++ b/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/CAstDumper.java @@ -24,7 +24,6 @@ import com.ibm.wala.util.collections.HashMapFactory; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.Map.Entry; @@ -63,7 +62,7 @@ public String dump(CAstEntity entity) { } private void dump(CAstEntity entity, int indent, StringBuilder buf) { - Collection scopedEntities = Collections.emptySet(); + final Collection scopedEntities; if (entity.getKind() == CAstEntity.SCRIPT_ENTITY) { buf.append(indent(indent)).append(entity.getName()).append(":\n"); scopedEntities = dumpScopedEntities(entity, indent + 2, buf); diff --git a/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/TestForInBodyExtraction.java b/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/TestForInBodyExtraction.java index c96bf4c7bc..48058ab6a8 100644 --- a/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/TestForInBodyExtraction.java +++ b/cast/js/src/testFixtures/java/com/ibm/wala/cast/js/test/TestForInBodyExtraction.java @@ -53,8 +53,8 @@ public static String eraseGeneratedNames(String str) { } public void testRewriter(String testName, String in, String out) { - String expected = null; - String actual = null; + String expected; + String actual; try { final var tmp = File.createTempFile("test", ".js", tmpDir); FileUtil.writeFile(tmp, in); diff --git a/cast/src/main/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java b/cast/src/main/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java index 19978a8cac..cb471cf987 100644 --- a/cast/src/main/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java +++ b/cast/src/main/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java @@ -162,9 +162,8 @@ private void translateModuleEntryToCAst( } else { TranslatorToCAst xlatorToCAst = getTranslatorToCAst(ast, moduleEntry, modules); - CAstEntity fileEntity = null; try { - fileEntity = xlatorToCAst.translateToCAst(); + final CAstEntity fileEntity = xlatorToCAst.translateToCAst(); if (DEBUG) { CAstPrinter.printTo(fileEntity, new PrintWriter(System.err)); diff --git a/cast/src/main/java/com/ibm/wala/cast/util/SourceBuffer.java b/cast/src/main/java/com/ibm/wala/cast/util/SourceBuffer.java index fa6bf4dfe1..9b3693ace9 100644 --- a/cast/src/main/java/com/ibm/wala/cast/util/SourceBuffer.java +++ b/cast/src/main/java/com/ibm/wala/cast/util/SourceBuffer.java @@ -103,7 +103,7 @@ public SourceBuffer(Position p) throws IOException { try (Reader pr = p.getReader()) { try (BufferedReader reader = new BufferedReader(pr)) { - String currentLine = null; + String currentLine; List lines = new ArrayList<>(); int offset = 0, line = 0; do { @@ -123,7 +123,7 @@ public SourceBuffer(Position p) throws IOException { int endColumn = -1; int startOffset = -1; int startLine = line; - int startColumn = -1; + final int startColumn; if (p.getLastOffset() >= 0) { if (p.getFirstOffset() == offset) { startOffset = p.getFirstOffset(); diff --git a/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/NormalOrder.java b/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/NormalOrder.java index 33d1759a3e..2a5cd110df 100644 --- a/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/NormalOrder.java +++ b/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/NormalOrder.java @@ -13,7 +13,7 @@ public class NormalOrder implements Comparator { @Override public int compare(Weight o1, Weight o2) { - int result = 0; + final int result; if (o1.getType() == Type.NOT_SET || o2.getType() == Type.NOT_SET) { throw new IllegalArgumentException("Tried to compare weights, which are not set yet."); diff --git a/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/Weight.java b/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/Weight.java index f52b3cf49b..579db9ce2d 100644 --- a/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/Weight.java +++ b/core/src/main/java/com/ibm/wala/analysis/arraybounds/hypergraph/weight/Weight.java @@ -39,7 +39,7 @@ public Weight(Type type, int number) { * @return this + other */ public Weight add(Weight other) { - Weight result = null; + final Weight result; if (this.getType() == Type.NUMBER) { if (other.getType() == Type.NUMBER) { result = new Weight(Type.NUMBER, this.getNumber() + other.getNumber()); diff --git a/core/src/main/java/com/ibm/wala/analysis/exceptionanalysis/ExceptionTransferFunctionProvider.java b/core/src/main/java/com/ibm/wala/analysis/exceptionanalysis/ExceptionTransferFunctionProvider.java index af2d6571b8..2511e8d8d7 100644 --- a/core/src/main/java/com/ibm/wala/analysis/exceptionanalysis/ExceptionTransferFunctionProvider.java +++ b/core/src/main/java/com/ibm/wala/analysis/exceptionanalysis/ExceptionTransferFunctionProvider.java @@ -71,7 +71,6 @@ public UnaryOperator getEdgeTransferFunction(CGNode dst, CGNo */ Iterator callsites = cg.getPossibleSites(src, dst); - BitVector filtered = new BitVector(transformer.getValues().getSize()); if (callsites.hasNext()) { @@ -84,7 +83,7 @@ public UnaryOperator getEdgeTransferFunction(CGNode dst, CGNo caught.retainAll(intraResult.getAnalysis(src).getCaughtExceptions(callsite)); } - filtered = transformer.computeBitVector(caught); + BitVector filtered = transformer.computeBitVector(caught); return new BitVectorMinusVector(filtered); } else { // This case should not happen, as we should only get src, dst pairs, diff --git a/core/src/main/java/com/ibm/wala/analysis/reflection/CloneInterpreter.java b/core/src/main/java/com/ibm/wala/analysis/reflection/CloneInterpreter.java index 08689b4f7c..eb32a4bfc1 100644 --- a/core/src/main/java/com/ibm/wala/analysis/reflection/CloneInterpreter.java +++ b/core/src/main/java/com/ibm/wala/analysis/reflection/CloneInterpreter.java @@ -162,7 +162,7 @@ private SSAInstruction[] makeStatements(IClass klass) { int retValue = nextLocal++; // value number of the result of the clone() NewSiteReference ref = NewSiteReference.make(NEW_PC, klass.getReference()); - SSANewInstruction N = null; + final SSANewInstruction N; if (klass.isArrayClass()) { int length = nextLocal++; statements.add(insts.ArrayLengthInstruction(statements.size(), length, 1)); diff --git a/core/src/main/java/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java b/core/src/main/java/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java index 61c4aadbf5..fb8281270b 100644 --- a/core/src/main/java/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java +++ b/core/src/main/java/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java @@ -532,7 +532,7 @@ private void addStatementsForSetOfTypes(Iterator it) { typesAllocated.add(T); int i = getLocalForType(T); NewSiteReference ref = NewSiteReference.make(getNewSiteForType(T), T); - SSANewInstruction a = null; + final SSANewInstruction a; if (T.isArrayType()) { int[] sizes = new int[((ArrayClass) klass).getDimensionality()]; initValueNumberForConstantOne(); diff --git a/core/src/main/java/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java b/core/src/main/java/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java index dc232b3577..d2d3a6e6fc 100644 --- a/core/src/main/java/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java +++ b/core/src/main/java/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java @@ -175,7 +175,7 @@ private IR makeIR(IMethod method, IMethod target, Context recv) { // pointer int args[] = new int[nargs]; int pc = 0; - int parametersVn = -1; // parametersVn will hold the value number of parameters array + final int parametersVn; // parametersVn will hold the value number of parameters array if (method.getReference().equals(CTOR_NEW_INSTANCE)) { // allocate the new object constructed @@ -239,7 +239,7 @@ private IR makeIR(IMethod method, IMethod target, Context recv) { } int exceptions = nextLocal++; - int result = -1; + final int result; // emit the dispatch and return instructions if (method.getReference().equals(CTOR_NEW_INSTANCE)) { diff --git a/core/src/main/java/com/ibm/wala/analysis/typeInference/TypeInference.java b/core/src/main/java/com/ibm/wala/analysis/typeInference/TypeInference.java index eb6c85b79b..f8e2e4af67 100644 --- a/core/src/main/java/com/ibm/wala/analysis/typeInference/TypeInference.java +++ b/core/src/main/java/com/ibm/wala/analysis/typeInference/TypeInference.java @@ -646,7 +646,7 @@ private TypeAbstraction meetDeclaredExceptionTypes(SSAGetCaughtExceptionInstruct Iterator it = bb.getCaughtExceptionTypes(); TypeReference t = it.next(); IClass klass = cha.lookupClass(t); - TypeAbstraction result = null; + TypeAbstraction result; if (klass == null) { // a type that cannot be loaded. // be pessimistic diff --git a/core/src/main/java/com/ibm/wala/classLoader/BytecodeClass.java b/core/src/main/java/com/ibm/wala/classLoader/BytecodeClass.java index 26860ddd82..ba0b66a88c 100644 --- a/core/src/main/java/com/ibm/wala/classLoader/BytecodeClass.java +++ b/core/src/main/java/com/ibm/wala/classLoader/BytecodeClass.java @@ -211,7 +211,7 @@ public IField getField(Atom name) { @Override public IField getField(Atom name, TypeName type) { - boolean unresolved = false; + boolean unresolved; try { // typically, there will be at most one field with the name IField field = getField(name); @@ -452,7 +452,7 @@ protected Collection computeAllInterfacesAsCollection() { // at this point result holds all interfaces the class directly extends. // now expand to a fixed point. - Set last = null; + Set last; do { last = HashSetFactory.make(result); for (IClass i : last) { @@ -519,7 +519,7 @@ protected void addFieldToList( Collection annotations, Collection typeAnnotations, TypeSignature sig) { - TypeName T = null; + final TypeName T; if (fieldType.get(fieldType.length() - 1) == ';') { T = TypeName.findOrCreate(fieldType, 0, fieldType.length() - 1); } else { diff --git a/core/src/main/java/com/ibm/wala/classLoader/ClassLoaderImpl.java b/core/src/main/java/com/ibm/wala/classLoader/ClassLoaderImpl.java index 2615c2a802..12c8e60610 100644 --- a/core/src/main/java/com/ibm/wala/classLoader/ClassLoaderImpl.java +++ b/core/src/main/java/com/ibm/wala/classLoader/ClassLoaderImpl.java @@ -291,7 +291,7 @@ private Map getAllClassAndSourceFileContents( Map result = HashMapFactory.make(); try (final JarInputStream s = new JarInputStream(new ByteArrayInputStream(jarFileContents), false)) { - JarEntry entry = null; + JarEntry entry; while ((entry = s.getNextJarEntry()) != null) { byte[] entryBytes = getEntryBytes(entrySizesForFile.get(entry.getName()), s); if (entryBytes == null) { diff --git a/core/src/main/java/com/ibm/wala/classLoader/ShrikeCTMethod.java b/core/src/main/java/com/ibm/wala/classLoader/ShrikeCTMethod.java index a0682fc292..624a84bdd7 100644 --- a/core/src/main/java/com/ibm/wala/classLoader/ShrikeCTMethod.java +++ b/core/src/main/java/com/ibm/wala/classLoader/ShrikeCTMethod.java @@ -269,7 +269,7 @@ protected void processDebugInfo(BytecodeInfo bcInfo) throws InvalidClassFileExce @Override public String getLocalVariableName(int bcIndex, int localNumber) { - int[][] map = null; + final int[][] map; try { map = getBCInfo().localVariableMap; } catch (InvalidClassFileException e1) { diff --git a/core/src/main/java/com/ibm/wala/classLoader/ShrikeIRFactory.java b/core/src/main/java/com/ibm/wala/classLoader/ShrikeIRFactory.java index bdb9f5ee56..109dd7c6d3 100644 --- a/core/src/main/java/com/ibm/wala/classLoader/ShrikeIRFactory.java +++ b/core/src/main/java/com/ibm/wala/classLoader/ShrikeIRFactory.java @@ -46,7 +46,7 @@ public IR makeIR(final IBytecodeMethod method, Context C, final SS if (method == null) { throw new IllegalArgumentException("null method"); } - com.ibm.wala.shrike.shrikeBT.IInstruction[] shrikeInstructions = null; + final com.ibm.wala.shrike.shrikeBT.IInstruction[] shrikeInstructions; try { shrikeInstructions = method.getInstructions(); } catch (InvalidClassFileException e) { diff --git a/core/src/main/java/com/ibm/wala/core/util/shrike/ShrikeUtil.java b/core/src/main/java/com/ibm/wala/core/util/shrike/ShrikeUtil.java index 0d53e62506..36976bdd01 100644 --- a/core/src/main/java/com/ibm/wala/core/util/shrike/ShrikeUtil.java +++ b/core/src/main/java/com/ibm/wala/core/util/shrike/ShrikeUtil.java @@ -51,7 +51,7 @@ public static TypeReference makeTypeReference(ClassLoaderReference loader, Strin return p; } ImmutableByteArray b = ImmutableByteArray.make(type); - TypeName T = null; + final TypeName T; /*if (b.get(0) != '[') { T = TypeName.findOrCreate(b, 0, b.length() - 1); } else {*/ diff --git a/core/src/main/java/com/ibm/wala/core/util/strings/StringStuff.java b/core/src/main/java/com/ibm/wala/core/util/strings/StringStuff.java index 145bcbdc5a..3927dc5201 100644 --- a/core/src/main/java/com/ibm/wala/core/util/strings/StringStuff.java +++ b/core/src/main/java/com/ibm/wala/core/util/strings/StringStuff.java @@ -274,7 +274,7 @@ public static final TypeName[] parseForParameterNames(Language l, ImmutableByteA while (StringStuff.isTypeCodeChar(b, i)) { ++i; } - TypeName T = null; + final TypeName T; byte c = b.get(i++); if (c == TypeReference.ClassTypeCode || c == TypeReference.OtherPrimitiveTypeCode) { while (b.get(i++) != ';') diff --git a/core/src/main/java/com/ibm/wala/dataflow/IFDS/TabulationSolver.java b/core/src/main/java/com/ibm/wala/dataflow/IFDS/TabulationSolver.java index f7cba0298d..7f239eeba8 100644 --- a/core/src/main/java/com/ibm/wala/dataflow/IFDS/TabulationSolver.java +++ b/core/src/main/java/com/ibm/wala/dataflow/IFDS/TabulationSolver.java @@ -550,7 +550,7 @@ protected void processCall(final PathEdge edge) { if (DEBUG_LEVEL > 0) { System.err.println(" process return site: " + returnSite); } - IUnaryFlowFunction f = null; + final IUnaryFlowFunction f; if (hasCallee) { f = flowFunctionMap.getCallToReturnFlowFunction(edge.target, returnSite); } else { diff --git a/core/src/main/java/com/ibm/wala/demandpa/alg/ContextSensitiveStateMachine.java b/core/src/main/java/com/ibm/wala/demandpa/alg/ContextSensitiveStateMachine.java index 5fa0ce0dd8..f32ce1a471 100644 --- a/core/src/main/java/com/ibm/wala/demandpa/alg/ContextSensitiveStateMachine.java +++ b/core/src/main/java/com/ibm/wala/demandpa/alg/ContextSensitiveStateMachine.java @@ -175,7 +175,7 @@ private void handleMethodEntry(CallerSiteContext callSite) { System.err.println("FOUND RECURSION"); System.err.println("stack " + prevStack + " contains " + callSite); } - CallerSiteContext topCallSite = null; + CallerSiteContext topCallSite; CallStack tmpStack = prevStack; // mark the appropriate call sites as recursive // and pop them diff --git a/core/src/main/java/com/ibm/wala/demandpa/alg/DemandRefinementPointsTo.java b/core/src/main/java/com/ibm/wala/demandpa/alg/DemandRefinementPointsTo.java index 148fe4c380..4b8bbde3c4 100644 --- a/core/src/main/java/com/ibm/wala/demandpa/alg/DemandRefinementPointsTo.java +++ b/core/src/main/java/com/ibm/wala/demandpa/alg/DemandRefinementPointsTo.java @@ -330,12 +330,11 @@ private Pair> outerRefinementLoo setNumNodesTraversed(0); setTraversalBudget(refinementPolicy.getBudgetForPass(passNum)); Collection curP2Set = null; - PointsToComputer computer = null; boolean completedPassInBudget = false; try { while (true) { try { - computer = new PointsToComputer(queried); + final PointsToComputer computer = new PointsToComputer(queried); computer.compute(); curP2Set = computer.getComputedP2Set(queried); // System.err.println("completed pass"); @@ -382,7 +381,7 @@ private Pair> outerRefinementLoo break; } } - PointsToResult result = null; + final PointsToResult result; if (succeeded) { result = PointsToResult.SUCCESS; } else if (passNum == numPasses) { @@ -491,7 +490,7 @@ public PointsToResult pointsToPassesPred( break; } } - PointsToResult result = null; + final PointsToResult result; if (succeeded) { result = PointsToResult.SUCCESS; } else if (passNum == numPasses) { @@ -572,7 +571,7 @@ private Pair> getFlowsToInternal( setNumNodesTraversed(0); setTraversalBudget(refinementPolicy.getBudgetForPass(passNum)); Collection curFlowsToSet = null; - FlowsToComputer computer = null; + FlowsToComputer computer; try { while (true) { try { @@ -619,7 +618,7 @@ private Pair> getFlowsToInternal( break; } } - PointsToResult result = null; + final PointsToResult result; if (succeeded) { result = PointsToResult.SUCCESS; } else if (passNum == numPasses) { @@ -2433,7 +2432,7 @@ private Collection> getBaseAndStored( return null; } IR ir = node.getIR(); - PointerKey base = null, stored = null; + final PointerKey base, stored; if (field == ArrayContents.v()) { final SSAInstruction instruction = ir.getInstructions()[fieldWrite.getInstructionIndex()]; diff --git a/core/src/main/java/com/ibm/wala/demandpa/flowgraph/AbstractDemandFlowGraph.java b/core/src/main/java/com/ibm/wala/demandpa/flowgraph/AbstractDemandFlowGraph.java index fbcc37e896..5e6c67a11a 100644 --- a/core/src/main/java/com/ibm/wala/demandpa/flowgraph/AbstractDemandFlowGraph.java +++ b/core/src/main/java/com/ibm/wala/demandpa/flowgraph/AbstractDemandFlowGraph.java @@ -346,7 +346,7 @@ private static void debugPrintIR(IR ir) { @Override public Set getPotentialCallers(PointerKey formalPk) { - CGNode callee = null; + final CGNode callee; if (formalPk instanceof LocalPointerKey) { callee = ((LocalPointerKey) formalPk).getNode(); } else if (formalPk instanceof ReturnValueKey) { diff --git a/core/src/main/java/com/ibm/wala/examples/drivers/PDFSlice.java b/core/src/main/java/com/ibm/wala/examples/drivers/PDFSlice.java index a4e11b36a2..9e4e8068c0 100644 --- a/core/src/main/java/com/ibm/wala/examples/drivers/PDFSlice.java +++ b/core/src/main/java/com/ibm/wala/examples/drivers/PDFSlice.java @@ -170,7 +170,7 @@ public static Process run( System.err.println("Statement: " + s); // compute the slice as a collection of statements - Collection slice = null; + final Collection slice; if (goBackward) { final PointerAnalysis pointerAnalysis = builder.getPointerAnalysis(); slice = Slicer.computeBackwardSlice(s, cg, pointerAnalysis, dOptions, cOptions); diff --git a/core/src/main/java/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java b/core/src/main/java/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java index 8ac8f5fd55..43e1c83f80 100644 --- a/core/src/main/java/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java +++ b/core/src/main/java/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java @@ -149,7 +149,7 @@ public SSAAbstractInvokeInstruction addInvocation(int[] params, CallSiteReferenc CallSiteReference newSite = CallSiteReference.make( statements.size(), site.getDeclaredTarget(), site.getInvocationCode()); - SSAAbstractInvokeInstruction s = null; + final SSAAbstractInvokeInstruction s; if (newSite.getDeclaredTarget().getReturnType().equals(TypeReference.Void)) { s = insts.InvokeInstruction(statements.size(), params, nextLocal++, newSite, null); } else { @@ -238,7 +238,7 @@ private SSANewInstruction addAllocation(TypeReference T, boolean invokeCtor) { // allocate an instance for the array contents NewSiteReference n = NewSiteReference.make(statements.size(), e); int alloc = nextLocal++; - SSANewInstruction ni = null; + final SSANewInstruction ni; if (e.isArrayType()) { int[] sizes = new int[((ArrayClass) cha.lookupClass(T)).getDimensionality()]; Arrays.fill(sizes, getValueNumberForIntConstant(1)); diff --git a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java index 8584ce8ae8..7022ba324b 100644 --- a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java +++ b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java @@ -1331,7 +1331,7 @@ protected IntSet getInstanceKeysForClass(IClass klass) { */ @SuppressWarnings("unused") protected IntSet filterForClass(IntSet S, IClass klass) { - MutableIntSet filter = null; + final MutableIntSet filter; if (klass.getReference().equals(TypeReference.JavaLangObject)) { return S; } else { diff --git a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationGraph.java b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationGraph.java index ae270e68f6..4dc8061e18 100644 --- a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationGraph.java +++ b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationGraph.java @@ -103,7 +103,7 @@ private static IBinaryNaturalRelation findOrCreateRelation( * @return a Relation object to track implicit equations using the operator */ private static IBinaryNaturalRelation makeRelation(AbstractOperator op) { - byte[] implementation = null; + final byte[] implementation; if (op instanceof AssignOperator) { // lots of assignments. implementation = diff --git a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationSystem.java b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationSystem.java index 07e5f3c421..03dce2d093 100644 --- a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationSystem.java +++ b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/PropagationSystem.java @@ -470,8 +470,7 @@ private int registerMultiDimArraysForArrayOfObjectTypes(int dim, int index, Arra for (int i = 1; i < dim; i++) { TypeReference jlo = makeArray(TypeReference.JavaLangObject, i); - IClass jloClass = null; - jloClass = aClass.getClassLoader().lookupClass(jlo.getName()); + final IClass jloClass = aClass.getClassLoader().lookupClass(jlo.getName()); MutableIntSet set = findOrCreateSparseSetForClass(jloClass); set.add(index); } diff --git a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/rta/TypeBasedPointerAnalysis.java b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/rta/TypeBasedPointerAnalysis.java index 7dd6fb916d..08aa97d8dc 100644 --- a/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/rta/TypeBasedPointerAnalysis.java +++ b/core/src/main/java/com/ibm/wala/ipa/callgraph/propagation/rta/TypeBasedPointerAnalysis.java @@ -102,7 +102,7 @@ public OrdinalSet getPointsToSet(PointerKey key) throws IllegalArgu /** Compute the set of {@link InstanceKey}s which may represent a particular type. */ private OrdinalSet computeOrdinalInstanceSet(IClass type) { - Collection klasses = null; + final Collection klasses; if (type.isInterface()) { klasses = getCallGraph().getClassHierarchy().getImplementors(type.getReference()); } else { diff --git a/core/src/main/java/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java b/core/src/main/java/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java index 75aa992c69..bd90bac271 100644 --- a/core/src/main/java/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java +++ b/core/src/main/java/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java @@ -160,7 +160,7 @@ protected SyntheticMethod findOrCreateSyntheticMethod(MethodReference m, boolean if (syntheticMethods.containsKey(m)) { return syntheticMethods.get(m); } else { - MethodSummary summ = null; + final MethodSummary summ; if (canIgnore(m)) { TypeReference T = m.getDeclaringClass(); IClass C = cha.lookupClass(T); @@ -199,7 +199,7 @@ protected SyntheticMethod findOrCreateSyntheticMethod(IMethod m, boolean isStati if (syntheticMethods.containsKey(ref)) { return syntheticMethods.get(ref); } else { - MethodSummary summ = null; + final MethodSummary summ; if (canIgnore(ref)) { summ = generateNoOp(ref, isStatic); } else { diff --git a/core/src/main/java/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java b/core/src/main/java/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java index 56e59c8deb..07fc9b3fa8 100644 --- a/core/src/main/java/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java +++ b/core/src/main/java/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java @@ -538,7 +538,7 @@ private void processAllocation(Attributes atts) { // create the allocation statement and add it to the method summary NewSiteReference ref = NewSiteReference.make(governingMethod.getNumberOfStatements(), type); - SSANewInstruction a = null; + final SSANewInstruction a; if (type.isArrayType()) { String size = atts.getValue(A_SIZE); Assertions.productionAssertion(size != null); diff --git a/core/src/main/java/com/ibm/wala/properties/WalaProperties.java b/core/src/main/java/com/ibm/wala/properties/WalaProperties.java index a7881ad1fd..96b821e7c2 100644 --- a/core/src/main/java/com/ibm/wala/properties/WalaProperties.java +++ b/core/src/main/java/com/ibm/wala/properties/WalaProperties.java @@ -71,7 +71,7 @@ public static String[] getJ2SEJarFiles() { * @see PlatformUtil#getJDKModules(boolean) */ public static String[] getJDKLibraryFiles(boolean justBase) { - Properties p = null; + final Properties p; try { p = WalaProperties.loadProperties(); } catch (WalaException e) { @@ -97,7 +97,7 @@ public static String[] getJDKLibraryFiles(boolean justBase) { * @throws IllegalStateException if the J2EE_DIR property is not set */ public static String[] getJ2EEJarFiles() { - Properties p = null; + final Properties p; try { p = WalaProperties.loadProperties(); } catch (WalaException e) { diff --git a/core/src/main/java/com/ibm/wala/ssa/SSABuilder.java b/core/src/main/java/com/ibm/wala/ssa/SSABuilder.java index 05b04acb78..f71beffe46 100644 --- a/core/src/main/java/com/ibm/wala/ssa/SSABuilder.java +++ b/core/src/main/java/com/ibm/wala/ssa/SSABuilder.java @@ -222,7 +222,7 @@ public int meetLocal(int n, int[] rhs, BasicBlock bb) { private boolean allTheSame(int[] rhs) { int x = -1; // set x := the first non-TOP value - int i = 0; + int i; for (i = 0; i < rhs.length; i++) { if (rhs[i] != TOP) { x = rhs[i]; diff --git a/core/src/main/java/com/ibm/wala/ssa/SSACFG.java b/core/src/main/java/com/ibm/wala/ssa/SSACFG.java index f3160b586d..100d9f1d01 100644 --- a/core/src/main/java/com/ibm/wala/ssa/SSACFG.java +++ b/core/src/main/java/com/ibm/wala/ssa/SSACFG.java @@ -163,7 +163,7 @@ public boolean equals(Object o) { private void recordExceptionTypes(Set set, IClassLoader loader) { for (ExceptionHandler handler : set) { - TypeReference t = null; + final TypeReference t; if (handler.getCatchClass() == null) { // by convention, in ShrikeCT this means catch everything t = TypeReference.JavaLangThrowable; diff --git a/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexIMethod.java b/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexIMethod.java index a0b40344bb..10bce03279 100644 --- a/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexIMethod.java +++ b/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexIMethod.java @@ -905,7 +905,7 @@ protected void parseBytecode() { // System.out.println("debug here"); instructions = new InstructionArray(); - int instLoc = 0; + int instLoc; int instCounter = -1; // int pc = 0; int currentCodeAddress = 0; diff --git a/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexUtil.java b/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexUtil.java index c2366c9d3c..5aa5a0dc5e 100644 --- a/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexUtil.java +++ b/dalvik/src/main/java/com/ibm/wala/dalvik/classLoader/DexUtil.java @@ -197,7 +197,7 @@ static TypeReference getTypeRef(String type, ClassLoaderReference clr) { static TypeName getTypeName(String fieldType) { ImmutableByteArray fieldTypeArray = ImmutableByteArray.make(fieldType); - TypeName T = null; + final TypeName T; if (fieldTypeArray.get(fieldTypeArray.length() - 1) == ';') { T = TypeName.findOrCreate(fieldTypeArray, 0, fieldTypeArray.length() - 1); } else { diff --git a/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/parameters/AndroidModelParameterManager.java b/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/parameters/AndroidModelParameterManager.java index 624338e5e6..112b711d07 100644 --- a/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/parameters/AndroidModelParameterManager.java +++ b/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/parameters/AndroidModelParameterManager.java @@ -100,7 +100,7 @@ private enum ValueStatus { private int currentScope = 0; /** For checking if type is CREATE or REUSE (optional) */ - private IInstantiationBehavior behaviour = null; + private IInstantiationBehavior behaviour; /** Description only used for toString() */ private String description; diff --git a/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/structure/AbstractAndroidModel.java b/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/structure/AbstractAndroidModel.java index ea0a704d8e..1503ecb24c 100644 --- a/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/structure/AbstractAndroidModel.java +++ b/dalvik/src/main/java/com/ibm/wala/dalvik/ipa/callgraph/androidModel/structure/AbstractAndroidModel.java @@ -76,10 +76,10 @@ public abstract class AbstractAndroidModel { private static final Logger logger = LoggerFactory.getLogger(AbstractAndroidModel.class); private ExecutionOrder currentSection = null; - protected VolatileMethodSummary body = null; - protected TypeSafeInstructionFactory insts = null; - protected SSAValueManager paramManager = null; - protected Iterable entryPoints = null; + protected VolatileMethodSummary body; + protected TypeSafeInstructionFactory insts; + protected SSAValueManager paramManager; + protected Iterable entryPoints; private IExecutionOrder lastQueriedMethod = null; // Used for sanity checks only // diff --git a/dalvik/src/main/java/com/ibm/wala/dalvik/ssa/DexSSABuilder.java b/dalvik/src/main/java/com/ibm/wala/dalvik/ssa/DexSSABuilder.java index 307107162c..b283bee2d4 100644 --- a/dalvik/src/main/java/com/ibm/wala/dalvik/ssa/DexSSABuilder.java +++ b/dalvik/src/main/java/com/ibm/wala/dalvik/ssa/DexSSABuilder.java @@ -245,7 +245,7 @@ public int meetLocal(int n, int[] rhs, DexCFG.BasicBlock bb) { private boolean allTheSame(int[] rhs) { int x = -1; // set x := the first non-TOP value - int i = 0; + int i; for (i = 0; i < rhs.length; i++) { if (rhs[i] != TOP) { x = rhs[i]; diff --git a/ide/jdt/src/main/java/com/ibm/wala/ide/util/JdtUtil.java b/ide/jdt/src/main/java/com/ibm/wala/ide/util/JdtUtil.java index 5f237f654e..641df4eddc 100644 --- a/ide/jdt/src/main/java/com/ibm/wala/ide/util/JdtUtil.java +++ b/ide/jdt/src/main/java/com/ibm/wala/ide/util/JdtUtil.java @@ -290,7 +290,7 @@ public static IMethod findJavaMethodInProjects( if (projects == null) { throw new IllegalArgumentException("null projects"); } - IType type = null; + final IType type; try { type = findJavaClassInProjects(klass, projects); } catch (Throwable t) { diff --git a/scandroid/src/main/java/org/scandroid/model/AppModelMethod.java b/scandroid/src/main/java/org/scandroid/model/AppModelMethod.java index 44f83f97eb..dc00926464 100644 --- a/scandroid/src/main/java/org/scandroid/model/AppModelMethod.java +++ b/scandroid/src/main/java/org/scandroid/model/AppModelMethod.java @@ -311,7 +311,7 @@ private int addLocal() { private SSANewInstruction processAllocation(TypeReference tr, Integer i, boolean isInner) { // create the allocation statement and add it to the method summary NewSiteReference ref = NewSiteReference.make(methodSummary.getNumberOfStatements(), tr); - SSANewInstruction a = null; + final SSANewInstruction a; if (tr.isArrayType()) { int[] sizes = new int[((ArrayClass) cha.lookupClass(tr)).getDimensionality()]; @@ -335,7 +335,7 @@ private SSANewInstruction processAllocation(TypeReference tr, Integer i, boolean // allocate an instance for the array contents NewSiteReference n = NewSiteReference.make(methodSummary.getNumberOfStatements(), e); int alloc = nextLocal++; - SSANewInstruction ni = null; + final SSANewInstruction ni; if (e.isArrayType()) { int[] sizes = new int[((ArrayClass) cha.lookupClass(tr)).getDimensionality()]; Arrays.fill(sizes, getValueNumberForIntConstant(1)); @@ -432,7 +432,7 @@ public SSAAbstractInvokeInstruction addInvocation(int[] params, CallSiteReferenc methodSummary.getNumberOfStatements(), site.getDeclaredTarget(), site.getInvocationCode()); - SSAAbstractInvokeInstruction s = null; + final SSAAbstractInvokeInstruction s; if (newSite.getDeclaredTarget().getReturnType().equals(TypeReference.Void)) { s = insts.InvokeInstruction( diff --git a/scandroid/src/main/java/org/scandroid/prefixtransfer/PrefixTransferGraph.java b/scandroid/src/main/java/org/scandroid/prefixtransfer/PrefixTransferGraph.java index 27847141b3..39ec58130b 100644 --- a/scandroid/src/main/java/org/scandroid/prefixtransfer/PrefixTransferGraph.java +++ b/scandroid/src/main/java/org/scandroid/prefixtransfer/PrefixTransferGraph.java @@ -105,7 +105,7 @@ public PrefixTransferGraph(PointerAnalysis pa) { } } } - InstanceKeySite node = null; + InstanceKeySite node; for (InstanceKey k : instanceKeys) { // create a node for each InstanceKey of type string if (k.getConcreteType().getName().toString().equals("Ljava/lang/String")) { diff --git a/scandroid/src/main/java/org/scandroid/util/DexDotUtil.java b/scandroid/src/main/java/org/scandroid/util/DexDotUtil.java index bc4549827e..97424322d3 100644 --- a/scandroid/src/main/java/org/scandroid/util/DexDotUtil.java +++ b/scandroid/src/main/java/org/scandroid/util/DexDotUtil.java @@ -261,7 +261,7 @@ private static String decorateNode( } private static String getLabel(T o, NodeDecorator d) throws WalaException { - String result = null; + String result; if (d == null) { // result = o.toString(); result = cleanUpString(o.toString()); diff --git a/scandroid/src/main/java/org/scandroid/util/EntryPoints.java b/scandroid/src/main/java/org/scandroid/util/EntryPoints.java index a452a9a26b..14cb69ff74 100644 --- a/scandroid/src/main/java/org/scandroid/util/EntryPoints.java +++ b/scandroid/src/main/java/org/scandroid/util/EntryPoints.java @@ -171,7 +171,6 @@ public void unpackApk(String classpath) { // String pathToJava = new String(System.getProperty("java.home").replace(" ", "\\ ") + // File.separator + "bin" + File.separator); pathToJava = System.getProperty("java.home") + File.separator + "bin" + File.separator; - String s = null; // String command = new String(pathToJava + "java -jar " + pathToApkTool + "apktool.jar d -f " + // pathToApkFile + " " + pathToApkTool + tempFolder); @@ -196,7 +195,7 @@ public void unpackApk(String classpath) { BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); // read the output from the command - + String s; while ((s = stdInput.readLine()) != null) {} // read any errors from the attempted command @@ -291,8 +290,8 @@ private void populateIntentList(String basePackage, Element eElement) { @SuppressWarnings("unused") private void populateEntryPoints(ClassHierarchy cha) { - String method = null; - IMethod im = null; + String method; + IMethod im; for (String[] intent : ActivityIntentList) { // method = IntentToMethod(intent[0]); method = "onCreate(Landroid/os/Bundle;)V"; diff --git a/shrike/src/main/java/com/ibm/wala/shrike/shrikeBT/shrikeCT/ClassInstrumenter.java b/shrike/src/main/java/com/ibm/wala/shrike/shrikeBT/shrikeCT/ClassInstrumenter.java index 28b6d305b5..ced899d995 100644 --- a/shrike/src/main/java/com/ibm/wala/shrike/shrikeBT/shrikeCT/ClassInstrumenter.java +++ b/shrike/src/main/java/com/ibm/wala/shrike/shrikeBT/shrikeCT/ClassInstrumenter.java @@ -351,7 +351,7 @@ private static CodeWriter makeNewCode(ClassWriter w, Compiler.Output output) { private LineNumberTableWriter makeNewLines( ClassWriter w, CodeReader oldCode, Compiler.Output output) throws InvalidClassFileException { - int[] newLineMap = null; + final int[] newLineMap; int[] oldLineMap = LineNumberTableReader.makeBytecodeToSourceMap(oldCode); if (oldLineMap != null) { // Map the old line number map onto the new bytecodes diff --git a/util/src/main/java/com/ibm/wala/util/collections/ImmutableStack.java b/util/src/main/java/com/ibm/wala/util/collections/ImmutableStack.java index b69488aa0c..e981682511 100644 --- a/util/src/main/java/com/ibm/wala/util/collections/ImmutableStack.java +++ b/util/src/main/java/com/ibm/wala/util/collections/ImmutableStack.java @@ -114,7 +114,7 @@ public ImmutableStack push(T entry) { return emptyStack(); } int size = entries.length + 1; - T[] tmpEntries = null; + final T[] tmpEntries; if (isWithinSizeLimit(size)) { tmpEntries = makeInternalArray(size); System.arraycopy(entries, 0, tmpEntries, 0, entries.length); @@ -237,7 +237,7 @@ public ImmutableStack pushAll(ImmutableStack other) { throw new IllegalArgumentException("null other"); } int size = entries.length + other.entries.length; - T[] tmpEntries = null; + final T[] tmpEntries; if (isWithinSizeLimit(size)) { tmpEntries = (T[]) new Object[size]; System.arraycopy(entries, 0, tmpEntries, 0, entries.length); diff --git a/util/src/main/java/com/ibm/wala/util/collections/SparseVector.java b/util/src/main/java/com/ibm/wala/util/collections/SparseVector.java index 4970521ab5..609036aacf 100644 --- a/util/src/main/java/com/ibm/wala/util/collections/SparseVector.java +++ b/util/src/main/java/com/ibm/wala/util/collections/SparseVector.java @@ -34,7 +34,7 @@ public class SparseVector implements IVector, Serializable { private static final int DEF_INITIAL_SIZE = 5; /** if indices[i] = x, then data[i] == get(x) */ - private MutableSparseIntSet indices = MutableSparseIntSet.makeEmpty(); + private MutableSparseIntSet indices; private Object[] data; diff --git a/util/src/main/java/com/ibm/wala/util/graph/GraphIntegrity.java b/util/src/main/java/com/ibm/wala/util/graph/GraphIntegrity.java index df3b0236d3..ca2ffb0107 100644 --- a/util/src/main/java/com/ibm/wala/util/graph/GraphIntegrity.java +++ b/util/src/main/java/com/ibm/wala/util/graph/GraphIntegrity.java @@ -101,11 +101,11 @@ private static void checkEdges(Graph G) throws UnsoundGraphException { @SuppressWarnings("unused") private static void checkNodeCount(Graph G) throws UnsoundGraphException { - int n1 = 0; - int n2 = 0; - int n3 = 0; - int n4 = 0; - int n5 = 0; + final int n1; + int n2; + final int n3; + final int n4; + final int n5; try { n1 = G.getNumberOfNodes(); n2 = 0; diff --git a/util/src/main/java/com/ibm/wala/util/intset/BasicNaturalRelation.java b/util/src/main/java/com/ibm/wala/util/intset/BasicNaturalRelation.java index 10e58f75a5..768e232ce0 100644 --- a/util/src/main/java/com/ibm/wala/util/intset/BasicNaturalRelation.java +++ b/util/src/main/java/com/ibm/wala/util/intset/BasicNaturalRelation.java @@ -233,7 +233,7 @@ public boolean hasNext() { @NullUnmarked @Override public IntPair next() { - IntPair result = null; + final IntPair result; if (nextIndex == smallStore.length) { int y = delegateIterator.next(); result = new IntPair(nextX, y); diff --git a/util/src/main/java/com/ibm/wala/util/intset/BitVector.java b/util/src/main/java/com/ibm/wala/util/intset/BitVector.java index e5ca9bf95d..ec491aae59 100644 --- a/util/src/main/java/com/ibm/wala/util/intset/BitVector.java +++ b/util/src/main/java/com/ibm/wala/util/intset/BitVector.java @@ -349,9 +349,7 @@ public void andNot(BitVector vector) { if (vector == null) { throw new IllegalArgumentException("null vector"); } - int ai = 0; - int bi = 0; - for (ai = 0, bi = 0; ai < bits.length && bi < vector.bits.length; ai++, bi++) { + for (int ai = 0, bi = 0; ai < bits.length && bi < vector.bits.length; ai++, bi++) { bits[ai] &= ~vector.bits[bi]; } } diff --git a/util/src/main/java/com/ibm/wala/util/intset/BitVectorBase.java b/util/src/main/java/com/ibm/wala/util/intset/BitVectorBase.java index c6e8651086..a4f8a6d458 100644 --- a/util/src/main/java/com/ibm/wala/util/intset/BitVectorBase.java +++ b/util/src/main/java/com/ibm/wala/util/intset/BitVectorBase.java @@ -95,7 +95,7 @@ public boolean isZero() { @Override @SuppressWarnings("unchecked") public Object clone() { - BitVectorBase result = null; + final BitVectorBase result; try { result = (BitVectorBase) super.clone(); } catch (CloneNotSupportedException e) { diff --git a/util/src/main/java/com/ibm/wala/util/intset/FixedSizeBitVector.java b/util/src/main/java/com/ibm/wala/util/intset/FixedSizeBitVector.java index d276872e6f..22efc741d9 100644 --- a/util/src/main/java/com/ibm/wala/util/intset/FixedSizeBitVector.java +++ b/util/src/main/java/com/ibm/wala/util/intset/FixedSizeBitVector.java @@ -300,7 +300,7 @@ public boolean isZero() { /** Clones the FixedSizeBitVector. */ @Override public Object clone() { - FixedSizeBitVector result = null; + final FixedSizeBitVector result; try { result = (FixedSizeBitVector) super.clone(); } catch (CloneNotSupportedException e) { diff --git a/util/src/main/java/com/ibm/wala/util/intset/MutableMapping.java b/util/src/main/java/com/ibm/wala/util/intset/MutableMapping.java index de09a5de47..198c3f78c8 100644 --- a/util/src/main/java/com/ibm/wala/util/intset/MutableMapping.java +++ b/util/src/main/java/com/ibm/wala/util/intset/MutableMapping.java @@ -38,7 +38,7 @@ public static MutableMapping make() { private Object[] array; - private int nextIndex = 0; + private int nextIndex; /** A mapping from object to Integer. */ final HashMap map = HashMapFactory.make(); diff --git a/util/src/main/java/com/ibm/wala/util/viz/DotUtil.java b/util/src/main/java/com/ibm/wala/util/viz/DotUtil.java index 3b3123eb19..1b8cea4da1 100644 --- a/util/src/main/java/com/ibm/wala/util/viz/DotUtil.java +++ b/util/src/main/java/com/ibm/wala/util/viz/DotUtil.java @@ -268,7 +268,7 @@ private static String decorateNode(T n, NodeDecorator d) throws WalaExcep } private static String getLabel(T n, NodeDecorator d) throws WalaException { - String result = null; + String result; if (d == null) { result = n.toString(); } else {