Remove type arguments that Java 1.7+ can infer for us

This commit is contained in:
Ben Liblit 2017-12-04 01:37:15 -06:00 committed by Manu Sridharan
parent b25e461bfe
commit 544a71ae72
144 changed files with 413 additions and 414 deletions

View File

@ -80,7 +80,7 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=error
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore

View File

@ -42,7 +42,7 @@ import java.util.Iterator;
public class BasicsGenerics { public class BasicsGenerics {
static ArrayList<String> strs = new ArrayList<String>(); static ArrayList<String> strs = new ArrayList<>();
static ArrayList<Integer> ints = new ArrayList<>(); static ArrayList<Integer> ints = new ArrayList<>();
public BasicsGenerics() { public BasicsGenerics() {

View File

@ -95,7 +95,7 @@ class MyGeneric<A extends Object, B extends IGeneric<A>> {
} }
public class CustomGenericsAndFields { public class CustomGenericsAndFields {
static ConcreteGeneric2<String> cg2 = new ConcreteGeneric2<String>(); static ConcreteGeneric2<String> cg2 = new ConcreteGeneric2<>();
static public ConcreteGeneric2<String> cg2WithSideEffects() { static public ConcreteGeneric2<String> cg2WithSideEffects() {
System.out.println("look at me! I'm a side effect!"); System.out.println("look at me! I'm a side effect!");
@ -109,7 +109,7 @@ public class CustomGenericsAndFields {
private void doit() { private void doit() {
// Simple: concrete generic // Simple: concrete generic
ConcreteGeneric<String> absinthe = new ConcreteGeneric<String>(); ConcreteGeneric<String> absinthe = new ConcreteGeneric<>();
IGeneric<String> rye = absinthe; IGeneric<String> rye = absinthe;
String foo = rye.bar("hello", "world"); String foo = rye.bar("hello", "world");
System.out.println(absinthe.foo() + foo); System.out.println(absinthe.foo() + foo);
@ -118,7 +118,7 @@ public class CustomGenericsAndFields {
String thrownaway = cg2.bar("a","b"); String thrownaway = cg2.bar("a","b");
cg2.setFoo("real one"); cg2.setFoo("real one");
MyGeneric<String,ConcreteGeneric2<String>> mygeneric = new MyGeneric<String,ConcreteGeneric2<String>>("useless",cg2); MyGeneric<String,ConcreteGeneric2<String>> mygeneric = new MyGeneric<>("useless",cg2);
String x = mygeneric.doFoo(); String x = mygeneric.doFoo();
System.out.println(x); System.out.println(x);
String y = cg2.x; String y = cg2.x;

View File

@ -49,7 +49,7 @@ public class GenericArrays {
List<?>[] lsa = new List<?>[10]; // ok, array of unbounded wildcard type List<?>[] lsa = new List<?>[10]; // ok, array of unbounded wildcard type
Object o = lsa; Object o = lsa;
Object[] oa = (Object[]) o; Object[] oa = (Object[]) o;
List<Integer> li = new ArrayList<Integer>(); List<Integer> li = new ArrayList<>();
li.add(new Integer(3)); li.add(new Integer(3));
oa[1] = li; // correct oa[1] = li; // correct
String s = (String) lsa[1].get(0); // run time error, but cast is explicit String s = (String) lsa[1].get(0); // run time error, but cast is explicit

View File

@ -64,7 +64,7 @@ public class GenericMemberClasses<T>
} }
} }
public static void main(String args[]) { public static void main(String args[]) {
(new GenericMemberClasses<Object>()).doit(); (new GenericMemberClasses<>()).doit();
} }
private void doit() { private void doit() {

View File

@ -47,14 +47,14 @@ public class GenericSuperSink {
private void doit() { private void doit() {
Collection<? super String> sink; Collection<? super String> sink;
Collection<String> cs = new ArrayList<String>(); Collection<String> cs = new ArrayList<>();
cs.add("hello"); cs.add("hello");
sink = new ArrayList<Object>(); sink = new ArrayList<Object>();
sink.add(cs.iterator().next()); sink.add(cs.iterator().next());
System.out.println(sink); System.out.println(sink);
sink = new ArrayList<String>(); sink = new ArrayList<>();
sink.add(cs.iterator().next()); sink.add(cs.iterator().next());
System.out.println(sink); System.out.println(sink);
} }

View File

@ -55,7 +55,7 @@ public class MethodGenerics {
} }
private void doit() { private void doit() {
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<>();
String array[] = new String[] { "coucou monde", "ciao mondo", "guten tag welt", "hola mundo", "shalom olam" }; String array[] = new String[] { "coucou monde", "ciao mondo", "guten tag welt", "hola mundo", "shalom olam" };
fromArrayToCollection(array, list); fromArrayToCollection(array, list);
System.out.println(list); System.out.println(list);

View File

@ -64,14 +64,14 @@ public class Wildcards {
} }
private void doit() { private void doit() {
ArrayList<String> e = new ArrayList<String>(); ArrayList<String> e = new ArrayList<>();
e.add("hello"); e.add("hello");
e.add("goodbye"); e.add("goodbye");
printCollection(e); printCollection(e);
printCollection1(e); printCollection1(e);
printCollection2(e); printCollection2(e);
ArrayList<Integer> e3 = new ArrayList<Integer>(); ArrayList<Integer> e3 = new ArrayList<>();
e3.add(new Integer(123)); e3.add(new Integer(123));
e3.add(new Integer(42)); e3.add(new Integer(42));
printCollection(e3); printCollection(e3);

View File

@ -91,7 +91,7 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=error org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=error
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=error

View File

@ -141,7 +141,7 @@ public class ArrayBoundsGraph extends DirectedHyperGraph<Integer> {
final EdgeWeight edgeWeight = new AdditiveEdgeWeight(weight); final EdgeWeight edgeWeight = new AdditiveEdgeWeight(weight);
final DirectedHyperEdge<Integer> edge = new DirectedHyperEdge<Integer>(); final DirectedHyperEdge<Integer> edge = new DirectedHyperEdge<>();
edge.getDestination().add(dstNode); edge.getDestination().add(dstNode);
edge.getSource().add(srcNode); edge.getSource().add(srcNode);
edge.setWeight(edgeWeight); edge.setWeight(edgeWeight);
@ -193,7 +193,7 @@ public class ArrayBoundsGraph extends DirectedHyperGraph<Integer> {
public HyperNode<Integer> addNode(Integer value) { public HyperNode<Integer> addNode(Integer value) {
HyperNode<Integer> result; HyperNode<Integer> result;
if (!this.getNodes().keySet().contains(value)) { if (!this.getNodes().keySet().contains(value)) {
result = new HyperNode<Integer>(value); result = new HyperNode<>(value);
this.getNodes().put(value, result); this.getNodes().put(value, result);
} else { } else {
result = this.getNodes().get(value); result = this.getNodes().get(value);
@ -227,7 +227,7 @@ public class ArrayBoundsGraph extends DirectedHyperGraph<Integer> {
throw new AssertionError("Source variables should only be created once."); throw new AssertionError("Source variables should only be created once.");
} }
SoftFinalHyperNode<Integer> node = new SoftFinalHyperNode<Integer>(var); SoftFinalHyperNode<Integer> node = new SoftFinalHyperNode<>(var);
this.getNodes().put(var, node); this.getNodes().put(var, node);
// final HyperNode<Integer> varNode = this.getNodes().get(var); // final HyperNode<Integer> varNode = this.getNodes().get(var);
@ -276,7 +276,7 @@ public class ArrayBoundsGraph extends DirectedHyperGraph<Integer> {
public void markAsArrayAccess(Integer array, Integer index) { public void markAsArrayAccess(Integer array, Integer index) {
Set<Integer> indices; Set<Integer> indices;
if (!this.arrayAccess.containsKey(array)) { if (!this.arrayAccess.containsKey(array)) {
indices = new HashSet<Integer>(); indices = new HashSet<>();
this.arrayAccess.put(array, indices); this.arrayAccess.put(array, indices);
} else { } else {
indices = this.arrayAccess.get(array); indices = this.arrayAccess.get(array);

View File

@ -46,7 +46,7 @@ public class ArrayBoundsGraphBuilder {
public ArrayBoundsGraphBuilder(IR ir) { public ArrayBoundsGraphBuilder(IR ir) {
this.ir = ir; this.ir = ir;
this.foundVariables = new HashSet<Integer>(); this.foundVariables = new HashSet<>();
this.defUse = new DefUse(ir); this.defUse = new DefUse(ir);
this.arrayReferenceInstructions = new HashSet<>(); this.arrayReferenceInstructions = new HashSet<>();
@ -210,7 +210,7 @@ public class ArrayBoundsGraphBuilder {
* @param graph * @param graph
*/ */
private static void collapseNonPhiEdges(ArrayBoundsGraph graph) { private static void collapseNonPhiEdges(ArrayBoundsGraph graph) {
final Map<HyperNode<Integer>, DirectedHyperEdge<Integer>> inEdges = new HashMap<HyperNode<Integer>, DirectedHyperEdge<Integer>>(); final Map<HyperNode<Integer>, DirectedHyperEdge<Integer>> inEdges = new HashMap<>();
final Set<DirectedHyperEdge<Integer>> edges = new HashSet<>(); final Set<DirectedHyperEdge<Integer>> edges = new HashSet<>();
edges.addAll(graph.getEdges()); edges.addAll(graph.getEdges());
for (final DirectedHyperEdge<Integer> edge : edges) { for (final DirectedHyperEdge<Integer> edge : edges) {
@ -323,7 +323,7 @@ public class ArrayBoundsGraphBuilder {
} }
private void exploreIr() { private void exploreIr() {
final Set<Integer> variablesUsedAsIndex = new HashSet<Integer>(); final Set<Integer> variablesUsedAsIndex = new HashSet<>();
for (final Set<Integer> variables : this.lowerBoundGraph for (final Set<Integer> variables : this.lowerBoundGraph
.getArrayAccess().values()) { .getArrayAccess().values()) {
variablesUsedAsIndex.addAll(variables); variablesUsedAsIndex.addAll(variables);
@ -386,7 +386,7 @@ public class ArrayBoundsGraphBuilder {
* the given variable. * the given variable.
*/ */
private void startDFS(int index) { private void startDFS(int index) {
final Stack<Integer> todo = new Stack<Integer>(); final Stack<Integer> todo = new Stack<>();
todo.push(index); todo.push(index);
while (!todo.isEmpty()) { while (!todo.isEmpty()) {

View File

@ -21,8 +21,8 @@ public class DirectedHyperEdge<T> {
private EdgeWeight weight; private EdgeWeight weight;
public DirectedHyperEdge() { public DirectedHyperEdge() {
this.tail = new HashSet<HyperNode<T>>(); this.tail = new HashSet<>();
this.head = new HashSet<HyperNode<T>>(); this.head = new HashSet<>();
} }
public Set<HyperNode<T>> getDestination() { public Set<HyperNode<T>> getDestination() {

View File

@ -31,7 +31,7 @@ public class HyperNode<T> {
public HyperNode(T value) { public HyperNode(T value) {
this.value = value; this.value = value;
this.outEdges = new HashSet<DirectedHyperEdge<T>>(); this.outEdges = new HashSet<>();
this.weight = Weight.NOT_SET; this.weight = Weight.NOT_SET;
this.newWeight = Weight.NOT_SET; this.newWeight = Weight.NOT_SET;
} }

View File

@ -37,7 +37,7 @@ public class Exception2BitvectorTransformer {
private void createValues(Set<TypeReference> exceptions) { private void createValues(Set<TypeReference> exceptions) {
TypeReference[] exceptionsArray = new TypeReference[exceptions.size()]; TypeReference[] exceptionsArray = new TypeReference[exceptions.size()];
exceptions.toArray(exceptionsArray); exceptions.toArray(exceptionsArray);
values = new ObjectArrayMapping<TypeReference>(exceptionsArray); values = new ObjectArrayMapping<>(exceptionsArray);
} }
public BitVector computeBitVector(Set<TypeReference> exceptions) { public BitVector computeBitVector(Set<TypeReference> exceptions) {

View File

@ -93,7 +93,7 @@ public class ExceptionAnalysis {
ExceptionTransferFunctionProvider transferFunctionProvider = new ExceptionTransferFunctionProvider(intraResult, callgraph, ExceptionTransferFunctionProvider transferFunctionProvider = new ExceptionTransferFunctionProvider(intraResult, callgraph,
transformer); transformer);
Graph<CGNode> graph = new InvertedGraph<CGNode>(callgraph); Graph<CGNode> graph = new InvertedGraph<>(callgraph);
BitVectorFramework<CGNode, TypeReference> problem = new BitVectorFramework<>(graph, transferFunctionProvider, BitVectorFramework<CGNode, TypeReference> problem = new BitVectorFramework<>(graph, transferFunctionProvider,
transformer.getValues()); transformer.getValues());

View File

@ -263,7 +263,7 @@ public class IntraproceduralExceptionAnalysis {
* given block. * given block.
*/ */
private Set<TypeReference> collectCaughtExceptions(ISSABasicBlock block) { private Set<TypeReference> collectCaughtExceptions(ISSABasicBlock block) {
LinkedHashSet<TypeReference> result = new LinkedHashSet<TypeReference>(); LinkedHashSet<TypeReference> result = new LinkedHashSet<>();
List<ISSABasicBlock> exceptionalSuccessors = ir.getControlFlowGraph().getExceptionalSuccessors(block); List<ISSABasicBlock> exceptionalSuccessors = ir.getControlFlowGraph().getExceptionalSuccessors(block);
for (ISSABasicBlock succ : exceptionalSuccessors) { for (ISSABasicBlock succ : exceptionalSuccessors) {
if (succ.isCatchBlock()) { if (succ.isCatchBlock()) {

View File

@ -36,9 +36,9 @@ public class IntraproceduralNullPointerAnalysis {
final int maxVarNum = ir.getSymbolTable().getMaxValueNumber(); final int maxVarNum = ir.getSymbolTable().getMaxValueNumber();
SSACFG cfg = ir.getControlFlowGraph(); SSACFG cfg = ir.getControlFlowGraph();
final NullPointerFrameWork<ISSABasicBlock> problem = new NullPointerFrameWork<ISSABasicBlock>( final NullPointerFrameWork<ISSABasicBlock> problem = new NullPointerFrameWork<>(
cfg, ir); cfg, ir);
this.solver = new NullPointerSolver<ISSABasicBlock>(problem, maxVarNum, this.solver = new NullPointerSolver<>(problem, maxVarNum,
ir, cfg.entry()); ir, cfg.entry());
try { try {
this.solver.solve(NO_PROGRESS_MONITOR); this.solver.solve(NO_PROGRESS_MONITOR);

View File

@ -78,7 +78,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
final NumberedNodeManager<Object> nodeMgr = new NumberedNodeManager<Object>() { final NumberedNodeManager<Object> nodeMgr = new NumberedNodeManager<Object>() {
@Override @Override
public Iterator<Object> iterator() { public Iterator<Object> iterator() {
return new CompoundIterator<Object>(pointerKeys.iterator(), P.getInstanceKeyMapping().iterator()); return new CompoundIterator<>(pointerKeys.iterator(), P.getInstanceKeyMapping().iterator());
} }
@Override @Override
@ -130,7 +130,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
@Override @Override
public Iterator<Object> iterateNodes(IntSet s) { public Iterator<Object> iterateNodes(IntSet s) {
return new NumberedNodeIterator<Object>(s, this); return new NumberedNodeIterator<>(s, this);
} }
}; };
@ -146,7 +146,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
if (p == null) { if (p == null) {
return EmptyIterator.instance(); return EmptyIterator.instance();
} else { } else {
return new IntMapIterator<Object>(p.intIterator(), toNode); return new IntMapIterator<>(p.intIterator(), toNode);
} }
} }
@ -174,7 +174,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
SparseIntSet s = factory.make(succ); SparseIntSet s = factory.make(succ);
return new IntMapIterator<Object>(s.intIterator(), toNode); return new IntMapIterator<>(s.intIterator(), toNode);
} }
@Override @Override
@ -332,7 +332,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
*/ */
private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) { private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) {
ArrayList<LocalPointerKey> list = new ArrayList<LocalPointerKey>(); ArrayList<LocalPointerKey> list = new ArrayList<>();
for (Object n : nodeManager) { for (Object n : nodeManager) {
if (n instanceof LocalPointerKey) { if (n instanceof LocalPointerKey) {
list.add((LocalPointerKey) n); list.add((LocalPointerKey) n);

View File

@ -46,7 +46,7 @@ public abstract class HeapGraphImpl<T extends InstanceKey> implements HeapGraph<
@Override @Override
public Iterator<Object> iterateNodes(IntSet s) { public Iterator<Object> iterateNodes(IntSet s) {
return new NumberedNodeIterator<Object>(s, this); return new NumberedNodeIterator<>(s, this);
} }
@Override @Override

View File

@ -176,17 +176,17 @@ public abstract class AbstractReflectionInterpreter implements SSAContextInterpr
/** /**
* List of synthetic allocation statements we model for this specialized instance * List of synthetic allocation statements we model for this specialized instance
*/ */
final protected ArrayList<SSAInstruction> allocations = new ArrayList<SSAInstruction>(); final protected ArrayList<SSAInstruction> allocations = new ArrayList<>();
/** /**
* List of synthetic invoke instructions we model for this specialized instance. * List of synthetic invoke instructions we model for this specialized instance.
*/ */
final protected ArrayList<SSAInstruction> calls = new ArrayList<SSAInstruction>(); final protected ArrayList<SSAInstruction> calls = new ArrayList<>();
/** /**
* List of all instructions * List of all instructions
*/ */
protected final ArrayList<SSAInstruction> allInstructions = new ArrayList<SSAInstruction>(); protected final ArrayList<SSAInstruction> allInstructions = new ArrayList<>();
private final SSAInstructionFactory insts = declaringClass.getClassLoader().getInstructionFactory(); private final SSAInstructionFactory insts = declaringClass.getClassLoader().getInstructionFactory();

View File

@ -115,7 +115,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
JavaTypeContext context = (JavaTypeContext) node.getContext(); JavaTypeContext context = (JavaTypeContext) node.getContext();
TypeReference tr = context.getType().getTypeReference(); TypeReference tr = context.getType().getTypeReference();
if (tr != null) { if (tr != null) {
return new NonNullSingletonIterator<NewSiteReference>(NewSiteReference.make(0, tr)); return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
} }
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
@ -131,7 +131,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
private static SSAInstruction[] makeStatements(JavaTypeContext context) { private static SSAInstruction[] makeStatements(JavaTypeContext context) {
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> statements = new ArrayList<>();
// vn1 is the string parameter // vn1 is the string parameter
int retValue = 2; int retValue = 2;
TypeReference tr = context.getType().getTypeReference(); TypeReference tr = context.getType().getTypeReference();

View File

@ -127,7 +127,7 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
JavaTypeContext context = (JavaTypeContext) node.getContext(); JavaTypeContext context = (JavaTypeContext) node.getContext();
TypeReference tr = context.getType().getTypeReference(); TypeReference tr = context.getType().getTypeReference();
if (tr != null) { if (tr != null) {
return new NonNullSingletonIterator<NewSiteReference>(NewSiteReference.make(0, tr)); return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
} }
return EmptyIterator.instance(); return EmptyIterator.instance();
} }

View File

@ -141,13 +141,13 @@ public class CloneInterpreter implements SSAContextInterpreter {
} }
assert understands(node); assert understands(node);
IClass cls = ContextUtil.getConcreteClassFromContext(node.getContext()); IClass cls = ContextUtil.getConcreteClassFromContext(node.getContext());
return new NonNullSingletonIterator<NewSiteReference>(NewSiteReference.make(NEW_PC, cls.getReference())); return new NonNullSingletonIterator<>(NewSiteReference.make(NEW_PC, cls.getReference()));
} }
@Override @Override
public Iterator<CallSiteReference> iterateCallSites(CGNode node) { public Iterator<CallSiteReference> iterateCallSites(CGNode node) {
assert understands(node); assert understands(node);
return new NonNullSingletonIterator<CallSiteReference>(ARRAYCOPY_SITE); return new NonNullSingletonIterator<>(ARRAYCOPY_SITE);
} }
/** /**
@ -156,7 +156,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
private SSAInstruction[] makeStatements(IClass klass) { private SSAInstruction[] makeStatements(IClass klass) {
assert klass != null; assert klass != null;
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> statements = new ArrayList<>();
// value number 1 is "this". // value number 1 is "this".
int nextLocal = 2; int nextLocal = 2;

View File

@ -348,7 +348,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
/** /**
* List of synthetic invoke instructions we model for this specialized instance. * List of synthetic invoke instructions we model for this specialized instance.
*/ */
final private ArrayList<SSAInstruction> calls = new ArrayList<SSAInstruction>(); final private ArrayList<SSAInstruction> calls = new ArrayList<>();
/** /**
* The method being modelled * The method being modelled

View File

@ -107,7 +107,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
} }
private static SSAInstruction[] makeStatements(JavaTypeContext context) { private static SSAInstruction[] makeStatements(JavaTypeContext context) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> statements = new ArrayList<>();
int nextLocal = 2; int nextLocal = 2;
int retValue = nextLocal++; int retValue = nextLocal++;
TypeReference tr = context.getType().getTypeReference(); TypeReference tr = context.getType().getTypeReference();

View File

@ -133,7 +133,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
GetMethodContext context = (GetMethodContext) node.getContext(); GetMethodContext context = (GetMethodContext) node.getContext();
TypeReference tr = context.getType().getTypeReference(); TypeReference tr = context.getType().getTypeReference();
if (tr != null) { if (tr != null) {
return new NonNullSingletonIterator<NewSiteReference>(NewSiteReference.make(0, tr)); return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
} }
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
@ -193,7 +193,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
GetMethodContext context, GetMethodContext context,
Map<Integer, ConstantValue> constants Map<Integer, ConstantValue> constants
) { ) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> statements = new ArrayList<>();
int nextLocal = ref.getNumberOfParameters() + 2; int nextLocal = ref.getNumberOfParameters() + 2;
IClass cls = context.getType().getType(); IClass cls = context.getType().getType();
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();

View File

@ -132,7 +132,7 @@ public class GetMethodContextSelector implements ContextSelector {
*/ */
protected static ConstantKey<String> makeConstantKey(IClassHierarchy cha,String str) { protected static ConstantKey<String> makeConstantKey(IClassHierarchy cha,String str) {
IClass cls = cha.lookupClass(TypeReference.JavaLangString); IClass cls = cha.lookupClass(TypeReference.JavaLangString);
ConstantKey<String> ck = new ConstantKey<String>(str,cls); ConstantKey<String> ck = new ConstantKey<>(str,cls);
return ck; return ck;
} }

View File

@ -210,7 +210,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
JavaTypeContext context = (JavaTypeContext) node.getContext(); JavaTypeContext context = (JavaTypeContext) node.getContext();
TypeReference tr = context.getType().getTypeReference(); TypeReference tr = context.getType().getTypeReference();
if (tr != null) { if (tr != null) {
return new NonNullSingletonIterator<NewSiteReference>(NewSiteReference.make(0, tr)); return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
} }
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
@ -282,7 +282,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
*/ */
private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection<IMethod> returnValues, JavaTypeContext context, private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection<IMethod> returnValues, JavaTypeContext context,
Map<Integer, ConstantValue> constants) { Map<Integer, ConstantValue> constants) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> statements = new ArrayList<>();
int nextLocal = ref.getNumberOfParameters() + 2; int nextLocal = ref.getNumberOfParameters() + 2;
int retValue = nextLocal++; int retValue = nextLocal++;
IClass cls = context.getType().getType(); IClass cls = context.getType().getType();
@ -329,7 +329,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
*/ */
private static SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection<IMethod> returnValues, private static SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection<IMethod> returnValues,
JavaTypeContext context, Map<Integer, ConstantValue> constants) { JavaTypeContext context, Map<Integer, ConstantValue> constants) {
ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> statements = new ArrayList<>();
int nextLocal = ref.getNumberOfParameters() + 2; int nextLocal = ref.getNumberOfParameters() + 2;
IClass cls = context.getType().getType(); IClass cls = context.getType().getType();
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();

View File

@ -209,8 +209,8 @@ public class MethodHandles {
public Iterator<FieldReference> iterateFields(CGNode node, Predicate<SSAInstruction> filter) { public Iterator<FieldReference> iterateFields(CGNode node, Predicate<SSAInstruction> filter) {
return return
new MapIterator<SSAInstruction,FieldReference>( new MapIterator<>(
new FilterIterator<SSAInstruction>(getIR(node).iterateNormalInstructions(), filter), new FilterIterator<>(getIR(node).iterateNormalInstructions(), filter),
object -> ((SSAFieldAccessInstruction)object).getDeclaredField()); object -> ((SSAFieldAccessInstruction)object).getDeclaredField());
} }
@ -269,7 +269,7 @@ public class MethodHandles {
code.addStatement(insts.LoadMetadataInstruction(code.getNextProgramCounter(), 2, TypeReference.JavaLangInvokeMethodType, ref.getDescriptor())); code.addStatement(insts.LoadMetadataInstruction(code.getNextProgramCounter(), 2, TypeReference.JavaLangInvokeMethodType, ref.getDescriptor()));
code.addStatement(insts.ReturnInstruction(code.getNextProgramCounter(), 2, false)); code.addStatement(insts.ReturnInstruction(code.getNextProgramCounter(), 2, false));
} }
irs.put(node, new SoftReference<IR>(m.makeIR(node.getContext(), SSAOptions.defaultOptions()))); irs.put(node, new SoftReference<>(m.makeIR(node.getContext(), SSAOptions.defaultOptions())));
} }
return irs.get(node).get(); return irs.get(node).get();

View File

@ -187,7 +187,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
} }
}; };
IKilldallFramework<BasicBlock, MachineState> problem = new BasicFramework<BasicBlock, MachineState>(cfg, xferFunctions); IKilldallFramework<BasicBlock, MachineState> problem = new BasicFramework<>(cfg, xferFunctions);
solver = new DataflowSolver<BasicBlock, MachineState>(problem) { solver = new DataflowSolver<BasicBlock, MachineState>(problem) {
private MachineState entry; private MachineState entry;

View File

@ -52,25 +52,25 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
/** /**
* An object to track nodes in this cfg * An object to track nodes in this cfg
*/ */
final private DelegatingNumberedNodeManager<T> nodeManager = new DelegatingNumberedNodeManager<T>(); final private DelegatingNumberedNodeManager<T> nodeManager = new DelegatingNumberedNodeManager<>();
/** /**
* An object to track most normal edges in this cfg * An object to track most normal edges in this cfg
*/ */
final private SparseNumberedEdgeManager<T> normalEdgeManager = new SparseNumberedEdgeManager<T>(nodeManager, 2, final private SparseNumberedEdgeManager<T> normalEdgeManager = new SparseNumberedEdgeManager<>(nodeManager, 2,
BasicNaturalRelation.SIMPLE); BasicNaturalRelation.SIMPLE);
/** /**
* An object to track not-to-exit exceptional edges in this cfg * An object to track not-to-exit exceptional edges in this cfg
*/ */
final private SparseNumberedEdgeManager<T> exceptionalEdgeManager = new SparseNumberedEdgeManager<T>(nodeManager, 0, final private SparseNumberedEdgeManager<T> exceptionalEdgeManager = new SparseNumberedEdgeManager<>(nodeManager, 0,
BasicNaturalRelation.SIMPLE); BasicNaturalRelation.SIMPLE);
/** /**
* An object to track not-to-exit exceptional edges in this cfg, indexed by block number. exceptionalEdges[i] is a list of block * An object to track not-to-exit exceptional edges in this cfg, indexed by block number. exceptionalEdges[i] is a list of block
* numbers that are non-exit exceptional successors of block i, in order of increasing "catch scope". * numbers that are non-exit exceptional successors of block i, in order of increasing "catch scope".
*/ */
final private SimpleVector<SimpleIntVector> exceptionalSuccessors = new SimpleVector<SimpleIntVector>(); final private SimpleVector<SimpleIntVector> exceptionalSuccessors = new SimpleVector<>();
/** /**
* Which basic blocks have a normal edge to exit()? * Which basic blocks have a normal edge to exit()?
@ -305,9 +305,9 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
public Iterator<T> getSuccNodes(T N) { public Iterator<T> getSuccNodes(T N) {
int number = getNumber(N); int number = getNumber(N);
if (normalToExit.get(number) && exceptionalToExit.get(number)) { if (normalToExit.get(number) && exceptionalToExit.get(number)) {
return new CompoundIterator<T>(iterateNormalSuccessorsWithoutExit(number), iterateExceptionalSuccessors(number)); return new CompoundIterator<>(iterateNormalSuccessorsWithoutExit(number), iterateExceptionalSuccessors(number));
} else { } else {
return new CompoundIterator<T>(iterateNormalSuccessors(number), iterateExceptionalSuccessors(number)); return new CompoundIterator<>(iterateNormalSuccessors(number), iterateExceptionalSuccessors(number));
} }
} }
@ -317,7 +317,7 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
*/ */
private Iterator<T> iterateExceptionalSuccessors(int number) { private Iterator<T> iterateExceptionalSuccessors(int number) {
if (exceptionalEdgeManager.hasAnySuccessor(number)) { if (exceptionalEdgeManager.hasAnySuccessor(number)) {
List<T> result = new ArrayList<T>(); List<T> result = new ArrayList<>();
SimpleIntVector v = exceptionalSuccessors.get(number); SimpleIntVector v = exceptionalSuccessors.get(number);
for (int i = 0; i <= v.getMaxIndex(); i++) { for (int i = 0; i <= v.getMaxIndex(); i++) {
result.add(getNode(v.get(i))); result.add(getNode(v.get(i)));
@ -328,7 +328,7 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
return result.iterator(); return result.iterator();
} else { } else {
if (exceptionalToExit.get(number)) { if (exceptionalToExit.get(number)) {
return new NonNullSingletonIterator<T>(exit()); return new NonNullSingletonIterator<>(exit());
} else { } else {
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
@ -365,7 +365,7 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
private Iterator<T> iterateNormalSuccessors(int number) { private Iterator<T> iterateNormalSuccessors(int number) {
if (fallThru.get(number)) { if (fallThru.get(number)) {
if (normalToExit.get(number)) { if (normalToExit.get(number)) {
return new IteratorPlusTwo<T>(normalEdgeManager.getSuccNodes(number), getNode(number + 1), exit()); return new IteratorPlusTwo<>(normalEdgeManager.getSuccNodes(number), getNode(number + 1), exit());
} else { } else {
return IteratorPlusOne.make(normalEdgeManager.getSuccNodes(number), getNode(number + 1)); return IteratorPlusOne.make(normalEdgeManager.getSuccNodes(number), getNode(number + 1));
} }
@ -591,7 +591,7 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
if (b == null) { if (b == null) {
throw new IllegalArgumentException("b is null"); throw new IllegalArgumentException("b is null");
} }
List<T> result = new ArrayList<T>(); List<T> result = new ArrayList<>();
for (Iterator<T> it = iterateExceptionalSuccessors(b.getNumber()); it.hasNext();) { for (Iterator<T> it = iterateExceptionalSuccessors(b.getNumber()); it.hasNext();) {
result.add(it.next()); result.add(it.next());
} }
@ -614,7 +614,7 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
*/ */
@Override @Override
public Iterator<T> iterateNodes(IntSet s) { public Iterator<T> iterateNodes(IntSet s) {
return new NumberedNodeIterator<T>(s, this); return new NumberedNodeIterator<>(s, this);
} }
@Override @Override

View File

@ -393,7 +393,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
public void addPhi(SSAPhiInstruction phiInstruction) { public void addPhi(SSAPhiInstruction phiInstruction) {
if (phis == null) { if (phis == null) {
phis = new ArrayList<SSAPhiInstruction>(1); phis = new ArrayList<>(1);
} }
phis.add(phiInstruction); phis.add(phiInstruction);
} }
@ -406,7 +406,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
public void addPi(SSAPiInstruction piInstruction) { public void addPi(SSAPiInstruction piInstruction) {
if (pis == null) { if (pis == null) {
pis = new ArrayList<SSAPiInstruction>(1); pis = new ArrayList<>(1);
} }
pis.add(piInstruction); pis.add(piInstruction);
} }
@ -614,7 +614,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
@Override @Override
public Iterator<SSAInstruction> iterator() { public Iterator<SSAInstruction> iterator() {
return new ArrayIterator<SSAInstruction>(getInstructions(), getFirstInstructionIndex(), getLastInstructionIndex()); return new ArrayIterator<>(getInstructions(), getFirstInstructionIndex(), getLastInstructionIndex());
} }
} }

View File

@ -360,7 +360,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
IClass caughtClass = cha.lookupClass(caughtException); IClass caughtClass = cha.lookupClass(caughtException);
// the set "caught" should be the set of exceptions that MUST // the set "caught" should be the set of exceptions that MUST
// have been caught by the handlers in scope // have been caught by the handlers in scope
ArrayList<TypeReference> caught = new ArrayList<TypeReference>(exceptionTypes.size()); ArrayList<TypeReference> caught = new ArrayList<>(exceptionTypes.size());
// check if we should add an edge to the catch block. // check if we should add an edge to the catch block.
for (TypeReference t : exceptionTypes) { for (TypeReference t : exceptionTypes) {
if (t != null) { if (t != null) {
@ -493,7 +493,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
@Override @Override
public Iterator<IInstruction> iterator() { public Iterator<IInstruction> iterator() {
return new ArrayIterator<IInstruction>(getInstructions(), getFirstInstructionIndex(), getLastInstructionIndex()); return new ArrayIterator<>(getInstructions(), getFirstInstructionIndex(), getLastInstructionIndex());
} }
} }

View File

@ -60,7 +60,7 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
private Map<T, Set<T>> buildControlDependence(boolean wantEdgeLabels) { private Map<T, Set<T>> buildControlDependence(boolean wantEdgeLabels) {
Map<T, Set<T>> controlDependence = HashMapFactory.make(cfg.getNumberOfNodes()); Map<T, Set<T>> controlDependence = HashMapFactory.make(cfg.getNumberOfNodes());
DominanceFrontiers<T> RDF = new DominanceFrontiers<T>(GraphInverter.invert(cfg), cfg.exit()); DominanceFrontiers<T> RDF = new DominanceFrontiers<>(GraphInverter.invert(cfg), cfg.exit());
if (wantEdgeLabels) { if (wantEdgeLabels) {
edgeLabels = HashMapFactory.make(); edgeLabels = HashMapFactory.make();

View File

@ -76,7 +76,7 @@ public final class AnalysisUtil {
* @return a Set of all blocks that contain an invoke * @return a Set of all blocks that contain an invoke
*/ */
public static Set<IExplodedBasicBlock> extractInvokeBlocks(final ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> cfg) { public static Set<IExplodedBasicBlock> extractInvokeBlocks(final ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> cfg) {
final HashSet<IExplodedBasicBlock> invokeBlocks = new HashSet<IExplodedBasicBlock>(); final HashSet<IExplodedBasicBlock> invokeBlocks = new HashSet<>();
for (final IExplodedBasicBlock block : cfg) { for (final IExplodedBasicBlock block : cfg) {
if (block.getInstruction() instanceof SSAAbstractInvokeInstruction) { if (block.getInstruction() instanceof SSAAbstractInvokeInstruction) {

View File

@ -78,7 +78,7 @@ public final class InterprocNullPointerAnalysis {
private InterprocNullPointerAnalysis(final TypeReference[] ignoredExceptions, final MethodState defaultMethodState, boolean optHasExceptions) { private InterprocNullPointerAnalysis(final TypeReference[] ignoredExceptions, final MethodState defaultMethodState, boolean optHasExceptions) {
this.ignoredExceptions = ignoredExceptions; this.ignoredExceptions = ignoredExceptions;
this.defaultMethodState = defaultMethodState; this.defaultMethodState = defaultMethodState;
this.states = new HashMap<CGNode, IntraprocAnalysisState>(); this.states = new HashMap<>();
this.optHasExceptions = optHasExceptions; this.optHasExceptions = optHasExceptions;
} }
@ -163,7 +163,7 @@ public final class InterprocNullPointerAnalysis {
private Map<CGNode, Map<SSAAbstractInvokeInstruction, ParameterState>> analysisFirstPass(final CGNode startNode, private Map<CGNode, Map<SSAAbstractInvokeInstruction, ParameterState>> analysisFirstPass(final CGNode startNode,
final ParameterState paramState, final IProgressMonitor progress) throws UnsoundGraphException, CancelException { final ParameterState paramState, final IProgressMonitor progress) throws UnsoundGraphException, CancelException {
final Map<CGNode, Map<SSAAbstractInvokeInstruction, ParameterState>> result = final Map<CGNode, Map<SSAAbstractInvokeInstruction, ParameterState>> result =
new HashMap<CGNode, Map<SSAAbstractInvokeInstruction, ParameterState>>(); new HashMap<>();
final IR ir = startNode.getIR(); final IR ir = startNode.getIR();
if (!startNode.getMethod().isStatic()) { if (!startNode.getMethod().isStatic()) {
@ -195,7 +195,7 @@ public final class InterprocNullPointerAnalysis {
final Set<CGNode> targets = cgFiltered.getPossibleTargets(startNode, invokeInstruction.getCallSite()); final Set<CGNode> targets = cgFiltered.getPossibleTargets(startNode, invokeInstruction.getCallSite());
for (final CGNode target : targets) { for (final CGNode target : targets) {
final HashMap<SSAAbstractInvokeInstruction, ParameterState> stateMap = new HashMap<SSAAbstractInvokeInstruction, ParameterState>(); final HashMap<SSAAbstractInvokeInstruction, ParameterState> stateMap = new HashMap<>();
stateMap.put(invokeInstruction, paramStateOfInvokeBlock); stateMap.put(invokeInstruction, paramStateOfInvokeBlock);
result.put(target, stateMap); result.put(target, stateMap);
} }
@ -218,7 +218,7 @@ public final class InterprocNullPointerAnalysis {
* Reduces the Callgraph to only the nodes that we need * Reduces the Callgraph to only the nodes that we need
*/ */
private static CallGraph computeFilteredCallgraph(final CallGraph cg) { private static CallGraph computeFilteredCallgraph(final CallGraph cg) {
final HashSet<Atom> filterSet = new HashSet<Atom>(); final HashSet<Atom> filterSet = new HashSet<>();
final Atom worldClinit = Atom.findOrCreateAsciiAtom("fakeWorldClinit"); final Atom worldClinit = Atom.findOrCreateAsciiAtom("fakeWorldClinit");
filterSet.add(worldClinit); filterSet.add(worldClinit);
filterSet.add(MethodReference.initAtom); filterSet.add(MethodReference.initAtom);
@ -254,14 +254,14 @@ public final class InterprocNullPointerAnalysis {
* @return the filtered CallGraph * @return the filtered CallGraph
*/ */
private CallGraph filter(final CallGraph fullCG) { private CallGraph filter(final CallGraph fullCG) {
final HashSet<CGNode> nodes = new HashSet<CGNode>(); final HashSet<CGNode> nodes = new HashSet<>();
// fill all nodes into a set // fill all nodes into a set
for (final CGNode n : fullCG) { for (final CGNode n : fullCG) {
nodes.add(n); nodes.add(n);
} }
final HashSet<CGNode> nodesToRemove = new HashSet<CGNode>(); final HashSet<CGNode> nodesToRemove = new HashSet<>();
// collect all nodes that we do not need // collect all nodes that we do not need
for (final CGNode node : nodes) { for (final CGNode node : nodes) {
for (final Atom method : filter) { for (final Atom method : filter) {
@ -272,7 +272,7 @@ public final class InterprocNullPointerAnalysis {
} }
nodes.removeAll(nodesToRemove); nodes.removeAll(nodesToRemove);
final HashSet<CGNode> partialRoots = new HashSet<CGNode>(); final HashSet<CGNode> partialRoots = new HashSet<>();
partialRoots.add(fullCG.getFakeRootNode()); partialRoots.add(fullCG.getFakeRootNode());
// delete the nodes // delete the nodes

View File

@ -39,10 +39,10 @@ final class IntraprocAnalysisState implements ExceptionPruningAnalysis<SSAInstru
private final ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> cfg; private final ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> cfg;
private final HashMap<IExplodedBasicBlock, NullPointerState> statesOfSsaVars = private final HashMap<IExplodedBasicBlock, NullPointerState> statesOfSsaVars =
new HashMap<IExplodedBasicBlock, NullPointerState>(); new HashMap<>();
private final HashMap<IExplodedBasicBlock, Object[]> valuesOfSsaVars = new HashMap<IExplodedBasicBlock, Object[]>(); private final HashMap<IExplodedBasicBlock, Object[]> valuesOfSsaVars = new HashMap<>();
private final HashMap<IExplodedBasicBlock, int[]> numbersOfSsaVarsThatAreParemerters = private final HashMap<IExplodedBasicBlock, int[]> numbersOfSsaVarsThatAreParemerters =
new HashMap<IExplodedBasicBlock, int[]>(); new HashMap<>();
private final boolean noAnalysisPossible; private final boolean noAnalysisPossible;
private final int deletedEdges; private final int deletedEdges;
private boolean throwsException = true; private boolean throwsException = true;

View File

@ -54,7 +54,7 @@ public class ExplodedCFGNullPointerAnalysis implements ExceptionPruningAnalysis<
public int compute(IProgressMonitor progress) throws UnsoundGraphException, CancelException { public int compute(IProgressMonitor progress) throws UnsoundGraphException, CancelException {
ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> orig = ExplodedControlFlowGraph.make(ir); ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> orig = ExplodedControlFlowGraph.make(ir);
intra = new IntraprocNullPointerAnalysis<IExplodedBasicBlock>(ir, orig, ignoredExceptions, initialState, mState); intra = new IntraprocNullPointerAnalysis<>(ir, orig, ignoredExceptions, initialState, mState);
intra.run(progress); intra.run(progress);
return intra.getNumberOfDeletedEdges(); return intra.getNumberOfDeletedEdges();

View File

@ -84,7 +84,7 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
maxVarNum = ir.getSymbolTable().getMaxValueNumber(); maxVarNum = ir.getSymbolTable().getMaxValueNumber();
} }
this.ignoreExceptions = new HashSet<TypeReference>(); this.ignoreExceptions = new HashSet<>();
if (ignoreExceptions != null) { if (ignoreExceptions != null) {
for (TypeReference tRef : ignoreExceptions) { for (TypeReference tRef : ignoreExceptions) {
@ -98,7 +98,7 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
private static <T extends ISSABasicBlock> List<T> private static <T extends ISSABasicBlock> List<T>
searchNodesWithPathToCatchAll(ControlFlowGraph<SSAInstruction, T> cfg) { searchNodesWithPathToCatchAll(ControlFlowGraph<SSAInstruction, T> cfg) {
final List<T> nodes = new LinkedList<T>(); final List<T> nodes = new LinkedList<>();
for (final T exp : cfg) { for (final T exp : cfg) {
final List<T> excSucc = cfg.getExceptionalSuccessors(exp); final List<T> excSucc = cfg.getExceptionalSuccessors(exp);
@ -134,9 +134,9 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
pruned = cfg; pruned = cfg;
} else { } else {
final List<T> catched = searchNodesWithPathToCatchAll(cfg); final List<T> catched = searchNodesWithPathToCatchAll(cfg);
final NullPointerFrameWork<T> problem = new NullPointerFrameWork<T>(cfg, ir); final NullPointerFrameWork<T> problem = new NullPointerFrameWork<>(cfg, ir);
solver = new NullPointerSolver<T>(problem, maxVarNum, cfg.entry(), ir, initialState); solver = new NullPointerSolver<>(problem, maxVarNum, cfg.entry(), ir, initialState);
solver.solve(progress); solver.solve(progress);
@ -151,7 +151,7 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
for (T node : deleted) { for (T node : deleted) {
deletedEdges += deleted.getSuccNodeCount(node); deletedEdges += deleted.getSuccNodeCount(node);
} }
final NegativeGraphFilter<T> filter = new NegativeGraphFilter<T>(deleted); final NegativeGraphFilter<T> filter = new NegativeGraphFilter<>(deleted);
final PrunedCFG<SSAInstruction, T> newCfg = PrunedCFG.make(cfg, filter); final PrunedCFG<SSAInstruction, T> newCfg = PrunedCFG.make(cfg, filter);
@ -201,7 +201,7 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
private final Graph<T> deleted; private final Graph<T> deleted;
private NegativeCFGBuilderVisitor() { private NegativeCFGBuilderVisitor() {
this.deleted = new SparseNumberedGraph<T>(2); this.deleted = new SparseNumberedGraph<>(2);
for (T bb : cfg) { for (T bb : cfg) {
deleted.addNode(bb); deleted.addNode(bb);
} }
@ -244,7 +244,7 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
return mState != null && !mState.throwsException((SSAAbstractInvokeInstruction) instr); return mState != null && !mState.throwsException((SSAAbstractInvokeInstruction) instr);
} else { } else {
Collection<TypeReference> exc = instr.getExceptionTypes(); Collection<TypeReference> exc = instr.getExceptionTypes();
Set<TypeReference> myExcs = new HashSet<TypeReference>(exc); Set<TypeReference> myExcs = new HashSet<>(exc);
myExcs.removeAll(ignoreExceptions); myExcs.removeAll(ignoreExceptions);
return myExcs.size() == 1 && myExcs.contains(TypeReference.JavaLangNullPointerException); return myExcs.size() == 1 && myExcs.contains(TypeReference.JavaLangNullPointerException);
@ -259,7 +259,7 @@ public class IntraprocNullPointerAnalysis<T extends ISSABasicBlock> {
return mState != null && !mState.throwsException((SSAAbstractInvokeInstruction) instr); return mState != null && !mState.throwsException((SSAAbstractInvokeInstruction) instr);
} else { } else {
Collection<TypeReference> exc = instr.getExceptionTypes(); Collection<TypeReference> exc = instr.getExceptionTypes();
Set<TypeReference> myExcs = new HashSet<TypeReference>(exc); Set<TypeReference> myExcs = new HashSet<>(exc);
myExcs.removeAll(ignoreExceptions); myExcs.removeAll(ignoreExceptions);
return myExcs.isEmpty(); return myExcs.isEmpty();

View File

@ -38,7 +38,7 @@ public class MutableCFG<X, T extends IBasicBlock<X>> extends SparseNumberedGraph
} }
public static <I, T extends IBasicBlock<I>> MutableCFG<I, T> copyFrom(ControlFlowGraph<I, T> cfg) { public static <I, T extends IBasicBlock<I>> MutableCFG<I, T> copyFrom(ControlFlowGraph<I, T> cfg) {
MutableCFG<I, T> mutable = new MutableCFG<I, T>(cfg); MutableCFG<I, T> mutable = new MutableCFG<>(cfg);
for (T node : cfg) { for (T node : cfg) {
mutable.addNode(node); mutable.addNode(node);
@ -108,7 +108,7 @@ public class MutableCFG<X, T extends IBasicBlock<X>> extends SparseNumberedGraph
public List<T> getExceptionalSuccessors(T b) { public List<T> getExceptionalSuccessors(T b) {
final List<T> origSucc = orig.getExceptionalSuccessors(b); final List<T> origSucc = orig.getExceptionalSuccessors(b);
final IntSet allSuccs = this.getSuccNodeNumbers(b); final IntSet allSuccs = this.getSuccNodeNumbers(b);
final List<T> thisSuccs = new LinkedList<T>(); final List<T> thisSuccs = new LinkedList<>();
for (final T block : origSucc) { for (final T block : origSucc) {
if (allSuccs.contains(block.getNumber())) { if (allSuccs.contains(block.getNumber())) {
@ -122,7 +122,7 @@ public class MutableCFG<X, T extends IBasicBlock<X>> extends SparseNumberedGraph
@Override @Override
public Collection<T> getNormalSuccessors(T b) { public Collection<T> getNormalSuccessors(T b) {
final List<T> excSuccs = getExceptionalSuccessors(b); final List<T> excSuccs = getExceptionalSuccessors(b);
final List<T> thisSuccs = new LinkedList<T>(); final List<T> thisSuccs = new LinkedList<>();
final Iterator<T> succs = getSuccNodes(b); final Iterator<T> succs = getSuccNodes(b);
while (succs.hasNext()) { while (succs.hasNext()) {
@ -139,7 +139,7 @@ public class MutableCFG<X, T extends IBasicBlock<X>> extends SparseNumberedGraph
public Collection<T> getExceptionalPredecessors(T b) { public Collection<T> getExceptionalPredecessors(T b) {
final Collection<T> origPreds = orig.getExceptionalPredecessors(b); final Collection<T> origPreds = orig.getExceptionalPredecessors(b);
final IntSet allPreds = this.getPredNodeNumbers(b); final IntSet allPreds = this.getPredNodeNumbers(b);
final List<T> thisPreds = new LinkedList<T>(); final List<T> thisPreds = new LinkedList<>();
for (final T block : origPreds) { for (final T block : origPreds) {
if (allPreds.contains(block.getNumber())) { if (allPreds.contains(block.getNumber())) {
@ -153,7 +153,7 @@ public class MutableCFG<X, T extends IBasicBlock<X>> extends SparseNumberedGraph
@Override @Override
public Collection<T> getNormalPredecessors(T b) { public Collection<T> getNormalPredecessors(T b) {
final Collection<T> excPreds = getExceptionalPredecessors(b); final Collection<T> excPreds = getExceptionalPredecessors(b);
final List<T> thisPreds = new LinkedList<T>(); final List<T> thisPreds = new LinkedList<>();
final Iterator<T> preds = getPredNodes(b); final Iterator<T> preds = getPredNodes(b);
while (preds.hasNext()) { while (preds.hasNext()) {

View File

@ -52,7 +52,7 @@ public class NullPointerFrameWork<T extends ISSABasicBlock> implements IKilldall
this.flow = cfg; this.flow = cfg;
} }
this.transferFunct = new NullPointerTransferFunctionProvider<T>(cfg, ir); this.transferFunct = new NullPointerTransferFunctionProvider<>(cfg, ir);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -36,7 +36,7 @@ public class ParameterState extends AbstractVariable<ParameterState> {
public static final int NO_THIS_PTR = -1; public static final int NO_THIS_PTR = -1;
// maps the parmeter's varNum --> State // maps the parmeter's varNum --> State
private final HashMap<Integer, State> params = new HashMap<Integer, State>(); private final HashMap<Integer, State> params = new HashMap<>();
public static ParameterState createDefault(IMethod m) { public static ParameterState createDefault(IMethod m) {
ParameterState p = new ParameterState(); ParameterState p = new ParameterState();

View File

@ -45,7 +45,7 @@ public class SSACFGNullPointerAnalysis implements ExceptionPruningAnalysis<SSAIn
public int compute(IProgressMonitor progress) throws UnsoundGraphException, CancelException { public int compute(IProgressMonitor progress) throws UnsoundGraphException, CancelException {
ControlFlowGraph<SSAInstruction, ISSABasicBlock> orig = ir.getControlFlowGraph(); ControlFlowGraph<SSAInstruction, ISSABasicBlock> orig = ir.getControlFlowGraph();
intra = new IntraprocNullPointerAnalysis<ISSABasicBlock>(ir, orig, ignoredExceptions, initialState, mState); intra = new IntraprocNullPointerAnalysis<>(ir, orig, ignoredExceptions, initialState, mState);
intra.run(progress); intra.run(progress);
return intra.getNumberOfDeletedEdges(); return intra.getNumberOfDeletedEdges();

View File

@ -77,7 +77,7 @@ public abstract class AbstractURLModule implements Module, ModuleEntry {
@Override @Override
public Iterator<ModuleEntry> getEntries() { public Iterator<ModuleEntry> getEntries() {
return new NonNullSingletonIterator<ModuleEntry>(this); return new NonNullSingletonIterator<>(this);
} }
@Override @Override

View File

@ -306,7 +306,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
*/ */
@Override @Override
public Collection<IField> getAllFields() { public Collection<IField> getAllFields() {
Collection<IField> result = new LinkedList<IField>(); Collection<IField> result = new LinkedList<>();
result.addAll(getAllInstanceFields()); result.addAll(getAllInstanceFields());
result.addAll(getAllStaticFields()); result.addAll(getAllStaticFields());
return result; return result;
@ -359,7 +359,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
*/ */
@Override @Override
public Collection<IField> getAllInstanceFields() { public Collection<IField> getAllInstanceFields() {
Collection<IField> result = new LinkedList<IField>(getDeclaredInstanceFields()); Collection<IField> result = new LinkedList<>(getDeclaredInstanceFields());
IClass s = getSuperclass(); IClass s = getSuperclass();
while (s != null) { while (s != null) {
result.addAll(s.getDeclaredInstanceFields()); result.addAll(s.getDeclaredInstanceFields());
@ -373,7 +373,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
*/ */
@Override @Override
public Collection<IField> getAllStaticFields() { public Collection<IField> getAllStaticFields() {
Collection<IField> result = new LinkedList<IField>(getDeclaredStaticFields()); Collection<IField> result = new LinkedList<>(getDeclaredStaticFields());
IClass s = getSuperclass(); IClass s = getSuperclass();
while (s != null) { while (s != null) {
result.addAll(s.getDeclaredStaticFields()); result.addAll(s.getDeclaredStaticFields());
@ -387,7 +387,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
*/ */
@Override @Override
public Collection<IMethod> getAllMethods() { public Collection<IMethod> getAllMethods() {
Collection<IMethod> result = new LinkedList<IMethod>(); Collection<IMethod> result = new LinkedList<>();
Iterator<IMethod> declaredMethods = getDeclaredMethods().iterator(); Iterator<IMethod> declaredMethods = getDeclaredMethods().iterator();
while (declaredMethods.hasNext()) { while (declaredMethods.hasNext()) {
result.add(declaredMethods.next()); result.add(declaredMethods.next());
@ -459,7 +459,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
IMethod inherit = superclass.getMethod(selector); IMethod inherit = superclass.getMethod(selector);
if (inherit != null) { if (inherit != null) {
if (inheritCache == null) { if (inheritCache == null) {
inheritCache = new BimodalMap<Selector, IMethod>(5); inheritCache = new BimodalMap<>(5);
} }
inheritCache.put(selector, inherit); inheritCache.put(selector, inherit);
return inherit; return inherit;
@ -473,7 +473,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
for(IMethod m : iface.getDeclaredMethods()) { for(IMethod m : iface.getDeclaredMethods()) {
if (!m.isAbstract() && m.getSelector().equals(selector)) { if (!m.isAbstract() && m.getSelector().equals(selector)) {
if (inheritCache == null) { if (inheritCache == null) {
inheritCache = new BimodalMap<Selector, IMethod>(5); inheritCache = new BimodalMap<>(5);
} }
inheritCache.put(selector, m); inheritCache.put(selector, m);
@ -484,7 +484,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
// no method found // no method found
if (inheritCache == null) { if (inheritCache == null) {
inheritCache = new BimodalMap<Selector, IMethod>(5); inheritCache = new BimodalMap<>(5);
} }
inheritCache.put(selector, null); inheritCache.put(selector, null);
return null; return null;
@ -536,7 +536,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
* classes can not be loaded * classes can not be loaded
*/ */
private Collection<IClass> array2IClassSet(ImmutableByteArray[] interfaces) { private Collection<IClass> array2IClassSet(ImmutableByteArray[] interfaces) {
ArrayList<IClass> result = new ArrayList<IClass>(interfaces.length); ArrayList<IClass> result = new ArrayList<>(interfaces.length);
for (ImmutableByteArray name : interfaces) { for (ImmutableByteArray name : interfaces) {
IClass klass = null; IClass klass = null;
klass = loader.lookupClass(TypeName.findOrCreate(name)); klass = loader.lookupClass(TypeName.findOrCreate(name));
@ -551,7 +551,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
protected List<IField> findDeclaredField(Atom name) { protected List<IField> findDeclaredField(Atom name) {
List<IField> result = new ArrayList<IField>(1); List<IField> result = new ArrayList<>(1);
if (instanceFields != null) { if (instanceFields != null) {
for (IField instanceField : instanceFields) { for (IField instanceField : instanceFields) {
@ -599,7 +599,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
if (methods.length > 5) { if (methods.length > 5) {
tmpMethodMap = HashMapFactory.make(methods.length); tmpMethodMap = HashMapFactory.make(methods.length);
} else { } else {
tmpMethodMap= new SmallMap<Selector, IMethod>(); tmpMethodMap= new SmallMap<>();
} }
for (IMethod m : methods) { for (IMethod m : methods) {
tmpMethodMap.put(m.getReference().getSelector(), m); tmpMethodMap.put(m.getReference().getSelector(), m);

View File

@ -206,7 +206,7 @@ public class CodeScanner {
private static List<FieldReference> getFieldsReadFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException { private static List<FieldReference> getFieldsReadFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException {
// TODO move the logic here from ShrikeCTMethodWrapper // TODO move the logic here from ShrikeCTMethodWrapper
LinkedList<FieldReference> result = new LinkedList<FieldReference>(); LinkedList<FieldReference> result = new LinkedList<>();
for (Iterator<FieldReference> it = M.getFieldsRead(); it.hasNext();) { for (Iterator<FieldReference> it = M.getFieldsRead(); it.hasNext();) {
result.add(it.next()); result.add(it.next());
} }
@ -215,7 +215,7 @@ public class CodeScanner {
private static List<FieldReference> getFieldsWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException { private static List<FieldReference> getFieldsWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException {
// TODO move the logic here from ShrikeCTMethodWrapper // TODO move the logic here from ShrikeCTMethodWrapper
LinkedList<FieldReference> result = new LinkedList<FieldReference>(); LinkedList<FieldReference> result = new LinkedList<>();
for (Iterator<FieldReference> it = M.getFieldsWritten(); it.hasNext();) { for (Iterator<FieldReference> it = M.getFieldsWritten(); it.hasNext();) {
result.add(it.next()); result.add(it.next());
} }
@ -224,7 +224,7 @@ public class CodeScanner {
private static List<TypeReference> getArraysWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException { private static List<TypeReference> getArraysWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException {
// TODO move the logic here from ShrikeCTMethodWrapper // TODO move the logic here from ShrikeCTMethodWrapper
List<TypeReference> result = new LinkedList<TypeReference>(); List<TypeReference> result = new LinkedList<>();
for (Iterator<TypeReference> it = M.getArraysWritten(); it.hasNext();) { for (Iterator<TypeReference> it = M.getArraysWritten(); it.hasNext();) {
result.add(it.next()); result.add(it.next());
} }
@ -291,7 +291,7 @@ public class CodeScanner {
* @return List of InvokeInstruction * @return List of InvokeInstruction
*/ */
private static List<CallSiteReference> getCallSites(SSAInstruction[] statements) { private static List<CallSiteReference> getCallSites(SSAInstruction[] statements) {
final List<CallSiteReference> result = new LinkedList<CallSiteReference>(); final List<CallSiteReference> result = new LinkedList<>();
Visitor v = new Visitor() { Visitor v = new Visitor() {
@Override @Override
public void visitInvoke(SSAInvokeInstruction instruction) { public void visitInvoke(SSAInvokeInstruction instruction) {
@ -311,7 +311,7 @@ public class CodeScanner {
* @return List of InvokeInstruction * @return List of InvokeInstruction
*/ */
private static List<NewSiteReference> getNewSites(SSAInstruction[] statements) { private static List<NewSiteReference> getNewSites(SSAInstruction[] statements) {
final List<NewSiteReference> result = new LinkedList<NewSiteReference>(); final List<NewSiteReference> result = new LinkedList<>();
Visitor v = new Visitor() { Visitor v = new Visitor() {
@Override @Override
public void visitNew(SSANewInstruction instruction) { public void visitNew(SSANewInstruction instruction) {
@ -335,7 +335,7 @@ public class CodeScanner {
if (statements == null) { if (statements == null) {
throw new IllegalArgumentException("statements == null"); throw new IllegalArgumentException("statements == null");
} }
final List<FieldReference> result = new LinkedList<FieldReference>(); final List<FieldReference> result = new LinkedList<>();
Visitor v = new Visitor() { Visitor v = new Visitor() {
@Override @Override
public void visitGet(SSAGetInstruction instruction) { public void visitGet(SSAGetInstruction instruction) {
@ -359,7 +359,7 @@ public class CodeScanner {
if (statements == null) { if (statements == null) {
throw new IllegalArgumentException("statements == null"); throw new IllegalArgumentException("statements == null");
} }
final List<FieldReference> result = new LinkedList<FieldReference>(); final List<FieldReference> result = new LinkedList<>();
Visitor v = new Visitor() { Visitor v = new Visitor() {
@Override @Override
public void visitPut(SSAPutInstruction instruction) { public void visitPut(SSAPutInstruction instruction) {
@ -383,7 +383,7 @@ public class CodeScanner {
if (statements == null) { if (statements == null) {
throw new IllegalArgumentException("statements == null"); throw new IllegalArgumentException("statements == null");
} }
final List<TypeReference> result = new LinkedList<TypeReference>(); final List<TypeReference> result = new LinkedList<>();
Visitor v = new Visitor() { Visitor v = new Visitor() {
@Override @Override

View File

@ -39,7 +39,7 @@ public class CompoundModule implements ModuleEntry, Module, SourceModule {
@Override @Override
public Iterator<ModuleEntry> getEntries() { public Iterator<ModuleEntry> getEntries() {
return new NonNullSingletonIterator<ModuleEntry>(this); return new NonNullSingletonIterator<>(this);
} }
@Override @Override
@ -103,7 +103,7 @@ public class CompoundModule implements ModuleEntry, Module, SourceModule {
} }
public class Reader extends java.io.Reader { public class Reader extends java.io.Reader {
private final List<Pair<Integer,URL>> locations = new ArrayList<Pair<Integer,URL>>(); private final List<Pair<Integer,URL>> locations = new ArrayList<>();
private int line = 0; private int line = 0;
private int index = 0; private int index = 0;
private LineNumberReader currentReader; private LineNumberReader currentReader;

View File

@ -49,7 +49,7 @@ public abstract class FileModule implements Module, ModuleEntry {
*/ */
@Override @Override
public Iterator<ModuleEntry> getEntries() { public Iterator<ModuleEntry> getEntries() {
return new NonNullSingletonIterator<ModuleEntry>(this); return new NonNullSingletonIterator<>(this);
} }
@Override @Override

View File

@ -561,7 +561,7 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons
if (target == null) { if (target == null) {
throw new IllegalArgumentException("target is null"); throw new IllegalArgumentException("target is null");
} }
ArrayList<TypeReference> set = new ArrayList<TypeReference>(cha.getJavaLangRuntimeExceptionTypes()); ArrayList<TypeReference> set = new ArrayList<>(cha.getJavaLangRuntimeExceptionTypes());
set.addAll(cha.getJavaLangErrorTypes()); set.addAll(cha.getJavaLangErrorTypes());
IClass klass = cha.lookupClass(target.getDeclaringClass()); IClass klass = cha.lookupClass(target.getDeclaringClass());

View File

@ -145,7 +145,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
} }
if (result == null) { if (result == null) {
result = computeBCInfo(); result = computeBCInfo();
bcInfo = new SoftReference<BytecodeInfo>(result); bcInfo = new SoftReference<>(result);
} }
return result; return result;
} }

View File

@ -80,8 +80,8 @@ public final class ShrikeClass extends JVMClass<IClassLoader> {
private void computeFields() throws InvalidClassFileException { private void computeFields() throws InvalidClassFileException {
ClassReader cr = reader.get(); ClassReader cr = reader.get();
int fieldCount = cr.getFieldCount(); int fieldCount = cr.getFieldCount();
List<FieldImpl> instanceList = new ArrayList<FieldImpl>(fieldCount); List<FieldImpl> instanceList = new ArrayList<>(fieldCount);
List<FieldImpl> staticList = new ArrayList<FieldImpl>(fieldCount); List<FieldImpl> staticList = new ArrayList<>(fieldCount);
try { try {
for (int i = 0; i < fieldCount; i++) { for (int i = 0; i < fieldCount; i++) {
int accessFlags = cr.getFieldAccessFlags(i); int accessFlags = cr.getFieldAccessFlags(i);

View File

@ -265,7 +265,7 @@ public abstract class AbstractAnalysisEngine<I extends InstanceKey> implements A
} }
public SDG<I> getSDG(DataDependenceOptions data, ControlDependenceOptions ctrl) { public SDG<I> getSDG(DataDependenceOptions data, ControlDependenceOptions ctrl) {
return new SDG<I>(getCallGraph(), getPointerAnalysis(), data, ctrl); return new SDG<>(getCallGraph(), getPointerAnalysis(), data, ctrl);
} }
public String getExclusionsFile() { public String getExclusionsFile() {

View File

@ -52,7 +52,7 @@ public class BackwardsSupergraph<T, P> implements ISupergraph<T, P> {
} }
public static <T, P> BackwardsSupergraph<T, P> make(ISupergraph<T, P> forwardGraph) { public static <T, P> BackwardsSupergraph<T, P> make(ISupergraph<T, P> forwardGraph) {
return new BackwardsSupergraph<T, P>(forwardGraph); return new BackwardsSupergraph<>(forwardGraph);
} }
/** /**
@ -99,7 +99,7 @@ public class BackwardsSupergraph<T, P> implements ISupergraph<T, P> {
System.err.println("called nodes: " System.err.println("called nodes: "
+ Iterator2Collection.toSet(new FilterIterator<>(getSuccNodes(ret), exitFilter))); + Iterator2Collection.toSet(new FilterIterator<>(getSuccNodes(ret), exitFilter)));
} }
return new FilterIterator<T>(getSuccNodes(ret), exitFilter); return new FilterIterator<>(getSuccNodes(ret), exitFilter);
} }
/** /**
@ -113,7 +113,7 @@ public class BackwardsSupergraph<T, P> implements ISupergraph<T, P> {
Predicate<T> sameProc = o -> getProcOf(ret).equals(getProcOf(o)) && !delegate.isExit(o); Predicate<T> sameProc = o -> getProcOf(ret).equals(getProcOf(o)) && !delegate.isExit(o);
Iterator<T> sameProcPreds = new FilterIterator<>(allPreds, sameProc); Iterator<T> sameProcPreds = new FilterIterator<>(allPreds, sameProc);
Predicate<T> notCall = o -> !delegate.isCall(o); Predicate<T> notCall = o -> !delegate.isCall(o);
return new FilterIterator<T>(sameProcPreds, notCall); return new FilterIterator<>(sameProcPreds, notCall);
} }
/* /*

View File

@ -28,7 +28,7 @@ public class BoundedPartiallyBalancedSolver<T, P, F> extends PartiallyBalancedTa
public static <T, P, F> BoundedPartiallyBalancedSolver<T, P, F> createdBoundedPartiallyBalancedSolver(PartiallyBalancedTabulationProblem<T, P, F> p, int bound, public static <T, P, F> BoundedPartiallyBalancedSolver<T, P, F> createdBoundedPartiallyBalancedSolver(PartiallyBalancedTabulationProblem<T, P, F> p, int bound,
IProgressMonitor monitor) { IProgressMonitor monitor) {
return new BoundedPartiallyBalancedSolver<T, P, F>(p, bound, monitor); return new BoundedPartiallyBalancedSolver<>(p, bound, monitor);
} }
private final int bound; private final int bound;

View File

@ -26,7 +26,7 @@ public class BoundedTabulationSolver<T, P, F> extends TabulationSolver<T, P, F>
public static <T, P, F> BoundedTabulationSolver<T, P, F> createBoundedTabulationSolver(TabulationProblem<T, P, F> p, int bound, public static <T, P, F> BoundedTabulationSolver<T, P, F> createBoundedTabulationSolver(TabulationProblem<T, P, F> p, int bound,
IProgressMonitor monitor) { IProgressMonitor monitor) {
return new BoundedTabulationSolver<T, P, F>(p, bound, monitor); return new BoundedTabulationSolver<>(p, bound, monitor);
} }
private final int bound; private final int bound;

View File

@ -34,14 +34,14 @@ public class CallFlowEdges {
* TODO: more representation optimization. A special representation for triples? sparse representations for CFG? exploit shorts * TODO: more representation optimization. A special representation for triples? sparse representations for CFG? exploit shorts
* for ints? * for ints?
*/ */
private final SparseVector<IBinaryNaturalRelation> edges = new SparseVector<IBinaryNaturalRelation>(1, 1.1f); private final SparseVector<IBinaryNaturalRelation> edges = new SparseVector<>(1, 1.1f);
/** /**
* a map from integer d1 -> int set. * a map from integer d1 -> int set.
* *
* for fact d1, identityPaths[d1] gives the set of block numbers C s.t. for c \in C, <c, d1> -> <s_p, d1> is an edge. * for fact d1, identityPaths[d1] gives the set of block numbers C s.t. for c \in C, <c, d1> -> <s_p, d1> is an edge.
*/ */
private final SparseVector<IntSet> identityEdges = new SparseVector<IntSet>(1, 1.1f); private final SparseVector<IntSet> identityEdges = new SparseVector<>(1, 1.1f);
public CallFlowEdges() { public CallFlowEdges() {
} }

View File

@ -96,7 +96,7 @@ public class ICFGSupergraph implements ISupergraph<BasicBlockInContext<IExploded
@Override @Override
public Iterator<? extends BasicBlockInContext<IExplodedBasicBlock>> getCalledNodes(BasicBlockInContext<IExplodedBasicBlock> call) { public Iterator<? extends BasicBlockInContext<IExplodedBasicBlock>> getCalledNodes(BasicBlockInContext<IExplodedBasicBlock> call) {
final Predicate<BasicBlockInContext<IExplodedBasicBlock>> isEntryFilter = BasicBlockInContext::isEntryBlock; final Predicate<BasicBlockInContext<IExplodedBasicBlock>> isEntryFilter = BasicBlockInContext::isEntryBlock;
return new FilterIterator<BasicBlockInContext<IExplodedBasicBlock>>(getSuccNodes(call), isEntryFilter); return new FilterIterator<>(getSuccNodes(call), isEntryFilter);
} }
@Override @Override
@ -114,7 +114,7 @@ public class ICFGSupergraph implements ISupergraph<BasicBlockInContext<IExploded
@Override @Override
public BasicBlockInContext<IExplodedBasicBlock> getLocalBlock(CGNode procedure, int i) { public BasicBlockInContext<IExplodedBasicBlock> getLocalBlock(CGNode procedure, int i) {
IExplodedBasicBlock b = icfg.getCFG(procedure).getNode(i); IExplodedBasicBlock b = icfg.getCFG(procedure).getNode(i);
return new BasicBlockInContext<IExplodedBasicBlock>(procedure, b); return new BasicBlockInContext<>(procedure, b);
} }
@Override @Override

View File

@ -50,7 +50,7 @@ public class LocalPathEdges {
* TODO: more representation optimization. A special representation for triples? sparse representations for CFG? exploit shorts * TODO: more representation optimization. A special representation for triples? sparse representations for CFG? exploit shorts
* for ints? * for ints?
*/ */
private final SparseVector<IBinaryNaturalRelation> paths = new SparseVector<IBinaryNaturalRelation>(1, 1.1f); private final SparseVector<IBinaryNaturalRelation> paths = new SparseVector<>(1, 1.1f);
/** /**
* If this is non-null, it holds a redundant representation of the paths information, designed to make getReachable(II) faster. * If this is non-null, it holds a redundant representation of the paths information, designed to make getReachable(II) faster.
@ -75,20 +75,20 @@ public class LocalPathEdges {
* *
* for fact d1, identityPaths[d1] gives the set of block numbers N s.t. for n \in N, <s_p, d1> -> <n, d1> is a path edge. * for fact d1, identityPaths[d1] gives the set of block numbers N s.t. for n \in N, <s_p, d1> -> <n, d1> is a path edge.
*/ */
private final SparseVector<IntSet> identityPaths = new SparseVector<IntSet>(1, 1.1f); private final SparseVector<IntSet> identityPaths = new SparseVector<>(1, 1.1f);
/** /**
* a map from integer d2 -> int set * a map from integer d2 -> int set
* *
* for fact d2, zeroPaths[d2] gives the set of block numbers N s.t. for n \in N, <s_p, 0> -> <n, d2> is a path edge. * for fact d2, zeroPaths[d2] gives the set of block numbers N s.t. for n \in N, <s_p, 0> -> <n, d2> is a path edge.
*/ */
private final SparseVector<IntSet> zeroPaths = new SparseVector<IntSet>(1, 1.1f); private final SparseVector<IntSet> zeroPaths = new SparseVector<>(1, 1.1f);
/** /**
* @param fastMerge if true, the representation uses extra space in order to support faster merge operations * @param fastMerge if true, the representation uses extra space in order to support faster merge operations
*/ */
public LocalPathEdges(boolean fastMerge) { public LocalPathEdges(boolean fastMerge) {
altPaths = fastMerge ? new SparseVector<IBinaryNaturalRelation>(1, 1.1f) : null; altPaths = fastMerge ? new SparseVector<>(1, 1.1f) : null;
} }
/** /**

View File

@ -39,7 +39,7 @@ public class LocalSummaryEdges {
* *
* TODO: more representation optimization. * TODO: more representation optimization.
*/ */
private final SparseVector<IBinaryNaturalRelation> summaries = new SparseVector<IBinaryNaturalRelation>(1, 1.1f); private final SparseVector<IBinaryNaturalRelation> summaries = new SparseVector<>(1, 1.1f);
/** /**
* Let (s_p,x) be an entry-exit pair, and let l := the long whose high word is s_p and low word is x. * Let (s_p,x) be an entry-exit pair, and let l := the long whose high word is s_p and low word is x.

View File

@ -31,7 +31,7 @@ public class PartiallyBalancedTabulationSolver<T, P, F> extends TabulationSolver
public static <T, P, F> PartiallyBalancedTabulationSolver<T, P, F> createPartiallyBalancedTabulationSolver( public static <T, P, F> PartiallyBalancedTabulationSolver<T, P, F> createPartiallyBalancedTabulationSolver(
PartiallyBalancedTabulationProblem<T, P, F> p, IProgressMonitor monitor) { PartiallyBalancedTabulationProblem<T, P, F> p, IProgressMonitor monitor) {
return new PartiallyBalancedTabulationSolver<T, P, F>(p, monitor); return new PartiallyBalancedTabulationSolver<>(p, monitor);
} }
private final Collection<Pair<T,Integer>> unbalancedSeeds = HashSetFactory.make(); private final Collection<Pair<T,Integer>> unbalancedSeeds = HashSetFactory.make();

View File

@ -30,7 +30,7 @@ public final class PathEdge<T> {
if (n == null) { if (n == null) {
throw new IllegalArgumentException("null n"); throw new IllegalArgumentException("null n");
} }
return new PathEdge<T>(s_p, d1, n, d2); return new PathEdge<>(s_p, d1, n, d2);
} }
private PathEdge(T s_p, int d1, T n, int d2) { private PathEdge(T s_p, int d1, T n, int d2) {

View File

@ -191,7 +191,7 @@ public class TabulationSolver<T, P, F> {
* @throws IllegalArgumentException if p is null * @throws IllegalArgumentException if p is null
*/ */
public static <T, P, F> TabulationSolver<T, P, F> make(TabulationProblem<T, P, F> p) { public static <T, P, F> TabulationSolver<T, P, F> make(TabulationProblem<T, P, F> p) {
return new TabulationSolver<T, P, F>(p, null); return new TabulationSolver<>(p, null);
} }
/** /**
@ -911,7 +911,7 @@ public class TabulationSolver<T, P, F> {
public String toString() { public String toString() {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
TreeMap<Object, TreeSet<T>> map = new TreeMap<Object, TreeSet<T>>(ToStringComparator.instance()); TreeMap<Object, TreeSet<T>> map = new TreeMap<>(ToStringComparator.instance());
Comparator<Object> c = (o1, o2) -> { Comparator<Object> c = (o1, o2) -> {
if (!(o1 instanceof IBasicBlock)) { if (!(o1 instanceof IBasicBlock)) {
@ -925,7 +925,7 @@ public class TabulationSolver<T, P, F> {
P proc = supergraph.getProcOf(n); P proc = supergraph.getProcOf(n);
TreeSet<T> s = map.get(proc); TreeSet<T> s = map.get(proc);
if (s == null) { if (s == null) {
s = new TreeSet<T>(c); s = new TreeSet<>(c);
map.put(proc, s); map.put(proc, s);
} }
s.add(n); s.add(n);

View File

@ -768,17 +768,17 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
/** /**
* forward worklist: for initially processing points-to queries * forward worklist: for initially processing points-to queries
*/ */
private final Collection<PointerKeyAndState> initWorklist = new LinkedHashSet<PointerKeyAndState>(); private final Collection<PointerKeyAndState> initWorklist = new LinkedHashSet<>();
/** /**
* worklist for variables whose points-to set has been updated * worklist for variables whose points-to set has been updated
*/ */
private final Collection<PointerKeyAndState> pointsToWorklist = new LinkedHashSet<PointerKeyAndState>(); private final Collection<PointerKeyAndState> pointsToWorklist = new LinkedHashSet<>();
/** /**
* worklist for variables whose tracked points-to set has been updated * worklist for variables whose tracked points-to set has been updated
*/ */
private final Collection<PointerKeyAndState> trackedPointsToWorklist = new LinkedHashSet<PointerKeyAndState>(); private final Collection<PointerKeyAndState> trackedPointsToWorklist = new LinkedHashSet<>();
/** /**
* maps a pointer key to those on-the-fly virtual calls for which it is the receiver * maps a pointer key to those on-the-fly virtual calls for which it is the receiver
@ -843,7 +843,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
private OrdinalSet<InstanceKeyAndState> makeOrdinalSet(IntSet intSet) { private OrdinalSet<InstanceKeyAndState> makeOrdinalSet(IntSet intSet) {
// make a copy here, to avoid comodification during iteration // make a copy here, to avoid comodification during iteration
// TODO remove the copying, do it only at necessary call sites // TODO remove the copying, do it only at necessary call sites
return new OrdinalSet<InstanceKeyAndState>(intSetFactory.makeCopy(intSet), ikAndStates); return new OrdinalSet<>(intSetFactory.makeCopy(intSet), ikAndStates);
} }
/** /**
@ -1974,7 +1974,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
private boolean doTopLevelTraversal(PointerKey pk, final Predicate<InstanceKey> pred, final PointsToComputer ptoComputer, private boolean doTopLevelTraversal(PointerKey pk, final Predicate<InstanceKey> pred, final PointsToComputer ptoComputer,
PointerAnalysis<InstanceKey> pa) { PointerAnalysis<InstanceKey> pa) {
final Set<PointerKeyAndState> visited = HashSetFactory.make(); final Set<PointerKeyAndState> visited = HashSetFactory.make();
final LinkedList<PointerKeyAndState> worklist = new LinkedList<PointerKeyAndState>(); final LinkedList<PointerKeyAndState> worklist = new LinkedList<>();
class Helper { class Helper {
@ -2385,7 +2385,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
// here we compute the number of unique *method* targets, as opposed to call graph nodes. // here we compute the number of unique *method* targets, as opposed to call graph nodes.
// if we have a context-sensitive call graph, with many targets representing clones of // if we have a context-sensitive call graph, with many targets representing clones of
// the same method, we don't want to count the clones twice // the same method, we don't want to count the clones twice
Set<IMethod> methodTargets = new HashSet<IMethod>(); Set<IMethod> methodTargets = new HashSet<>();
for (CGNode node : possibleTargets) { for (CGNode node : possibleTargets) {
methodTargets.add(node.getMethod()); methodTargets.add(node.getMethod());
} }

View File

@ -92,7 +92,7 @@ public class SimpleDemandPointsTo extends AbstractDemandPointsTo {
System.err.println(g.toString()); System.err.println(g.toString());
} }
SlowDFSDiscoverTimeIterator<Object> dfs = new SlowDFSDiscoverTimeIterator<Object>(g, pk); SlowDFSDiscoverTimeIterator<Object> dfs = new SlowDFSDiscoverTimeIterator<>(g, pk);
Collection<InstanceKey> keys = HashSetFactory.make(); Collection<InstanceKey> keys = HashSetFactory.make();
while (dfs.hasNext()) { while (dfs.hasNext()) {
Object o = dfs.next(); Object o = dfs.next();

View File

@ -50,7 +50,7 @@ public class DummyStateMachine<T> implements StateMachine<T> {
@Override @Override
public StateMachine<T> make() { public StateMachine<T> make() {
return new DummyStateMachine<T>(); return new DummyStateMachine<>();
} }
} }

View File

@ -123,7 +123,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
int paramPos = pk.getValueNumber() - 1; int paramPos = pk.getValueNumber() - 1;
ArrayList<PointerKeyAndCallSite> paramSuccs = new ArrayList<PointerKeyAndCallSite>(); ArrayList<PointerKeyAndCallSite> paramSuccs = new ArrayList<>();
// iterate over callers // iterate over callers
for (CGNode caller : cg) { for (CGNode caller : cg) {
// TODO optimization: we don't need to add the graph if null is passed // TODO optimization: we don't need to add the graph if null is passed
@ -155,7 +155,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
if (instrs == null) { if (instrs == null) {
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
ArrayList<PointerKeyAndCallSite> paramPreds = new ArrayList<PointerKeyAndCallSite>(); ArrayList<PointerKeyAndCallSite> paramPreds = new ArrayList<>();
for (SSAAbstractInvokeInstruction callInstr : instrs) { for (SSAAbstractInvokeInstruction callInstr : instrs) {
for (int i = 0; i < callInstr.getNumberOfUses(); i++) { for (int i = 0; i < callInstr.getNumberOfUses(); i++) {
if (pk.getValueNumber() != callInstr.getUse(i)) if (pk.getValueNumber() != callInstr.getUse(i))
@ -185,7 +185,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
SSAAbstractInvokeInstruction callInstr = callDefs.get(pk); SSAAbstractInvokeInstruction callInstr = callDefs.get(pk);
if (callInstr == null) if (callInstr == null)
return EmptyIterator.instance(); return EmptyIterator.instance();
ArrayList<PointerKeyAndCallSite> returnSuccs = new ArrayList<PointerKeyAndCallSite>(); ArrayList<PointerKeyAndCallSite> returnSuccs = new ArrayList<>();
boolean isExceptional = pk.getValueNumber() == callInstr.getException(); boolean isExceptional = pk.getValueNumber() == callInstr.getException();
CallSiteReference callSiteRef = callInstr.getCallSite(); CallSiteReference callSiteRef = callInstr.getCallSite();
@ -212,7 +212,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
return EmptyIterator.instance(); return EmptyIterator.instance();
} }
boolean isExceptional = pk == heapModel.getPointerKeyForExceptionalReturnValue(cgNode); boolean isExceptional = pk == heapModel.getPointerKeyForExceptionalReturnValue(cgNode);
ArrayList<PointerKeyAndCallSite> returnPreds = new ArrayList<PointerKeyAndCallSite>(); ArrayList<PointerKeyAndCallSite> returnPreds = new ArrayList<>();
// iterate over callers // iterate over callers
for (CGNode caller : cg) { for (CGNode caller : cg) {
// TODO we don't need to add the graph if null is passed // TODO we don't need to add the graph if null is passed

View File

@ -271,7 +271,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
for (MemoryAccess a : writes) { for (MemoryAccess a : writes) {
addSubgraphForNode(a.getNode()); addSubgraphForNode(a.getNode());
} }
ArrayList<PointerKey> written = new ArrayList<PointerKey>(); ArrayList<PointerKey> written = new ArrayList<>();
for (MemoryAccess a : writes) { for (MemoryAccess a : writes) {
IR ir = a.getNode().getIR(); IR ir = a.getNode().getIR();
SSAPutInstruction s = (SSAPutInstruction) ir.getInstructions()[a.getInstructionIndex()]; SSAPutInstruction s = (SSAPutInstruction) ir.getInstructions()[a.getInstructionIndex()];
@ -332,7 +332,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
for (MemoryAccess a : reads) { for (MemoryAccess a : reads) {
addSubgraphForNode(a.getNode()); addSubgraphForNode(a.getNode());
} }
ArrayList<PointerKey> readInto = new ArrayList<PointerKey>(); ArrayList<PointerKey> readInto = new ArrayList<>();
for (MemoryAccess a : reads) { for (MemoryAccess a : reads) {
IR ir = a.getNode().getIR(); IR ir = a.getNode().getIR();
SSAGetInstruction s = (SSAGetInstruction) ir.getInstructions()[a.getInstructionIndex()]; SSAGetInstruction s = (SSAGetInstruction) ir.getInstructions()[a.getInstructionIndex()];
@ -355,7 +355,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
for (MemoryAccess a : arrayWrites) { for (MemoryAccess a : arrayWrites) {
addSubgraphForNode(a.getNode()); addSubgraphForNode(a.getNode());
} }
ArrayList<PointerKey> written = new ArrayList<PointerKey>(); ArrayList<PointerKey> written = new ArrayList<>();
for (MemoryAccess a : arrayWrites) { for (MemoryAccess a : arrayWrites) {
final CGNode node = a.getNode(); final CGNode node = a.getNode();
IR ir = node.getIR(); IR ir = node.getIR();
@ -388,7 +388,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
for (MemoryAccess a : arrayReads) { for (MemoryAccess a : arrayReads) {
addSubgraphForNode(a.getNode()); addSubgraphForNode(a.getNode());
} }
ArrayList<PointerKey> read = new ArrayList<PointerKey>(); ArrayList<PointerKey> read = new ArrayList<>();
for (MemoryAccess a : arrayReads) { for (MemoryAccess a : arrayReads) {
IR ir = a.getNode().getIR(); IR ir = a.getNode().getIR();
SSAArrayLoadInstruction s = (SSAArrayLoadInstruction) ir.getInstructions()[a.getInstructionIndex()]; SSAArrayLoadInstruction s = (SSAArrayLoadInstruction) ir.getInstructions()[a.getInstructionIndex()];

View File

@ -52,7 +52,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
private final Map<PointerKey, Set<Statement>> invRef; private final Map<PointerKey, Set<Statement>> invRef;
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis<InstanceKey> pa) { public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
this(pa, new SDG<InstanceKey>(cg, pa, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE)); this(pa, new SDG<>(cg, pa, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE));
} }
public PABasedMemoryAccessMap(PointerAnalysis<InstanceKey> pa, SDG<InstanceKey> sdg) { public PABasedMemoryAccessMap(PointerAnalysis<InstanceKey> pa, SDG<InstanceKey> sdg) {
@ -71,7 +71,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
@Override @Override
public Collection<MemoryAccess> getArrayReads(PointerKey arrayRef) { public Collection<MemoryAccess> getArrayReads(PointerKey arrayRef) {
Collection<MemoryAccess> memAccesses = new ArrayList<MemoryAccess>(); Collection<MemoryAccess> memAccesses = new ArrayList<>();
if (DEBUG) { if (DEBUG) {
System.err.println(("looking at reads of array ref " + arrayRef)); System.err.println(("looking at reads of array ref " + arrayRef));
} }
@ -84,7 +84,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
@Override @Override
public Collection<MemoryAccess> getArrayWrites(PointerKey arrayRef) { public Collection<MemoryAccess> getArrayWrites(PointerKey arrayRef) {
Collection<MemoryAccess> memAccesses = new ArrayList<MemoryAccess>(); Collection<MemoryAccess> memAccesses = new ArrayList<>();
if (DEBUG) { if (DEBUG) {
System.err.println(("looking at writes to array ref " + arrayRef)); System.err.println(("looking at writes to array ref " + arrayRef));
} }
@ -100,7 +100,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
@Override @Override
public Collection<MemoryAccess> getFieldReads(PointerKey baseRef, IField field) { public Collection<MemoryAccess> getFieldReads(PointerKey baseRef, IField field) {
Collection<MemoryAccess> memAccesses = new ArrayList<MemoryAccess>(); Collection<MemoryAccess> memAccesses = new ArrayList<>();
for (InstanceKey ik : pa.getPointsToSet(baseRef)) { for (InstanceKey ik : pa.getPointsToSet(baseRef)) {
PointerKey ifk = heapModel.getPointerKeyForInstanceField(ik, field); PointerKey ifk = heapModel.getPointerKeyForInstanceField(ik, field);
convertStmtsToMemoryAccess(invRef.get(ifk), memAccesses); convertStmtsToMemoryAccess(invRef.get(ifk), memAccesses);
@ -110,7 +110,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
@Override @Override
public Collection<MemoryAccess> getFieldWrites(PointerKey baseRef, IField field) { public Collection<MemoryAccess> getFieldWrites(PointerKey baseRef, IField field) {
Collection<MemoryAccess> memAccesses = new ArrayList<MemoryAccess>(); Collection<MemoryAccess> memAccesses = new ArrayList<>();
for (InstanceKey ik : pa.getPointsToSet(baseRef)) { for (InstanceKey ik : pa.getPointsToSet(baseRef)) {
PointerKey ifk = heapModel.getPointerKeyForInstanceField(ik, field); PointerKey ifk = heapModel.getPointerKeyForInstanceField(ik, field);
convertStmtsToMemoryAccess(invMod.get(ifk), memAccesses); convertStmtsToMemoryAccess(invMod.get(ifk), memAccesses);
@ -120,14 +120,14 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
@Override @Override
public Collection<MemoryAccess> getStaticFieldReads(IField field) { public Collection<MemoryAccess> getStaticFieldReads(IField field) {
Collection<MemoryAccess> result = new ArrayList<MemoryAccess>(); Collection<MemoryAccess> result = new ArrayList<>();
convertStmtsToMemoryAccess(invRef.get(heapModel.getPointerKeyForStaticField(field)), result); convertStmtsToMemoryAccess(invRef.get(heapModel.getPointerKeyForStaticField(field)), result);
return result; return result;
} }
@Override @Override
public Collection<MemoryAccess> getStaticFieldWrites(IField field) { public Collection<MemoryAccess> getStaticFieldWrites(IField field) {
Collection<MemoryAccess> result = new ArrayList<MemoryAccess>(); Collection<MemoryAccess> result = new ArrayList<>();
convertStmtsToMemoryAccess(invMod.get(heapModel.getPointerKeyForStaticField(field)), result); convertStmtsToMemoryAccess(invMod.get(heapModel.getPointerKeyForStaticField(field)), result);
return result; return result;
} }

View File

@ -437,7 +437,7 @@ public class SimpleMemoryAccessMap implements MemoryAccessMap {
} }
public void repOk() { public void repOk() {
for (MemoryAccess m : Iterator2Iterable.make(new CompoundIterator<MemoryAccess>(arrayReads.iterator(), arrayWrites.iterator()))) { for (MemoryAccess m : Iterator2Iterable.make(new CompoundIterator<>(arrayReads.iterator(), arrayWrites.iterator()))) {
CGNode node = m.getNode(); CGNode node = m.getNode();
IR ir = node.getIR(); IR ir = node.getIR();
assert ir != null : "null IR for " + node + " but we have a memory access"; assert ir != null : "null IR for " + node + " but we have a memory access";

View File

@ -118,7 +118,7 @@ public class AnalysisScope {
*/ */
private SetOfClasses exclusions; private SetOfClasses exclusions;
final protected LinkedHashMap<Atom, ClassLoaderReference> loadersByName = new LinkedHashMap<Atom, ClassLoaderReference>(); final protected LinkedHashMap<Atom, ClassLoaderReference> loadersByName = new LinkedHashMap<>();
/** /**
* Special class loader for array instances * Special class loader for array instances
@ -131,7 +131,7 @@ public class AnalysisScope {
protected AnalysisScope(Collection<? extends Language> languages) { protected AnalysisScope(Collection<? extends Language> languages) {
super(); super();
this.languages = new HashMap<Atom, Language>(); this.languages = new HashMap<>();
for (Language l : languages) { for (Language l : languages) {
this.languages.put(l.getName(), l); this.languages.put(l.getName(), l);
} }
@ -377,7 +377,7 @@ public class AnalysisScope {
private JarFile getRtJar() { private JarFile getRtJar() {
return RtJar.getRtJar( return RtJar.getRtJar(
new MapIterator<Module,JarFile>( new MapIterator<Module,JarFile>(
new FilterIterator<Module>(getModules(getPrimordialLoader()).iterator(), JarFileModule.class::isInstance), M -> ((JarFileModule) M).getJarFile())); new FilterIterator<>(getModules(getPrimordialLoader()).iterator(), JarFileModule.class::isInstance), M -> ((JarFileModule) M).getJarFile()));
} }
public String getJavaLibraryVersion() throws IllegalStateException { public String getJavaLibraryVersion() throws IllegalStateException {
@ -434,7 +434,7 @@ public class AnalysisScope {
// Note: 'arrayClassLoader' object will be built from scratch in remote process // Note: 'arrayClassLoader' object will be built from scratch in remote process
// represent modules map as a set of strings (corresponding to analysis scope file lines. // represent modules map as a set of strings (corresponding to analysis scope file lines.
List<String> moduleLines = new ArrayList<String>(); List<String> moduleLines = new ArrayList<>();
for (Map.Entry<ClassLoaderReference, List<Module>> e : moduleMap.entrySet()) { for (Map.Entry<ClassLoaderReference, List<Module>> e : moduleMap.entrySet()) {
ClassLoaderReference lrReference = e.getKey(); ClassLoaderReference lrReference = e.getKey();
String moduleLdr = lrReference.getName().toString(); String moduleLdr = lrReference.getName().toString();
@ -467,7 +467,7 @@ public class AnalysisScope {
} }
// represent loaderImplByRef map as set of strings // represent loaderImplByRef map as set of strings
List<String> ldrImplLines = new ArrayList<String>(); List<String> ldrImplLines = new ArrayList<>();
for (Map.Entry<ClassLoaderReference, String> e : loaderImplByRef.entrySet()) { for (Map.Entry<ClassLoaderReference, String> e : loaderImplByRef.entrySet()) {
ClassLoaderReference lrReference = e.getKey(); ClassLoaderReference lrReference = e.getKey();
String ldrName = lrReference.getName().toString(); String ldrName = lrReference.getName().toString();

View File

@ -41,13 +41,13 @@ public class CallGraphTransitiveClosure {
public static <T> Map<CGNode, OrdinalSet<T>> transitiveClosure(CallGraph cg, Map<CGNode, Collection<T>> nodeResults) { public static <T> Map<CGNode, OrdinalSet<T>> transitiveClosure(CallGraph cg, Map<CGNode, Collection<T>> nodeResults) {
try { try {
// invert the call graph, to compute the bottom-up result // invert the call graph, to compute the bottom-up result
GenReach<CGNode, T> gr = new GenReach<CGNode, T>(GraphInverter.invert(cg), nodeResults); GenReach<CGNode, T> gr = new GenReach<>(GraphInverter.invert(cg), nodeResults);
BitVectorSolver<CGNode> solver = new BitVectorSolver<CGNode>(gr); BitVectorSolver<CGNode> solver = new BitVectorSolver<>(gr);
solver.solve(null); solver.solve(null);
Map<CGNode, OrdinalSet<T>> result = HashMapFactory.make(); Map<CGNode, OrdinalSet<T>> result = HashMapFactory.make();
for (CGNode n : cg) { for (CGNode n : cg) {
BitVectorVariable bv = solver.getOut(n); BitVectorVariable bv = solver.getOut(n);
result.put(n, new OrdinalSet<T>(bv.getValue(), gr.getLatticeValues())); result.put(n, new OrdinalSet<>(bv.getValue(), gr.getLatticeValues()));
} }
return result; return result;
} catch (CancelException e) { } catch (CancelException e) {

View File

@ -28,7 +28,7 @@ public interface ContextItem {
} }
public static <T> Value make(T v) { public static <T> Value make(T v) {
return new Value<T>(v); return new Value<>(v);
} }
@Override @Override

View File

@ -160,7 +160,7 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
public Set<CGNode> getPossibleTargets(CGNode node, CallSiteReference site) { public Set<CGNode> getPossibleTargets(CGNode node, CallSiteReference site) {
return Iterator2Collection.toSet( return Iterator2Collection.toSet(
new MapIterator<IMethod,CGNode>( new MapIterator<IMethod,CGNode>(
new FilterIterator<IMethod>( new FilterIterator<>(
getPossibleTargets(site), getPossibleTargets(site),
this::isRelevantMethod this::isRelevantMethod
), ),
@ -182,7 +182,7 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
@Override @Override
public Iterator<CallSiteReference> getPossibleSites(final CGNode src, final CGNode target) { public Iterator<CallSiteReference> getPossibleSites(final CGNode src, final CGNode target) {
return return
new FilterIterator<CallSiteReference>(getInterpreter(src).iterateCallSites(src), new FilterIterator<>(getInterpreter(src).iterateCallSites(src),
o -> getPossibleTargets(src, o).contains(target)); o -> getPossibleTargets(src, o).contains(target));
} }
@ -237,7 +237,7 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
return n; return n;
} }
private Stack<CGNode> newNodes = new Stack<CGNode>(); private Stack<CGNode> newNodes = new Stack<>();
private void closure() throws CancelException { private void closure() throws CancelException {
while (! newNodes.isEmpty()) { while (! newNodes.isEmpty()) {
@ -290,7 +290,7 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
preds.add(node); preds.add(node);
} }
} }
predecessors.put(n, new SoftReference<Set<CGNode>>(preds)); predecessors.put(n, new SoftReference<>(preds));
return preds; return preds;
} }
} }
@ -307,7 +307,7 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
@Override @Override
public Iterator<CGNode> getSuccNodes(final CGNode n) { public Iterator<CGNode> getSuccNodes(final CGNode n) {
return new FilterIterator<CGNode>(new ComposedIterator<CallSiteReference, CGNode>(n.iterateCallSites()) { return new FilterIterator<>(new ComposedIterator<CallSiteReference, CGNode>(n.iterateCallSites()) {
@Override @Override
public Iterator<? extends CGNode> makeInner(CallSiteReference outer) { public Iterator<? extends CGNode> makeInner(CallSiteReference outer) {
return getPossibleTargets(n, outer).iterator(); return getPossibleTargets(n, outer).iterator();

View File

@ -54,7 +54,7 @@ import com.ibm.wala.util.warnings.Warnings;
*/ */
public abstract class AbstractRootMethod extends SyntheticMethod { public abstract class AbstractRootMethod extends SyntheticMethod {
final protected ArrayList<SSAInstruction> statements = new ArrayList<SSAInstruction>(); final protected ArrayList<SSAInstruction> statements = new ArrayList<>();
private Map<ConstantValue, Integer> constant2ValueNumber = HashMapFactory.make(); private Map<ConstantValue, Integer> constant2ValueNumber = HashMapFactory.make();
@ -361,7 +361,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
@Override @Override
public Iterator<NewSiteReference> iterateNewSites(CGNode node) { public Iterator<NewSiteReference> iterateNewSites(CGNode node) {
ArrayList<NewSiteReference> result = new ArrayList<NewSiteReference>(); ArrayList<NewSiteReference> result = new ArrayList<>();
SSAInstruction[] statements = getStatements(options.getSSAOptions()); SSAInstruction[] statements = getStatements(options.getSSAOptions());
for (SSAInstruction statement : statements) { for (SSAInstruction statement : statements) {
if (statement instanceof SSANewInstruction) { if (statement instanceof SSANewInstruction) {
@ -373,7 +373,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
} }
public Iterator<SSAInstruction> getInvokeStatements() { public Iterator<SSAInstruction> getInvokeStatements() {
ArrayList<SSAInstruction> result = new ArrayList<SSAInstruction>(); ArrayList<SSAInstruction> result = new ArrayList<>();
SSAInstruction[] statements = getStatements(options.getSSAOptions()); SSAInstruction[] statements = getStatements(options.getSSAOptions());
for (SSAInstruction statement : statements) { for (SSAInstruction statement : statements) {
if (statement instanceof SSAInvokeInstruction) { if (statement instanceof SSAInvokeInstruction) {

View File

@ -45,7 +45,7 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private final DelegatingNumberedNodeManager<CGNode> nodeManager = new DelegatingNumberedNodeManager<CGNode>(); private final DelegatingNumberedNodeManager<CGNode> nodeManager = new DelegatingNumberedNodeManager<>();
/** /**
* A fake root node for the graph * A fake root node for the graph
@ -231,7 +231,7 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
@Override @Override
public String toString() { public String toString() {
StringBuffer result = new StringBuffer(""); StringBuffer result = new StringBuffer("");
for (Iterator<CGNode> i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<CGNode>(getFakeRootNode())); i.hasNext();) { for (Iterator<CGNode> i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<>(getFakeRootNode())); i.hasNext();) {
CGNode n = i.next(); CGNode n = i.next();
result.append(nodeToString(this, n) + "\n"); result.append(nodeToString(this, n) + "\n");
} }

View File

@ -137,12 +137,12 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> imp
* A Mapping from call site program counter (int) -> Object, where Object is a CGNode if we've discovered exactly one target for * A Mapping from call site program counter (int) -> Object, where Object is a CGNode if we've discovered exactly one target for
* the site, or an IntSet of node numbers if we've discovered more than one target for the site. * the site, or an IntSet of node numbers if we've discovered more than one target for the site.
*/ */
protected final SparseVector<Object> targets = new SparseVector<Object>(); protected final SparseVector<Object> targets = new SparseVector<>();
private final MutableSharedBitVectorIntSet allTargets = new MutableSharedBitVectorIntSet(); private final MutableSharedBitVectorIntSet allTargets = new MutableSharedBitVectorIntSet();
private WeakReference<IR> ir = new WeakReference<IR>(null); private WeakReference<IR> ir = new WeakReference<>(null);
private WeakReference<DefUse> du = new WeakReference<DefUse>(null); private WeakReference<DefUse> du = new WeakReference<>(null);
/** /**
* @param method * @param method
@ -186,7 +186,7 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> imp
*/ */
protected Iterator<CallSiteReference> getPossibleSites(final CGNode to) { protected Iterator<CallSiteReference> getPossibleSites(final CGNode to) {
final int n = getCallGraph().getNumber(to); final int n = getCallGraph().getNumber(to);
return new FilterIterator<CallSiteReference>(iterateCallSites(), o -> { return new FilterIterator<>(iterateCallSites(), o -> {
IntSet s = getPossibleTargetNumbers(o); IntSet s = getPossibleTargetNumbers(o);
return s == null ? false : s.contains(n); return s == null ? false : s.contains(n);
}); });
@ -304,7 +304,7 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> imp
IR ir = this.ir.get(); IR ir = this.ir.get();
if (ir == null) { if (ir == null) {
ir = getCallGraph().getInterpreter(this).getIR(this); ir = getCallGraph().getInterpreter(this).getIR(this);
this.ir = new WeakReference<IR>(ir); this.ir = new WeakReference<>(ir);
} }
return ir; return ir;
} }
@ -319,7 +319,7 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> imp
DefUse du = this.du.get(); DefUse du = this.du.get();
if (du == null) { if (du == null) {
du = getCallGraph().getInterpreter(this).getDU(this); du = getCallGraph().getInterpreter(this).getDU(this);
this.du = new WeakReference<DefUse>(du); this.du = new WeakReference<>(du);
} }
return du; return du;
} }
@ -386,7 +386,7 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> imp
if (s == null) { if (s == null) {
return EmptyIterator.instance(); return EmptyIterator.instance();
} else { } else {
return new IntMapIterator<CGNode>(s.intIterator(), toNode); return new IntMapIterator<>(s.intIterator(), toNode);
} }
} }
@ -400,7 +400,7 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> imp
@Override @Override
public Iterator<CGNode> getSuccNodes(CGNode N) { public Iterator<CGNode> getSuccNodes(CGNode N) {
ExplicitNode n = (ExplicitNode) N; ExplicitNode n = (ExplicitNode) N;
return new IntMapIterator<CGNode>(n.getAllTargetNumbers().intIterator(), toNode); return new IntMapIterator<>(n.getAllTargetNumbers().intIterator(), toNode);
} }
@Override @Override

View File

@ -112,7 +112,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
@Override @Override
public Iterator<CGNode> iterateNodes(IntSet nodes) { public Iterator<CGNode> iterateNodes(IntSet nodes) {
return new FilterIterator<CGNode>(cg.iterateNodes(nodes), this::containsNode); return new FilterIterator<>(cg.iterateNodes(nodes), this::containsNode);
} }
@Override @Override

View File

@ -46,7 +46,7 @@ public abstract class AbstractPointerAnalysis implements PointerAnalysis<Instanc
@Override @Override
public HeapGraph<InstanceKey> getHeapGraph() { public HeapGraph<InstanceKey> getHeapGraph() {
if (heapGraph == null) { if (heapGraph == null) {
heapGraph = new BasicHeapGraph<InstanceKey>(this, cg); heapGraph = new BasicHeapGraph<>(this, cg);
} }
return heapGraph; return heapGraph;
} }

View File

@ -91,8 +91,8 @@ public class AllocationSite implements InstanceKey {
@Override @Override
public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) { public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) {
return new MapIterator<CGNode, Pair<CGNode, NewSiteReference>>( return new MapIterator<>(
new FilterIterator<CGNode>( new FilterIterator<>(
CG.getNodes(method.getReference()).iterator(), CG.getNodes(method.getReference()).iterator(),
o -> o.getMethod().equals(method) o -> o.getMethod().equals(method)
), ),

View File

@ -50,7 +50,7 @@ public abstract class AllocationSiteInNode extends AbstractTypeInNode {
@Override @Override
public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) { public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) {
return new NonNullSingletonIterator<Pair<CGNode, NewSiteReference>>(Pair.make(getNode(), getSite())); return new NonNullSingletonIterator<>(Pair.make(getNode(), getSite()));
} }
} }

View File

@ -119,7 +119,7 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
@Override @Override
public <T> InstanceKey getInstanceKeyForConstant(TypeReference type, T S) { public <T> InstanceKey getInstanceKeyForConstant(TypeReference type, T S) {
if (options.getUseConstantSpecificKeys()) { if (options.getUseConstantSpecificKeys()) {
return new ConstantKey<T>(S, cha.lookupClass(type)); return new ConstantKey<>(S, cha.lookupClass(type));
} else { } else {
return new ConcreteTypeKey(cha.lookupClass(type)); return new ConcreteTypeKey(cha.lookupClass(type));
} }

View File

@ -107,7 +107,7 @@ public class ClassBasedInstanceKeys implements InstanceKeyFactory {
return null; return null;
} else { } else {
if (options.getUseConstantSpecificKeys()) { if (options.getUseConstantSpecificKeys()) {
return new ConstantKey<T>(S, cha.lookupClass(type)); return new ConstantKey<>(S, cha.lookupClass(type));
} else { } else {
return new ConcreteTypeKey(cha.lookupClass(type)); return new ConcreteTypeKey(cha.lookupClass(type));
} }
@ -136,17 +136,17 @@ public class ClassBasedInstanceKeys implements InstanceKeyFactory {
return new ConcreteTypeKey(cls); return new ConcreteTypeKey(cls);
} else { } else {
// return the IClass itself, wrapped as a constant! // return the IClass itself, wrapped as a constant!
return new ConstantKey<IClass>(klass, cls); return new ConstantKey<>(klass, cls);
} }
} else if (obj instanceof MethodReference) { } else if (obj instanceof MethodReference) {
IMethod m = cha.resolveMethod((MethodReference)obj); IMethod m = cha.resolveMethod((MethodReference)obj);
if (m == null) { if (m == null) {
return new ConcreteTypeKey(cls); return new ConcreteTypeKey(cls);
} else { } else {
return new ConstantKey<IMethod>(m, cls); return new ConstantKey<>(m, cls);
} }
} else if (obj instanceof Descriptor) { } else if (obj instanceof Descriptor) {
return new ConstantKey<Descriptor>((Descriptor)obj, cls); return new ConstantKey<>((Descriptor)obj, cls);
} else { } else {
// other cases // other cases
throw new Error(); throw new Error();

View File

@ -104,8 +104,8 @@ public final class ConcreteTypeKey implements InstanceKey {
return new ComposedIterator<CGNode, Pair<CGNode, NewSiteReference>>(CG.iterator()) { return new ComposedIterator<CGNode, Pair<CGNode, NewSiteReference>>(CG.iterator()) {
@Override @Override
public Iterator<? extends Pair<CGNode, NewSiteReference>> makeInner(final CGNode outer) { public Iterator<? extends Pair<CGNode, NewSiteReference>> makeInner(final CGNode outer) {
return new MapIterator<NewSiteReference, Pair<CGNode, NewSiteReference>>( return new MapIterator<>(
new FilterIterator<NewSiteReference>( new FilterIterator<>(
outer.iterateNewSites(), outer.iterateNewSites(),
o -> o.getDeclaredType().equals(type.getReference()) o -> o.getDeclaredType().equals(type.getReference())
), ),

View File

@ -135,7 +135,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
return OrdinalSet.empty(); return OrdinalSet.empty();
} else { } else {
IntSet S = v.getValue(); IntSet S = v.getValue();
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
} }
@ -261,7 +261,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
} }
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtPhi(CGNode node, SSAPhiInstruction instruction) { private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtPhi(CGNode node, SSAPhiInstruction instruction) {
@ -277,7 +277,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
} }
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtALoad(CGNode node, SSAArrayLoadInstruction instruction) { private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtALoad(CGNode node, SSAArrayLoadInstruction instruction) {
@ -292,7 +292,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
S.addAll(set); S.addAll(set);
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtGet(CGNode node, SSAGetInstruction instruction) { private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtGet(CGNode node, SSAGetInstruction instruction) {
@ -321,7 +321,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
} }
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
} }
@ -369,7 +369,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
} }
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtCheckCast(CGNode node, SSACheckCastInstruction instruction) { private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtCheckCast(CGNode node, SSACheckCastInstruction instruction) {
@ -397,7 +397,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
} }
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtCall(LocalPointerKey lpk, CGNode node, SSAInvokeInstruction call) { private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtCall(LocalPointerKey lpk, CGNode node, SSAInvokeInstruction call) {
@ -420,7 +420,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
assert index != -1 : "instance " + element + " not mapped!"; assert index != -1 : "instance " + element + " not mapped!";
} }
} }
return new OrdinalSet<InstanceKey>(s, instanceKeys); return new OrdinalSet<>(s, instanceKeys);
} }
/** /**
@ -435,7 +435,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
S.addAll(set); S.addAll(set);
} }
} }
return new OrdinalSet<InstanceKey>(S, instanceKeys); return new OrdinalSet<>(S, instanceKeys);
} }
/* /*

View File

@ -41,7 +41,7 @@ public class PointsToMap {
* <li>UNIFIED * <li>UNIFIED
* </ul> * </ul>
*/ */
private final IVector<Object> pointsToSets = new SimpleVector<Object>(); private final IVector<Object> pointsToSets = new SimpleVector<>();
private final IntegerUnionFind uf = new IntegerUnionFind(); private final IntegerUnionFind uf = new IntegerUnionFind();
@ -200,7 +200,7 @@ public class PointsToMap {
* @return {@link Iterator}&lt;{@link PointerKey}&gt; * @return {@link Iterator}&lt;{@link PointerKey}&gt;
*/ */
public Iterator<PointerKey> getTransitiveRoots() { public Iterator<PointerKey> getTransitiveRoots() {
return new FilterIterator<PointerKey>(iterateKeys(), this::isTransitiveRoot); return new FilterIterator<>(iterateKeys(), this::isTransitiveRoot);
} }
/** /**

View File

@ -56,12 +56,12 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
/** /**
* Track nodes (PointsToSet Variables and AbstractEquations) * Track nodes (PointsToSet Variables and AbstractEquations)
*/ */
private final NumberedNodeManager<INodeWithNumber> nodeManager = new DelegatingNumberedNodeManager<INodeWithNumber>(); private final NumberedNodeManager<INodeWithNumber> nodeManager = new DelegatingNumberedNodeManager<>();
/** /**
* Track edges (equations) that are not represented implicitly * Track edges (equations) that are not represented implicitly
*/ */
private final NumberedEdgeManager<INodeWithNumber> edgeManager = new SparseNumberedEdgeManager<INodeWithNumber>(nodeManager, 2, private final NumberedEdgeManager<INodeWithNumber> edgeManager = new SparseNumberedEdgeManager<>(nodeManager, 2,
BasicNaturalRelation.SIMPLE); BasicNaturalRelation.SIMPLE);
private final DelegateGraph delegateGraph = new DelegateGraph(); private final DelegateGraph delegateGraph = new DelegateGraph();
@ -75,14 +75,14 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
* for UnaryOperator op, let R be implicitMap.get(op) then (i,j) \in R implies i op j is an equation in the graph * for UnaryOperator op, let R be implicitMap.get(op) then (i,j) \in R implies i op j is an equation in the graph
* *
*/ */
private final SmallMap<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> implicitUnaryMap = new SmallMap<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation>(); private final SmallMap<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> implicitUnaryMap = new SmallMap<>();
/** /**
* The inverse of relations in the implicit map * The inverse of relations in the implicit map
* *
* for UnaryOperator op, let R be invImplicitMap.get(op) then (i,j) \in R implies j op i is an equation in the graph * for UnaryOperator op, let R be invImplicitMap.get(op) then (i,j) \in R implies j op i is an equation in the graph
*/ */
private final SmallMap<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> invImplicitUnaryMap = new SmallMap<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation>(); private final SmallMap<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> invImplicitUnaryMap = new SmallMap<>();
/** /**
* Number of implicit unary equations registered * Number of implicit unary equations registered
@ -271,7 +271,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
@Override @Override
public Iterator<AbstractStatement> getStatements() { public Iterator<AbstractStatement> getStatements() {
Iterator<AbstractStatement> it = IteratorUtil.filter(delegateGraph.iterator(), AbstractStatement.class); Iterator<AbstractStatement> it = IteratorUtil.filter(delegateGraph.iterator(), AbstractStatement.class);
return new CompoundIterator<AbstractStatement>(it, new GlobalImplicitIterator()); return new CompoundIterator<>(it, new GlobalImplicitIterator());
} }
/** /**
@ -668,10 +668,10 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
IBinaryNaturalRelation R = (IBinaryNaturalRelation) invImplicitUnaryMap.getValue(i); IBinaryNaturalRelation R = (IBinaryNaturalRelation) invImplicitUnaryMap.getValue(i);
IntSet s = R.getRelated(number); IntSet s = R.getRelated(number);
if (s != null) { if (s != null) {
result = new CompoundIterator<INodeWithNumber>(new ImplicitUseIterator(op, v, s), result); result = new CompoundIterator<>(new ImplicitUseIterator(op, v, s), result);
} }
} }
List<AbstractStatement> list = new ArrayList<AbstractStatement>(); List<AbstractStatement> list = new ArrayList<>();
while (result.hasNext()) { while (result.hasNext()) {
list.add((AbstractStatement) result.next()); list.add((AbstractStatement) result.next());
} }
@ -694,11 +694,11 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
IBinaryNaturalRelation R = (IBinaryNaturalRelation) implicitUnaryMap.getValue(i); IBinaryNaturalRelation R = (IBinaryNaturalRelation) implicitUnaryMap.getValue(i);
IntSet s = R.getRelated(number); IntSet s = R.getRelated(number);
if (s != null) { if (s != null) {
result = new CompoundIterator<INodeWithNumber>(new ImplicitDefIterator(op, s, v), result); result = new CompoundIterator<>(new ImplicitDefIterator(op, s, v), result);
} }
} }
List<AbstractStatement> list = new ArrayList<AbstractStatement>(); List<AbstractStatement> list = new ArrayList<>();
while (result.hasNext()) { while (result.hasNext()) {
list.add((AbstractStatement) result.next()); list.add((AbstractStatement) result.next());
} }

View File

@ -212,7 +212,7 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
* @return an List of instance keys corresponding to the integers in a set * @return an List of instance keys corresponding to the integers in a set
*/ */
List<InstanceKey> getInstances(IntSet set) { List<InstanceKey> getInstances(IntSet set) {
LinkedList<InstanceKey> result = new LinkedList<InstanceKey>(); LinkedList<InstanceKey> result = new LinkedList<>();
for (IntIterator it = set.intIterator(); it.hasNext();) { for (IntIterator it = set.intIterator(); it.hasNext();) {
int j = it.next(); int j = it.next();
result.add(getInstanceKey(j)); result.add(getInstanceKey(j));

View File

@ -483,7 +483,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
System.err.println("getIncomingPEIs " + bb); System.err.println("getIncomingPEIs " + bb);
} }
ControlFlowGraph<SSAInstruction, ISSABasicBlock> g = ir.getControlFlowGraph(); ControlFlowGraph<SSAInstruction, ISSABasicBlock> g = ir.getControlFlowGraph();
List<ProgramCounter> result = new ArrayList<ProgramCounter>(g.getPredNodeCount(bb)); List<ProgramCounter> result = new ArrayList<>(g.getPredNodeCount(bb));
for (Iterator<ISSABasicBlock> it = g.getPredNodes(bb); it.hasNext();) { for (Iterator<ISSABasicBlock> it = g.getPredNodes(bb); it.hasNext();) {
BasicBlock pred = (BasicBlock) it.next(); BasicBlock pred = (BasicBlock) it.next();
if (DEBUG) { if (DEBUG) {
@ -1167,7 +1167,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
System.err.println("Add side effect, dispatch to " + instruction + " for " + params); System.err.println("Add side effect, dispatch to " + instruction + " for " + params);
} }
final List<PointerKey> pks = new ArrayList<PointerKey>(params.size()); final List<PointerKey> pks = new ArrayList<>(params.size());
params.foreach(x -> { params.foreach(x -> {
if (!contentsAreInvariant(symbolTable, du, instruction.getUse(x))) { if (!contentsAreInvariant(symbolTable, du, instruction.getUse(x))) {
pks.add(getBuilder().getPointerKeyForLocal(node, instruction.getUse(x))); pks.add(getBuilder().getPointerKeyForLocal(node, instruction.getUse(x)));

View File

@ -54,8 +54,8 @@ public class SmushedAllocationSiteInNode extends AbstractTypeInNode {
@Override @Override
public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) { public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) {
return new MapIterator<NewSiteReference,Pair<CGNode, NewSiteReference>>( return new MapIterator<>(
new FilterIterator<NewSiteReference>( new FilterIterator<>(
getNode().iterateNewSites(), getNode().iterateNewSites(),
o -> o.getDeclaredType().equals(getConcreteType().getReference())), o -> o.getDeclaredType().equals(getConcreteType().getReference())),
object -> Pair.make(getNode(), object)); object -> Pair.make(getNode(), object));

View File

@ -83,7 +83,7 @@ public class SmushedAllocationSiteInstanceKeys implements InstanceKeyFactory {
@Override @Override
public <T> InstanceKey getInstanceKeyForConstant(TypeReference type, T S) { public <T> InstanceKey getInstanceKeyForConstant(TypeReference type, T S) {
if (options.getUseConstantSpecificKeys()) if (options.getUseConstantSpecificKeys())
return new ConstantKey<T>(S, cha.lookupClass(type)); return new ConstantKey<>(S, cha.lookupClass(type));
else else
return new ConcreteTypeKey(cha.lookupClass(type)); return new ConcreteTypeKey(cha.lookupClass(type));
} }

View File

@ -261,7 +261,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
throw new IllegalArgumentException("null type"); throw new IllegalArgumentException("null type");
} }
if (disambiguateConstants() || isReflectiveType(type)) { if (disambiguateConstants() || isReflectiveType(type)) {
return new ConstantKey<T>(S, getClassHierarchy().lookupClass(type)); return new ConstantKey<>(S, getClassHierarchy().lookupClass(type));
} else { } else {
return classBased.getInstanceKeyForConstant(type, S); return classBased.getInstanceKeyForConstant(type, S);
} }

View File

@ -143,7 +143,7 @@ public class TypeBasedPointerAnalysis extends AbstractPointerAnalysis {
int index = getInstanceKeyMapping().add(new ConcreteTypeKey(klass)); int index = getInstanceKeyMapping().add(new ConcreteTypeKey(klass));
s.add(index); s.add(index);
} }
return new OrdinalSet<InstanceKey>(s, getInstanceKeyMapping()); return new OrdinalSet<>(s, getInstanceKeyMapping());
} }
private IClass inferType(PointerKey key) { private IClass inferType(PointerKey key) {

View File

@ -70,9 +70,9 @@ public final class CallGraphPruning {
System.out.println("Running optimization with depth: " + depth); System.out.println("Running optimization with depth: " + depth);
} }
this.marked = new LinkedList<CGNode>(); this.marked = new LinkedList<>();
this.keep = new HashSet<CGNode>(); this.keep = new HashSet<>();
this.visited = new LinkedList<CGNode>(); this.visited = new LinkedList<>();
this.depth = depth; this.depth = depth;
this.pruningPolicy = policy; this.pruningPolicy = policy;
@ -107,8 +107,8 @@ public final class CallGraphPruning {
private void addDepth(CGNode node) { private void addDepth(CGNode node) {
LinkedList<CGNode> A = new LinkedList<CGNode>(); LinkedList<CGNode> A = new LinkedList<>();
LinkedList<CGNode> B = new LinkedList<CGNode>(); LinkedList<CGNode> B = new LinkedList<>();
int i = depth; int i = depth;
A.add(node); A.add(node);
while (i > 0) { while (i > 0) {

View File

@ -55,7 +55,7 @@ public class PrunedCallGraph implements CallGraph {
@Override @Override
public Iterator<CGNode> iterator() { public Iterator<CGNode> iterator() {
Iterator<CGNode> tmp = cg.iterator(); Iterator<CGNode> tmp = cg.iterator();
Collection<CGNode> col = new LinkedList<CGNode>(); Collection<CGNode> col = new LinkedList<>();
while (tmp.hasNext()) { while (tmp.hasNext()) {
CGNode n = tmp.next(); CGNode n = tmp.next();
if (keep.contains(n)) { if (keep.contains(n)) {
@ -96,7 +96,7 @@ public class PrunedCallGraph implements CallGraph {
@Override @Override
public Iterator<CGNode> getPredNodes(CGNode n) { public Iterator<CGNode> getPredNodes(CGNode n) {
Iterator<CGNode> tmp = cg.getPredNodes(n); Iterator<CGNode> tmp = cg.getPredNodes(n);
Collection<CGNode> col = new LinkedList<CGNode>(); Collection<CGNode> col = new LinkedList<>();
while (tmp.hasNext()) { while (tmp.hasNext()) {
CGNode no = tmp.next(); CGNode no = tmp.next();
if (keep.contains(no) && !removedEdge(no, n)) { if (keep.contains(no) && !removedEdge(no, n)) {
@ -124,7 +124,7 @@ public class PrunedCallGraph implements CallGraph {
@Override @Override
public Iterator<CGNode> getSuccNodes(CGNode n) { public Iterator<CGNode> getSuccNodes(CGNode n) {
Iterator<CGNode> tmp = cg.getSuccNodes(n); Iterator<CGNode> tmp = cg.getSuccNodes(n);
Collection<CGNode> col = new LinkedList<CGNode>(); Collection<CGNode> col = new LinkedList<>();
while (tmp.hasNext()) { while (tmp.hasNext()) {
CGNode no = tmp.next(); CGNode no = tmp.next();
if (keep.contains(no) && !removedEdge(n, no)) { if (keep.contains(no) && !removedEdge(n, no)) {
@ -218,7 +218,7 @@ public class PrunedCallGraph implements CallGraph {
@Override @Override
public Iterator<CGNode> iterateNodes(IntSet s) { public Iterator<CGNode> iterateNodes(IntSet s) {
Iterator<CGNode> tmp = cg.iterateNodes(s); Iterator<CGNode> tmp = cg.iterateNodes(s);
Collection<CGNode> col = new LinkedList<CGNode>(); Collection<CGNode> col = new LinkedList<>();
while (tmp.hasNext()) { while (tmp.hasNext()) {
CGNode n = tmp.next(); CGNode n = tmp.next();
if (keep.contains(n)) { if (keep.contains(n)) {
@ -287,7 +287,7 @@ public class PrunedCallGraph implements CallGraph {
@Override @Override
public Collection<CGNode> getEntrypointNodes() { public Collection<CGNode> getEntrypointNodes() {
Collection<CGNode> tmp = cg.getEntrypointNodes(); Collection<CGNode> tmp = cg.getEntrypointNodes();
Set<CGNode> ret = new HashSet<CGNode>(); Set<CGNode> ret = new HashSet<>();
for (CGNode n : tmp) { for (CGNode n : tmp) {
if (keep.contains(n)) { if (keep.contains(n)) {
ret.add(n); ret.add(n);
@ -310,7 +310,7 @@ public class PrunedCallGraph implements CallGraph {
@Override @Override
public Set<CGNode> getNodes(MethodReference m) { public Set<CGNode> getNodes(MethodReference m) {
Set<CGNode> tmp = cg.getNodes(m); Set<CGNode> tmp = cg.getNodes(m);
Set<CGNode> ret = new HashSet<CGNode>(); Set<CGNode> ret = new HashSet<>();
for (CGNode n : tmp) { for (CGNode n : tmp) {
if (keep.contains(n)) { if (keep.contains(n)) {
ret.add(n); ret.add(n);
@ -332,7 +332,7 @@ public class PrunedCallGraph implements CallGraph {
return null; return null;
} }
Set<CGNode> tmp = cg.getPossibleTargets(node, site); Set<CGNode> tmp = cg.getPossibleTargets(node, site);
Set<CGNode> ret = new HashSet<CGNode>(); Set<CGNode> ret = new HashSet<>();
for (CGNode n : tmp) { for (CGNode n : tmp) {
if (keep.contains(n) && !removedEdge(node, n)) { if (keep.contains(n) && !removedEdge(node, n)) {
ret.add(n); ret.add(n);

View File

@ -55,7 +55,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
/** /**
* Graph implementation we delegate to. * Graph implementation we delegate to.
*/ */
final private NumberedGraph<BasicBlockInContext<T>> g = new SlowSparseNumberedGraph<BasicBlockInContext<T>>(2); final private NumberedGraph<BasicBlockInContext<T>> g = new SlowSparseNumberedGraph<>(2);
/** /**
* Governing call graph * Governing call graph
@ -190,8 +190,8 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
if (pb.equals(cfg.entry())) { if (pb.equals(cfg.entry())) {
// entry block has no instructions // entry block has no instructions
BasicBlockInContext<T> p = new BasicBlockInContext<T>(n, pb); BasicBlockInContext<T> p = new BasicBlockInContext<>(n, pb);
BasicBlockInContext<T> b = new BasicBlockInContext<T>(n, bb); BasicBlockInContext<T> b = new BasicBlockInContext<>(n, bb);
g.addEdge(p, b); g.addEdge(p, b);
continue; continue;
} }
@ -204,14 +204,14 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
if (inst instanceof SSAAbstractInvokeInstruction) { if (inst instanceof SSAAbstractInvokeInstruction) {
if (CALL_TO_RETURN_EDGES) { if (CALL_TO_RETURN_EDGES) {
// Add a "normal" edge from the predecessor block to this block. // Add a "normal" edge from the predecessor block to this block.
BasicBlockInContext<T> p = new BasicBlockInContext<T>(n, pb); BasicBlockInContext<T> p = new BasicBlockInContext<>(n, pb);
BasicBlockInContext<T> b = new BasicBlockInContext<T>(n, bb); BasicBlockInContext<T> b = new BasicBlockInContext<>(n, bb);
g.addEdge(p, b); g.addEdge(p, b);
} }
} else { } else {
// previous instruction is not a call instruction. // previous instruction is not a call instruction.
BasicBlockInContext<T> p = new BasicBlockInContext<T>(n, pb); BasicBlockInContext<T> p = new BasicBlockInContext<>(n, pb);
BasicBlockInContext<T> b = new BasicBlockInContext<T>(n, bb); BasicBlockInContext<T> b = new BasicBlockInContext<>(n, bb);
if (!g.containsNode(p) || !g.containsNode(b)) { if (!g.containsNode(p) || !g.containsNode(b)) {
assert g.containsNode(p) : "IPCFG does not contain " + p; assert g.containsNode(p) : "IPCFG does not contain " + p;
assert g.containsNode(b) : "IPCFG does not contain " + b; assert g.containsNode(b) : "IPCFG does not contain " + b;
@ -238,9 +238,9 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
private void addEdgesFromExitToReturn(CGNode caller, T returnBlock, CGNode target, private void addEdgesFromExitToReturn(CGNode caller, T returnBlock, CGNode target,
ControlFlowGraph<SSAInstruction, ? extends T> targetCFG) { ControlFlowGraph<SSAInstruction, ? extends T> targetCFG) {
T texit = targetCFG.exit(); T texit = targetCFG.exit();
BasicBlockInContext<T> exit = new BasicBlockInContext<T>(target, texit); BasicBlockInContext<T> exit = new BasicBlockInContext<>(target, texit);
addNodeForBasicBlockIfNeeded(exit); addNodeForBasicBlockIfNeeded(exit);
BasicBlockInContext<T> ret = new BasicBlockInContext<T>(caller, returnBlock); BasicBlockInContext<T> ret = new BasicBlockInContext<>(caller, returnBlock);
if (!g.containsNode(exit) || !g.containsNode(ret)) { if (!g.containsNode(exit) || !g.containsNode(ret)) {
assert g.containsNode(exit) : "IPCFG does not contain " + exit; assert g.containsNode(exit) : "IPCFG does not contain " + exit;
assert g.containsNode(ret) : "IPCFG does not contain " + ret; assert g.containsNode(ret) : "IPCFG does not contain " + ret;
@ -261,9 +261,9 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
private void addEdgesFromCallToEntry(CGNode caller, T callBlock, CGNode target, private void addEdgesFromCallToEntry(CGNode caller, T callBlock, CGNode target,
ControlFlowGraph<SSAInstruction, ? extends T> targetCFG) { ControlFlowGraph<SSAInstruction, ? extends T> targetCFG) {
T tentry = targetCFG.entry(); T tentry = targetCFG.entry();
BasicBlockInContext<T> entry = new BasicBlockInContext<T>(target, tentry); BasicBlockInContext<T> entry = new BasicBlockInContext<>(target, tentry);
addNodeForBasicBlockIfNeeded(entry); addNodeForBasicBlockIfNeeded(entry);
BasicBlockInContext<T> call = new BasicBlockInContext<T>(caller, callBlock); BasicBlockInContext<T> call = new BasicBlockInContext<>(caller, callBlock);
if (!g.containsNode(entry) || !g.containsNode(call)) { if (!g.containsNode(entry) || !g.containsNode(call)) {
assert g.containsNode(entry) : "IPCFG does not contain " + entry; assert g.containsNode(entry) : "IPCFG does not contain " + entry;
assert g.containsNode(call) : "IPCFG does not contain " + call; assert g.containsNode(call) : "IPCFG does not contain " + call;
@ -325,16 +325,16 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
System.err.println("Adding edge " + ccfg.getBlockForInstruction(i) + " to " + entryBlock); System.err.println("Adding edge " + ccfg.getBlockForInstruction(i) + " to " + entryBlock);
} }
T callerBB = ccfg.getBlockForInstruction(i); T callerBB = ccfg.getBlockForInstruction(i);
BasicBlockInContext<T> b1 = new BasicBlockInContext<T>(caller, callerBB); BasicBlockInContext<T> b1 = new BasicBlockInContext<>(caller, callerBB);
// need to add a node for caller basic block, in case we haven't processed caller yet // need to add a node for caller basic block, in case we haven't processed caller yet
addNodeForBasicBlockIfNeeded(b1); addNodeForBasicBlockIfNeeded(b1);
BasicBlockInContext<T> b2 = new BasicBlockInContext<T>(n, entryBlock); BasicBlockInContext<T> b2 = new BasicBlockInContext<>(n, entryBlock);
g.addEdge(b1, b2); g.addEdge(b1, b2);
// also add edges from exit node to all return nodes (successor of call bb) // also add edges from exit node to all return nodes (successor of call bb)
for (Iterator<? extends T> succIter = ccfg.getSuccNodes(callerBB); succIter.hasNext();) { for (Iterator<? extends T> succIter = ccfg.getSuccNodes(callerBB); succIter.hasNext();) {
T returnBB = succIter.next(); T returnBB = succIter.next();
BasicBlockInContext<T> b3 = new BasicBlockInContext<T>(n, exitBlock); BasicBlockInContext<T> b3 = new BasicBlockInContext<>(n, exitBlock);
BasicBlockInContext<T> b4 = new BasicBlockInContext<T>(caller, returnBB); BasicBlockInContext<T> b4 = new BasicBlockInContext<>(caller, returnBB);
addNodeForBasicBlockIfNeeded(b4); addNodeForBasicBlockIfNeeded(b4);
g.addEdge(b3, b4); g.addEdge(b3, b4);
} }
@ -355,7 +355,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
if (DEBUG_LEVEL > 1) { if (DEBUG_LEVEL > 1) {
System.err.println("IPCFG Add basic block " + bb); System.err.println("IPCFG Add basic block " + bb);
} }
BasicBlockInContext<T> b = new BasicBlockInContext<T>(N, bb); BasicBlockInContext<T> b = new BasicBlockInContext<>(N, bb);
addNodeForBasicBlockIfNeeded(b); addNodeForBasicBlockIfNeeded(b);
} }
} }
@ -455,7 +455,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
ControlFlowGraph<SSAInstruction, T> cfg = getCFG(n); ControlFlowGraph<SSAInstruction, T> cfg = getCFG(n);
if (cfg != null) { if (cfg != null) {
for (T bb : cfg) { for (T bb : cfg) {
BasicBlockInContext<T> block = new BasicBlockInContext<T>(n, bb); BasicBlockInContext<T> block = new BasicBlockInContext<>(n, bb);
if (hasCall(block)) { if (hasCall(block)) {
addCalleeEdgesForCall(n, block); addCalleeEdgesForCall(n, block);
} }
@ -474,7 +474,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
ControlFlowGraph<SSAInstruction, T> cfg = getCFG(returnBlock); ControlFlowGraph<SSAInstruction, T> cfg = getCFG(returnBlock);
for (Iterator<? extends T> it = cfg.getPredNodes(returnBlock.getDelegate()); it.hasNext();) { for (Iterator<? extends T> it = cfg.getPredNodes(returnBlock.getDelegate()); it.hasNext();) {
T b = it.next(); T b = it.next();
final BasicBlockInContext<T> block = new BasicBlockInContext<T>(node, b); final BasicBlockInContext<T> block = new BasicBlockInContext<>(node, b);
if (hasCall(block)) { if (hasCall(block)) {
addCalleeEdgesForCall(node, block); addCalleeEdgesForCall(node, block);
} }
@ -519,7 +519,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
addEdgesFromExitToReturn(n, retBlock, tn, tcfg); addEdgesFromExitToReturn(n, retBlock, tn, tcfg);
if (irrelevantTargets) { if (irrelevantTargets) {
// Add a "normal" edge from the call block to the return block. // Add a "normal" edge from the call block to the return block.
g.addEdge(callBlock, new BasicBlockInContext<T>(n, retBlock)); g.addEdge(callBlock, new BasicBlockInContext<>(n, retBlock));
} }
} }
} }
@ -813,7 +813,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
ControlFlowGraph<SSAInstruction, ? extends T> cfg = getCFG(n); ControlFlowGraph<SSAInstruction, ? extends T> cfg = getCFG(n);
if (cfg != null) { if (cfg != null) {
T entry = cfg.entry(); T entry = cfg.entry();
return new BasicBlockInContext<T>(n, entry); return new BasicBlockInContext<>(n, entry);
} else { } else {
return null; return null;
} }
@ -822,7 +822,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
public BasicBlockInContext<T> getExit(CGNode n) { public BasicBlockInContext<T> getExit(CGNode n) {
ControlFlowGraph<SSAInstruction, ? extends T> cfg = getCFG(n); ControlFlowGraph<SSAInstruction, ? extends T> cfg = getCFG(n);
T entry = cfg.exit(); T entry = cfg.exit();
return new BasicBlockInContext<T>(n, entry); return new BasicBlockInContext<>(n, entry);
} }
/** /**
@ -839,7 +839,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
// a successor node is a return site if it is in the same // a successor node is a return site if it is in the same
// procedure, and is not the entry() node. // procedure, and is not the entry() node.
Predicate<BasicBlockInContext> isReturn = other -> !other.isEntryBlock() && node.equals(other.getNode()); Predicate<BasicBlockInContext> isReturn = other -> !other.isEntryBlock() && node.equals(other.getNode());
return new FilterIterator<BasicBlockInContext<T>>(getSuccNodes(callBlock), isReturn); return new FilterIterator<>(getSuccNodes(callBlock), isReturn);
} }
/** /**
@ -855,7 +855,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
final CGNode node = returnBlock.getNode(); final CGNode node = returnBlock.getNode();
Predicate<T> dispatchFilter = callBlock -> { Predicate<T> dispatchFilter = callBlock -> {
BasicBlockInContext<T> bb = new BasicBlockInContext<T>(node, callBlock); BasicBlockInContext<T> bb = new BasicBlockInContext<>(node, callBlock);
if (!hasCall(bb, cfg)) { if (!hasCall(bb, cfg)) {
return false; return false;
} }
@ -869,10 +869,10 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
Function<T, BasicBlockInContext<T>> toContext = object -> { Function<T, BasicBlockInContext<T>> toContext = object -> {
T b = object; T b = object;
return new BasicBlockInContext<T>(node, b); return new BasicBlockInContext<>(node, b);
}; };
MapIterator<T, BasicBlockInContext<T>> m = new MapIterator<T, BasicBlockInContext<T>>(it, toContext); MapIterator<T, BasicBlockInContext<T>> m = new MapIterator<>(it, toContext);
return new FilterIterator<BasicBlockInContext<T>>(m, isCall); return new FilterIterator<>(m, isCall);
} }
private final Predicate<BasicBlockInContext<T>> isCall = this::hasCall; private final Predicate<BasicBlockInContext<T>> isCall = this::hasCall;
@ -884,7 +884,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
ControlFlowGraph<SSAInstruction, T> cfg = getCFG(bb); ControlFlowGraph<SSAInstruction, T> cfg = getCFG(bb);
for (Iterator<? extends T> it = cfg.getPredNodes(bb.getDelegate()); it.hasNext();) { for (Iterator<? extends T> it = cfg.getPredNodes(bb.getDelegate()); it.hasNext();) {
T b = it.next(); T b = it.next();
if (hasCall(new BasicBlockInContext<T>(bb.getNode(), b))) { if (hasCall(new BasicBlockInContext<>(bb.getNode(), b))) {
return true; return true;
} }
} }

View File

@ -37,7 +37,7 @@ public class ExceptionPrunedCFG {
} }
public static <I, T extends IBasicBlock<I>> PrunedCFG<I, T> make(ControlFlowGraph<I, T> cfg) { public static <I, T extends IBasicBlock<I>> PrunedCFG<I, T> make(ControlFlowGraph<I, T> cfg) {
return PrunedCFG.make(cfg, new ExceptionEdgePruner<I, T>(cfg)); return PrunedCFG.make(cfg, new ExceptionEdgePruner<>(cfg));
} }
} }

View File

@ -51,7 +51,7 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
if (cfg == null) { if (cfg == null) {
throw new IllegalArgumentException("cfg is null"); throw new IllegalArgumentException("cfg is null");
} }
return new PrunedCFG<I, T>(cfg, filter); return new PrunedCFG<>(cfg, filter);
} }
private static class FilteredCFGEdges<I, T extends IBasicBlock<I>> implements NumberedEdgeManager<T> { private static class FilteredCFGEdges<I, T extends IBasicBlock<I>> implements NumberedEdgeManager<T> {
@ -68,24 +68,24 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
} }
public Iterator<T> getExceptionalSuccessors(final T N) { public Iterator<T> getExceptionalSuccessors(final T N) {
return new FilterIterator<T>(cfg.getExceptionalSuccessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasExceptionalEdge(N, o)); return new FilterIterator<>(cfg.getExceptionalSuccessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasExceptionalEdge(N, o));
} }
public Iterator<T> getNormalSuccessors(final T N) { public Iterator<T> getNormalSuccessors(final T N) {
return new FilterIterator<T>(cfg.getNormalSuccessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasNormalEdge(N, o)); return new FilterIterator<>(cfg.getNormalSuccessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasNormalEdge(N, o));
} }
public Iterator<T> getExceptionalPredecessors(final T N) { public Iterator<T> getExceptionalPredecessors(final T N) {
return new FilterIterator<T>(cfg.getExceptionalPredecessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasExceptionalEdge(o, N)); return new FilterIterator<>(cfg.getExceptionalPredecessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasExceptionalEdge(o, N));
} }
public Iterator<T> getNormalPredecessors(final T N) { public Iterator<T> getNormalPredecessors(final T N) {
return new FilterIterator<T>(cfg.getNormalPredecessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasNormalEdge(o, N)); return new FilterIterator<>(cfg.getNormalPredecessors(N).iterator(), o -> currentCFGNodes.containsNode(o) && filter.hasNormalEdge(o, N));
} }
@Override @Override
public Iterator<T> getSuccNodes(final T N) { public Iterator<T> getSuccNodes(final T N) {
return new FilterIterator<T>(cfg.getSuccNodes(N), o -> currentCFGNodes.containsNode(o) && (filter.hasNormalEdge(N, o) || filter.hasExceptionalEdge(N, o))); return new FilterIterator<>(cfg.getSuccNodes(N), o -> currentCFGNodes.containsNode(o) && (filter.hasNormalEdge(N, o) || filter.hasExceptionalEdge(N, o)));
} }
@Override @Override
@ -105,7 +105,7 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
@Override @Override
public Iterator<T> getPredNodes(final T N) { public Iterator<T> getPredNodes(final T N) {
return new FilterIterator<T>(cfg.getPredNodes(N), o -> currentCFGNodes.containsNode(o) && (filter.hasNormalEdge(o, N) || filter.hasExceptionalEdge(o, N))); return new FilterIterator<>(cfg.getPredNodes(N), o -> currentCFGNodes.containsNode(o) && (filter.hasNormalEdge(o, N) || filter.hasExceptionalEdge(o, N)));
} }
@Override @Override
@ -200,7 +200,7 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
} }
private Iterator<T> filterNodes(Iterator<T> nodeIterator) { private Iterator<T> filterNodes(Iterator<T> nodeIterator) {
return new FilterIterator<T>(nodeIterator, subset::contains); return new FilterIterator<>(nodeIterator, subset::contains);
} }
@Override @Override
@ -243,7 +243,7 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
private PrunedCFG(final ControlFlowGraph<I, T> cfg, final EdgeFilter<T> filter) { private PrunedCFG(final ControlFlowGraph<I, T> cfg, final EdgeFilter<T> filter) {
this.cfg = cfg; this.cfg = cfg;
Graph<T> temp = new AbstractNumberedGraph<T>() { Graph<T> temp = new AbstractNumberedGraph<T>() {
private final NumberedEdgeManager<T> edges = new FilteredCFGEdges<I, T>(cfg, cfg, filter); private final NumberedEdgeManager<T> edges = new FilteredCFGEdges<>(cfg, cfg, filter);
@Override @Override
protected NumberedNodeManager<T> getNodeManager() { protected NumberedNodeManager<T> getNodeManager() {
@ -262,8 +262,8 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
reachable.add(cfg.entry()); reachable.add(cfg.entry());
reachable.add(cfg.exit()); reachable.add(cfg.exit());
this.nodes = new FilteredNodes<T>(cfg, reachable); this.nodes = new FilteredNodes<>(cfg, reachable);
this.edges = new FilteredCFGEdges<I, T>(cfg, nodes, filter); this.edges = new FilteredCFGEdges<>(cfg, nodes, filter);
} }
@Override @Override
@ -278,7 +278,7 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
@Override @Override
public List<T> getExceptionalSuccessors(final T N) { public List<T> getExceptionalSuccessors(final T N) {
ArrayList<T> result = new ArrayList<T>(); ArrayList<T> result = new ArrayList<>();
for (Iterator<T> it = edges.getExceptionalSuccessors(N); it.hasNext();) { for (Iterator<T> it = edges.getExceptionalSuccessors(N); it.hasNext();) {
result.add(it.next()); result.add(it.next());
} }

View File

@ -37,7 +37,7 @@ public class ArrayOutOfBoundFilter implements ExceptionFilter<SSAInstruction> {
.getBoundsCheckNecessary().get(instruction); .getBoundsCheckNecessary().get(instruction);
if (unnecessary == UnnecessaryCheck.BOTH) { if (unnecessary == UnnecessaryCheck.BOTH) {
final LinkedList<FilteredException> result = new LinkedList<FilteredException>(); final LinkedList<FilteredException> result = new LinkedList<>();
result.add(new FilteredException( result.add(new FilteredException(
TypeReference.JavaLangArrayIndexOutOfBoundsException)); TypeReference.JavaLangArrayIndexOutOfBoundsException));

View File

@ -35,7 +35,7 @@ ExceptionFilter<SSAInstruction> {
public Collection<FilteredException> filteredExceptions( public Collection<FilteredException> filteredExceptions(
SSAInstruction instruction) { SSAInstruction instruction) {
if (this.analysis.nullPointerExceptionThrowState(instruction) == State.NOT_NULL) { if (this.analysis.nullPointerExceptionThrowState(instruction) == State.NOT_NULL) {
final LinkedList<FilteredException> result = new LinkedList<FilteredException>(); final LinkedList<FilteredException> result = new LinkedList<>();
result.add(new FilteredException( result.add(new FilteredException(
TypeReference.JavaLangNullPointerException)); TypeReference.JavaLangNullPointerException));
return result; return result;

View File

@ -40,7 +40,7 @@ public class CombinedInterproceduralExceptionFilter<Instruction> implements Inte
@Override @Override
public ExceptionFilter<Instruction> getFilter(CGNode node) { public ExceptionFilter<Instruction> getFilter(CGNode node) {
CombinedExceptionFilter<Instruction> result = new CombinedExceptionFilter<Instruction>(); CombinedExceptionFilter<Instruction> result = new CombinedExceptionFilter<>();
for (InterproceduralExceptionFilter<Instruction> exceptionFilter:filter) { for (InterproceduralExceptionFilter<Instruction> exceptionFilter:filter) {
result.add(exceptionFilter.getFilter(node)); result.add(exceptionFilter.getFilter(node));
} }

Some files were not shown because too many files have changed in this diff Show More