Fix Eclipse warnings about methods that can be declared static

The fix is to add "static" where appropriate, of course.  I've also
simplified calls to such methods to reflect the fact that they no
longer need a specific object to call the method on.

In projects that contain test inputs, I've left the non-static
declarations unchanged, and instead downgraded the warning to be
ignored.  In all other projects, this warning has been upgraded to an
error.
This commit is contained in:
Ben Liblit 2017-07-12 16:10:20 -07:00 committed by Manu Sridharan
parent 0aadaa7aa0
commit 594525a83f
50 changed files with 106 additions and 107 deletions

View File

@ -83,7 +83,7 @@ org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled

View File

@ -83,7 +83,7 @@ org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=error
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled

View File

@ -132,7 +132,7 @@ public class NodejsRequireTargetSelector implements MethodTargetSelector {
return calledMethod;
}
private JavaScriptInvoke getInvokeInstruction(CGNode caller, CallSiteReference site) {
private static JavaScriptInvoke getInvokeInstruction(CGNode caller, CallSiteReference site) {
IR callerIR = caller.getIR();
SSAAbstractInvokeInstruction callInstrs[] = callerIR.getCalls(site);
assert callInstrs.length == 1;

View File

@ -110,12 +110,12 @@ public class NodejsRequiredSourceModule extends SourceFileModule {
return className;
}
private void loadWrapperSources() throws IOException {
private static void loadWrapperSources() throws IOException {
MODULE_WRAPPER_SOURCE = loadWrapperSource(MODULE_WRAPPER_FILENAME);
JSON_WRAPPER_SOURCE = loadWrapperSource(JSON_WRAPPER_FILENAME);
}
private String loadWrapperSource(String filename) throws IOException {
private static String loadWrapperSource(String filename) throws IOException {
InputStream url = NodejsRequiredSourceModule.class.getClassLoader().getResourceAsStream(filename);
return new String(Streams.inputStream2ByteArray(url));
}

View File

@ -84,7 +84,7 @@ org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled

View File

@ -83,7 +83,7 @@ org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled

View File

@ -36,7 +36,6 @@ public final class SemiSparseMutableIntSetTest extends WalaTestCase {
// --- Test cases
@SuppressWarnings("static-method")
@Test public void testCase1() {
final SemiSparseMutableIntSet ssmIntSet = new SemiSparseMutableIntSet();
ssmIntSet.add(1);

View File

@ -93,7 +93,7 @@ org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled

View File

@ -66,11 +66,11 @@ public class ArrayBoundsGraphBuilder {
this.lowerBoundGraph.updateNodeEdges();
this.upperBoundGraph.updateNodeEdges();
this.bundleDeadEnds(this.lowerBoundGraph);
this.bundleDeadEnds(this.upperBoundGraph);
bundleDeadEnds(this.lowerBoundGraph);
bundleDeadEnds(this.upperBoundGraph);
this.collapseNonPhiEdges(this.lowerBoundGraph);
this.collapseNonPhiEdges(this.upperBoundGraph);
collapseNonPhiEdges(this.lowerBoundGraph);
collapseNonPhiEdges(this.upperBoundGraph);
this.lowerBoundGraph.updateNodeEdges();
this.upperBoundGraph.updateNodeEdges();
@ -185,7 +185,7 @@ public class ArrayBoundsGraphBuilder {
*
* @param graph
*/
private void bundleDeadEnds(ArrayBoundsGraph graph) {
private static void bundleDeadEnds(ArrayBoundsGraph graph) {
final Set<HyperNode<Integer>> nodes = new HashSet<>();
nodes.addAll(graph.getNodes().values());
@ -207,7 +207,7 @@ public class ArrayBoundsGraphBuilder {
*
* @param graph
*/
private void collapseNonPhiEdges(ArrayBoundsGraph graph) {
private static void collapseNonPhiEdges(ArrayBoundsGraph graph) {
final Map<HyperNode<Integer>, DirectedHyperEdge<Integer>> inEdges = new HashMap<HyperNode<Integer>, DirectedHyperEdge<Integer>>();
final Set<DirectedHyperEdge<Integer>> edges = new HashSet<>();
edges.addAll(graph.getEdges());

View File

@ -51,10 +51,10 @@ public class ConditionNormalizer {
if (i == 0) {
// make sure the other is lhs
this.op = this.swapOperator(this.op);
this.op = swapOperator(this.op);
}
if (!branchIsTaken) {
this.op = this.negateOperator(this.op);
this.op = negateOperator(this.op);
}
this.rhs = var;
}
@ -73,7 +73,7 @@ public class ConditionNormalizer {
return this.rhs;
}
private Operator negateOperator(Operator op) {
private static Operator negateOperator(Operator op) {
switch (op) {
case EQ:
return Operator.NE;
@ -93,7 +93,7 @@ public class ConditionNormalizer {
}
}
private Operator swapOperator(Operator op) {
private static Operator swapOperator(Operator op) {
switch (op) {
case EQ:
return op;

View File

@ -31,7 +31,7 @@ public class InitializedBitVectorSolver extends BitVectorSolver<CGNode> {
return newBV();
}
private BitVectorVariable newBV() {
private static BitVectorVariable newBV() {
/*
* If we do not initialize BitVectorVariable, with a BitVector, it contains
* null, which may crash in combination with {@link BitVectorMinusVector}

View File

@ -129,7 +129,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
return EmptyIterator.instance();
}
private SSAInstruction[] makeStatements(JavaTypeContext context) {
private static SSAInstruction[] makeStatements(JavaTypeContext context) {
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>();
// vn1 is the string parameter
@ -149,7 +149,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
return result;
}
private IR makeIR(IMethod method, JavaTypeContext context) {
private static IR makeIR(IMethod method, JavaTypeContext context) {
SSAInstruction instrs[] = makeStatements(context);
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null);
}

View File

@ -173,7 +173,7 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
return null;
}
private IMethod getPublicDefaultCtor(IClass klass) {
private static IMethod getPublicDefaultCtor(IClass klass) {
IMethod ctorMethod = klass.getMethod(defCtorSelector);
if (ctorMethod != null && ctorMethod.isPublic() && ctorMethod.getDeclaringClass() == klass) {
return ctorMethod;

View File

@ -47,7 +47,7 @@ class ClassNewInstanceContextSelector implements ContextSelector {
return null;
}
private boolean isTypeConstant(InstanceKey instance) {
private static boolean isTypeConstant(InstanceKey instance) {
if (instance instanceof ConstantKey) {
ConstantKey c = (ConstantKey) instance;
if (c.getValue() instanceof IClass) {

View File

@ -106,7 +106,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
return EmptyIterator.instance();
}
private SSAInstruction[] makeStatements(JavaTypeContext context) {
private static SSAInstruction[] makeStatements(JavaTypeContext context) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>();
int nextLocal = 2;
int retValue = nextLocal++;
@ -126,7 +126,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
return result;
}
private IR makeIR(IMethod method, JavaTypeContext context) {
private static IR makeIR(IMethod method, JavaTypeContext context) {
SSAInstruction instrs[] = makeStatements(context);
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null);
}

View File

@ -150,7 +150,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
* @param cls the class
* @param name the name
*/
private Collection<IMethod> getDeclaredNormalMethods(IClass cls,Atom name) {
private static Collection<IMethod> getDeclaredNormalMethods(IClass cls,Atom name) {
Collection<IMethod> result = HashSetFactory.make();
for (IMethod m : cls.getDeclaredMethods()) {
if (!m.isInit() && !m.isClinit() && m.getSelector().getName().equals(name)) {
@ -166,7 +166,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
* @param cls the class
* @param name the name
*/
private Collection<IMethod> getAllNormalPublicMethods(IClass cls,Atom name) {
private static Collection<IMethod> getAllNormalPublicMethods(IClass cls,Atom name) {
Collection<IMethod> result = HashSetFactory.make();
Collection<IMethod> allMethods = null;
allMethods = cls.getAllMethods();
@ -186,7 +186,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
* @param returnValues the possible return values for this method
* @return the statements
*/
private SSAInstruction[] getParticularMethodStatements
private static SSAInstruction[] getParticularMethodStatements
(
MethodReference ref,
Collection<IMethod> returnValues,
@ -217,7 +217,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
return result;
}
private SSAInstruction[] makeGetMethodStatements
private static SSAInstruction[] makeGetMethodStatements
(
GetMethodContext context,
Map<Integer,ConstantValue> constants,
@ -234,7 +234,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
/**
* Create statements for {@link Class#getDeclaredMethod(String, Class...)}.
*/
private SSAInstruction[] makeGetDeclaredMethodStatements(GetMethodContext context, Map<Integer, ConstantValue> constants,Atom name) {
private static SSAInstruction[] makeGetDeclaredMethodStatements(GetMethodContext context, Map<Integer, ConstantValue> constants,Atom name) {
IClass cls = context.getType().getType();
if (cls == null) {
return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants);

View File

@ -114,7 +114,7 @@ public class GetMethodContextSelector implements ContextSelector {
* If <tt>instance</tt> is a {@link ConstantKey} and its value is an instance of {@link IClass},
* return that value. Otherwise, return <tt>null</tt>.
*/
private IClass getTypeConstant(InstanceKey instance) {
private static IClass getTypeConstant(InstanceKey instance) {
if (instance instanceof ConstantKey) {
ConstantKey c = (ConstantKey) instance;
if (c.getValue() instanceof IClass) {
@ -147,7 +147,7 @@ public class GetMethodContextSelector implements ContextSelector {
* This object understands a dispatch to {@link java.lang.Class#getMethod(String, Class...)}
* or {@link java.lang.Class#getDeclaredMethod} when the receiver is a type constant.
*/
private boolean mayUnderstand(CGNode caller,CallSiteReference site,IMethod targetMethod,InstanceKey instance) {
private static boolean mayUnderstand(CGNode caller,CallSiteReference site,IMethod targetMethod,InstanceKey instance) {
return UNDERSTOOD_METHOD_REFS.contains(targetMethod.getReference())
&& getTypeConstant(instance) != null;
}

View File

@ -128,7 +128,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
return getIR(node);
}
private IR makeIR(IMethod method, JavaTypeContext context) {
private static IR makeIR(IMethod method, JavaTypeContext context) {
Map<Integer, ConstantValue> constants = HashMapFactory.make();
if (method.getReference().equals(GET_CONSTRUCTOR)) {
SSAInstruction instrs[] = makeGetCtorStatements(context, constants);
@ -224,7 +224,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* Get all non-constructor, non-class-initializer methods declared by a class
*/
private Collection<IMethod> getDeclaredNormalMethods(IClass cls) {
private static Collection<IMethod> getDeclaredNormalMethods(IClass cls) {
Collection<IMethod> result = HashSetFactory.make();
for (IMethod m : cls.getDeclaredMethods()) {
if (!m.isInit() && !m.isClinit()) {
@ -237,7 +237,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* Get all non-constructor, non-class-initializer methods declared by a class and all its superclasses
*/
private Collection<IMethod> getAllNormalPublicMethods(IClass cls) {
private static Collection<IMethod> getAllNormalPublicMethods(IClass cls) {
Collection<IMethod> result = HashSetFactory.make();
Collection<IMethod> allMethods = null;
allMethods = cls.getAllMethods();
@ -252,7 +252,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* Get all the constructors of a class
*/
private Collection<IMethod> getConstructors(IClass cls) {
private static Collection<IMethod> getConstructors(IClass cls) {
Collection<IMethod> result = HashSetFactory.make();
for (IMethod m : cls.getDeclaredMethods()) {
if (m.isInit()) {
@ -265,7 +265,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* Get all the public constructors of a class
*/
private Collection<IMethod> getPublicConstructors(IClass cls) {
private static Collection<IMethod> getPublicConstructors(IClass cls) {
Collection<IMethod> result = HashSetFactory.make();
for (IMethod m : cls.getDeclaredMethods()) {
if (m.isInit() && m.isPublic()) {
@ -280,7 +280,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
*
* @param returnValues the possible return values for this method.
*/
private SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection<IMethod> returnValues, JavaTypeContext context,
private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection<IMethod> returnValues, JavaTypeContext context,
Map<Integer, ConstantValue> constants) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>();
int nextLocal = ref.getNumberOfParameters() + 2;
@ -327,7 +327,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
*
* @param returnValues the possible return values for this method.
*/
private SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection<IMethod> returnValues,
private static SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection<IMethod> returnValues,
JavaTypeContext context, Map<Integer, ConstantValue> constants) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>();
int nextLocal = ref.getNumberOfParameters() + 2;
@ -356,7 +356,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* create statements for getConstructor()
*/
private SSAInstruction[] makeGetCtorStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetCtorStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getParticularMethodStatements(GET_CONSTRUCTOR, null, context, constants);
@ -366,7 +366,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
}
// TODO
private SSAInstruction[] makeGetCtorsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetCtorsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants);
@ -375,7 +375,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
}
}
private SSAInstruction[] makeGetMethodStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetMethodStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getParticularMethodStatements(GET_METHOD, null, context, constants);
@ -384,7 +384,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
}
}
private SSAInstruction[] makeGetMethodsStatments(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetMethodsStatments(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getMethodArrayStatements(GET_METHODS, null, context, constants);
@ -396,7 +396,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* create statements for getConstructor()
*/
private SSAInstruction[] makeGetDeclCtorStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetDeclCtorStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getParticularMethodStatements(GET_DECLARED_CONSTRUCTOR, null, context, constants);
@ -405,7 +405,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
}
}
private SSAInstruction[] makeGetDeclCtorsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetDeclCtorsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants);
@ -417,7 +417,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* create statements for getDeclaredMethod()
*/
private SSAInstruction[] makeGetDeclaredMethodStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetDeclaredMethodStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants);
@ -429,7 +429,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
/**
* create statements for getDeclaredMethod()
*/
private SSAInstruction[] makeGetDeclaredMethodsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
private static SSAInstruction[] makeGetDeclaredMethodsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
IClass cls = context.getType().getType();
if (cls == null) {
return getMethodArrayStatements(GET_DECLARED_METHODS, null, context, constants);

View File

@ -56,7 +56,7 @@ class JavaLangClassContextSelector implements ContextSelector {
return null;
}
private IClass getTypeConstant(InstanceKey instance) {
private static IClass getTypeConstant(InstanceKey instance) {
if (instance instanceof ConstantKey) {
ConstantKey c = (ConstantKey) instance;
if (c.getValue() instanceof IClass) {
@ -82,7 +82,7 @@ class JavaLangClassContextSelector implements ContextSelector {
/**
* This object may understand a dispatch to Class.getContructor when the receiver is a type constant.
*/
private boolean mayUnderstand(CGNode caller, CallSiteReference site, IMethod targetMethod, InstanceKey instance) {
private static boolean mayUnderstand(CGNode caller, CallSiteReference site, IMethod targetMethod, InstanceKey instance) {
return UNDERSTOOD_METHOD_REFS.contains(targetMethod.getReference()) && getTypeConstant(instance) != null;
}

View File

@ -105,7 +105,7 @@ class ReflectiveInvocationSelector implements ContextSelector {
/**
* This object may understand a dispatch to Constructor.newInstance().
*/
private boolean mayUnderstand(CGNode caller, CallSiteReference site, IMethod targetMethod, InstanceKey instance) {
private static boolean mayUnderstand(CGNode caller, CallSiteReference site, IMethod targetMethod, InstanceKey instance) {
if (instance instanceof ConstantKey) {
if (targetMethod.getReference().equals(ReflectiveInvocationInterpreter.METHOD_INVOKE) ||
isConstructorConstant(instance)
@ -116,7 +116,7 @@ class ReflectiveInvocationSelector implements ContextSelector {
return false;
}
private boolean isConstructorConstant(InstanceKey instance) {
private static boolean isConstructorConstant(InstanceKey instance) {
if (instance instanceof ConstantKey) {
ConstantKey c = (ConstantKey) instance;
if (c.getConcreteType().getReference().equals(TypeReference.JavaLangReflectConstructor)) {

View File

@ -346,7 +346,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
* @param bb the basic block at whose entry the meet occurs
* @return true if the lhs value changes. false otherwise.
*/
private boolean meet(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
private static boolean meet(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
boolean changed = meetStacks(lhs, rhs, bb, meeter);
@ -362,7 +362,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
* @param bb the basic block at whose entry the meet occurs
* @return true if the lhs value changes. false otherwise.
*/
private boolean meetForCatchBlock(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
private static boolean meetForCatchBlock(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
boolean changed = meetStacksAtCatchBlock(lhs, bb, meeter);
changed |= meetLocals(lhs, rhs, bb, meeter);
@ -377,7 +377,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
* @param bb the basic block at whose entry the meet occurs
* @return true if the lhs value changes. false otherwise.
*/
private boolean meetStacksAtCatchBlock(IVariable lhs, BasicBlock bb, Meeter meeter) {
private static boolean meetStacksAtCatchBlock(IVariable lhs, BasicBlock bb, Meeter meeter) {
boolean changed = false;
MachineState L = (MachineState) lhs;
@ -412,7 +412,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
* @param bb the basic block at whose entry the meet occurs
* @return true if the lhs value changes. false otherwise.
*/
private boolean meetStacks(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
private static boolean meetStacks(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
boolean changed = false;
MachineState L = (MachineState) lhs;
@ -465,7 +465,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
* @param bb the basic block at whose entry the meet occurs
* @return true if the lhs value changes. false otherwise.
*/
private boolean meetLocals(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
private static boolean meetLocals(IVariable lhs, IVariable[] rhs, BasicBlock bb, Meeter meeter) {
boolean changed = false;
MachineState L = (MachineState) lhs;

View File

@ -267,7 +267,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
return "delared type := " + type;
}
public boolean isNullary() {
public static boolean isNullary() {
return true;
}

View File

@ -129,7 +129,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
clearPis(getInstructions());
}
private void clearPis(SSAInstruction[] instructions) {
private static void clearPis(SSAInstruction[] instructions) {
for (int i = 0; i < instructions.length; i++) {
if (instructions[i] instanceof SSAPiInstruction) {
instructions[i] = null;
@ -216,7 +216,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
/**
* set to null any slots in the array with phi instructions
*/
private void clearPhis(SSAInstruction[] instructions) {
private static void clearPhis(SSAInstruction[] instructions) {
for (int i = 0; i < instructions.length; i++) {
if (instructions[i] instanceof SSAPhiInstruction) {
instructions[i] = null;

View File

@ -181,7 +181,7 @@ public class ClassLoaderImpl implements IClassLoader {
/**
* Remove from s any class file module entries which already are in t
*/
private void removeClassFiles(Set<ModuleEntry> s, Set<ModuleEntry> t) {
private static void removeClassFiles(Set<ModuleEntry> s, Set<ModuleEntry> t) {
Set<String> old = HashSetFactory.make();
for (Iterator<ModuleEntry> it = t.iterator(); it.hasNext();) {
ModuleEntry m = it.next();
@ -345,7 +345,7 @@ public class ClassLoaderImpl implements IClassLoader {
return result;
}
private byte[] getEntryBytes(JarEntry entry, Long size, InputStream is) throws IOException {
private static byte[] getEntryBytes(JarEntry entry, Long size, InputStream is) throws IOException {
if (size == null) {
return null;
}
@ -556,7 +556,7 @@ public class ClassLoaderImpl implements IClassLoader {
/**
* get the contents of a jar file. if any IO exceptions occur, catch and return null.
*/
private void getJarFileContents(JarFileModule archive) {
private static void getJarFileContents(JarFileModule archive) {
String jarFileName = archive.getJarFile().getName();
InputStream s = null;
try {

View File

@ -496,7 +496,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
copyVisitorSetsToArrays(simpleVisitor, info);
}
private void copyVisitorSetsToArrays(SimpleVisitor simpleVisitor, BytecodeInfo info) {
private static void copyVisitorSetsToArrays(SimpleVisitor simpleVisitor, BytecodeInfo info) {
info.newSites = new NewSiteReference[simpleVisitor.newSites.size()];
int i = 0;
for (Iterator<NewSiteReference> it = simpleVisitor.newSites.iterator(); it.hasNext();) {

View File

@ -343,7 +343,7 @@ public final class ShrikeCTMethod extends ShrikeBTMethod implements IBytecodeMet
ClassReader.AttrIterator iter = new AttrIterator();
getClassReader().initMethodAttributeIterator(shrikeMethodIndex, iter);
return ((ShrikeClass)getDeclaringClass()).getReader(iter, attrName, reader);
return ShrikeClass.getReader(iter, attrName, reader);
}
private CodeReader getCodeReader() {

View File

@ -305,7 +305,7 @@ public final class ShrikeClass extends JVMClass<IClassLoader> {
T getReader(ClassReader.AttrIterator iter) throws InvalidClassFileException;
}
<T> T getReader(ClassReader.AttrIterator iter, String attrName, GetReader<T> reader) {
static <T> T getReader(ClassReader.AttrIterator iter, String attrName, GetReader<T> reader) {
// search for the attribute
try {
for (; iter.isValid(); iter.advance()) {

View File

@ -148,7 +148,7 @@ public class CallFlowEdges {
}
// TODO optimize
private IntSet getDomain(IBinaryNaturalRelation r) {
private static IntSet getDomain(IBinaryNaturalRelation r) {
MutableIntSet result = MutableSparseIntSet.makeEmpty();
int maxKeyValue = r.maxKeyValue();
for (int i = 0; i <= maxKeyValue; i++) {

View File

@ -501,7 +501,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
/**
* do all instance keys in p2set pass ikeyPred?
*/
private boolean passesPred(Collection<InstanceKeyAndState> curP2Set, final Predicate<InstanceKey> ikeyPred) {
private static boolean passesPred(Collection<InstanceKeyAndState> curP2Set, final Predicate<InstanceKey> ikeyPred) {
return Util.forAll(curP2Set, new Predicate<InstanceKeyAndState>() {
@Override
@ -2000,11 +2000,11 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
}
}
private SSAAbstractInvokeInstruction[] getCallInstrs(CGNode node, CallSiteReference site) {
private static SSAAbstractInvokeInstruction[] getCallInstrs(CGNode node, CallSiteReference site) {
return node.getIR().getCalls(site);
}
private boolean hasNullIR(CGNode node) {
private static boolean hasNullIR(CGNode node) {
boolean ret = node.getMethod().isNative();
assert node.getIR() != null || ret;
return ret;
@ -2457,7 +2457,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
return true;
}
private boolean predHoldsForPk(PointerKey curPk, Predicate<InstanceKey> pred, PointerAnalysis<InstanceKey> pa) {
private static boolean predHoldsForPk(PointerKey curPk, Predicate<InstanceKey> pred, PointerAnalysis<InstanceKey> pa) {
PointerKey curPkForPAHeapModel = convertToHeapModel(curPk, pa.getHeapModel());
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(curPkForPAHeapModel);
for (InstanceKey ik : pointsToSet) {
@ -2468,7 +2468,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
return true;
}
private PointerKey convertToHeapModel(PointerKey curPk, HeapModel heapModel) {
private static PointerKey convertToHeapModel(PointerKey curPk, HeapModel heapModel) {
return AbstractFlowGraph.convertPointerKeyToHeapModel(curPk, heapModel);
}

View File

@ -336,7 +336,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
protected abstract FlowStatementVisitor makeVisitor(CGNode node);
private void debugPrintIR(IR ir) {
private static void debugPrintIR(IR ir) {
if (DEBUG) {
if (ir == null) {
System.err.println("\n No statements\n");

View File

@ -531,7 +531,7 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
return new StatementVisitor(node, ir, du);
}
private void debugPrintIR(IR ir) {
private static void debugPrintIR(IR ir) {
if (DEBUG) {
if (ir == null) {
System.err.println("\n No statements\n");

View File

@ -133,7 +133,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
return result;
}
private void convertStmtsToMemoryAccess(Collection<Statement> stmts, Collection<MemoryAccess> result) {
private static void convertStmtsToMemoryAccess(Collection<Statement> stmts, Collection<MemoryAccess> result) {
if (stmts == null) {
return;
}

View File

@ -57,7 +57,7 @@ public class AllApplicationEntrypoints extends HashSet<Entrypoint> {
/**
* @return true iff klass is loaded by the application loader.
*/
private boolean isApplicationClass(AnalysisScope scope, IClass klass) {
private static boolean isApplicationClass(AnalysisScope scope, IClass klass) {
return scope.getApplicationLoader().equals(klass.getClassLoader().getReference());
}
}

View File

@ -70,7 +70,7 @@ public class PointerKeyComparator implements Comparator {
}
}
private int compareLocalKey(LocalPointerKey key1, Object key2) {
private static int compareLocalKey(LocalPointerKey key1, Object key2) {
if (key2 instanceof LocalPointerKey) {
int l1 = key1.getValueNumber();
int l2 = ((LocalPointerKey)key2).getValueNumber();
@ -91,7 +91,7 @@ public class PointerKeyComparator implements Comparator {
else return -1;
}
private int compareReturnValueKey(ReturnValueKey key1, Object key2) {
private static int compareReturnValueKey(ReturnValueKey key1, Object key2) {
if (key2 instanceof ReturnValueKey) {
int n1 = key1.getNode().getGraphNodeId();
int n2 = ((ReturnValueKey)key2).getNode().getGraphNodeId();
@ -106,7 +106,7 @@ public class PointerKeyComparator implements Comparator {
else return -1;
}
private int compareExceptionKey(ExceptionReturnValueKey key1, Object key2) {
private static int compareExceptionKey(ExceptionReturnValueKey key1, Object key2) {
if (key2 instanceof ExceptionReturnValueKey) {
int n1 = key1.getNode().getGraphNodeId();
int n2 = ((ExceptionReturnValueKey)key2).getNode().getGraphNodeId();

View File

@ -97,7 +97,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
/**
* @return a relation in map m corresponding to a key
*/
private IBinaryNaturalRelation findOrCreateRelation(Map<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> m,
private static IBinaryNaturalRelation findOrCreateRelation(Map<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> m,
UnaryOperator<PointsToSetVariable> key) {
IBinaryNaturalRelation result = m.get(key);
if (result == null) {
@ -110,7 +110,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
/**
* @return a Relation object to track implicit equations using the operator
*/
private IBinaryNaturalRelation makeRelation(AbstractOperator op) {
private static IBinaryNaturalRelation makeRelation(AbstractOperator op) {
byte[] implementation = null;
if (op instanceof AssignOperator) {
// lots of assignments.
@ -225,7 +225,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
/**
* @return true iff this equation should be represented implicitly in this data structure
*/
private boolean useImplicitRepresentation(IFixedPointStatement s) {
private static boolean useImplicitRepresentation(IFixedPointStatement s) {
AbstractStatement eq = (AbstractStatement) s;
AbstractOperator op = eq.getOperator();
return (op instanceof AssignOperator || op instanceof PropagationCallGraphBuilder.FilterOperator);

View File

@ -499,7 +499,7 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
}
}
private TypeReference makeArray(TypeReference element, int dim) {
private static TypeReference makeArray(TypeReference element, int dim) {
TypeReference iArrayRef = element;
for (int i = 0; i < dim; i++) {
iArrayRef = TypeReference.findOrCreateArrayOf(iArrayRef);

View File

@ -108,7 +108,7 @@ public class ReflectionHandler {
*
* @return set of nodes whose interpretation has changed.
*/
private Set<CGNode> modifyFactoryInterpreter(Statement returnStatement, Collection<Statement> casts,
private static Set<CGNode> modifyFactoryInterpreter(Statement returnStatement, Collection<Statement> casts,
RTAContextInterpreter contextInterpreter, IClassHierarchy cha) {
HashSet<CGNode> result = HashSetFactory.make();

View File

@ -727,7 +727,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
}
protected boolean isRootType(IClass klass) {
return getBuilder().isRootType(klass);
return SSAPropagationCallGraphBuilder.isRootType(klass);
}
/*
@ -2184,12 +2184,12 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
return true;
}
private boolean isRootType(IClass klass) {
private static boolean isRootType(IClass klass) {
return klass.getClassHierarchy().isRootClass(klass);
}
@SuppressWarnings("unused")
private boolean isRootType(FilteredPointerKey.TypeFilter filter) {
private static boolean isRootType(FilteredPointerKey.TypeFilter filter) {
if (filter instanceof FilteredPointerKey.SingleClassFilter) {
return isRootType(((FilteredPointerKey.SingleClassFilter) filter).getConcreteType());
} else {

View File

@ -268,7 +268,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
}
}
private boolean isReflectiveType(TypeReference type) {
private static boolean isReflectiveType(TypeReference type) {
return type.equals(TypeReference.JavaLangReflectConstructor) || type.equals(TypeReference.JavaLangReflectMethod);
}

View File

@ -38,7 +38,7 @@ implements EdgeFilter<Block> {
.contains(dst);
final SSAInstruction relevantInstruction = src.getLastInstruction();
if (hasExceptionalEdge && relevantInstruction != null) {
if (this.weKnowAllExceptions(relevantInstruction)) {
if (weKnowAllExceptions(relevantInstruction)) {
final Collection<TypeReference> thrownExceptions = relevantInstruction
.getExceptionTypes();
@ -79,7 +79,7 @@ implements EdgeFilter<Block> {
* @return if we know all exceptions, that can occur at this address from
* getExceptionTypes()
*/
private boolean weKnowAllExceptions(SSAInstruction instruction) {
private static boolean weKnowAllExceptions(SSAInstruction instruction) {
return !((instruction instanceof SSAAbstractInvokeInstruction) || (instruction instanceof SSAAbstractThrowInstruction));
}
}

View File

@ -595,7 +595,7 @@ public class ClassHierarchy implements IClassHierarchy {
* @param selector method selector
* @return the method if found, else null
*/
private IMethod findMethod(IClass clazz, Selector selector) {
private static IMethod findMethod(IClass clazz, Selector selector) {
return clazz.getMethod(selector);
}
@ -787,7 +787,7 @@ public class ClassHierarchy implements IClassHierarchy {
}
}
private Set<IClass> getSuperclasses(IClass c) throws ClassHierarchyException {
private static Set<IClass> getSuperclasses(IClass c) throws ClassHierarchyException {
HashSet<IClass> result = HashSetFactory.make(3);
while (c.getSuperclass() != null) {
result.add(c.getSuperclass());

View File

@ -738,7 +738,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
}
}
private boolean hasBasePointer(SSAInstruction use) {
private static boolean hasBasePointer(SSAInstruction use) {
if (use instanceof SSAFieldAccessInstruction) {
SSAFieldAccessInstruction f = (SSAFieldAccessInstruction) use;
return !f.isStatic();
@ -751,7 +751,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
}
}
private int getBasePointer(SSAInstruction use) {
private static int getBasePointer(SSAInstruction use) {
if (use instanceof SSAFieldAccessInstruction) {
SSAFieldAccessInstruction f = (SSAFieldAccessInstruction) use;
return f.getRef();
@ -788,7 +788,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
/**
* @return {@link IntSet} representing instruction indices of each PEI in the ir
*/
private IntSet getPEIs(final IR ir) {
private static IntSet getPEIs(final IR ir) {
BitVectorIntSet result = new BitVectorIntSet();
for (int i = 0; i < ir.getInstructions().length; i++) {
if (ir.getInstructions()[i] != null && ir.getInstructions()[i].isPEI()) {
@ -852,7 +852,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
/**
* Convert a NORMAL or PHI Statement to an SSAInstruction
*/
private SSAInstruction statement2SSAInstruction(SSAInstruction[] instructions, Statement s) {
private static SSAInstruction statement2SSAInstruction(SSAInstruction[] instructions, Statement s) {
SSAInstruction statement = null;
switch (s.getKind()) {
case NORMAL:
@ -1040,7 +1040,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
/**
* @return the set of all locations read by any callee at a call site.
*/
private OrdinalSet<PointerKey> unionHeapLocations(CallGraph cg, CGNode n, SSAAbstractInvokeInstruction call,
private static OrdinalSet<PointerKey> unionHeapLocations(CallGraph cg, CGNode n, SSAAbstractInvokeInstruction call,
Map<CGNode, OrdinalSet<PointerKey>> loc) {
BitVectorIntSet bv = new BitVectorIntSet();
for (CGNode t : cg.getPossibleTargets(n, call.getCallSite())) {

View File

@ -172,7 +172,7 @@ public class MethodBypass {
* @param type
* @return Atom that represents the package name, or null if this is the unnamed package.
*/
private Atom extractPackage(TypeReference type) {
private static Atom extractPackage(TypeReference type) {
String s = type.getName().toString();
int index = s.lastIndexOf('/');
if (index == -1) {

View File

@ -56,7 +56,7 @@ public class SyntheticIR extends IR {
/**
* throw an assertion if the instruction array contains a phi instruction
*/
private void repOK(SSAInstruction[] instructions) {
private static void repOK(SSAInstruction[] instructions) {
for (SSAInstruction s : instructions) {
if (s instanceof SSAPhiInstruction) {
Assertions.UNREACHABLE();

View File

@ -1049,7 +1049,7 @@ public class SSABuilder extends AbstractIntStackMachine {
/**
* @return the indices i s.t. x[i] == y, or null if none found.
*/
private int[] extractIndices(int[] x, int y) {
private static int[] extractIndices(int[] x, int y) {
assert x != null;
int count = 0;
for (int i = 0; i < x.length; i++) {

View File

@ -234,7 +234,7 @@ public final class Descriptor {
return result.toString();
}
private void appendSemicolonIfNeeded(StringBuffer result, TypeName p) {
private static void appendSemicolonIfNeeded(StringBuffer result, TypeName p) {
if (p.isArrayType()) {
TypeName e = p.getInnermostElementType();
String x = e.toUnicodeString();

View File

@ -48,7 +48,7 @@ public class FormalTypeParameter extends Signature {
interfaceBounds = parseForInterfaceBounds(s);
}
private TypeSignature parseForClassBound(String s) {
private static TypeSignature parseForClassBound(String s) {
int start = s.indexOf(':');
if (start == s.length() - 1) {
return null;
@ -64,7 +64,7 @@ public class FormalTypeParameter extends Signature {
}
}
private TypeSignature[] parseForInterfaceBounds(String s) {
private static TypeSignature[] parseForInterfaceBounds(String s) {
List<TypeSignature> list = new LinkedList<TypeSignature>();
int start = s.indexOf(':');
@ -85,7 +85,7 @@ public class FormalTypeParameter extends Signature {
return list.toArray(result);
}
private String parseForId(String s) throws IllegalArgumentException {
private static String parseForId(String s) throws IllegalArgumentException {
if (s.indexOf(':') == -1) {
throw new IllegalArgumentException(s);
}

View File

@ -87,7 +87,7 @@ public class ShrikeClassReaderHandle {
* Read is into bytes
* @throws IOException
*/
private void readBytes(InputStream is, ByteArrayOutputStream bytes) throws IOException {
private static void readBytes(InputStream is, ByteArrayOutputStream bytes) throws IOException {
int n = 0;
byte[] buffer = new byte[1024];
while (n > -1) {

View File

@ -609,7 +609,7 @@ public class TypeSafeInstructionFactory {
return insts.PhiInstruction(iindex, result.getNumber(), aParams);
}
private boolean isSuperclassOf(final TypeReference superClass, final TypeReference subClass) {
private static boolean isSuperclassOf(final TypeReference superClass, final TypeReference subClass) {
return true; // TODO
}

View File

@ -121,7 +121,7 @@ public class IrViewer extends JPanel{
static final int NA = -1;
private int parseIrLine(String line) {
private static int parseIrLine(String line) {
int firstSpace = line.indexOf(' ');
if (firstSpace > 0) {
String pcString = line.substring(0, firstSpace);