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:
sjfink 2007-06-01 21:38:35 +00:00
parent d263256581
commit 8e52444761
32 changed files with 64 additions and 96 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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>();

View File

@ -48,7 +48,7 @@ public class ClassLoaderImpl implements IClassLoader {
/**
* classes to ignore
*/
private SetOfClasses exclusions;
final private SetOfClasses exclusions;
/**
* Identity for this class loader

View File

@ -121,7 +121,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
* Exception types this method might throw. Computed on demand.
*/
private TypeReference[] exceptionTypes;
/**
* the "Signature" attribute; holds information on generics
*/
@ -136,7 +136,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
public ShrikeBTMethod(IClass klass) {
this.declaringClass = klass;
}
protected BytecodeInfo getBCInfo() throws InvalidClassFileException {
BytecodeInfo result = null;
if (bcInfo != null) {
@ -178,7 +178,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
if (isNative()) {
return empty;
}
return (getBCInfo().newSites == null) ? empty : Collections.unmodifiableCollection(Arrays.asList(getBCInfo().newSites));
}
@ -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;
@ -369,7 +368,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
public boolean isFinal() {
return ((getModifiers() & Constants.ACC_FINAL) != 0);
}
public boolean isVolatile() {
return ((getModifiers() & Constants.ACC_VOLATILE) != 0);
}
@ -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) {
@ -544,14 +542,14 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
/**
*
* A visitor used to process bytecodes
*
*
*/
private class SimpleVisitor extends Instruction.Visitor {
private final BytecodeInfo info;
public SimpleVisitor(BytecodeInfo info) {
this.info = info;
this.info = info;
}
// TODO: make a better Set implementation for these.
@ -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,7 +741,8 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
/**
* Clients should not modify the returned array. TODO: clone to avoid the
* problem?
* @throws InvalidClassFileException
*
* @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();
@ -774,8 +774,8 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
return null;
}
}
protected abstract String computeGenericsSignature() throws InvalidClassFileException;
protected abstract String computeGenericsSignature() throws InvalidClassFileException;
/*
* @see com.ibm.wala.classLoader.IMethod#getLineNumber(int)
@ -829,7 +829,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
public abstract String getLocalVariableName(int bcIndex, int localNumber) throws InvalidClassFileException;
/*
* TODO: cache for efficiency?
* TODO: cache for efficiency?
*
* @see com.ibm.wala.classLoader.IMethod#hasLocalVariableTable()
*/

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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));
}

View File

@ -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.

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -303,7 +303,7 @@ public class EngineTimings {
private static class Phase {
String name;
int depth;
final int depth;
long millis;

View File

@ -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

View File

@ -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;