make many fields final
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1232 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
d263256581
commit
8e52444761
|
@ -98,7 +98,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
/**
|
||||
* Mapping from TypeReference -> IR TODO: Soft references?
|
||||
*/
|
||||
private Map<TypeReference, IR> IRCache = HashMapFactory.make();
|
||||
final private Map<TypeReference, IR> IRCache = HashMapFactory.make();
|
||||
|
||||
public IR getIR(CGNode node, WarningSet warnings) {
|
||||
if (node == null) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
*/
|
||||
public class ReceiverTypeInference {
|
||||
|
||||
private TypeInference ti;
|
||||
final private TypeInference ti;
|
||||
|
||||
/**
|
||||
* Mapping from call site reference to InvokeInstruction. TODO: this kind of
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TypeInference extends SSAInference implements FixedPointConstants {
|
|||
/**
|
||||
* The governing class hierarchy
|
||||
*/
|
||||
protected IClassHierarchy cha;
|
||||
final protected IClassHierarchy cha;
|
||||
|
||||
/**
|
||||
* A singleton instance of the phi operator.
|
||||
|
|
|
@ -238,7 +238,7 @@ public class InducedCFG extends AbstractCFG {
|
|||
// TODO: extend the following to deal with catch blocks. Right now
|
||||
// it simply breaks basic blocks at PEIs.
|
||||
public class PEIVisitor extends SSAInstruction.Visitor {
|
||||
private boolean[] r;
|
||||
final private boolean[] r;
|
||||
|
||||
protected PEIVisitor(boolean[] r) {
|
||||
this.r = r;
|
||||
|
|
|
@ -223,7 +223,7 @@ public class ShrikeCFG extends AbstractCFG {
|
|||
/**
|
||||
* The number of the ShrikeBT instruction that begins this block.
|
||||
*/
|
||||
private int startIndex;
|
||||
final private int startIndex;
|
||||
|
||||
public BasicBlock(int startIndex) {
|
||||
this.startIndex = startIndex;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class BVControlDependenceGraph extends AbstractNumberedGraph<IBasicBlock>
|
|||
*/
|
||||
private final EdgeManager<IBasicBlock> edgeManager;
|
||||
|
||||
private boolean ignoreUnreachableCode = false;
|
||||
private final boolean ignoreUnreachableCode;
|
||||
|
||||
private final HashMap<IBasicBlock, BasicBlock> bbMap = new HashMap<IBasicBlock, BasicBlock>();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
/**
|
||||
* classes to ignore
|
||||
*/
|
||||
private SetOfClasses exclusions;
|
||||
final private SetOfClasses exclusions;
|
||||
|
||||
/**
|
||||
* Identity for this class loader
|
||||
|
|
|
@ -191,13 +191,13 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
if (isNative()) {
|
||||
return Collections.EMPTY_SET;
|
||||
}
|
||||
return (getBCInfo().implicitExceptions == null) ? Arrays.asList(new TypeReference[0]) : Arrays.asList(getBCInfo().implicitExceptions);
|
||||
return (getBCInfo().implicitExceptions == null) ? Arrays.asList(new TypeReference[0]) : Arrays
|
||||
.asList(getBCInfo().implicitExceptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a cheap pass over the bytecodes to collect some
|
||||
* mapping information. Some methods require this as a pre-req to accessing
|
||||
* ShrikeCT information.
|
||||
* Do a cheap pass over the bytecodes to collect some mapping information.
|
||||
* Some methods require this as a pre-req to accessing ShrikeCT information.
|
||||
*
|
||||
* @throws InvalidClassFileException
|
||||
*/
|
||||
|
@ -321,8 +321,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
Atom name = Atom.findOrCreateUnicodeAtom(getMethodName());
|
||||
ImmutableByteArray desc = ImmutableByteArray.make(getMethodSignature());
|
||||
Descriptor D = Descriptor.findOrCreate(desc);
|
||||
return
|
||||
MethodReference.findOrCreate(declaringClass.getReference(), name, D);
|
||||
return MethodReference.findOrCreate(declaringClass.getReference(), name, D);
|
||||
} catch (InvalidClassFileException e) {
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
|
@ -404,7 +403,6 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
*/
|
||||
protected abstract void processDebugInfo(BytecodeInfo bcInfo) throws InvalidClassFileException;
|
||||
|
||||
|
||||
private void processBytecodesWithShrikeBT(BytecodeInfo info) throws InvalidClassFileException {
|
||||
info.decoder = makeDecoder();
|
||||
if (Assertions.verifyAssertions) {
|
||||
|
@ -561,9 +559,9 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
|
||||
Set<FieldReference> fieldsRead = HashSetFactory.make(5);
|
||||
|
||||
Set<NewSiteReference> newSites = HashSetFactory.make(5);
|
||||
final Set<NewSiteReference> newSites = HashSetFactory.make(5);
|
||||
|
||||
Set<TypeReference> arraysRead = HashSetFactory.make(5);
|
||||
final Set<TypeReference> arraysRead = HashSetFactory.make(5);
|
||||
|
||||
Set<TypeReference> arraysWritten = HashSetFactory.make(5);
|
||||
|
||||
|
@ -619,8 +617,8 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
@Override
|
||||
public void visitInvoke(InvokeInstruction instruction) {
|
||||
ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader();
|
||||
MethodReference m = MethodReference.findOrCreate(loader, instruction.getClassType(), instruction.getMethodName(),
|
||||
instruction.getMethodSignature());
|
||||
MethodReference m = MethodReference.findOrCreate(loader, instruction.getClassType(), instruction.getMethodName(), instruction
|
||||
.getMethodSignature());
|
||||
int programCounter = 0;
|
||||
try {
|
||||
programCounter = getProgramCounter();
|
||||
|
@ -743,6 +741,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
/**
|
||||
* Clients should not modify the returned array. TODO: clone to avoid the
|
||||
* problem?
|
||||
*
|
||||
* @throws InvalidClassFileException
|
||||
*
|
||||
* @see com.ibm.wala.classLoader.IMethod#getDeclaredExceptions()
|
||||
|
@ -760,7 +759,8 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
private TypeReference[] computeDeclaredExceptions() {
|
||||
try {
|
||||
String[] strings = getDeclaredExceptionTypeNames();
|
||||
if (strings == null) return null;
|
||||
if (strings == null)
|
||||
return null;
|
||||
|
||||
ClassLoaderReference loader = getDeclaringClass().getClassLoader().getReference();
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class AnalysisOptions {
|
|||
/**
|
||||
* An object that identifies the entrypoints for the call graph
|
||||
*/
|
||||
private Iterable<Entrypoint> entrypoints;
|
||||
private final Iterable<Entrypoint> entrypoints;
|
||||
|
||||
/**
|
||||
* An object which represents the user specification for reflection
|
||||
|
@ -157,20 +157,18 @@ public class AnalysisOptions {
|
|||
this.ssaCache = new SSACache(factory);
|
||||
this.cfgCache = new CFGCache(factory);
|
||||
ReferenceCleanser.registerAnalysisOptions(this);
|
||||
this.entrypoints = null;
|
||||
}
|
||||
|
||||
public AnalysisOptions() {
|
||||
this(new DefaultIRFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor AnalysisOptions.
|
||||
*
|
||||
* @param scope
|
||||
* @param e
|
||||
*/
|
||||
public AnalysisOptions(AnalysisScope scope, IRFactory factory, Iterable<Entrypoint> e) {
|
||||
this(factory);
|
||||
this.irFactory = factory;
|
||||
this.ssaCache = new SSACache(factory);
|
||||
this.cfgCache = new CFGCache(factory);
|
||||
ReferenceCleanser.registerAnalysisOptions(this);
|
||||
this.analysisScope = scope;
|
||||
this.entrypoints = e;
|
||||
}
|
||||
|
@ -179,30 +177,14 @@ public class AnalysisOptions {
|
|||
this(scope, new DefaultIRFactory(), e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the analysisScope.
|
||||
*
|
||||
* @return AnalysisScope
|
||||
*/
|
||||
public AnalysisScope getAnalysisScope() {
|
||||
return analysisScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the analysisScope.
|
||||
*
|
||||
* @param analysisScope
|
||||
* The analysisScope to set
|
||||
*/
|
||||
public void setAnalysisScope(AnalysisScope analysisScope) {
|
||||
this.analysisScope = analysisScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entrypoints.
|
||||
*
|
||||
* @return Entrypoints
|
||||
*/
|
||||
public Iterable<Entrypoint> getEntrypoints() {
|
||||
return entrypoints;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class ArgumentTypeEntrypoint extends Entrypoint {
|
||||
|
||||
private TypeReference[][] paramTypes;
|
||||
final private TypeReference[][] paramTypes;
|
||||
|
||||
private final IClassHierarchy cha;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.ibm.wala.util.collections.HashSetFactory;
|
|||
*/
|
||||
public class ComposedEntrypoints implements Iterable<Entrypoint> {
|
||||
|
||||
private Set<Entrypoint> entrypoints = HashSetFactory.make();
|
||||
final private Set<Entrypoint> entrypoints = HashSetFactory.make();
|
||||
|
||||
public ComposedEntrypoints(Iterable<Entrypoint> A, Iterable<Entrypoint> B) {
|
||||
if (A == null) {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class PropagationSystem extends DefaultFixedPointSolver {
|
|||
*
|
||||
* This maintains a map from PointsToSetVariable -> Set<UnarySideEffect>
|
||||
*/
|
||||
private Map<PointsToSetVariable,Set<UnarySideEffect>> fixedSetMap = HashMapFactory.make();
|
||||
final private Map<PointsToSetVariable,Set<UnarySideEffect>> fixedSetMap = HashMapFactory.make();
|
||||
|
||||
/**
|
||||
* Governing call graph;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
|
|||
/**
|
||||
* Graph implementation we delegate to.
|
||||
*/
|
||||
private NumberedGraph<BasicBlockInContext> G = new SlowSparseNumberedGraph<BasicBlockInContext>(2);
|
||||
final private NumberedGraph<BasicBlockInContext> G = new SlowSparseNumberedGraph<BasicBlockInContext>(2);
|
||||
|
||||
/**
|
||||
* Governing call graph
|
||||
|
|
|
@ -60,10 +60,8 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
*/
|
||||
private final Language language;
|
||||
|
||||
/**
|
||||
* mapping from IClass to Node
|
||||
*/
|
||||
private HashMap<IClass, Node> map = HashMapFactory.make();
|
||||
|
||||
final private HashMap<IClass, Node> map = HashMapFactory.make();
|
||||
|
||||
/**
|
||||
* root node of the class hierarchy
|
||||
|
@ -80,7 +78,7 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
*
|
||||
* XXX is order significant??
|
||||
*/
|
||||
private IClassLoader[] loaders;
|
||||
final private IClassLoader[] loaders;
|
||||
|
||||
/**
|
||||
* An object which tracks analysis warnings
|
||||
|
|
|
@ -17,25 +17,16 @@ package com.ibm.wala.ssa;
|
|||
* @author sfink
|
||||
*/
|
||||
public class ConstantValue implements Value {
|
||||
private Object constant;
|
||||
final private Object constant;
|
||||
|
||||
/**
|
||||
* @param constant
|
||||
*/
|
||||
public ConstantValue(Object constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param constant
|
||||
*/
|
||||
public ConstantValue(int constant) {
|
||||
this(new Integer(constant));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param constant
|
||||
*/
|
||||
public ConstantValue(double constant) {
|
||||
this(new Double(constant));
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class DefUse {
|
|||
/**
|
||||
* A Mapping from integer -> Instruction
|
||||
*/
|
||||
private ArrayList<SSAInstruction> allInstructions = new ArrayList<SSAInstruction>();
|
||||
final private ArrayList<SSAInstruction> allInstructions = new ArrayList<SSAInstruction>();
|
||||
|
||||
/**
|
||||
* prevent the IR from being collected while this is live.
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class IR {
|
|||
/**
|
||||
* Symbol table
|
||||
*/
|
||||
private SymbolTable symbolTable;
|
||||
final private SymbolTable symbolTable;
|
||||
|
||||
/**
|
||||
* Mapping from CallSiteReference program counters to instruction[] indices
|
||||
|
@ -76,7 +76,7 @@ public abstract class IR {
|
|||
/**
|
||||
* Mapping from PEI program counters to instruction[] indices
|
||||
*/
|
||||
private Map<ProgramCounter, Integer> peiMapping = HashMapFactory.make();
|
||||
final private Map<ProgramCounter, Integer> peiMapping = HashMapFactory.make();
|
||||
|
||||
/**
|
||||
* Mapping from SSAInstruction to Basic Block, computed lazily
|
||||
|
@ -420,7 +420,7 @@ public abstract class IR {
|
|||
private class NormalIterator implements Iterator<SSAInstruction> {
|
||||
int nextIndex = -1;
|
||||
|
||||
SSAInstruction[] instructions = getInstructions();
|
||||
final SSAInstruction[] instructions = getInstructions();
|
||||
|
||||
NormalIterator() {
|
||||
advanceIndex(0);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SSABuilder extends AbstractIntStackMachine {
|
|||
/**
|
||||
* A wrapper around the method being analyzed.
|
||||
*/
|
||||
private ShrikeCTMethod method;
|
||||
final private ShrikeCTMethod method;
|
||||
|
||||
/**
|
||||
* Governing symbol table
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SSACache {
|
|||
/**
|
||||
* A cache of SSA IRs
|
||||
*/
|
||||
private AuxiliaryCache irCache = new AuxiliaryCache();
|
||||
final private AuxiliaryCache irCache = new AuxiliaryCache();
|
||||
|
||||
/**
|
||||
* A cache of DefUse information
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SymbolTable {
|
|||
/**
|
||||
* value numbers for parameters to this method
|
||||
*/
|
||||
private int[] parameters;
|
||||
final private int[] parameters;
|
||||
|
||||
/**
|
||||
* Mapping from Constant -> value number
|
||||
|
|
|
@ -138,7 +138,7 @@ public final class Descriptor {
|
|||
private static class Key {
|
||||
private TypeName returnType;
|
||||
private TypeName[] parameters;
|
||||
private int hashCode; // cached for efficiency
|
||||
final private int hashCode; // cached for efficiency
|
||||
Key(TypeName returnType, TypeName[] parameters) {
|
||||
this.returnType = returnType;
|
||||
this.parameters = parameters;
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.NoSuchElementException;
|
|||
public class CompoundIterator<T> implements Iterator<T> {
|
||||
|
||||
Iterator<? extends T> A;
|
||||
Iterator<? extends T> B;
|
||||
final Iterator<? extends T> B;
|
||||
public CompoundIterator(Iterator<? extends T> A, Iterator<? extends T> B) {
|
||||
this.A = A;
|
||||
this.B = B;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Random;
|
|||
*/
|
||||
public class DeterministicHashCode {
|
||||
|
||||
private static Random r = new Random(1000);
|
||||
final private static Random r = new Random(1000);
|
||||
|
||||
public static synchronized int get() {
|
||||
return r.nextInt();
|
||||
|
|
|
@ -30,7 +30,7 @@ public class IntensionalSetOfStrings {
|
|||
private static final boolean DEBUG = false;
|
||||
|
||||
private Pattern pattern;
|
||||
private String regex;
|
||||
final private String regex;
|
||||
private boolean needsCompile = true;
|
||||
|
||||
public IntensionalSetOfStrings(String xmlFile, ClassLoader loader) throws WalaException {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BFSIterator<T> implements Iterator<T> {
|
|||
/**
|
||||
* Set of nodes that have been visited
|
||||
*/
|
||||
HashSet<T> visited = HashSetFactory.make();
|
||||
final HashSet<T> visited = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* index of the node currently being searched
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BFSPathFinder<T> {
|
|||
/**
|
||||
* an enumeration of all nodes to search from
|
||||
*/
|
||||
private Iterator<T> roots;
|
||||
final private Iterator<T> roots;
|
||||
|
||||
/**
|
||||
* Construct a breadth-first enumerator starting with a particular node in a
|
||||
|
|
|
@ -50,7 +50,7 @@ public class DFSPathFinder<T> extends Stack<T> {
|
|||
/**
|
||||
* an enumeration of all nodes to search from
|
||||
*/
|
||||
private Iterator<T> roots;
|
||||
final private Iterator<T> roots;
|
||||
|
||||
/**
|
||||
* An iterator of child nodes for each node being searched
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SlowDFSFinishTimeIterator<T> extends DFSFinishTimeIterator<T> {
|
|||
/**
|
||||
* An iterator of child nodes for each node being searched
|
||||
*/
|
||||
private Map<T, Iterator<? extends T>> pendingChildren = HashMapFactory.make(25);
|
||||
final private Map<T, Iterator<? extends T>> pendingChildren = HashMapFactory.make(25);
|
||||
|
||||
/**
|
||||
* Construct a depth-first enumerator starting with a particular node
|
||||
|
|
|
@ -30,7 +30,7 @@ public class TwoLevelIntVector implements IntVector {
|
|||
* Array of IntVector: data.get(i) holds data[i*PAGE_SIZE] ...
|
||||
* data[(i+1)*PAGESIZE - 1]
|
||||
*/
|
||||
private Vector<SparseIntVector> data = new Vector<SparseIntVector>();
|
||||
final private Vector<SparseIntVector> data = new Vector<SparseIntVector>();
|
||||
|
||||
private final int defaultValue;
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ public class EngineTimings {
|
|||
private static class Phase {
|
||||
String name;
|
||||
|
||||
int depth;
|
||||
final int depth;
|
||||
|
||||
long millis;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public class EclipseAnalysisScope extends AnalysisScope {
|
|||
* A Set containing String objects, each String object representing the plugin
|
||||
* id of a plug-in, fragment, or bundle being analyzed.
|
||||
*/
|
||||
private Set<String> pluginIds = HashSetFactory.make();
|
||||
final private Set<String> pluginIds = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* name of plugin being analyzed
|
||||
|
|
|
@ -201,11 +201,8 @@ public class CallGraphWarnings {
|
|||
*/
|
||||
private static class NoCalleeWarning extends MethodWarning {
|
||||
|
||||
private CallSiteReference site;
|
||||
final private CallSiteReference site;
|
||||
|
||||
/**
|
||||
* @param node
|
||||
*/
|
||||
public NoCalleeWarning(CGNode node, CallSiteReference site) {
|
||||
super(node.getMethod().getReference());
|
||||
this.site = site;
|
||||
|
|
Loading…
Reference in New Issue