Remove redundant generic type parameters where possible

Instead, rely on Java's ability to infer type parameters in many
contexts.  This removes 665 Eclipse warnings.

Note: a few of these changes are to files under "test" subdirectories.
Presumably those are files that serve as test inputs rather than being
part of WALA code proper.  As far as I can tell, these changes do not
break any WALA tests.  But if any of those tests were specifically
intended to exercise WALA on code with non-inferred generic type
parameters, then I really should be leaving those alone.
This commit is contained in:
Ben Liblit 2017-03-11 21:20:51 -06:00
parent 1cf7f0f3d3
commit 994a70500f
242 changed files with 668 additions and 668 deletions

View File

@ -61,7 +61,7 @@ import com.ibm.wala.util.debug.Assertions;
public class JDT2CAstUtils {
public static Collection<CAstQualifier> mapModifiersToQualifiers(int modifiers, boolean isInterface, boolean isAnnotation) {
Set<CAstQualifier> quals = new LinkedHashSet<CAstQualifier>();
Set<CAstQualifier> quals = new LinkedHashSet<>();
if (isInterface)
quals.add(CAstQualifier.INTERFACE);
@ -299,7 +299,7 @@ public class JDT2CAstUtils {
}
public static Collection<IMethodBinding> getOverriddenMethod(IMethodBinding met) {
HashMap<ITypeBinding, IMethodBinding> overridden = new HashMap<ITypeBinding, IMethodBinding>();
HashMap<ITypeBinding, IMethodBinding> overridden = new HashMap<>();
if (met == null)
return null;
getMethodInClassOrSuperclass(met, met.getDeclaringClass(), true, overridden);

View File

@ -253,7 +253,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
public CAstEntity translateToCAst() {
List<CAstEntity> declEntities = new ArrayList<CAstEntity>();
List<CAstEntity> declEntities = new ArrayList<>();
for (Iterator<CAstEntity> iter = cu.types().iterator(); iter.hasNext();) {
AbstractTypeDeclaration decl = (AbstractTypeDeclaration) iter.next();
@ -422,13 +422,13 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
private CAstEntity createClassDeclaration(ASTNode n, List/* <BodyDeclaration> */bodyDecls,
List/* EnumConstantDeclaration */enumConstants, ITypeBinding typeBinding, String name, int modifiers,
boolean isInterface, boolean isAnnotation, WalkContext context) {
final List<CAstEntity> memberEntities = new ArrayList<CAstEntity>();
final List<CAstEntity> memberEntities = new ArrayList<>();
// find and collect all initializers (type Initializer) and field initializers (type VariableDeclarationFragment).
// instance initializer code will be inserted into each constructors.
// all static initializer code will be grouped together in its own entity.
ArrayList<ASTNode> inits = new ArrayList<ASTNode>();
ArrayList<ASTNode> staticInits = new ArrayList<ASTNode>();
ArrayList<ASTNode> inits = new ArrayList<>();
ArrayList<ASTNode> staticInits = new ArrayList<>();
if (enumConstants != null) {
for (Object decl : enumConstants) {
@ -582,7 +582,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
assert superCtor != null : "couldn't find constructor for anonymous class";
// PART II: make ctor with simply "super(a,b,c...)"
final Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<CAstNode, CAstEntity>();
final Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<>();
final MethodContext context = new MethodContext(oldContext, memberEntities);
MethodDeclaration fakeCtor = ast.newMethodDeclaration();
fakeCtor.setConstructor(true);
@ -592,7 +592,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
// PART IIa: make a fake JDT constructor method with the proper number of args
// Make fake args that will be passed
String[] fakeArguments = new String[superCtor.getParameterTypes().length + 1];
ArrayList<CAstType> paramTypes = new ArrayList<CAstType>(superCtor.getParameterTypes().length);
ArrayList<CAstType> paramTypes = new ArrayList<>(superCtor.getParameterTypes().length);
for (int i = 0; i < fakeArguments.length; i++)
fakeArguments[i] = (i == 0) ? "this" : ("argument" + i); // TODO: change to invalid name and don't use
// singlevariabledeclaration below
@ -744,7 +744,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
//
// add a method exactly like overridden that calls overriding
final Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<CAstNode, CAstEntity>();
final Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<>();
final MethodContext context = new MethodContext(oldContext, memberEntities);
CAstNode calltarget;
@ -755,7 +755,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
ITypeBinding paramTypes[] = overridden.getParameterTypes();
ArrayList<CAstNode> arguments = new ArrayList<CAstNode>();
ArrayList<CAstNode> arguments = new ArrayList<>();
int i = 0;
for (Object o : overriding.parameters()) {
SingleVariableDeclaration svd = (SingleVariableDeclaration) o;
@ -775,7 +775,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
// make parameters to new synthetic method
// use RETURN TYPE of overridden, everything else from overriding (including parameter names)
ArrayList<CAstType> paramCAstTypes = new ArrayList<CAstType>(overridden.getParameterTypes().length);
ArrayList<CAstType> paramCAstTypes = new ArrayList<>(overridden.getParameterTypes().length);
for (ITypeBinding paramType : overridden.getParameterTypes())
paramCAstTypes.add(fTypeDict.getCAstTypeFor(paramType));
return new ProcedureEntity(mdast, overriding, overridingBinding.getDeclaringClass(), memberEntities, context, paramCAstTypes,
@ -789,7 +789,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
private CAstEntity visit(MethodDeclaration n, ITypeBinding classBinding, WalkContext oldContext, ArrayList<ASTNode> inits) {
// pass in memberEntities to the context, later visit(New) etc. may add classes
final Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<CAstNode, CAstEntity>();
final Map<CAstNode, CAstEntity> memberEntities = new LinkedHashMap<>();
final MethodContext context = new MethodContext(oldContext, memberEntities); // LEFTOUT: in polyglot there is a
// class context in between method and
// root
@ -929,7 +929,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
this.annotations = annotations;
// from CodeBodyEntity
fEntities = new LinkedHashMap<CAstNode, Collection<CAstEntity>>();
fEntities = new LinkedHashMap<>();
for (Iterator keys = entities.keySet().iterator(); keys.hasNext();) {
CAstNode key = (CAstNode) keys.next();
fEntities.put(key, Collections.singleton(entities.get(key)));
@ -947,7 +947,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
}
if (parameterTypes == null) {
fParameterTypes = new ArrayList<CAstType>(fDecl.parameters().size());
fParameterTypes = new ArrayList<>(fDecl.parameters().size());
for (Object p : fDecl.parameters()) {
fParameterNames[i++] = ((SingleVariableDeclaration) p).getName().getIdentifier();
fParameterTypes.add(fTypeDict.getCAstTypeFor(((SingleVariableDeclaration) p).resolveBinding().getType()));
@ -962,7 +962,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
}
} else {
fParameterNames = new String[0];
fParameterTypes = new ArrayList<CAstType>(0); // static initializer
fParameterTypes = new ArrayList<>(0); // static initializer
}
}
@ -1093,7 +1093,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
@Override
public Collection<CAstType>/* <CAstType> */getExceptionTypes() {
if (fExceptionTypes == null) {
fExceptionTypes = new LinkedHashSet<CAstType>();
fExceptionTypes = new LinkedHashSet<>();
if (fDecl != null)
for (Object exception : fDecl.thrownExceptionTypes())
@ -1270,7 +1270,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
* (VariableDeclarationStatements) may expand to more than one CAstNode.
*/
private ArrayList<CAstNode> createBlock(Block n, WalkContext context) {
ArrayList<CAstNode> stmtNodes = new ArrayList<CAstNode>();
ArrayList<CAstNode> stmtNodes = new ArrayList<>();
for (Object s : n.statements())
visitNodeOrNodes((ASTNode) s, context, stmtNodes);
return stmtNodes;
@ -1316,7 +1316,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
* One VariableDeclarationStatement represents more than one CAstNode statement.
*/
private ArrayList<CAstNode> visit(VariableDeclarationStatement n, WalkContext context) {
ArrayList<CAstNode> result = new ArrayList<CAstNode>();
ArrayList<CAstNode> result = new ArrayList<>();
for (Object o : n.fragments())
result.add(visit((VariableDeclarationFragment) o, context));

View File

@ -129,7 +129,7 @@ public class JDTTypeDictionary extends CAstTypeDictionaryImpl {
// just ignore it
// TEST DOUBLE ARRAYS! and maybe ask someone?
assert fEltJdtType.isArray() || fEltJdtType.isClass() : "Non-primitive, non-reference array element type!";
Collection<CAstType> supers = new ArrayList<CAstType>();
Collection<CAstType> supers = new ArrayList<>();
for (ITypeBinding type : fEltJdtType.getInterfaces()) {
supers.add(getCAstTypeFor(type));
}
@ -175,7 +175,7 @@ public class JDTTypeDictionary extends CAstTypeDictionaryImpl {
.getSuperclass();
int N = fType.getInterfaces().length + 1;
fSuperTypes = new ArrayList<CAstType>(N);
fSuperTypes = new ArrayList<>(N);
// Following assumes that noone can call getSupertypes() before we have
// created CAstType's for every type in the program being analyzed.
fSuperTypes.add(getCAstTypeFor(superType));

View File

@ -129,8 +129,8 @@ public class ECJSourceModuleTranslator implements SourceModuleTranslator {
}
private Pair<String[],String[]> computeClassPath(AnalysisScope scope) {
List<String> sources = new LinkedList<String>();
List<String> libs = new LinkedList<String>();
List<String> sources = new LinkedList<>();
List<String> libs = new LinkedList<>();
for (ClassLoaderReference cl : scope.getLoaders()) {
while (cl != null) {
@ -174,7 +174,7 @@ public class ECJSourceModuleTranslator implements SourceModuleTranslator {
@SuppressWarnings("unchecked")
@Override
public void loadAllSources(Set<ModuleEntry> modules) {
List<String> sources = new LinkedList<String>();
List<String> sources = new LinkedList<>();
Map<String, ModuleEntry> sourceMap = HashMapFactory.make();
for(ModuleEntry m : modules) {
if (m.isSourceFile()) {

View File

@ -126,7 +126,7 @@ public abstract class IRTests {
protected static class EdgeAssertions implements IRAssertion {
public final String srcDescriptor;
public final List/* <String> */<String> tgtDescriptors = new ArrayList<String>();
public final List/* <String> */<String> tgtDescriptors = new ArrayList<>();
public EdgeAssertions(String srcDescriptor) {
this.srcDescriptor = srcDescriptor;

View File

@ -74,7 +74,7 @@ public class AstJavaModRef<T extends InstanceKey> extends AstModRef<T> {
@Override
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
return new AstJavaModVisitor<T>(n, result, h, pa);
return new AstJavaModVisitor<>(n, result, h, pa);
}
}

View File

@ -59,7 +59,7 @@ public class AstJavaSlicer extends Slicer {
}
public static Set<Statement> gatherStatements(CallGraph CG, Collection<CGNode> partialRoots, Predicate<SSAInstruction> filter) {
Set<Statement> result = new HashSet<Statement>();
Set<Statement> result = new HashSet<>();
for (Iterator<CGNode> ns = DFS.getReachableNodes(CG, partialRoots).iterator(); ns.hasNext();) {
CGNode n = ns.next();
IR nir = n.getIR();
@ -110,7 +110,7 @@ public class AstJavaSlicer extends Slicer {
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis<InstanceKey> pa,
Collection<CGNode> partialRoots, boolean multiThreadedCode) throws IllegalArgumentException, CancelException {
CallGraph pcg = PartialCallGraph.make(CG, new LinkedHashSet<CGNode>(partialRoots));
CallGraph pcg = PartialCallGraph.make(CG, new LinkedHashSet<>(partialRoots));
SDG sdg = new SDG(pcg, pa, new AstJavaModRef(), DataDependenceOptions.FULL, ControlDependenceOptions.FULL);
//System.err.println(("SDG:\n" + sdg));
Set<Statement> stmts = gatherAssertions(CG, partialRoots);

View File

@ -155,7 +155,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
@Override
public Collection<IClass> getDirectInterfaces() {
List<IClass> result = new ArrayList<IClass>();
List<IClass> result = new ArrayList<>();
for (Iterator iter = superTypeNames.iterator(); iter.hasNext();) {
TypeName name = (TypeName) iter.next();
IClass domoType = lookupClass(name);
@ -540,7 +540,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
}
public IClass defineType(CAstEntity type, String typeName, CAstEntity owner) {
Collection<TypeName> superTypeNames = new ArrayList<TypeName>();
Collection<TypeName> superTypeNames = new ArrayList<>();
for (Iterator superTypes = type.getType().getSupertypes().iterator(); superTypes.hasNext();) {
superTypeNames.add(toWALATypeName(((CAstType) superTypes.next())));
}

View File

@ -55,7 +55,7 @@ public class NuValidatorHtmlParser implements IHtmlParser {
parser.setXmlPolicy(XmlViolationPolicy.ALLOW);
parser.setContentHandler(new ContentHandler() {
private Locator locator;
private Stack<ITag> tags = new Stack<ITag>();;
private Stack<ITag> tags = new Stack<>();;
private int countLines(char[] ch, int start, int length) {
LineNumberReader r = new LineNumberReader(new StringReader (new String(ch, start, length)));
@ -99,7 +99,7 @@ public class NuValidatorHtmlParser implements IHtmlParser {
@Override
public Set<java.util.Map.Entry<String, Pair<String,Position>>> entrySet() {
if (es == null) {
es = new HashSet<Map.Entry<String,Pair<String,Position>>>();
es = new HashSet<>();
for(int i = 0; i < atts.getLength(); i++) {
final int index = i;
es.add(new Map.Entry<String,Pair<String,Position>>() {

View File

@ -658,7 +658,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
@Override
public CAstNode visitArrayLiteral(ArrayLiteral node, WalkContext arg) {
int index = 0;
List<CAstNode> eltNodes = new ArrayList<CAstNode>(2 * node.getElements().size());
List<CAstNode> eltNodes = new ArrayList<>(2 * node.getElements().size());
eltNodes.add(((isPrologueScript(arg)) ? makeBuiltinNew("Array") : handleNew(arg, "Array", null)));
for(AstNode elt : node.getElements()) {
if (elt instanceof EmptyExpression) {
@ -695,7 +695,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
@Override
public CAstNode visitBlock(Block node, WalkContext arg) {
List<CAstNode> nodes = new ArrayList<CAstNode>();
List<CAstNode> nodes = new ArrayList<>();
for(Node child : node) {
nodes.add(visit((AstNode)child, arg));
}
@ -995,7 +995,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
@Override
public CAstNode visitFunctionNode(FunctionNode fn, WalkContext context) {
WalkContext child = new FunctionContext(context, fn);
List<CAstNode> body = new ArrayList<CAstNode>();
List<CAstNode> body = new ArrayList<>();
body.add(visit(fn.getBody(), child));
String name;
@ -1238,7 +1238,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
@Override
public CAstNode visitScope(Scope node, WalkContext arg) {
List<CAstNode> nodes = new ArrayList<CAstNode>();
List<CAstNode> nodes = new ArrayList<>();
for(Node child : node) {
nodes.add(visit((AstNode)child, arg));
}
@ -2415,7 +2415,7 @@ private CAstNode[] walkChildren(final Node n, WalkContext context) {
final FunctionContext child = new ScriptContext(new RootContext(), top, top.getSourceName());
TranslatingVisitor tv = new TranslatingVisitor();
List<CAstNode> body = new ArrayList<CAstNode>();
List<CAstNode> body = new ArrayList<>();
for(Node bn : top) {
body.add(tv.visit((AstNode)bn, child));
}

View File

@ -92,7 +92,7 @@ public class CAstDumper {
}
private Collection<CAstEntity> dumpScopedEntities(CAstEntity entity, int indent, StringBuilder buf) {
ArrayList<CAstEntity> scopedEntities = new ArrayList<CAstEntity>();
ArrayList<CAstEntity> scopedEntities = new ArrayList<>();
Map<CAstEntity, CAstNode> m = HashMapFactory.make();
for(Entry<CAstNode, Collection<CAstEntity>> e : entity.getAllScopedEntities().entrySet())
for(CAstEntity scopedEntity : e.getValue()) {

View File

@ -340,7 +340,7 @@ public abstract class TestPointerAnalyses {
PrototypeFieldVertex proto = new PrototypeFieldVertex(PrototypeField.__proto__, o);
if (hg.containsNode(proto)) {
return
new MapIterator<Object,ObjectVertex>(hg.getSuccNodes(proto),
new MapIterator<>(hg.getSuccNodes(proto),
new Function<Object,ObjectVertex>() {
@Override
public ObjectVertex apply(Object object) {

View File

@ -92,7 +92,7 @@ public class FlowGraph implements Iterable<Vertex> {
private GraphReachability<Vertex,FuncVertex> optimistic_closure;
public FlowGraph() {
this.graph = new SlowSparseNumberedGraph<Vertex>(1);
this.graph = new SlowSparseNumberedGraph<>(1);
this.factory = new VertexFactory();
}
@ -125,8 +125,8 @@ public class FlowGraph implements Iterable<Vertex> {
// compute transitive closure
GraphReachability<Vertex, T> optimistic_closure =
new GraphReachability<Vertex,T>(
new InvertedGraph<Vertex>(pruned_flowgraph),
new GraphReachability<>(
new InvertedGraph<>(pruned_flowgraph),
new Predicate<Vertex>() {
@Override public boolean test(Vertex o) {
return type.isInstance(o);
@ -187,7 +187,7 @@ public class FlowGraph implements Iterable<Vertex> {
private GraphReachability<Vertex,ObjectVertex> pointerAnalysis = computeClosure(graph, monitor, ObjectVertex.class);
private final ExtensionGraph<Vertex> dataflow = new ExtensionGraph<Vertex>(graph);
private final ExtensionGraph<Vertex> dataflow = new ExtensionGraph<>(graph);
protected IR getIR(final IAnalysisCacheView cache, FuncVertex func) {
return cache.getIR(func.getConcreteType().getMethod(AstMethodReference.fnSelector));
@ -288,8 +288,8 @@ public class FlowGraph implements Iterable<Vertex> {
return new Iterable<PointerKey> () {
@Override
public Iterator<PointerKey> iterator() {
return new CompoundIterator<PointerKey>(factory.getArgVertices().iterator(),
new CompoundIterator<PointerKey>(factory.getRetVertices().iterator(),
return new CompoundIterator<>(factory.getArgVertices().iterator(),
new CompoundIterator<>(factory.getRetVertices().iterator(),
new CompoundIterator<PointerKey>(factory.getVarVertices().iterator(),
factory.getPropVertices().iterator())));
}

View File

@ -16,7 +16,7 @@ import java.util.List;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
public class CompositeFileMapping implements FileMapping {
private final List<FileMapping> mappings = new ArrayList<FileMapping>(2);
private final List<FileMapping> mappings = new ArrayList<>(2);
public CompositeFileMapping(FileMapping a, FileMapping b) {
addMapping(a);

View File

@ -38,10 +38,10 @@ public class DefaultSourceExtractor extends DomLessSourceExtractor{
private final HashMap<String, String> constructors = HashMapFactory.make();
private final Stack<String> stack = new Stack<String>();
private final Stack<String> stack = new Stack<>();
private final Stack<ITag> forms = new Stack<ITag>();
private final Set<Pair<ITag,String>> sets = new HashSet<Pair<ITag,String>>();
private final Stack<ITag> forms = new Stack<>();
private final Set<Pair<ITag,String>> sets = new HashSet<>();
public HtmlCallBack(URL entrypointUrl, IUrlResolver urlResolver) {
super(entrypointUrl, urlResolver);

View File

@ -227,7 +227,7 @@ public class ArgumentSpecialization {
} else if ((s = CAstPattern.match(destructuredCallPattern, root)) != null) {
if (argRefs.containsKey(s.getSingle("name").getValue().toString())) {
List<CAstNode> x = new ArrayList<CAstNode>();
List<CAstNode> x = new ArrayList<>();
CAstNode ref = handleArgumentRef(argRefs.get(s.getSingle("name").getValue().toString()));
if (ref != null) {
x.add(ref);

View File

@ -145,7 +145,7 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
boolean suffix = funName.startsWith("suffix:");
if (suffix) {
Set<CGNode> nodes = new HashSet<CGNode>();
Set<CGNode> nodes = new HashSet<>();
String tail = funName.substring(7);
for (CGNode n : CG) {
if (n.getMethod().getReference().getDeclaringClass().getName().toString().endsWith(tail)) {
@ -190,7 +190,7 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
throws IOException {
try {
TranslatorToCAst toCAst = getTranslatorFactory().make(new CAstImpl(), M);
final Set<String> names = new HashSet<String>();
final Set<String> names = new HashSet<>();
JSAstTranslator toIR = new JSAstTranslator(cl) {
@Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
@ -268,7 +268,7 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
@Override
public Iterator<? extends ModuleEntry> getEntries() {
return new NonNullSingletonIterator<Bootstrap>(this);
return new NonNullSingletonIterator<>(this);
}
@Override

View File

@ -379,7 +379,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
S.addAll(set);
}
}
pointsToSet = new OrdinalSet<InstanceKey>(S, analysis.getInstanceKeyMapping());
pointsToSet = new OrdinalSet<>(S, analysis.getInstanceKeyMapping());
}
@Override

View File

@ -53,7 +53,7 @@ public class LoadFileTargetSelector implements MethodTargetSelector {
IMethod target = base.getCalleeTarget(caller, site, receiver);
if (target != null && target.getReference().equals(loadFileFunRef)) {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
SSAInstruction call = caller.getIR().getInstructions()[caller.getIR().getCallInstructionIndices(site).intIterator().next()];
if (call.getNumberOfUses() > 1) {
LocalPointerKey fileNameV = new LocalPointerKey(caller, call.getUse(1));

View File

@ -65,7 +65,7 @@ public class RecursionCheckContextSelector implements ContextSelector {
if (!recursionPossible(callee)) {
return false;
}
LinkedList<Pair<Context,Collection<IMethod>>> worklist = new LinkedList<Pair<Context,Collection<IMethod>>>();
LinkedList<Pair<Context,Collection<IMethod>>> worklist = new LinkedList<>();
worklist.push(Pair.make(baseContext, (Collection<IMethod>)Collections.singleton(callee)));
while (!worklist.isEmpty()) {
Pair<Context, Collection<IMethod>> p = worklist.removeFirst();
@ -115,7 +115,7 @@ public class RecursionCheckContextSelector implements ContextSelector {
System.err.println("context " + baseContext);
return false;
}
Collection<IMethod> newEncountered = new ArrayList<IMethod>(curEncountered);
Collection<IMethod> newEncountered = new ArrayList<>(curEncountered);
newEncountered.add(method);
worklist.add(Pair.make(callerNode.getContext(),newEncountered));
return true;

View File

@ -32,7 +32,7 @@ public abstract class Correlation {
protected Correlation(String indexName, Set<String> flownThroughLocals) {
this.indexName = indexName;
this.flownThroughLocals = new HashSet<String>(flownThroughLocals);
this.flownThroughLocals = new HashSet<>(flownThroughLocals);
}
public String getIndexName() {

View File

@ -89,11 +89,11 @@ public class CorrelationFinder {
public static CorrelationSummary findCorrelatedAccesses(IMethod method, IR ir) {
AstMethod astMethod = (AstMethod)method;
DefUse du = new DefUse(ir);
OrdinalSetMapping<SSAInstruction> instrIndices = new ObjectArrayMapping<SSAInstruction>(ir.getInstructions());
OrdinalSetMapping<SSAInstruction> instrIndices = new ObjectArrayMapping<>(ir.getInstructions());
CorrelationSummary summary = new CorrelationSummary(method, instrIndices);
// collect all dynamic property writes in the method
LinkedList<AbstractReflectivePut> puts = new LinkedList<AbstractReflectivePut>();
LinkedList<AbstractReflectivePut> puts = new LinkedList<>();
for(SSAInstruction inst : Iterator2Iterable.make(ir.iterateNormalInstructions()))
if(inst instanceof AbstractReflectivePut)
puts.addFirst((AbstractReflectivePut)inst);
@ -133,7 +133,7 @@ public class CorrelationFinder {
MutableIntSet reached = new BitVectorIntSet();
reached.add(get.getDef());
// saturate reached by following def-use chains through phi instructions and across function calls
LinkedList<Integer> worklist = new LinkedList<Integer>();
LinkedList<Integer> worklist = new LinkedList<>();
MutableIntSet done = new BitVectorIntSet();
worklist.add(get.getDef());
while(!worklist.isEmpty()) {
@ -192,7 +192,7 @@ public class CorrelationFinder {
}
private static Set<String> getSourceLevelNames(IR ir, int index, IntSet vs) {
Set<String> res = new HashSet<String>();
Set<String> res = new HashSet<>();
for(IntIterator iter=vs.intIterator();iter.hasNext();) {
String name = getSourceLevelName(ir, index, iter.next());
if(name != null)
@ -203,7 +203,7 @@ public class CorrelationFinder {
// checks whether the given SSA variable must always be assigned a numeric value
private static boolean mustBeNumeric(IR ir, DefUse du, int v) {
LinkedList<Integer> worklist = new LinkedList<Integer>();
LinkedList<Integer> worklist = new LinkedList<>();
MutableIntSet done = new BitVectorIntSet();
worklist.add(v);
while(!worklist.isEmpty()) {
@ -244,7 +244,7 @@ public class CorrelationFinder {
}
private void printCorrelatedAccesses(Map<IMethod, CorrelationSummary> summaries) {
List<Pair<Position, String>> correlations = new ArrayList<Pair<Position,String>>();
List<Pair<Position, String>> correlations = new ArrayList<>();
for(CorrelationSummary summary : summaries.values())
correlations.addAll(summary.pp());

View File

@ -42,7 +42,7 @@ public final class CorrelationSummary {
}
public List<Pair<Position, String>> pp() {
List<Pair<Position, String>> res = new ArrayList<Pair<Position, String>>();
List<Pair<Position, String>> res = new ArrayList<>();
for(Correlation correlation : correlations) {
res.add(Pair.make(correlation.getStartPosition(positions), correlation.pp(positions)));
}

View File

@ -102,7 +102,7 @@ public abstract class CAstRewriterExt extends CAstRewriter<NodePos, NoKey> {
}
}
private final HashSet<Entity> entities_to_add = HashSetFactory.make();
private final Stack<CAstEntity> entities = new Stack<CAstEntity>();
private final Stack<CAstEntity> entities = new Stack<>();
public CAstNode addNode(CAstNode node, CAstControlFlowMap flow) {
Set<CAstNode> nodes = extra_nodes.get(flow);

View File

@ -179,7 +179,7 @@ import com.ibm.wala.util.debug.UnimplementedError;
*
*/
public class ClosureExtractor extends CAstRewriterExt {
private LinkedList<ExtractionPolicy> policies = new LinkedList<ExtractionPolicy>();
private LinkedList<ExtractionPolicy> policies = new LinkedList<>();
private final ExtractionPolicyFactory policyFactory;
private static final boolean LOCALISE = true;
@ -237,7 +237,7 @@ public class ClosureExtractor extends CAstRewriterExt {
if(regions == null || usesArguments(root)) {
return copyNode(root, cfg, context, nodeMap);
} else {
ArrayList<CAstNode> copied_children = new ArrayList<CAstNode>();
ArrayList<CAstNode> copied_children = new ArrayList<>();
int next_child = 0;
// code in between regions is handled by invoking copyNodes, the regions themselves by extractRegion
for(ExtractionRegion region : regions) {
@ -445,8 +445,8 @@ public class ClosureExtractor extends CAstRewriterExt {
*
* The whole thing is then wrapped into a block.
*/
ArrayList<CAstNode> prologue = new ArrayList<CAstNode>();
ArrayList<CAstNode> fun_body_stmts = new ArrayList<CAstNode>();
ArrayList<CAstNode> prologue = new ArrayList<>();
ArrayList<CAstNode> fun_body_stmts = new ArrayList<>();
// if we are extracting a block, unwrap it
if(extractingBlock) {
@ -588,7 +588,7 @@ public class ClosureExtractor extends CAstRewriterExt {
* a null pointer exception on the call; these are infeasible, but we add them anyway to get the same AST
* as with a manual extraction.
*/
List<CAstNode> args = new ArrayList<CAstNode>();
List<CAstNode> args = new ArrayList<>();
CAstNode funExpr = Ast.makeNode(FUNCTION_EXPR, Ast.makeConstant(new_entity));
args.add(funExpr);
context.setCallSite(funExpr);
@ -609,7 +609,7 @@ public class ClosureExtractor extends CAstRewriterExt {
addExnFlow(call, null, entity, context);
// if the extracted code contains jumps, we need to insert some fix-up code
List<CAstNode> stmts = new ArrayList<CAstNode>(prologue);
List<CAstNode> stmts = new ArrayList<>(prologue);
if(context.containsJump()) {
CAstNode decl = Ast.makeNode(ASSIGN,
addExnFlow(makeVarRef("re$"), JavaScriptTypes.ReferenceError, entity, context),

View File

@ -151,7 +151,7 @@ public class CorrelatedPairExtractionPolicy extends ExtractionPolicy {
List<ExtractionRegion> regions = region_map.get(region_info.fst);
if(regions == null)
region_map.put(region_info.fst, regions = new LinkedList<ExtractionRegion>());
region_map.put(region_info.fst, regions = new LinkedList<>());
for(int i=0;i<regions.size();++i) {
ExtractionRegion region2 = regions.get(i);
if(region2.getEnd() <= region_info.snd.getStart())

View File

@ -96,7 +96,7 @@ class ExtractedFunction implements CAstEntity {
private void computeParms() {
if(this.parms == null) {
ArrayList<String> parms = new ArrayList<String>();
ArrayList<String> parms = new ArrayList<>();
parms.add(name);
parms.add("this");
parms.addAll(pos.getParameters());

View File

@ -22,7 +22,7 @@ import com.ibm.wala.cast.tree.CAstNode;
*
*/
public class NodeLabeller {
private ArrayList<CAstNode> nodes = new ArrayList<CAstNode>();
private ArrayList<CAstNode> nodes = new ArrayList<>();
/**
* Adds a node to the mapping if it is not present yet.

View File

@ -169,6 +169,6 @@ public class JavaScriptModRef<T extends InstanceKey> extends AstModRef<T> {
@Override
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
return new JavaScriptModVisitor<T>(n, result, h, pa);
return new JavaScriptModVisitor<>(n, result, h, pa);
}
}

View File

@ -151,7 +151,7 @@ public interface JavaScriptTranslatorToCAst extends TranslatorToCAst {
private final CAstSourcePositionRecorder pos = new CAstSourcePositionRecorder();
private final CAstControlFlowRecorder cfg = new CAstControlFlowRecorder(pos);
private final Map<CAstNode, Collection<CAstEntity>> scopedEntities = HashMapFactory.make();
private final Vector<CAstNode> initializers = new Vector<CAstNode>();
private final Vector<CAstNode> initializers = new Vector<>();
protected FunctionContext(C parent, T s) {
super(parent);
@ -262,7 +262,7 @@ public interface JavaScriptTranslatorToCAst extends TranslatorToCAst {
* helps to handle cases like x.y.f(), where we would like to store x.y in
* baseVar, but not x when we recurse.
*/
private final Set<T> baseFor = new HashSet<T>();
private final Set<T> baseFor = new HashSet<>();
private int operationIndex;

View File

@ -160,7 +160,7 @@ public class CallGraph2JSON {
private static String joinWith(Iterable<String> lst, String sep) {
StringBuffer res = new StringBuffer();
ArrayList<String> strings = new ArrayList<String>();
ArrayList<String> strings = new ArrayList<>();
for(String s : lst)
if(s != null)
strings.add(s);

View File

@ -35,7 +35,7 @@ public class JsPaPanel extends PaPanel {
private static final long serialVersionUID = 1L;
private MutableMapping<List<ObjectPropertyCatalogKey>> instanceKeyIdToObjectPropertyCatalogKey = MutableMapping.<List<ObjectPropertyCatalogKey>> make();
private List<AstGlobalPointerKey> globalsPointerKeys = new ArrayList<AstGlobalPointerKey>();
private List<AstGlobalPointerKey> globalsPointerKeys = new ArrayList<>();
public JsPaPanel(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
super(cg, pa);
@ -65,7 +65,7 @@ public class JsPaPanel extends PaPanel {
@Override
protected List<PointerKey> getPointerKeysUnderInstanceKey(InstanceKey ik) {
List<PointerKey> ret = new ArrayList<PointerKey>();
List<PointerKey> ret = new ArrayList<>();
ret.addAll(super.getPointerKeysUnderInstanceKey(ik));
int ikIndex = pa.getInstanceKeyMapping().getMappedIndex(ik);
ret.addAll(nonNullList(instanceKeyIdToObjectPropertyCatalogKey.getMappedObject(ikIndex)));
@ -77,7 +77,7 @@ public class JsPaPanel extends PaPanel {
@Override
protected List<Object> getRootNodes() {
List<Object> ret = new ArrayList<Object>(2);
List<Object> ret = new ArrayList<>(2);
ret.add(cgNodesRoot);
ret.add(globalsRoot);
return ret;
@ -85,7 +85,7 @@ public class JsPaPanel extends PaPanel {
@Override
protected List<Object> getChildrenFor(Object node) {
List<Object> ret = new ArrayList<Object>();
List<Object> ret = new ArrayList<>();
if (node == cgNodesRoot){
for (int nodeId = 0 ; nodeId < cg.getNumberOfNodes(); nodeId++){
CGNode cgNode = cg.getNode(nodeId);

View File

@ -41,13 +41,13 @@ import junit.framework.Assert;
public abstract class TestCAstTranslator extends WalaTestCase {
protected static class TranslatorAssertions {
private final Set<String> classes = new HashSet<String>();
private final Set<String> classes = new HashSet<>();
private final Map<String, String> supers = new HashMap<String, String>();
private final Map<String, String> supers = new HashMap<>();
private final Set<Pair<String, String>> instanceFields = new HashSet<Pair<String, String>>();
private final Set<Pair<String, String>> instanceFields = new HashSet<>();
private final Set<Pair<String, String>> staticFields = new HashSet<Pair<String, String>>();
private final Set<Pair<String, String>> staticFields = new HashSet<>();
private final Map<Pair<String, Object>, Object> instanceMethods = HashMapFactory.make();

View File

@ -136,7 +136,7 @@ public abstract class TestCallGraphShape extends WalaTestCase {
check_target: for (int j = 0; j < ((String[]) assertionData[i][1]).length; j++) {
Iterator srcs = (assertionData[i][0] instanceof String) ? getNodes(CG, (String) assertionData[i][0]).iterator()
: new NonNullSingletonIterator<CGNode>(CG.getFakeRootNode());
: new NonNullSingletonIterator<>(CG.getFakeRootNode());
Assert.assertTrue("cannot find " + assertionData[i][0], srcs.hasNext());

View File

@ -76,7 +76,7 @@ public class DelegatingAstPointerKeys implements AstPointerKeyFactory {
@Override
public Iterator<PointerKey> getPointerKeysForReflectedFieldWrite(InstanceKey I, InstanceKey F) {
List<PointerKey> result = new LinkedList<PointerKey>();
List<PointerKey> result = new LinkedList<>();
if (F instanceof ConstantKey) {
PointerKey ifk = getInstanceFieldPointerKeyForConstant(I, (ConstantKey) F);
@ -120,7 +120,7 @@ public class DelegatingAstPointerKeys implements AstPointerKeyFactory {
if (F instanceof ConstantKey) {
PointerKey ifk = getInstanceFieldPointerKeyForConstant(I, (ConstantKey) F);
if (ifk != null) {
return new NonNullSingletonIterator<PointerKey>(ifk);
return new NonNullSingletonIterator<>(ifk);
}
}
return new NonNullSingletonIterator<PointerKey>(ReflectedFieldPointerKey.mapped(new ConcreteTypeKey(getFieldNameType(F)), I));

View File

@ -98,12 +98,12 @@ abstract public class ScopeMappingInstanceKeys implements InstanceKeyFactory {
Iterator<CGNode> result = EmptyIterator.instance();
for (CGNode callerOfConstructor : constructorCallers) {
if (callerOfConstructor.getMethod().getReference().getDeclaringClass().getName().toString().equals(name.snd)) {
result = new CompoundIterator<CGNode>(result, new NonNullSingletonIterator<CGNode>(callerOfConstructor));
result = new CompoundIterator<>(result, new NonNullSingletonIterator<>(callerOfConstructor));
} else {
PointerKey funcKey = builder.getPointerKeyForLocal(callerOfConstructor, 1);
for (InstanceKey funcPtr : builder.getPointerAnalysis().getPointsToSet(funcKey)) {
if (funcPtr instanceof ScopeMappingInstanceKey) {
result = new CompoundIterator<CGNode>(result, ((ScopeMappingInstanceKey) funcPtr).getFunargNodes(name));
result = new CompoundIterator<>(result, ((ScopeMappingInstanceKey) funcPtr).getFunargNodes(name));
}
}
}
@ -138,7 +138,7 @@ abstract public class ScopeMappingInstanceKeys implements InstanceKeyFactory {
@Override
public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) {
return new FilterIterator<Pair<CGNode, NewSiteReference>>(
return new FilterIterator<>(
base.getCreationSites(CG),
new Predicate<Pair<CGNode, NewSiteReference>>() {
@Override public boolean test(Pair<CGNode, NewSiteReference> o) {

View File

@ -91,7 +91,7 @@ public class AstModRef<T extends InstanceKey> extends ModRef<T> {
@Override
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h) {
return new AstRefVisitor<T>(n, result, pa, (AstHeapModel)h);
return new AstRefVisitor<>(n, result, pa, (AstHeapModel)h);
}
protected static class AstModVisitor<T extends InstanceKey>

View File

@ -116,7 +116,7 @@ public abstract class AbstractSSAConversion {
protected AbstractSSAConversion(IR ir, SSAOptions options) {
this.CFG = ir.getControlFlowGraph();
this.DF = new DominanceFrontiers<ISSABasicBlock>(ir.getControlFlowGraph(), ir.getControlFlowGraph().entry());
this.DF = new DominanceFrontiers<>(ir.getControlFlowGraph(), ir.getControlFlowGraph().entry());
this.dominatorTree = DF.dominatorTree();
this.flags = new int[2 * ir.getControlFlowGraph().getNumberOfNodes()];
this.instructions = getInstructions(ir);
@ -142,7 +142,7 @@ public abstract class AbstractSSAConversion {
}
protected final Iterator<SSAInstruction> iterateInstructions(IR ir) {
return new ArrayIterator<SSAInstruction>(getInstructions(ir));
return new ArrayIterator<>(getInstructions(ir));
}
protected void init() {
@ -173,7 +173,7 @@ public abstract class AbstractSSAConversion {
private void addDefiningBlock(Set<SSACFG.BasicBlock>[] A, SSACFG.BasicBlock BB, int i) {
if (!skip(i)) {
if (A[i] == null) {
A[i] = new LinkedHashSet<SSACFG.BasicBlock>(2);
A[i] = new LinkedHashSet<>(2);
}
A[i].add(BB);
}
@ -191,7 +191,7 @@ public abstract class AbstractSSAConversion {
setWork(X, 0);
}
Set<BasicBlock> W = new LinkedHashSet<BasicBlock>();
Set<BasicBlock> W = new LinkedHashSet<>();
for (int V = 0; V < assignmentMap.length; V++) {
// some things (e.g. constants) have no defs at all
@ -285,7 +285,7 @@ public abstract class AbstractSSAConversion {
// SEARCH(Y)
// SearchPostRec(X)
ArrayList<Frame> stack = new ArrayList<Frame>();
ArrayList<Frame> stack = new ArrayList<>();
SearchPreRec(X);
push(stack, new Frame(X, dominatorTree.getSuccNodes(X)));

View File

@ -575,7 +575,7 @@ public class SSAConversion extends AbstractSSAConversion {
protected void initializeVariables() {
for (int V = 1; V <= getMaxValueNumber(); V++) {
if (!skip(V)) {
R[V] = new ArrayList<CopyPropagationRecord>();
R[V] = new ArrayList<>();
}
}

View File

@ -209,7 +209,7 @@ public class LiveAnalysis {
/**
* Create the solver
*/
final BitVectorSolver<ISSABasicBlock> S = new BitVectorSolver<ISSABasicBlock>(new IKilldallFramework<ISSABasicBlock, BitVectorVariable>() {
final BitVectorSolver<ISSABasicBlock> S = new BitVectorSolver<>(new IKilldallFramework<ISSABasicBlock, BitVectorVariable>() {
private final Graph<ISSABasicBlock> G = GraphInverter.invert(cfg);
@Override

View File

@ -34,7 +34,7 @@ class AbstractFieldEntity extends AbstractDataEntity {
this.name = name;
this.declaringClass = declaringClass;
this.modifiers = new HashSet<CAstQualifier>();
this.modifiers = new HashSet<>();
if (modifiers != null) {
this.modifiers.addAll(modifiers);
}

View File

@ -31,7 +31,7 @@ public class AbstractGlobalEntity extends AbstractDataEntity {
public AbstractGlobalEntity(String name, CAstType type, Set<CAstQualifier> modifiers) {
this.name = name;
this.type = type;
this.modifiers = new HashSet<CAstQualifier>();
this.modifiers = new HashSet<>();
if (modifiers != null) {
this.modifiers.addAll(modifiers);
}

View File

@ -562,7 +562,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
private int lastIndex = -2;
private final List<SSAInstruction> instructions = new ArrayList<SSAInstruction>();
private final List<SSAInstruction> instructions = new ArrayList<>();
@Override
public int getNumber() {
@ -704,12 +704,12 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
public final class IncipientCFG extends SparseNumberedGraph<PreBasicBlock> {
protected class Unwind {
private final Map<PreBasicBlock, UnwindState> unwindData = new LinkedHashMap<PreBasicBlock, UnwindState>();
private final Map<PreBasicBlock, UnwindState> unwindData = new LinkedHashMap<>();
/**
* a cache of generated blocks
*/
private final Map<Pair<UnwindState, Pair<PreBasicBlock, Boolean>>, PreBasicBlock> code = new LinkedHashMap<Pair<UnwindState, Pair<PreBasicBlock, Boolean>>, PreBasicBlock>();
private final Map<Pair<UnwindState, Pair<PreBasicBlock, Boolean>>, PreBasicBlock> code = new LinkedHashMap<>();
void setUnwindState(PreBasicBlock block, UnwindState context) {
unwindData.put(block, context);
@ -820,21 +820,21 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
private Unwind unwind = null;
private final List<PreBasicBlock> blocks = new ArrayList<PreBasicBlock>();
private final List<PreBasicBlock> blocks = new ArrayList<>();
private PreBasicBlock entryBlock;
private final Map<CAstNode, PreBasicBlock> nodeToBlock = new LinkedHashMap<CAstNode, PreBasicBlock>();
private final Map<CAstNode, PreBasicBlock> nodeToBlock = new LinkedHashMap<>();
private final Map<Object, Set<Pair<PreBasicBlock, Boolean>>> delayedEdges = new LinkedHashMap<Object, Set<Pair<PreBasicBlock, Boolean>>>();
private final Map<Object, Set<Pair<PreBasicBlock, Boolean>>> delayedEdges = new LinkedHashMap<>();
private final Object exitMarker = new Object();
private final Set<PreBasicBlock> deadBlocks = new LinkedHashSet<PreBasicBlock>();
private final Set<PreBasicBlock> deadBlocks = new LinkedHashSet<>();
private final Set<PreBasicBlock> normalToExit = new LinkedHashSet<PreBasicBlock>();
private final Set<PreBasicBlock> normalToExit = new LinkedHashSet<>();
private final Set<PreBasicBlock> exceptionalToExit = new LinkedHashSet<PreBasicBlock>();
private final Set<PreBasicBlock> exceptionalToExit = new LinkedHashSet<>();
private Position[] linePositions = new Position[10];
@ -1563,9 +1563,9 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
public abstract class AbstractScope implements Scope {
private final Scope parent;
private final Map<String, Symbol> values = new LinkedHashMap<String, Symbol>();
private final Map<String, Symbol> values = new LinkedHashMap<>();
private final Map<String, String> caseInsensitiveNames = new LinkedHashMap<String, String>();
private final Map<String, String> caseInsensitiveNames = new LinkedHashMap<>();
protected abstract SymbolTable getUnderlyingSymtab();
@ -2016,8 +2016,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
private Scope makeGlobalScope() {
final Map<String, AbstractSymbol> globalSymbols = new LinkedHashMap<String, AbstractSymbol>();
final Map<String, String> caseInsensitiveNames = new LinkedHashMap<String, String>();
final Map<String, AbstractSymbol> globalSymbols = new LinkedHashMap<>();
final Map<String, String> caseInsensitiveNames = new LinkedHashMap<>();
return new Scope() {
@Override
@ -2183,8 +2183,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
protected Scope makeTypeScope(final CAstEntity type, final Scope parent) {
final Map<String, AbstractSymbol> typeSymbols = new LinkedHashMap<String, AbstractSymbol>();
final Map<String, String> caseInsensitiveNames = new LinkedHashMap<String, String>();
final Map<String, AbstractSymbol> typeSymbols = new LinkedHashMap<>();
final Map<String, String> caseInsensitiveNames = new LinkedHashMap<>();
return new Scope() {
private final String mapName(String nm) {
String mappedName = caseInsensitiveNames.get(nm.toLowerCase());
@ -2541,7 +2541,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
* maps nodes in the current function to the value number holding their value
* or, for constants, to their constant value.
*/
private final Map<CAstNode, Integer> results = new LinkedHashMap<CAstNode, Integer>();
private final Map<CAstNode, Integer> results = new LinkedHashMap<>();
public CodeEntityContext(WalkContext parent, Scope entityScope, CAstEntity s) {
super(parent, s);
@ -2839,7 +2839,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
Pair<Pair<String, String>, Integer>[] EN = null;
if (exposedNamesForReadSet != null || exposedNamesForWriteSet != null) {
Set<Pair<Pair<String, String>, Integer>> exposedNamesSet = new HashSet<Pair<Pair<String, String>, Integer>>();
Set<Pair<Pair<String, String>, Integer>> exposedNamesSet = new HashSet<>();
if (exposedNamesForReadSet != null) {
exposedNamesSet.addAll(exposedNamesForReadSet);
}
@ -2850,7 +2850,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
if (exposedNamesForReadSet != null) {
Set<String> readOnlyNames = new HashSet<String>();
Set<String> readOnlyNames = new HashSet<>();
for (Pair<Pair<String, String>, Integer> v : exposedNamesForReadSet) {
if (entityName != null && entityName.equals(v.fst.snd)) {
readOnlyNames.add(v.fst.fst);
@ -2883,7 +2883,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
if (accesses != null) {
Set<String> parents = new LinkedHashSet<String>();
Set<String> parents = new LinkedHashSet<>();
for (Iterator<Access> ACS = accesses.iterator(); ACS.hasNext();) {
Access AC = ACS.next();
if (AC.variableDefiner != null) {
@ -4270,7 +4270,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
int v = context.getValue(switchValue);
Collection<Object> caseLabels = ctrl.getTargetLabels(n);
Map<Object, PreBasicBlock> labelToBlock = new LinkedHashMap<Object, PreBasicBlock>();
Map<Object, PreBasicBlock> labelToBlock = new LinkedHashMap<>();
for (Iterator kases = caseLabels.iterator(); kases.hasNext();) {
Object x = kases.next();
if (x != CAstControlFlowMap.SWITCH_DEFAULT) {
@ -4673,7 +4673,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
private final ModuleEntry module;
private final Map<CAstEntity, String> entityNames = new LinkedHashMap<CAstEntity, String>();
private final Map<CAstEntity, String> entityNames = new LinkedHashMap<>();
public RootContext(CAstEntity N, ModuleEntry module) {
this.N = N;

View File

@ -12,7 +12,7 @@ import com.ibm.wala.cast.tree.rewrite.CAstRewriterFactory;
import com.ibm.wala.classLoader.ModuleEntry;
public class RewritingTranslatorToCAst implements TranslatorToCAst {
private final List<CAstRewriterFactory> rewriters = new LinkedList<CAstRewriterFactory>();
private final List<CAstRewriterFactory> rewriters = new LinkedList<>();
protected final ModuleEntry M;
private final TranslatorToCAst base;

View File

@ -54,7 +54,7 @@ public abstract class CAstAbstractLoader implements IClassLoader {
/**
* warnings generated while loading each module
*/
private final Map<ModuleEntry, Set<Warning>> errors = new HashMap<ModuleEntry, Set<Warning>>();
private final Map<ModuleEntry, Set<Warning>> errors = new HashMap<>();
public CAstAbstractLoader(IClassHierarchy cha, IClassLoader parent) {
this.cha = cha;
@ -82,7 +82,7 @@ public abstract class CAstAbstractLoader implements IClassLoader {
}
private Iterator<ModuleEntry> getMessages(final byte severity) {
return new MapIterator<Map.Entry<ModuleEntry,Set<Warning>>, ModuleEntry>(new FilterIterator<Map.Entry<ModuleEntry,Set<Warning>>>(errors.entrySet().iterator(), new Predicate<Map.Entry<ModuleEntry,Set<Warning>>>() {
return new MapIterator<>(new FilterIterator<Map.Entry<ModuleEntry,Set<Warning>>>(errors.entrySet().iterator(), new Predicate<Map.Entry<ModuleEntry,Set<Warning>>>() {
@Override public boolean test(Entry<ModuleEntry, Set<Warning>> o) {
for(Warning w : o.getValue()) {
if (w.getLevel() == severity) {

View File

@ -95,7 +95,7 @@ public abstract class CAstAbstractModuleLoader extends CAstAbstractLoader {
final CAst ast = new CAstImpl();
// convert everything to CAst
final Set<Pair<CAstEntity, ModuleEntry>> topLevelEntities = new LinkedHashSet<Pair<CAstEntity, ModuleEntry>>();
final Set<Pair<CAstEntity, ModuleEntry>> topLevelEntities = new LinkedHashSet<>();
for (Iterator<Module> mes = modules.iterator(); mes.hasNext();) {
translateModuleToCAst(mes.next(), ast, topLevelEntities);
}

View File

@ -40,15 +40,15 @@ import com.ibm.wala.cast.tree.CAstSourcePositionMap;
public class CAstControlFlowRecorder implements CAstControlFlowMap {
private final CAstSourcePositionMap src;
private final Map<CAstNode, Object> CAstToNode = new LinkedHashMap<CAstNode, Object>();
private final Map<CAstNode, Object> CAstToNode = new LinkedHashMap<>();
private final Map<Object, CAstNode> nodeToCAst = new LinkedHashMap<Object, CAstNode>();
private final Map<Object, CAstNode> nodeToCAst = new LinkedHashMap<>();
private final Map<Key, Object> table = new LinkedHashMap<Key, Object>();
private final Map<Key, Object> table = new LinkedHashMap<>();
private final Map<Object, Set<Object>> labelMap = new LinkedHashMap<Object, Set<Object>>();
private final Map<Object, Set<Object>> labelMap = new LinkedHashMap<>();
private final Map<Object, Set<Object>> sourceMap = new LinkedHashMap<Object, Set<Object>>();
private final Map<Object, Set<Object>> sourceMap = new LinkedHashMap<>();
/**
* for optimizing {@link #getMappedNodes()}; methods that change the set of
@ -126,7 +126,7 @@ public class CAstControlFlowRecorder implements CAstControlFlowMap {
public Collection<CAstNode> getMappedNodes() {
Collection<CAstNode> nodes = cachedMappedNodes;
if (nodes == null) {
nodes = new LinkedHashSet<CAstNode>();
nodes = new LinkedHashSet<>();
for (Iterator<Key> keys = table.keySet().iterator(); keys.hasNext();) {
Key key = keys.next();
nodes.add(nodeToCAst.get(key.from));
@ -159,12 +159,12 @@ public class CAstControlFlowRecorder implements CAstControlFlowMap {
Set<Object> ls = labelMap.get(from);
if (ls == null)
labelMap.put(from, ls = new LinkedHashSet<Object>(2));
labelMap.put(from, ls = new LinkedHashSet<>(2));
ls.add(label);
Set<Object> ss = sourceMap.get(to);
if (ss == null)
sourceMap.put(to, ss = new LinkedHashSet<Object>(2));
sourceMap.put(to, ss = new LinkedHashSet<>(2));
ss.add(from);
}

View File

@ -309,7 +309,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
protected Map<CAstNode, Collection<CAstEntity>> copyChildren(CAstNode root, Map<Pair<CAstNode, K>, CAstNode> nodeMap,
Map<CAstNode, Collection<CAstEntity>> children) {
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<CAstNode, Collection<CAstEntity>>();
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
@ -319,7 +319,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
CAstNode newNode = entry.getValue();
if (children.containsKey(oldNode)) {
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
Set<CAstEntity> newEntities = new LinkedHashSet<>();
newChildren.put(newNode, newEntities);
for (Iterator oldEntities = ((Collection) children.get(oldNode)).iterator(); oldEntities.hasNext();) {
newEntities.add(rewrite((CAstEntity) oldEntities.next()));
@ -331,7 +331,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
CAstNode key = entry.getKey();
if (key == null) {
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
Set<CAstEntity> newEntities = new LinkedHashSet<>();
newChildren.put(key, newEntities);
for (Iterator oldEntities = ((Collection) entry.getValue()).iterator(); oldEntities.hasNext();) {
newEntities.add(rewrite((CAstEntity) oldEntities.next()));
@ -448,11 +448,11 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
} else if (recursive) {
Map<CAstNode, Collection<CAstEntity>> children = root.getAllScopedEntities();
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<CAstNode, Collection<CAstEntity>>();
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>();
for (Iterator<Map.Entry<CAstNode, Collection<CAstEntity>>> keys = children.entrySet().iterator(); keys.hasNext();) {
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
CAstNode key = entry.getKey();
Set<CAstEntity> newValues = new LinkedHashSet<CAstEntity>();
Set<CAstEntity> newValues = new LinkedHashSet<>();
newChildren.put(key, newValues);
for (Iterator es = entry.getValue().iterator(); es.hasNext();) {
newValues.add(rewrite((CAstEntity) es.next()));

View File

@ -80,7 +80,7 @@ public class CAstFunctions {
}
public static Iterator<CAstNode> findAll(CAstNode tree, Predicate<?> f) {
return new FilterIterator<CAstNode>(iterateNodes(tree), f);
return new FilterIterator<>(iterateNodes(tree), f);
}
}

View File

@ -102,7 +102,7 @@ public class CAstPattern {
((List<CAstNode>) o).add(result);
} else {
assert o instanceof CAstNode;
List<Object> x = new ArrayList<Object>();
List<Object> x = new ArrayList<>();
x.add(o);
x.add(result);
put(name, x);
@ -472,7 +472,7 @@ public class CAstPattern {
result = new CAstPattern(name, CHILD_KIND, null);
} else if (patternString.startsWith("|(", start)) {
List<CAstPattern> alternatives = new ArrayList<CAstPattern>();
List<CAstPattern> alternatives = new ArrayList<>();
start += 2;
do {
alternatives.add(parse());
@ -517,7 +517,7 @@ public class CAstPattern {
result = new CAstPattern(name, kind, null);
} else {
List<CAstPattern> children = new ArrayList<CAstPattern>();
List<CAstPattern> children = new ArrayList<>();
start = patternString.indexOf('(', start) + 1;
do {
children.add(parse());

View File

@ -30,7 +30,7 @@ public class SourceBuffer {
BufferedReader reader = new BufferedReader(p.getReader());
String currentLine = null;
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();
int offset = 0, line = 0;
do {
currentLine = reader.readLine();

View File

@ -114,11 +114,11 @@ public class PruneArrayOutOfBoundExceptionEdge {
ArrayOutOfBoundsAnalysis arrayBoundsAnalysis = new ArrayOutOfBoundsAnalysis(ir);
IntraproceduralNullPointerAnalysis nullPointerAnalysis = new IntraproceduralNullPointerAnalysis(ir);
CombinedExceptionFilter<SSAInstruction> filter = new CombinedExceptionFilter<SSAInstruction>();
CombinedExceptionFilter<SSAInstruction> filter = new CombinedExceptionFilter<>();
filter.add(new ArrayOutOfBoundFilter(arrayBoundsAnalysis));
filter.add(new NullPointerExceptionFilter(nullPointerAnalysis));
ExceptionFilter2EdgeFilter<ISSABasicBlock> edgeFilter = new ExceptionFilter2EdgeFilter<ISSABasicBlock>(filter, cha, cfg);
ExceptionFilter2EdgeFilter<ISSABasicBlock> edgeFilter = new ExceptionFilter2EdgeFilter<>(filter, cha, cfg);
PrunedCFG<SSAInstruction, ISSABasicBlock> prunedCfg = PrunedCFG.make(cfg, edgeFilter);
return Pair.make(cfg, prunedCfg);
@ -195,8 +195,8 @@ public class PruneArrayOutOfBoundExceptionEdge {
private boolean checkExceptionalSuccessors(ISSABasicBlock block, SSACFG cfg, PrunedCFG<SSAInstruction, ISSABasicBlock> prunedCfg,
IMethod method, String identifyer) {
boolean isEdgeRemoved = false;
LinkedHashSet<ISSABasicBlock> exceptionalSuccessorCfg = new LinkedHashSet<ISSABasicBlock>(cfg.getExceptionalSuccessors(block));
LinkedHashSet<ISSABasicBlock> exceptionalSuccessorPruned = new LinkedHashSet<ISSABasicBlock>(
LinkedHashSet<ISSABasicBlock> exceptionalSuccessorCfg = new LinkedHashSet<>(cfg.getExceptionalSuccessors(block));
LinkedHashSet<ISSABasicBlock> exceptionalSuccessorPruned = new LinkedHashSet<>(
prunedCfg.getExceptionalSuccessors(block));
if (!exceptionalSuccessorCfg.equals(exceptionalSuccessorPruned)) {
@ -229,8 +229,8 @@ public class PruneArrayOutOfBoundExceptionEdge {
}
private void checkNormalSuccessors(SSACFG cfg, PrunedCFG<SSAInstruction, ISSABasicBlock> prunedCfg, ISSABasicBlock block) {
LinkedHashSet<ISSABasicBlock> normalSuccessorCfg = new LinkedHashSet<ISSABasicBlock>(cfg.getNormalSuccessors(block));
LinkedHashSet<ISSABasicBlock> normalSuccessorPruned = new LinkedHashSet<ISSABasicBlock>(prunedCfg.getNormalSuccessors(block));
LinkedHashSet<ISSABasicBlock> normalSuccessorCfg = new LinkedHashSet<>(cfg.getNormalSuccessors(block));
LinkedHashSet<ISSABasicBlock> normalSuccessorPruned = new LinkedHashSet<>(prunedCfg.getNormalSuccessors(block));
collector.checkThat("", normalSuccessorPruned, equalTo(normalSuccessorCfg));
}

View File

@ -69,24 +69,24 @@ public class ExtensionGraphTest {
@Test
public void testAugment() {
NumberedGraph<String> base = makeBaseGraph();
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<String>(base)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<>(base)));
NumberedGraph<String> x = new ExtensionGraph<String>(base);
NumberedGraph<String> x = new ExtensionGraph<>(base);
augmentA(x);
Assert.assertEquals("base+A has 5 SCCs", 5, IteratorUtil.count(new SCCIterator<String>(x)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<String>(base)));
Assert.assertEquals("base+A has 5 SCCs", 5, IteratorUtil.count(new SCCIterator<>(x)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<>(base)));
NumberedGraph<String> y = new ExtensionGraph<String>(x);
NumberedGraph<String> y = new ExtensionGraph<>(x);
augmentB(y);
Assert.assertEquals("base+A+B has 7 SCCs", 7, IteratorUtil.count(new SCCIterator<String>(y)));
Assert.assertEquals("base+A has 5 SCCs", 5, IteratorUtil.count(new SCCIterator<String>(x)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<String>(base)));
Assert.assertEquals("base+A+B has 7 SCCs", 7, IteratorUtil.count(new SCCIterator<>(y)));
Assert.assertEquals("base+A has 5 SCCs", 5, IteratorUtil.count(new SCCIterator<>(x)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<>(base)));
NumberedGraph<String> z = new ExtensionGraph<String>(y);
NumberedGraph<String> z = new ExtensionGraph<>(y);
augmentC(z);
Assert.assertEquals("base+A+B+C has 3 SCCs", 3, IteratorUtil.count(new SCCIterator<String>(z)));
Assert.assertEquals("base+A+B has 7 SCCs", 7, IteratorUtil.count(new SCCIterator<String>(y)));
Assert.assertEquals("base+A has 5 SCCs", 5, IteratorUtil.count(new SCCIterator<String>(x)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<String>(base)));
Assert.assertEquals("base+A+B+C has 3 SCCs", 3, IteratorUtil.count(new SCCIterator<>(z)));
Assert.assertEquals("base+A+B has 7 SCCs", 7, IteratorUtil.count(new SCCIterator<>(y)));
Assert.assertEquals("base+A has 5 SCCs", 5, IteratorUtil.count(new SCCIterator<>(x)));
Assert.assertEquals("base has 8 SCCs", 8, IteratorUtil.count(new SCCIterator<>(base)));
}
}

View File

@ -99,7 +99,7 @@ public class FloydWarshallTest extends WalaTestCase {
}
public static NumberedGraph<Node> makeGraph() {
NumberedGraph<Node> G = new DelegatingNumberedGraph<Node>();
NumberedGraph<Node> G = new DelegatingNumberedGraph<>();
for(int i = 0; i <= 8; i++) {
G.addNode(new Node(i));
@ -169,9 +169,9 @@ public class FloydWarshallTest extends WalaTestCase {
}
public static Set<List<Node>> expectedPaths(NumberedGraph<Node> G) {
Set<List<Node>> paths = new HashSet<List<Node>>();
paths.add(new LinkedList<Node>(Arrays.asList(G.getNode(2),G.getNode(3),G.getNode(4),G.getNode(6))));
paths.add(new LinkedList<Node>(Arrays.asList(G.getNode(2),G.getNode(3),G.getNode(5),G.getNode(7))));
Set<List<Node>> paths = new HashSet<>();
paths.add(new LinkedList<>(Arrays.asList(G.getNode(2),G.getNode(3),G.getNode(4),G.getNode(6))));
paths.add(new LinkedList<>(Arrays.asList(G.getNode(2),G.getNode(3),G.getNode(5),G.getNode(7))));
return paths;
}
}

View File

@ -127,7 +127,7 @@ public class GraphDataflowTest extends WalaTestCase {
* @throws CancelException
*/
public static String solveNodeOnly(Graph<String> G) throws CancelException {
final OrdinalSetMapping<String> values = new MutableMapping<String>(nodes);
final OrdinalSetMapping<String> values = new MutableMapping<>(nodes);
ITransferFunctionProvider<String, BitVectorVariable> functions = new ITransferFunctionProvider<String, BitVectorVariable>() {
@Override
@ -158,14 +158,14 @@ public class GraphDataflowTest extends WalaTestCase {
};
BitVectorFramework<String,String> F = new BitVectorFramework<String,String>(G, functions, values);
BitVectorSolver<String> s = new BitVectorSolver<String>(F);
BitVectorFramework<String,String> F = new BitVectorFramework<>(G, functions, values);
BitVectorSolver<String> s = new BitVectorSolver<>(F);
s.solve(null);
return result2String(s);
}
public static String solveNodeEdge(Graph<String> G) throws CancelException {
final OrdinalSetMapping<String> values = new MutableMapping<String>(nodes);
final OrdinalSetMapping<String> values = new MutableMapping<>(nodes);
ITransferFunctionProvider<String, BitVectorVariable> functions = new ITransferFunctionProvider<String, BitVectorVariable>() {
@Override
@ -201,8 +201,8 @@ public class GraphDataflowTest extends WalaTestCase {
};
BitVectorFramework<String,String> F = new BitVectorFramework<String,String>(G, functions, values);
BitVectorSolver<String> s = new BitVectorSolver<String>(F);
BitVectorFramework<String,String> F = new BitVectorFramework<>(G, functions, values);
BitVectorSolver<String> s = new BitVectorSolver<>(F);
s.solve(null);
return result2String(s);
}

View File

@ -41,7 +41,7 @@ public class PathFinderTest {
}
private static DFSAllPathsFinder<String> makeFinder(Graph<String> g, String start, final String end) {
return new DFSAllPathsFinder<String>(g, start, new Predicate<String>() {
return new DFSAllPathsFinder<>(g, start, new Predicate<String>() {
@Override public boolean test(String o) {
return end.equals(o);
}

View File

@ -600,7 +600,7 @@ public class PrimitivesTest extends WalaTestCase {
}
@Test public void testSmallMap() {
SmallMap<Integer, Integer> M = new SmallMap<Integer, Integer>();
SmallMap<Integer, Integer> M = new SmallMap<>();
Integer I1 = new Integer(1);
Integer I2 = new Integer(2);
Integer I3 = new Integer(3);
@ -622,7 +622,7 @@ public class PrimitivesTest extends WalaTestCase {
}
@Test public void testBimodalMap() {
Map<Integer, Integer> M = new BimodalMap<Integer, Integer>(3);
Map<Integer, Integer> M = new BimodalMap<>(3);
Integer I1 = new Integer(1);
Integer I2 = new Integer(2);
Integer I3 = new Integer(3);
@ -665,7 +665,7 @@ public class PrimitivesTest extends WalaTestCase {
NumberedGraph<Integer> G = makeBFSTestGraph();
// path from 0 to 8
BFSPathFinder<Integer> pf = new BFSPathFinder<Integer>(G, G.getNode(0), G.getNode(8));
BFSPathFinder<Integer> pf = new BFSPathFinder<>(G, G.getNode(0), G.getNode(8));
List<Integer> p = pf.find();
// path should be 8, 6, 4, 2, 0
@ -678,31 +678,31 @@ public class PrimitivesTest extends WalaTestCase {
@Test public void testBoundedBFS() {
NumberedGraph<Integer> G = makeBFSTestGraph();
BoundedBFSIterator<Integer> bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 0);
BoundedBFSIterator<Integer> bfs = new BoundedBFSIterator<>(G, G.getNode(0), 0);
Collection<Integer> c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 1);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 1);
bfs = new BoundedBFSIterator<>(G, G.getNode(0), 1);
c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 3);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 2);
bfs = new BoundedBFSIterator<>(G, G.getNode(0), 2);
c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 5);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 3);
bfs = new BoundedBFSIterator<>(G, G.getNode(0), 3);
c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 7);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 4);
bfs = new BoundedBFSIterator<>(G, G.getNode(0), 4);
c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 9);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 5);
bfs = new BoundedBFSIterator<>(G, G.getNode(0), 5);
c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 10);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 500);
bfs = new BoundedBFSIterator<>(G, G.getNode(0), 500);
c = Iterator2Collection.toSet(bfs);
Assert.assertTrue(c.size() == 10);
}

View File

@ -59,10 +59,10 @@ public class WelshPowellTest {
}
private <T> NumberedGraph<TypedNode<T>> buildGraph(T[][] data) {
DelegatingNumberedGraph<TypedNode<T>> G = new DelegatingNumberedGraph<TypedNode<T>>();
DelegatingNumberedGraph<TypedNode<T>> G = new DelegatingNumberedGraph<>();
Map<T,TypedNode<T>> nodes = HashMapFactory.make();
for(int i = 0; i < data.length; i++) {
TypedNode<T> n = new TypedNode<T>(data[i][0]);
TypedNode<T> n = new TypedNode<>(data[i][0]);
nodes.put(data[i][0], n);
G.addNode(n);
}

View File

@ -38,7 +38,7 @@ public final class TwoLevelVectorTest extends WalaTestCase {
// --- Test cases
@Test public void testCase1() {
final TwoLevelVector<Integer> tlVector = new TwoLevelVector<Integer>();
final TwoLevelVector<Integer> tlVector = new TwoLevelVector<>();
tlVector.iterator();
tlVector.set(2147483647, 56);
Assert.assertNotNull(tlVector.iterator());

View File

@ -284,7 +284,7 @@ public abstract class AbstractPtrTest {
}
protected StateMachineFactory<IFlowLabel> getStateMachineFactory() {
return new DummyStateMachine.Factory<IFlowLabel>();
return new DummyStateMachine.Factory<>();
}
}

View File

@ -91,19 +91,19 @@ public class ExceptionAnalysis2EdgeFilterTest {
* We will ignore some exceptions to focus on the exceptions we want to
* raise (OwnException, ArrayIndexOutOfBoundException)
*/
filter = new CombinedInterproceduralExceptionFilter<SSAInstruction>();
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(TypeReference.JavaLangOutOfMemoryError)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter = new CombinedInterproceduralExceptionFilter<>();
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(TypeReference.JavaLangOutOfMemoryError)));
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangNullPointerException)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangExceptionInInitializerError)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangNegativeArraySizeException)));
}
@Test
public void test() {
HashMap<String, Integer> deletedExceptional = new HashMap<String, Integer>();
HashMap<String, Integer> deletedExceptional = new HashMap<>();
int deletedNormal = 0;
ExceptionAnalysis analysis = new ExceptionAnalysis(cg, pointerAnalysis, cha, filter);
@ -114,7 +114,7 @@ public class ExceptionAnalysis2EdgeFilterTest {
EdgeFilter<ISSABasicBlock> exceptionAnalysedEdgeFilter = new ExceptionAnalysis2EdgeFilter(analysis, node);
SSACFG cfg_orig = node.getIR().getControlFlowGraph();
ExceptionFilter2EdgeFilter<ISSABasicBlock> filterOnlyEdgeFilter = new ExceptionFilter2EdgeFilter<ISSABasicBlock>(
ExceptionFilter2EdgeFilter<ISSABasicBlock> filterOnlyEdgeFilter = new ExceptionFilter2EdgeFilter<>(
filter.getFilter(node), cha, cfg_orig);
ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = PrunedCFG.make(cfg_orig, filterOnlyEdgeFilter);
ControlFlowGraph<SSAInstruction, ISSABasicBlock> exceptionPruned = PrunedCFG.make(cfg_orig, exceptionAnalysedEdgeFilter);

View File

@ -85,15 +85,15 @@ public class ExceptionAnalysisTest {
* We will ignore some exceptions to focus on the exceptions we want to
* raise (OwnException, ArrayIndexOutOfBoundException)
*/
filter = new CombinedInterproceduralExceptionFilter<SSAInstruction>();
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(TypeReference.JavaLangOutOfMemoryError)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter = new CombinedInterproceduralExceptionFilter<>();
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(TypeReference.JavaLangOutOfMemoryError)));
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangNullPointerException)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangExceptionInInitializerError)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangExceptionInInitializerError)));
filter.add(new IgnoreExceptionsInterFilter<SSAInstruction>(new IgnoreExceptionsFilter(
filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
TypeReference.JavaLangNegativeArraySizeException)));
}

View File

@ -192,7 +192,7 @@ public class TypeAnnotationTest extends WalaTestCase {
)
);
final List<Pair<TypePathKind, Integer>> path = new LinkedList<Pair<TypePathKind,Integer>>();
final List<Pair<TypePathKind, Integer>> path = new LinkedList<>();
path.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 0));
path.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 0));
@ -223,27 +223,27 @@ public class TypeAnnotationTest extends WalaTestCase {
Collection<TypeAnnotation> expectedAnnotations = HashSetFactory.make();
{
final List<Pair<TypePathKind, Integer>> pathA = new LinkedList<Pair<TypePathKind,Integer>>();
final List<Pair<TypePathKind, Integer>> pathA = new LinkedList<>();
expectedAnnotations.add(makeForAnnotations6("A", pathA));
}
{
final List<Pair<TypePathKind, Integer>> pathB = new LinkedList<Pair<TypePathKind,Integer>>();
final List<Pair<TypePathKind, Integer>> pathB = new LinkedList<>();
pathB.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 0));
expectedAnnotations.add(makeForAnnotations6("B", pathB));
}
{
final List<Pair<TypePathKind, Integer>> pathC = new LinkedList<Pair<TypePathKind,Integer>>();
final List<Pair<TypePathKind, Integer>> pathC = new LinkedList<>();
pathC.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 0));
pathC.add(Pair.make(TypeAnnotationsReader.TypePathKind.WILDCARD_BOUND, 0));
expectedAnnotations.add(makeForAnnotations6("C", pathC));
}
{
final List<Pair<TypePathKind, Integer>> pathD = new LinkedList<Pair<TypePathKind,Integer>>();
final List<Pair<TypePathKind, Integer>> pathD = new LinkedList<>();
pathD.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 1));
expectedAnnotations.add(makeForAnnotations6("D", pathD));
}
{
final List<Pair<TypePathKind, Integer>> pathE = new LinkedList<Pair<TypePathKind,Integer>>();
final List<Pair<TypePathKind, Integer>> pathE = new LinkedList<>();
pathE.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 1));
pathE.add(Pair.make(TypeAnnotationsReader.TypePathKind.TYPE_ARGUMENT, 0));
expectedAnnotations.add(makeForAnnotations6("E", pathE));

View File

@ -85,7 +85,7 @@ public abstract class DynamicCallGraphTestBase extends WalaTestCase {
}
}
List<String> args = new ArrayList<String>();
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(testJarLocation, "-o", instrumentedJarLocation));
if (rtJar != null) {
args.addAll(Arrays.asList("--rt-jar", rtJar));

View File

@ -79,7 +79,7 @@ public class ContextInsensitiveReachingDefs {
*/
@SuppressWarnings("unchecked")
private OrdinalSetMapping<Pair<CGNode, Integer>> numberPutStatics() {
ArrayList<Pair<CGNode, Integer>> putInstrs = new ArrayList<Pair<CGNode, Integer>>();
ArrayList<Pair<CGNode, Integer>> putInstrs = new ArrayList<>();
for (CGNode node : icfg.getCallGraph()) {
IR ir = node.getIR();
if (ir == null) {
@ -181,9 +181,9 @@ public class ContextInsensitiveReachingDefs {
*/
public BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> analyze() {
// the framework describes the dataflow problem, in particular the underlying graph and the transfer functions
BitVectorFramework<BasicBlockInContext<IExplodedBasicBlock>, Pair<CGNode, Integer>> framework = new BitVectorFramework<BasicBlockInContext<IExplodedBasicBlock>, Pair<CGNode, Integer>>(
BitVectorFramework<BasicBlockInContext<IExplodedBasicBlock>, Pair<CGNode, Integer>> framework = new BitVectorFramework<>(
icfg, new TransferFunctions(), putInstrNumbering);
BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> solver = new BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>>(
BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> solver = new BitVectorSolver<>(
framework);
try {
solver.solve(null);

View File

@ -162,7 +162,7 @@ public class DataflowTest extends WalaTestCase {
if (delegate.getNumber() == 4) {
IntSet solution = solver.getOut(bb).getValue();
IntIterator intIterator = solution.intIterator();
List<Pair<CGNode, Integer>> applicationDefs = new ArrayList<Pair<CGNode,Integer>>();
List<Pair<CGNode, Integer>> applicationDefs = new ArrayList<>();
while (intIterator.hasNext()) {
int next = intIterator.next();
final Pair<CGNode, Integer> def = reachingDefs.getNodeAndInstrForNumber(next);
@ -195,7 +195,7 @@ public class DataflowTest extends WalaTestCase {
if (delegate.getNumber() == 4) {
IntSet solution = result.getResult(bb);
IntIterator intIterator = solution.intIterator();
List<Pair<CGNode, Integer>> applicationDefs = new ArrayList<Pair<CGNode,Integer>>();
List<Pair<CGNode, Integer>> applicationDefs = new ArrayList<>();
while (intIterator.hasNext()) {
int next = intIterator.next();
final Pair<CGNode, Integer> def = reachingDefs.getDomain().getMappedObject(next);

View File

@ -77,7 +77,7 @@ public class IntraprocReachingDefs {
* generate a numbering of the putstatic instructions
*/
private OrdinalSetMapping<Integer> numberPutStatics() {
ArrayList<Integer> putInstrs = new ArrayList<Integer>();
ArrayList<Integer> putInstrs = new ArrayList<>();
IR ir = ecfg.getIR();
SSAInstruction[] instructions = ir.getInstructions();
for (int i = 0; i < instructions.length; i++) {
@ -98,7 +98,7 @@ public class IntraprocReachingDefs {
bv.set(instrNum);
}
}
return new ObjectArrayMapping<Integer>(putInstrs.toArray(new Integer[putInstrs.size()]));
return new ObjectArrayMapping<>(putInstrs.toArray(new Integer[putInstrs.size()]));
}
private class TransferFunctions implements ITransferFunctionProvider<IExplodedBasicBlock, BitVectorVariable> {
@ -155,9 +155,9 @@ public class IntraprocReachingDefs {
*/
public BitVectorSolver<IExplodedBasicBlock> analyze() {
// the framework describes the dataflow problem, in particular the underlying graph and the transfer functions
BitVectorFramework<IExplodedBasicBlock, Integer> framework = new BitVectorFramework<IExplodedBasicBlock, Integer>(ecfg,
BitVectorFramework<IExplodedBasicBlock, Integer> framework = new BitVectorFramework<>(ecfg,
new TransferFunctions(), putInstrNumbering);
BitVectorSolver<IExplodedBasicBlock> solver = new BitVectorSolver<IExplodedBasicBlock>(framework);
BitVectorSolver<IExplodedBasicBlock> solver = new BitVectorSolver<>(framework);
try {
solver.solve(null);
} catch (CancelException e) {

View File

@ -109,7 +109,7 @@ public class PDFControlDependenceGraph {
}
System.err.println(ir.toString());
ControlDependenceGraph<ISSABasicBlock> cdg = new ControlDependenceGraph<ISSABasicBlock>(ir.getControlFlowGraph());
ControlDependenceGraph<ISSABasicBlock> cdg = new ControlDependenceGraph<>(ir.getControlFlowGraph());
Properties wp = null;
try {

View File

@ -96,7 +96,7 @@ public class PDFTypeHierarchy {
public static <T> Graph<T> pruneGraph(Graph<T> g, Predicate<T> f) throws WalaException {
Collection<T> slice = GraphSlicer.slice(g, f);
return GraphSlicer.prune(g, new CollectionFilter<T>(slice));
return GraphSlicer.prune(g, new CollectionFilter<>(slice));
}
/**

View File

@ -97,7 +97,7 @@ public class ScopeFileCallGraph {
}
private static Iterable<Entrypoint> makePublicEntrypoints(AnalysisScope scope, IClassHierarchy cha, String entryClass) {
Collection<Entrypoint> result = new ArrayList<Entrypoint>();
Collection<Entrypoint> result = new ArrayList<>();
IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application,
StringStuff.deployment2CanonicalTypeString(entryClass)));
for (IMethod m : klass.getDeclaredMethods()) {

View File

@ -161,7 +161,7 @@ public abstract class DroidBenchCGTest extends DalvikCallGraphTestBase {
}
public static Collection<Object[]> generateData(String droidBenchRoot, final URI[] androidLibs, final File androidJavaJar, final String filter) {
final List<Object[]> files = new LinkedList<Object[]>();
final List<Object[]> files = new LinkedList<>();
FileUtil.recurseFiles(new VoidFunction<File>() {
@Override
public void apply(File f) {

View File

@ -75,7 +75,7 @@ public class Util {
}
public static URI[] androidLibs() {
List<URI> libs = new ArrayList<URI>();
List<URI> libs = new ArrayList<>();
if (walaProperties != null && walaProperties.getProperty(ANDROID_RT_DEX_DIR) != null) {
for(File lib : new File(walaProperties.getProperty(ANDROID_RT_DEX_DIR)).listFiles(new FilenameFilter() {
@Override

View File

@ -360,7 +360,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
IClass caughtClass = cha.lookupClass(caughtException);
// the set "caught" should be the set of exceptions that MUST
// 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.
for (TypeReference t : exceptionTypes) {
if (t != null) {
@ -645,7 +645,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
}
public Iterator<Instruction> iterator() {
return new ArrayIterator<Instruction>(getInstructions(), getFirstInstructionIndex(), getLastInstructionIndex());
return new ArrayIterator<>(getInstructions(), getFirstInstructionIndex(), getLastInstructionIndex());
}
}

View File

@ -107,7 +107,7 @@ public class DexFileModule implements Module {
}
// create ModuleEntries from ClassDefItem
entries = new HashSet<ModuleEntry>();
entries = new HashSet<>();
Section<ClassDefItem> cldeff = dexfile.ClassDefsSection;
for (ClassDefItem cdefitems : cldeff.getItems()) {

View File

@ -298,7 +298,7 @@ public class DexIClass extends BytecodeClass<IClassLoader> {
}
List<AnnotationItem> getAnnotations(MethodIdItem m, Set<AnnotationVisibility> types) {
List<AnnotationItem> result = new ArrayList<AnnotationItem>();
List<AnnotationItem> result = new ArrayList<>();
AnnotationDirectoryItem d = dexModuleEntry.getClassDefItem().getAnnotations();
if (d != null && d.getMethodAnnotations(m) != null) {
for(AnnotationItem a : d.getMethodAnnotations(m).getAnnotations()) {
@ -311,7 +311,7 @@ public class DexIClass extends BytecodeClass<IClassLoader> {
}
List<AnnotationItem> getAnnotations(FieldIdItem m) {
List<AnnotationItem> result = new ArrayList<AnnotationItem>();
List<AnnotationItem> result = new ArrayList<>();
AnnotationDirectoryItem d = dexModuleEntry.getClassDefItem().getAnnotations();
if (d != null) {
for(AnnotationItem a : d.getFieldAnnotations(m).getAnnotations()) {
@ -345,7 +345,7 @@ public class DexIClass extends BytecodeClass<IClassLoader> {
*/
@Override
protected IMethod[] computeDeclaredMethods() throws InvalidClassFileException {
ArrayList<IMethod> methodsAL = new ArrayList<IMethod>();
ArrayList<IMethod> methodsAL = new ArrayList<>();
if (methods == null && classDef.getClassData() == null)
methods = new IMethod[0];

View File

@ -219,7 +219,7 @@ public class DexIMethod implements IBytecodeMethod {
if (myClass.getClassDefItem().getAnnotations() == null) {
return null;
}
ArrayList<String> strings = new ArrayList<String>();
ArrayList<String> strings = new ArrayList<>();
AnnotationSetItem annotationSet = myClass.getClassDefItem().getAnnotations().getMethodAnnotations(eMethod.method);
/** END Custom change: Variable Names in synth. methods */
@ -619,7 +619,7 @@ public class DexIMethod implements IBytecodeMethod {
return handlers;
}
ArrayList<ArrayList<ExceptionHandler>> temp_array = new ArrayList<ArrayList<ExceptionHandler>>();
ArrayList<ArrayList<ExceptionHandler>> temp_array = new ArrayList<>();
for (int i = 0; i < instructions().size(); i++) {
temp_array.add(new ArrayList<ExceptionHandler>());
}
@ -3228,7 +3228,7 @@ public class DexIMethod implements IBytecodeMethod {
// assert(false) : "Please review getCallSites-Implementation before use!"; // TODO
ArrayList<CallSiteReference> csites = new ArrayList<CallSiteReference>();
ArrayList<CallSiteReference> csites = new ArrayList<>();
// XXX The call Sites in this method or to this method?!!!
for (Instruction inst: instructions()) {
if (inst instanceof Invoke) {

View File

@ -68,9 +68,9 @@ public class InstructionArray implements Collection<Instruction> {
List<Integer> index2pc;
public InstructionArray() {
instructions = new ArrayList<Instruction>();
pc2index = new HashMap<Integer, Integer>();
index2pc = new ArrayList<Integer>();
instructions = new ArrayList<>();
pc2index = new HashMap<>();
index2pc = new ArrayList<>();
}
public boolean add(Instruction e) {

View File

@ -173,7 +173,7 @@ public class AndroidModel /* makes SummarizedMethod */
* @param name The name the generated method will be known as
*/
protected void build(Atom name) throws CancelException {
final List<AndroidEntryPoint> restrictedEntries = new ArrayList<AndroidEntryPoint>();
final List<AndroidEntryPoint> restrictedEntries = new ArrayList<>();
for (AndroidEntryPoint ep: AndroidEntryPointManager.ENTRIES) {
if (selectEntryPoint(ep)) {
@ -416,11 +416,11 @@ public class AndroidModel /* makes SummarizedMethod */
// Collect arguments to ep
// if there are multiple paramses call the entrypoint multiple times
//
List<List<SSAValue>> paramses = new ArrayList<List<SSAValue>>(1);
List<List<SSAValue>> paramses = new ArrayList<>(1);
{
final List<Integer> mutliTypePositions = new ArrayList<Integer>();
final List<Integer> mutliTypePositions = new ArrayList<>();
{ // Add single-type parameters and collect positions for multi-type
final List<SSAValue> params = new ArrayList<SSAValue>(ep.getNumberOfParameters());
final List<SSAValue> params = new ArrayList<>(ep.getNumberOfParameters());
paramses.add(params);
for (int i = 0; i < ep.getNumberOfParameters(); ++i) {
@ -452,12 +452,12 @@ public class AndroidModel /* makes SummarizedMethod */
final int typeCountOnPosition = typesOnPosition.length;
{ // Extend the list size to hold the product
final List<List<SSAValue>> new_paramses = new ArrayList<List<SSAValue>>(paramses.size() * typeCountOnPosition);
final List<List<SSAValue>> new_paramses = new ArrayList<>(paramses.size() * typeCountOnPosition);
for (int i = 0; i < typeCountOnPosition; ++i) {
//new_paramses.addAll(paramses); *grrr* JVM! You could copy at least null - but noooo...
for (final List<SSAValue> params : paramses) {
final List<SSAValue> new_params = new ArrayList<SSAValue>(params.size());
final List<SSAValue> new_params = new ArrayList<>(params.size());
new_params.addAll(params);
new_paramses.add(new_params);
}
@ -533,7 +533,7 @@ public class AndroidModel /* makes SummarizedMethod */
this.paramManager.invalidate(returnKey);
final SSAValue newValue = this.paramManager.getFree(returnType, returnKey);
final int phiPC = body.getNextProgramCounter();
final List<SSAValue> toPhi = new ArrayList<SSAValue>(2);
final List<SSAValue> toPhi = new ArrayList<>(2);
toPhi.add(oldValue);
toPhi.add(returnValue);
final SSAPhiInstruction phi = tsif.PhiInstruction(phiPC, newValue, toPhi);
@ -635,7 +635,7 @@ public class AndroidModel /* makes SummarizedMethod */
} catch (Exception e) { }
}*/
final List<Parameter> modelsActivities = modelAcc.allExtend(AndroidTypes.ActivityName, getClassHierarchy()); // are in models scope
final List<SSAValue> allActivities = new ArrayList<SSAValue>(modelsActivities.size()); // create instances in this scope
final List<SSAValue> allActivities = new ArrayList<>(modelsActivities.size()); // create instances in this scope
for (Parameter activity: modelsActivities) {
final TypeReference activityType = activity.getType();
final Parameter inAsMethod = acc.firstOf(activityType);
@ -676,7 +676,7 @@ public class AndroidModel /* makes SummarizedMethod */
assert(allActivities.size() == modelsActivities.size());
// The defaults for connectThrough
final Set<SSAValue> defaults = new HashSet<SSAValue>();
final Set<SSAValue> defaults = new HashSet<>();
{ // Calls that don't take a bundle usually call through with a null-bundle
final SSAValue nullBundle = pm.getUnmanaged(AndroidTypes.Bundle, "nullBundle");
redirect.addConstant(nullBundle.getNumber(), new ConstantValue(null));
@ -722,7 +722,7 @@ public class AndroidModel /* makes SummarizedMethod */
// Call the model
{
final List<SSAValue> redirectParams = acc.connectThrough(modelAcc, new HashSet<SSAValue>(allActivities), defaults,
final List<SSAValue> redirectParams = acc.connectThrough(modelAcc, new HashSet<>(allActivities), defaults,
getClassHierarchy(), /* IInstantiator this.createInstance(type, redirect, pm) */ instantiator, false, null, null);
final int callPC = redirect.getNextProgramCounter();
final CallSiteReference site = CallSiteReference.make(callPC, this.model.getReference(),
@ -770,8 +770,8 @@ public class AndroidModel /* makes SummarizedMethod */
// Collect all Activity.mResultCode and Activity.mResultData
// Result information of all activities.
final List<SSAValue> resultCodes = new ArrayList<SSAValue>();
final List<SSAValue> resultData = new ArrayList<SSAValue>();
final List<SSAValue> resultCodes = new ArrayList<>();
final List<SSAValue> resultData = new ArrayList<>();
final SSAValue mResultCode; // = Phi(resultCodes)
final SSAValue mResultData; // = Phi(resultData)
@ -796,7 +796,7 @@ public class AndroidModel /* makes SummarizedMethod */
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
//final SSAValue exception = new SSAValue(pm.getUnmanaged(), TypeReference.JavaLangException, asMethod, "exception");
final SSAValue exception = pm.getException();
final List<SSAValue> params = new ArrayList<SSAValue>();
final List<SSAValue> params = new ArrayList<>();
params.add(self);
params.add(outRequestCode); // Was an agument to start...
params.add(mResultCode);
@ -880,7 +880,7 @@ public class AndroidModel /* makes SummarizedMethod */
final SummarizedMethod model = getMethod();
final List<SSAValue> params = new ArrayList<SSAValue>();
final List<SSAValue> params = new ArrayList<>();
{ // Collect Params
final FlatInstantiator instantiator = new FlatInstantiator(encap, instructionFactory, pm, this.cha, asMethod, this.scope);

View File

@ -144,7 +144,7 @@ public final /* singleton */ class AndroidModelClass extends SyntheticClass {
final MethodReference ctor = MethodReference.findOrCreate(component, MethodReference.initSelector);
final CallSiteReference site = CallSiteReference.make(pc, ctor, IInvokeInstruction.Dispatch.SPECIAL);
final SSAValue exception = new SSAValue(ssaNo++, TypeReference.JavaLangException, clinitRef);
final List<SSAValue> params = new ArrayList<SSAValue>();
final List<SSAValue> params = new ArrayList<>();
params.add(instance);
final SSAInstruction ctorCall = instructionFactory.InvokeInstruction(pc, params, exception, site);
clinit.addStatement(ctorCall);
@ -237,7 +237,7 @@ public final /* singleton */ class AndroidModelClass extends SyntheticClass {
// Contents of the class: Fields
// We have none...
//
private Map<Atom, IField> fields = new HashMap<Atom, IField>();
private Map<Atom, IField> fields = new HashMap<>();
@Override
public IField getField(Atom name) {

View File

@ -107,7 +107,7 @@ public class AndroidModelParameterManager {
}
/** The main data-structure of the management */
private Map<TypeReference, List<ManagedParameter>> seenTypes = new HashMap<TypeReference, List<ManagedParameter>>();
private Map<TypeReference, List<ManagedParameter>> seenTypes = new HashMap<>();
/**
* Setting the behaviour may be handy in the later model.
@ -204,7 +204,7 @@ public class AndroidModelParameterManager {
}
param.setInScope = currentScope;
List<ManagedParameter> aParam = new ArrayList<ManagedParameter>();
List<ManagedParameter> aParam = new ArrayList<>();
aParam.add(param);
@ -296,7 +296,7 @@ public class AndroidModelParameterManager {
}
List<ManagedParameter> aParam = new ArrayList<ManagedParameter>();
List<ManagedParameter> aParam = new ArrayList<>();
aParam.add(param);
seenTypes.put(type, aParam);
@ -330,7 +330,7 @@ public class AndroidModelParameterManager {
if (seenTypes.containsKey(type)) {
seenTypes.get(type).add(param);
} else {
List<ManagedParameter> aParam = new ArrayList<ManagedParameter>();
List<ManagedParameter> aParam = new ArrayList<>();
aParam.add(param);
seenTypes.put(type, aParam);
@ -372,7 +372,7 @@ public class AndroidModelParameterManager {
if (seenTypes.containsKey(type)) {
seenTypes.get(type).add(param);
} else {
List<ManagedParameter> aParam = new ArrayList<ManagedParameter>();
List<ManagedParameter> aParam = new ArrayList<>();
aParam.add(param);
seenTypes.put(type, aParam);
@ -475,7 +475,7 @@ public class AndroidModelParameterManager {
throw new IllegalArgumentException("The argument type may not be null");
}
List<Integer> ret = new ArrayList<Integer>();
List<Integer> ret = new ArrayList<>();
if (seenTypes.containsKey(type)) {
for (ManagedParameter param : seenTypes.get(type)) {

View File

@ -89,15 +89,15 @@ public class DefaultInstantiationBehavior extends IInstantiationBehavior impleme
}
public static BehaviorKey<TypeName> mk(TypeName base) {
return new BehaviorKey<TypeName>(base);
return new BehaviorKey<>(base);
}
public static BehaviorKey<Atom> mk(Atom base) {
return new BehaviorKey<Atom>(base);
return new BehaviorKey<>(base);
}
public static BehaviorKey<Atom> mkPackage(String pack) {
return new BehaviorKey<Atom>(Atom.findOrCreateAsciiAtom(pack));
return new BehaviorKey<>(Atom.findOrCreateAsciiAtom(pack));
}
@Override
@ -122,7 +122,7 @@ public class DefaultInstantiationBehavior extends IInstantiationBehavior impleme
}
private final Map<BehaviorKey, BehviourValue> behaviours = new HashMap<BehaviorKey, BehviourValue>();
private final Map<BehaviorKey, BehviourValue> behaviours = new HashMap<>();
private final transient IClassHierarchy cha;
public DefaultInstantiationBehavior(final IClassHierarchy cha) {
@ -350,7 +350,7 @@ public class DefaultInstantiationBehavior extends IInstantiationBehavior impleme
if (this.serializationIncludesCache) {
stream.writeObject(this.behaviours);
} else {
final Map<BehaviorKey, BehviourValue> strippedBehaviours = new HashMap<BehaviorKey, BehviourValue>();
final Map<BehaviorKey, BehviourValue> strippedBehaviours = new HashMap<>();
for (final BehaviorKey key : this.behaviours.keySet()) {
final BehviourValue val = this.behaviours.get(key);
if (! val.isCached() ) {

View File

@ -149,7 +149,7 @@ public class FlatInstantiator implements IInstantiator {
}
if (seen == null) {
logger.debug("Empty seen");
seen = new HashSet<SSAValue>();
seen = new HashSet<>();
}
if (currentDepth > this.maxDepth) {
@ -251,7 +251,7 @@ public class FlatInstantiator implements IInstantiator {
this.body.addConstant(arrayLength.getNumber(), new ConstantValue(1));
arrayLength.setAssigned();
final ArrayList<SSAValue> params = new ArrayList<SSAValue>(1);
final ArrayList<SSAValue> params = new ArrayList<>(1);
params.add(arrayLength);
newInst = this.instructionFactory.NewInstruction(pc, instance, nRef, params);
@ -271,7 +271,7 @@ public class FlatInstantiator implements IInstantiator {
} else {
// Abstract, Interface or array
logger.debug("Not a regular class {}", T);
final Set<SSAValue> subInstances = new HashSet<SSAValue>();
final Set<SSAValue> subInstances = new HashSet<>();
for (final TypeReference type : types) {
final IClass subKlass = this.cha.lookupClass(type);
@ -286,7 +286,7 @@ public class FlatInstantiator implements IInstantiator {
selectAndCallCtor(subInstance, seen, currentDepth);
assert (subInstance.getNumber() == newInst.getDef()) : "Unexpected: number and def differ: " + subInstance.getNumber() + ", " +
newInst.getDef();
final Set<SSAValue> newSeen = new HashSet<SSAValue>(); // Narf
final Set<SSAValue> newSeen = new HashSet<>(); // Narf
newSeen.addAll(seen);
newSeen.add(subInstance);
seen = newSeen;
@ -391,7 +391,7 @@ public class FlatInstantiator implements IInstantiator {
final int pc = this.body.getNextProgramCounter();
final SSAValue exception = pm.getException();
final CallSiteReference site = CallSiteReference.make(pc, ctor, IInvokeInstruction.Dispatch.SPECIAL);
final List<SSAValue> params = new ArrayList<SSAValue>(1 + ctorParams.size());
final List<SSAValue> params = new ArrayList<>(1 + ctorParams.size());
params.add(self);
params.addAll(ctorParams);
final SSAInstruction ctorCall = instructionFactory.InvokeInstruction(pc, params, exception, site);
@ -411,7 +411,7 @@ public class FlatInstantiator implements IInstantiator {
this.body.addConstant(nullSelf.getNumber(), new ConstantValue(null));
nullSelf.setAssigned();
//}
final Set<SSAValue> seen = new HashSet<SSAValue>(1 + overrides.size());
final Set<SSAValue> seen = new HashSet<>(1 + overrides.size());
seen.add(nullSelf);
seen.addAll(overrides);
@ -433,7 +433,7 @@ public class FlatInstantiator implements IInstantiator {
private Set<TypeReference> getTypes(final TypeReference T) {
final IClass cls = this.cha.lookupClass(T);
if (isExcluded(cls)) {
return new HashSet<TypeReference>();
return new HashSet<>();
}
return getTypes(T, Collections.EMPTY_SET);
}
@ -443,7 +443,7 @@ public class FlatInstantiator implements IInstantiator {
*/
private Set<TypeReference> getTypes(final TypeReference T, final Set<TypeReference> seen) {
logger.debug("getTypes({}, {})", T, seen);
final Set<TypeReference> ret = new HashSet<TypeReference>();
final Set<TypeReference> ret = new HashSet<>();
ret.add(T);
if (T.isPrimitiveType()) {

View File

@ -134,7 +134,7 @@ public class Instantiator implements IInstantiator {
}
if (seen == null) {
logger.debug("Empty seen");
seen = new HashSet<SSAValue>();
seen = new HashSet<>();
}
{ // Special type?
@ -252,7 +252,7 @@ public class Instantiator implements IInstantiator {
this.body.addConstant(arrayLength.getNumber(), new ConstantValue(1));
arrayLength.setAssigned();
final ArrayList<SSAValue> params = new ArrayList<SSAValue>(1);
final ArrayList<SSAValue> params = new ArrayList<>(1);
params.add(arrayLength);
newInst = this.instructionFactory.NewInstruction(pc, instance, nRef, params);
@ -272,7 +272,7 @@ public class Instantiator implements IInstantiator {
} else {
// Abstract, Interface or array
logger.debug("Not a regular class {}", T);
final Set<SSAValue> subInstances = new HashSet<SSAValue>();
final Set<SSAValue> subInstances = new HashSet<>();
for (final TypeReference type : types) {
final IClass subKlass = this.cha.lookupClass(type);
@ -287,7 +287,7 @@ public class Instantiator implements IInstantiator {
selectAndCallCtor(subInstance, seen);
assert (subInstance.getNumber() == newInst.getDef()) : "Unexpected: number and def differ: " + subInstance.getNumber() + ", " +
newInst.getDef();
final Set<SSAValue> newSeen = new HashSet<SSAValue>(); // Narf
final Set<SSAValue> newSeen = new HashSet<>(); // Narf
newSeen.addAll(seen);
newSeen.add(subInstance);
seen = newSeen;
@ -392,7 +392,7 @@ public class Instantiator implements IInstantiator {
final int pc = this.body.getNextProgramCounter();
final SSAValue exception = pm.getException();
final CallSiteReference site = CallSiteReference.make(pc, ctor, IInvokeInstruction.Dispatch.SPECIAL);
final List<SSAValue> params = new ArrayList<SSAValue>(1 + ctorParams.size());
final List<SSAValue> params = new ArrayList<>(1 + ctorParams.size());
params.add(self);
params.addAll(ctorParams);
final SSAInstruction ctorCall = instructionFactory.InvokeInstruction(pc, params, exception, site);
@ -412,7 +412,7 @@ public class Instantiator implements IInstantiator {
this.body.addConstant(nullSelf.getNumber(), new ConstantValue(null));
nullSelf.setAssigned();
//}
final Set<SSAValue> seen = new HashSet<SSAValue>(1 + overrides.size());
final Set<SSAValue> seen = new HashSet<>(1 + overrides.size());
seen.add(nullSelf);
seen.addAll(overrides);
@ -434,7 +434,7 @@ public class Instantiator implements IInstantiator {
private Set<TypeReference> getTypes(final TypeReference T) {
final IClass cls = this.cha.lookupClass(T);
if (isExcluded(cls)) {
return new HashSet<TypeReference>();
return new HashSet<>();
}
return getTypes(T, Collections.EMPTY_SET);
}
@ -444,7 +444,7 @@ public class Instantiator implements IInstantiator {
*/
private Set<TypeReference> getTypes(final TypeReference T, final Set<TypeReference> seen) {
logger.debug("getTypes({}, {})", T, seen);
final Set<TypeReference> ret = new HashSet<TypeReference>();
final Set<TypeReference> ret = new HashSet<>();
ret.add(T);
if (T.isPrimitiveType()) {
@ -540,7 +540,7 @@ public class Instantiator implements IInstantiator {
if (T.isPrimitiveType()) {
throw new IllegalArgumentException("Not you that call primitive type on :P");
}
final List<TypeReference> ret = new ArrayList<TypeReference>();
final List<TypeReference> ret = new ArrayList<>();
IClass cls = this.cha.lookupClass(T);
if (cls == null) {

View File

@ -94,11 +94,11 @@ public class LoadedInstantiationBehavior extends IInstantiationBehavior implemen
}
public static BehaviorKey<TypeName> mk(TypeName base) {
return new BehaviorKey<TypeName>(base);
return new BehaviorKey<>(base);
}
public static BehaviorKey<Atom> mk(Atom base) {
return new BehaviorKey<Atom>(base);
return new BehaviorKey<>(base);
}
@ -124,7 +124,7 @@ public class LoadedInstantiationBehavior extends IInstantiationBehavior implemen
}
private InstanceBehavior defaultBehavior = null;
private final Map<BehaviorKey, BehviourValue> behaviours = new HashMap<BehaviorKey, BehviourValue>();
private final Map<BehaviorKey, BehviourValue> behaviours = new HashMap<>();
private final IClassHierarchy cha;
public LoadedInstantiationBehavior(IClassHierarchy cha) {
@ -304,7 +304,7 @@ public class LoadedInstantiationBehavior extends IInstantiationBehavior implemen
if (this.serializationIncludesCache) {
stream.writeObject(this.behaviours);
} else {
final Map<BehaviorKey, BehviourValue> strippedBehaviours = new HashMap<BehaviorKey, BehviourValue>();
final Map<BehaviorKey, BehviourValue> strippedBehaviours = new HashMap<>();
for (final BehaviorKey key : this.behaviours.keySet()) {
final BehviourValue val = this.behaviours.get(key);
if (! val.isCached() ) {

View File

@ -114,7 +114,7 @@ public class ReuseParameters {
*/
public void collectParameters(final Iterable<? extends Entrypoint> entrypoints) {
// int paramsToModel = firstParamSSA();
this.reuseParameters = new ArrayList<TypeName>();
this.reuseParameters = new ArrayList<>();
for (final Entrypoint ep : entrypoints) {
final int paramCount = ep.getNumberOfParameters();

View File

@ -105,7 +105,7 @@ public class SpecializedInstantiator extends FlatInstantiator {
/* package private */ SSAValue createInstance(final TypeReference T, final boolean asManaged, VariableKey key, Set<? extends SSAValue> seen, int currentDepth) {
if (seen == null) {
seen = new HashSet<SSAValue>();
seen = new HashSet<>();
}
if (currentDepth > this.maxDepth) {
@ -143,7 +143,7 @@ public class SpecializedInstantiator extends FlatInstantiator {
private static final Set<TypeReference> understandTypes = new HashSet<TypeReference>();
private static final Set<TypeReference> understandTypes = new HashSet<>();
static {
understandTypes.add(AndroidTypes.Context);
understandTypes.add(AndroidTypes.ContextWrapper);
@ -159,7 +159,7 @@ public class SpecializedInstantiator extends FlatInstantiator {
* Creates a new instance of android/content/Context.
*/
public SSAValue createContext(final TypeReference T, final boolean asManaged, VariableKey key, Set<? extends SSAValue> seen) {
final List<SSAValue> appComponents = new ArrayList<SSAValue>();
final List<SSAValue> appComponents = new ArrayList<>();
{
// TODO: Can we create a tighter conterxt?
// TODO: Force an Application-Context?
@ -248,7 +248,7 @@ public class SpecializedInstantiator extends FlatInstantiator {
// call: ContextWrapper(Context base)
final MethodReference ctor = MethodReference.findOrCreate(T, MethodReference.initAtom,
Descriptor.findOrCreate(new TypeName[] { AndroidTypes.ContextName }, TypeReference.VoidName));
final List<SSAValue> params = new ArrayList<SSAValue>();
final List<SSAValue> params = new ArrayList<>();
params.add(context);
addCallCtor(instance, ctor, params);
}

View File

@ -99,7 +99,7 @@ public abstract class AbstractAndroidModel {
assert (start != null) : "The argument start was null";
assert (end != null) : "The argument end was null";
List<TypeReference> returnTypes = new ArrayList<TypeReference>();
List<TypeReference> returnTypes = new ArrayList<>();
for (Entrypoint ep : this.entryPoints) {
if (ep instanceof AndroidEntryPoint) {
AndroidEntryPoint aep = (AndroidEntryPoint)ep;

View File

@ -112,7 +112,7 @@ public class LoopAndroidModel extends SingleStartAndroidModel {
paramManager.scopeDown(true);
// Top-Half of Phi-Handling
outerStartingPhis = new HashMap<TypeReference, SSAValue>();
outerStartingPhis = new HashMap<>();
List<TypeReference> outerPhisNeeded = returnTypesBetween(ExecutionOrder.START_OF_LOOP,
ExecutionOrder.AFTER_LOOP);
@ -147,7 +147,7 @@ public class LoopAndroidModel extends SingleStartAndroidModel {
logger.info("Setting block-inner Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final SSAValue oldPhi = outerStartingPhis.get(phiType);
final List<SSAValue> forPhi = new ArrayList<SSAValue>(2);
final List<SSAValue> forPhi = new ArrayList<>(2);
forPhi.add(paramManager.getSuper(oldPhi.key));
forPhi.add(paramManager.getCurrent(oldPhi.key));

View File

@ -106,7 +106,7 @@ public class LoopKillAndroidModel extends LoopAndroidModel {
paramManager.scopeDown(true);
// Top-Half of Phi-Handling
outerStartingPhis = new HashMap<TypeReference, SSAValue>();
outerStartingPhis = new HashMap<>();
List<TypeReference> outerPhisNeeded = returnTypesBetween(ExecutionOrder.START_OF_LOOP,
ExecutionOrder.AFTER_LOOP);
@ -141,7 +141,7 @@ public class LoopKillAndroidModel extends LoopAndroidModel {
logger.info("Setting block-inner Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final SSAValue oldPhi = outerStartingPhis.get(phiType);
final List<SSAValue> forPhi = new ArrayList<SSAValue>(2);
final List<SSAValue> forPhi = new ArrayList<>(2);
forPhi.add(paramManager.getSuper(oldPhi.key));
forPhi.add(paramManager.getCurrent(oldPhi.key));

View File

@ -111,7 +111,7 @@ public class SingleStartAndroidModel extends AbstractAndroidModel {
paramManager.scopeDown(true);
// Top-Half of Phi-Handling
outerStartingPhis = new HashMap<TypeReference, SSAValue>();
outerStartingPhis = new HashMap<>();
List<TypeReference> outerPhisNeeded = returnTypesBetween(ExecutionOrder.START_OF_LOOP,
ExecutionOrder.AFTER_LOOP);
@ -146,7 +146,7 @@ public class SingleStartAndroidModel extends AbstractAndroidModel {
logger.info("Setting block-inner Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final SSAValue oldPhi = outerStartingPhis.get(phiType);
final List<SSAValue> forPhi = new ArrayList<SSAValue>(2);
final List<SSAValue> forPhi = new ArrayList<>(2);
forPhi.add(paramManager.getSuper(oldPhi.key));
forPhi.add(paramManager.getCurrent(oldPhi.key));

View File

@ -166,7 +166,7 @@ public class AndroidBoot {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.ActivityThread, MethodReference.initSelector);
final SSAValue exception = this.pm.getUnmanaged(TypeReference.JavaLangException, "ctor_exc" );
final CallSiteReference site = CallSiteReference.make(pc, mRef, IInvokeInstruction.Dispatch.SPECIAL);
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(mainThread);
final SSAInstruction ctorCall = instructionFactory.InvokeInstruction(pc, params, exception, site);
body.addStatement(ctorCall);
@ -188,7 +188,7 @@ public class AndroidBoot {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.ActivityThread, mSel);
final CallSiteReference site = CallSiteReference.make(pc, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = this.pm.getException();
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(mainThread);
final SSAInstruction call = instructionFactory.InvokeInstruction(pc, systemContext, params, exception, site);
body.addStatement(call);
@ -234,7 +234,7 @@ public class AndroidBoot {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.ContextImpl, MethodReference.initSelector);
final SSAValue exception = this.pm.getUnmanaged(TypeReference.JavaLangException, "ctor_exc" );
final CallSiteReference site = CallSiteReference.make(pc, mRef, IInvokeInstruction.Dispatch.SPECIAL);
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(packageContext);
final SSAInstruction ctorCall = instructionFactory.InvokeInstruction(pc, params, exception, site);
body.addStatement(ctorCall);
@ -334,7 +334,7 @@ public class AndroidBoot {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.ContextImpl, mSel);
final SSAValue exception = this.pm.getException();
final CallSiteReference site = CallSiteReference.make(pc, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final List<SSAValue> params = new ArrayList<SSAValue>(7);
final List<SSAValue> params = new ArrayList<>(7);
params.add(packageContext);
params.add(nullApk); // TODO: This would contain a Context too?
params.add(nullIBinder); // OK: is null in Android-Sources too

View File

@ -209,7 +209,7 @@ public class AndroidStartComponentTool {
AndroidTypes.ConfigurationName }, TypeReference.VoidName);
final Selector mSel = new Selector(Atom.findOrCreateAsciiAtom("attach"), desc);
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.Activity, mSel);
final List<SSAValue> params = new ArrayList<SSAValue>(13);
final List<SSAValue> params = new ArrayList<>(13);
params.add(null); // activity
params.add(context);
params.add(thread);
@ -349,7 +349,7 @@ public class AndroidStartComponentTool {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.IntentSender, mSel);
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = pm.getException();
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(intentSender);
final SSAInstruction invokation = instructionFactory.InvokeInstruction(callPC, iIntentSender, params, exception, site);
redirect.addStatement(invokation);
@ -361,7 +361,7 @@ public class AndroidStartComponentTool {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.IntentSender, mSel);
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = pm.getException();
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(iIntentSender);
final SSAInstruction invokation = instructionFactory.InvokeInstruction(callPC, iBinder, params, exception, site);
redirect.addStatement(invokation);
@ -396,7 +396,7 @@ public class AndroidStartComponentTool {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.ActivityThread, mSel);
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = pm.getException();
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(mMainThread);
final SSAInstruction invokation = instructionFactory.InvokeInstruction(callPC, iBinder, params, exception, site);
redirect.addStatement(invokation);
@ -469,7 +469,7 @@ public class AndroidStartComponentTool {
final MethodReference mRef = MethodReference.findOrCreate(AndroidTypes.Activity, mSel);
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = pm.getException();
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(activity);
params.add(intent);
final SSAInstruction invokation = instructionFactory.InvokeInstruction(callPC, params, exception, site);

View File

@ -220,7 +220,7 @@ public class ExternalModel extends AndroidModel {
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = new SSAValue(nextLocal++, TypeReference.JavaLangException, this.mRef, "exception");
outBundle = new SSAValue(nextLocal++, inBundle);
final List<SSAValue> params = new ArrayList<SSAValue>(1);
final List<SSAValue> params = new ArrayList<>(1);
params.add(inIntent);
final SSAInstruction invokation = instructionFactory.InvokeInstruction(callPC, outBundle,
params, exception, site);
@ -276,7 +276,7 @@ public class ExternalModel extends AndroidModel {
final CallSiteReference site = CallSiteReference.make(callPC, mRef, IInvokeInstruction.Dispatch.VIRTUAL);
final SSAValue exception = new SSAValue(nextLocal++, TypeReference.JavaLangException, this.mRef, "exception");
outIntent = new SSAValue(nextLocal++, inIntent);
final List<SSAValue> params = new ArrayList<SSAValue>(3);
final List<SSAValue> params = new ArrayList<>(3);
params.add(inIntent);
params.add(outName);
params.add(outValue);

View File

@ -199,7 +199,7 @@ public class Overrides {
*/
public MethodTargetSelector overrideAll() throws CancelException {
final HashMap<MethodReference, SummarizedMethod> overrides = HashMapFactory.make();
final Map<AndroidComponent, AndroidModel> callTo = new EnumMap<AndroidComponent, AndroidModel>(AndroidComponent.class);
final Map<AndroidComponent, AndroidModel> callTo = new EnumMap<>(AndroidComponent.class);
final IProgressMonitor monitor = AndroidEntryPointManager.MANAGER.getProgressMonitor();
int monitorCounter = 0;

View File

@ -201,7 +201,7 @@ public class SystemServiceModel extends AndroidModel {
if (this.target.equals("phone")) {
retVal = instantiator.createInstance(AndroidTypes.TelephonyManager, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(AndroidTypes.TelephonyManager, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
//} else if (this.target.equals("Lwindow")) { // TODO: Is an interface
//
// final TypeName wmN = TypeName.findOrCreate("Landroid/view/WindowManager");
@ -216,43 +216,43 @@ public class SystemServiceModel extends AndroidModel {
final TypeName n = TypeName.findOrCreate("Landroid/app/KeyguardManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else if (this.target.equals("location")) {
final TypeName n = TypeName.findOrCreate("Landroid/location/LocationManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else if (this.target.equals("search")) {
// TODO: Param: Handler
final TypeName n = TypeName.findOrCreate("Landroid/app/SearchManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
//} else if (this.target.equals("Lvibrator")) { // TODO: Is abstract
} else if (this.target.equals("connection")) {
// TODO: use ConnectivityManager.from
final TypeName n = TypeName.findOrCreate("Landroid/net/ConnectivityManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else if (this.target.equals("wifi")) {
// Handle Params: Context context, IWifiManager service
final TypeName n = TypeName.findOrCreate("Landroid/net/wifi/WifiManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else if (this.target.equals("input_method")) {
// TODO: Use InputMethodManager.getInstance?
final TypeName n = TypeName.findOrCreate("Landroid/view/inputmethod/InputMethodManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else if (this.target.equals("uimode")) {
final TypeName n = TypeName.findOrCreate("Landroid/app/UiModeManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else if (this.target.equals("download")) {
// TODO: Params ContentResolver resolver, String packageName
final TypeName n = TypeName.findOrCreate("Landroid/app/DownloadManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<>(pAcc.all()));
} else {
retVal = pm.getUnmanaged(TypeReference.JavaLangObject, "notFound");
this.body.addConstant(retVal.getNumber(), new ConstantValue(null));

View File

@ -171,10 +171,10 @@ public class UnknownTargetModel extends AndroidModel {
final TypeName[] othersA = miniModel.getDescriptor().getParameters();
final Set<TypeName> others;
if (othersA != null) {
others = new HashSet<TypeName>(Arrays.asList(othersA));
others = new HashSet<>(Arrays.asList(othersA));
} else {
others = new HashSet<TypeName>();
others = new HashSet<>();
}
doMini = others.size() > 0;
others.addAll(Arrays.asList(externalModel.getDescriptor().getParameters()));

View File

@ -87,7 +87,7 @@ public class DexFakeRootMethod extends AbstractRootMethod {
public static final MethodReference rootMethod = MethodReference.findOrCreate(FakeRootClass.FAKE_ROOT_CLASS, name, descr);
public static Map<TypeReference, Integer> referenceTypeMap = new HashMap<TypeReference, Integer>();
public static Map<TypeReference, Integer> referenceTypeMap = new HashMap<>();
// public static Set<TypeReference> referenceTypeSet = new HashSet<TypeReference>();

View File

@ -57,8 +57,8 @@ import com.ibm.wala.util.strings.StringStuff;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
/*package*/ class IntentMap {
private final Map<InstanceKey, Intent> seen = new HashMap<InstanceKey, Intent>();
private final Map<Intent, Intent> immutables = new HashMap<Intent, Intent>();
private final Map<InstanceKey, Intent> seen = new HashMap<>();
private final Map<Intent, Intent> immutables = new HashMap<>();
public Intent findOrCreateImmutable(final Intent intent) {
if (immutables.containsKey(intent)) {

View File

@ -199,7 +199,7 @@ public abstract class AbstractIntRegisterMachine 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) {
private MachineState entry;

View File

@ -118,7 +118,7 @@ public final class AndroidEntryPointLocator {
WITH_ANDROID
}
private final static List<AndroidPossibleEntryPoint> possibleEntryPoints = new ArrayList<AndroidPossibleEntryPoint>();
private final static List<AndroidPossibleEntryPoint> possibleEntryPoints = new ArrayList<>();
protected final Set<LocatorFlags> flags;
public AndroidEntryPointLocator(final Set<LocatorFlags> flags) {
@ -146,7 +146,7 @@ public final class AndroidEntryPointLocator {
throw new IllegalArgumentException("I need a ClassHierarchy to search");
}
Set<AndroidEntryPoint> entryPoints = new HashSet<AndroidEntryPoint>();
Set<AndroidEntryPoint> entryPoints = new HashSet<>();
mon.beginTask("Locating Entrypoints", IProgressMonitor.UNKNOWN);
int dummy = 0; // for the progress monitor
@ -183,7 +183,7 @@ nextMethod:
} // for IClass : cha
if (this.flags.contains(LocatorFlags.EP_HEURISTIC) || this.flags.contains(LocatorFlags.CB_HEURISTIC)) {
final Set<TypeReference> bases = new HashSet<TypeReference>();
final Set<TypeReference> bases = new HashSet<>();
if (this.flags.contains(LocatorFlags.EP_HEURISTIC)) {
// Add bases for EP-Heuristic
@ -216,7 +216,7 @@ nextMethod:
}
List<AndroidEntryPoint> ret = new ArrayList<AndroidEntryPoint>(entryPoints);
List<AndroidEntryPoint> ret = new ArrayList<>(entryPoints);
Collections.sort(ret, new AndroidEntryPoint.ExecutionOrderComperator());
mon.done();
return ret;

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