Remove redundant casts and imports, improve doc comments

This commit is contained in:
Michael Heilmann 2014-06-26 17:51:26 +02:00
parent 080fc8253e
commit 0bb5e6998e
63 changed files with 89 additions and 120 deletions

View File

@ -207,7 +207,7 @@ public class PolyglotIdentityMapper implements IdentityMapper<Type, CodeInstance
}
public String anonLocalTypeToTypeID(ClassType ctype) {
CodeInstance procInstance= (CodeInstance) fLocalTypeMap.get(ctype);
CodeInstance procInstance= fLocalTypeMap.get(ctype);
String outerTypeID= typeToTypeID(ctype.outer());
String shortName= (ctype.isAnonymous()) ? PolyglotJava2CAstTranslator.anonTypeName(ctype) : ctype.fullName().name().toString();

View File

@ -1122,7 +1122,7 @@ public class PolyglotJava2CAstTranslator {
Node stmt = l.statement();
while (stmt instanceof Block) {
stmt = (Node) ((Block) stmt).statements().iterator().next();
stmt = ((Block) stmt).statements().iterator().next();
}
wc.getLabelMap().put(stmt, l.labelNode().id().toString());
@ -1176,7 +1176,7 @@ public class PolyglotJava2CAstTranslator {
Node breakTarget = makeBreakTarget(d);
Node continueTarget = makeContinueTarget(d);
String loopLabel = (String) wc.getLabelMap().get(d);
String loopLabel = wc.getLabelMap().get(d);
CAstNode continueNode = walkNodes(continueTarget, wc);
CAstNode breakNode = walkNodes(breakTarget, wc);
@ -1194,17 +1194,17 @@ public class PolyglotJava2CAstTranslator {
public CAstNode visit(For f, WalkContext wc) {
Node breakTarget = makeBreakTarget(f);
Node continueTarget = makeContinueTarget(f);
String loopLabel = (String) wc.getLabelMap().get(f);
String loopLabel = wc.getLabelMap().get(f);
WalkContext lc = new LoopContext(wc, loopLabel, breakTarget, continueTarget);
CAstNode[] inits = new CAstNode[f.inits().size()];
for (int i = 0; i < inits.length; i++) {
inits[i] = walkNodes((Node) f.inits().get(i), wc);
inits[i] = walkNodes(f.inits().get(i), wc);
}
CAstNode[] iters = new CAstNode[f.iters().size()];
for (int i = 0; i < iters.length; i++) {
iters[i] = walkNodes((Node) f.iters().get(i), wc);
iters[i] = walkNodes(f.iters().get(i), wc);
}
CAstNode initsBlock = makeNode(wc, fFactory, f, CAstNode.BLOCK_STMT, inits);
@ -1223,7 +1223,7 @@ public class PolyglotJava2CAstTranslator {
Node breakTarget = makeBreakTarget(w);
Node continueTarget = makeContinueTarget(w);
String loopLabel = (String) wc.getLabelMap().get(w);
String loopLabel = wc.getLabelMap().get(w);
LoopContext lc = new LoopContext(wc, loopLabel, breakTarget, continueTarget);
/*
@ -1239,7 +1239,7 @@ public class PolyglotJava2CAstTranslator {
fNodeFactory.Id(s.position(), "switchBreakLabel" + s.position().toString().replace('.', '_')),
fNodeFactory.Empty(s.position()));
CAstNode breakAst = walkNodes(breakLabel, wc);
String loopLabel = (String) wc.getLabelMap().get(s);
String loopLabel = wc.getLabelMap().get(s);
WalkContext child = new BreakContext(wc, loopLabel, breakLabel);
Expr cond = s.expr();
List cases = s.elements();
@ -1455,7 +1455,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Iterator getScopedEntities(CAstNode construct) {
public Iterator<CAstEntity> getScopedEntities(CAstNode construct) {
Assertions.UNREACHABLE("CompilationUnitEntity asked for AST-related entities, but it has no AST.");
return null;
}
@ -1494,8 +1494,8 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Collection getQualifiers() {
return Collections.EMPTY_LIST;
public Collection<CAstQualifier> getQualifiers() {
return Collections.emptyList();
}
@Override
@ -1595,7 +1595,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Iterator getScopedEntities(CAstNode construct) {
public Iterator<CAstEntity> getScopedEntities(CAstNode construct) {
if (fEntities.containsKey(construct)) {
return (fEntities.get(construct)).iterator();
} else {
@ -1680,7 +1680,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Iterator getScopedEntities(CAstNode construct) {
public Iterator<CAstEntity> getScopedEntities(CAstNode construct) {
Assertions.UNREACHABLE("Non-AST-bearing entity (ClassEntity) asked for scoped entities related to a given AST node");
return null;
}
@ -1719,7 +1719,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Collection getQualifiers() {
public Collection<CAstQualifier> getQualifiers() {
if (fCT == fTypeSystem.Object()) { // pretend the root of the hierarchy is always a class
return mapFlagsToQualifiers(fCT.flags().clear(Flags.INTERFACE));
}
@ -1858,7 +1858,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Collection getQualifiers() {
public Collection<CAstQualifier> getQualifiers() {
return mapFlagsToQualifiers(getFlags());
}
@ -1882,7 +1882,7 @@ public class PolyglotJava2CAstTranslator {
fParameterTypes = new ArrayList<CAstType>(formalTypes.size());
for (Iterator iter = formalTypes.iterator(); iter.hasNext();) {
fParameterTypes.add(fMc.getTypeDictionary().getCAstTypeFor((Type) iter.next()));
fParameterTypes.add(fMc.getTypeDictionary().getCAstTypeFor(iter.next()));
}
}
return fParameterTypes;
@ -1980,7 +1980,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Iterator getScopedEntities(CAstNode construct) {
public Iterator<CAstEntity> getScopedEntities(CAstNode construct) {
return EmptyIterator.instance();
}
@ -2028,7 +2028,7 @@ public class PolyglotJava2CAstTranslator {
}
@Override
public Collection getQualifiers() {
public Collection<CAstQualifier> getQualifiers() {
return mapFlagsToQualifiers(fFI.flags());
}
@ -2641,9 +2641,9 @@ public class PolyglotJava2CAstTranslator {
* Maps front-end-specific representations into WALA references of the appropriate kind.
* @author rfuhrer
*
* @param <T> The front-end-specific representation of a type (e.g., for Polyglot, a Type)
* @param <M> The front-end-specific representation of a procedure/method (e.g., for Polyglot, a CodeInstance)
* @param <F> The front-end-specific representation of a field (e.g., for Polyglot, a FieldInstance)
* @param <TypeRep> The front-end-specific representation of a type (e.g., for Polyglot, a Type)
* @param <MethodRep> The front-end-specific representation of a procedure/method (e.g., for Polyglot, a CodeInstance)
* @param <FieldRep> The front-end-specific representation of a field (e.g., for Polyglot, a FieldInstance)
*/
public interface IdentityMapper<TypeRep, MethodRep, FieldRep> {
MemberReference getMethodRef(MethodRep method);
@ -2783,7 +2783,6 @@ public class PolyglotJava2CAstTranslator {
return ct.fullName() + "$" + pos.line() + "$" + pos.column();
}
@SuppressWarnings("unchecked")
protected CAstEntity walkEntity(Node rootNode, final WalkContext context) {
if (rootNode instanceof SourceFile) {
SourceFile file = (SourceFile) rootNode;
@ -2806,7 +2805,7 @@ public class PolyglotJava2CAstTranslator {
} else if (rootNode instanceof New) {
final New n = (New) rootNode;
final List<CAstEntity> memberEntities = new ArrayList<CAstEntity>();
ClassType anonType = (ClassType) n.anonType().asType();
ClassType anonType = n.anonType().asType();
String anonTypeName = anonTypeName(anonType);
final ClassContext classContext = new ClassContext(anonType, memberEntities, context);
@ -2865,7 +2864,7 @@ public class PolyglotJava2CAstTranslator {
if (body.statements().size() <= 0)
return false;
Stmt maybeSuper = (Stmt) body.statements().get(0);
Stmt maybeSuper = body.statements().get(0);
return isSpecialCallStmt(maybeSuper, kind);
}

View File

@ -135,7 +135,7 @@ public class AstJavaTypeInference extends AstTypeInference {
for (int i = 0; i < rhs.length; i++) {
if (rhs[i] != null) {
TypeVariable r = (TypeVariable) rhs[i];
TypeVariable r = rhs[i];
TypeAbstraction ta = r.getType();
if (ta instanceof PointType) {
if (ta.getType().equals(getStringClass())) {
@ -154,7 +154,7 @@ public class AstJavaTypeInference extends AstTypeInference {
if (meet == null) {
return super.evaluate(lhs, rhs);
} else {
TypeVariable L = (TypeVariable) lhs;
TypeVariable L = lhs;
TypeAbstraction lhsType = L.getType();
if (lhsType.equals(meet)) {

View File

@ -18,7 +18,6 @@ import com.ibm.wala.cast.tree.CAstControlFlowMap;
import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.CAstNode;
import com.ibm.wala.cast.tree.CAstSourcePositionMap;
import com.ibm.wala.cast.tree.CAstType;
import com.ibm.wala.cast.tree.impl.CAstOperator;
import com.ibm.wala.cast.tree.rewrite.CAstRewriter;
import com.ibm.wala.classLoader.CallSiteReference;

View File

@ -174,7 +174,7 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
system.newSideEffect(new UnaryOperator<PointsToSetVariable>() {
@Override
public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) {
IntSetVariable tv = (IntSetVariable) rhs;
IntSetVariable tv = rhs;
if (tv.getValue() != null) {
tv.getValue().foreach(new IntSetAction() {
@Override

View File

@ -31,11 +31,9 @@ public class AstJavaZeroOneContainerCFABuilder extends AstJavaCFABuilder {
/**
* @param cha governing class hierarchy
* @param warnings object to track analysis warnings
* @param options call graph construction options
* @param appContextSelector application-specific logic to choose contexts
* @param appContextInterpreter application-specific logic to interpret a method in context
* @param reflect reflection specification
*/
public AstJavaZeroOneContainerCFABuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) {

View File

@ -21,7 +21,7 @@ import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys;
import com.ibm.wala.ipa.cha.IClassHierarchy;
/**
* 0-1-CFA Call graph builder, optimized to not disambiguate instances of "uninteresting" types
* 0-1-CFA Call graph builder, optimized to not disambiguate instances of "uninteresting" types.
*/
public class AstJavaZeroXCFABuilder extends AstJavaCFABuilder {
@ -47,7 +47,6 @@ public class AstJavaZeroXCFABuilder extends AstJavaCFABuilder {
* @param cl classloader that can find DOMO resources
* @param scope representation of the analysis scope
* @param xmlFiles set of Strings that are names of XML files holding bypass logic specifications.
* @param dmd deployment descriptor abstraction
* @return a 0-1-Opt-CFA Call Graph Builder.
*/
public static AstJavaCFABuilder make(AnalysisOptions options, AnalysisCache cache, IClassHierarchy cha, ClassLoader cl,

View File

@ -57,7 +57,7 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
if (AstTranslator.DEBUG_LEXICAL)
System.err.println((base + " has parents: " + result));
return (LexicalParent[]) result.toArray(new LexicalParent[result.size()]);
return result.toArray(new LexicalParent[result.size()]);
}
}

View File

@ -49,11 +49,11 @@ public class JavaPrimitiveTypeMap {
}
public static String getShortName(String longName) {
return ((JavaPrimitiveType) primNameMap.get(longName)).getName();
return primNameMap.get(longName).getName();
}
public static JavaPrimitiveType lookupType(String longName) {
return (JavaPrimitiveType) primNameMap.get(longName);
return primNameMap.get(longName);
}
public static final JavaPrimitiveType VoidType = new JavaPrimitiveType("void", "V");

View File

@ -7,7 +7,6 @@ import org.junit.Test;
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.Error;
import com.ibm.wala.cast.js.rhino.callgraph.fieldbased.test.CGUtil.BuilderType;
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.WalaException;

View File

@ -50,7 +50,7 @@ public class JavaScriptAnalysisEngine extends AbstractAnalysisEngine {
try {
loaderFactory = new JavaScriptLoaderFactory(translatorFactory);
SourceModule[] files = (SourceModule[]) moduleFiles.toArray(new SourceModule[moduleFiles.size()]);
SourceModule[] files = moduleFiles.toArray(new SourceModule[moduleFiles.size()]);
scope = new CAstAnalysisScope(files, loaderFactory, Collections.singleton(JavaScriptLoader.JS));
} catch (IOException e) {

View File

@ -10,7 +10,6 @@
*****************************************************************************/
package com.ibm.wala.cast.js.translator;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@ -36,7 +35,6 @@ import com.ibm.wala.cfg.AbstractCFG;
import com.ibm.wala.cfg.IBasicBlock;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAInstructionFactory;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.MethodReference;
@ -379,7 +377,7 @@ public class JSAstTranslator extends AstTranslator {
if (f.getKind() == CAstNode.CONSTANT && f.getValue() instanceof String) {
String field = (String) f.getValue();
FieldReference fieldRef = FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom((String) field),
FieldReference fieldRef = FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field),
JavaScriptTypes.Root);
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(result, ref, fieldRef));
@ -392,7 +390,7 @@ public class JSAstTranslator extends AstTranslator {
@Override
protected boolean visitInstanceOf(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
WalkContext context = (WalkContext) c;
WalkContext context = c;
int result = context.currentScope().allocateTempValue();
context.setValue(n, result);
return false;
@ -400,7 +398,7 @@ public class JSAstTranslator extends AstTranslator {
@Override
protected void leaveInstanceOf(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
WalkContext context = (WalkContext) c;
WalkContext context = c;
int result = context.getValue(n);
visit(n.getChild(0), context, visitor);

View File

@ -29,7 +29,6 @@ import com.ibm.wala.util.collections.Filter;
import com.ibm.wala.util.collections.FilterIterator;
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.intset.OrdinalSet;
/**
* An {@link InstanceKeyFactory} that returns {@link ScopeMappingInstanceKey}s

View File

@ -45,8 +45,9 @@ public abstract class FixedParametersInvokeInstruction
/**
* Constructor InvokeInstruction. This case for void return values
* @param i
* @param params
* @param exception
* @param site
*/
public FixedParametersInvokeInstruction(int[] params, int exception, CallSiteReference site) {
this(null, params, exception, site);

View File

@ -10,7 +10,6 @@
*****************************************************************************/
package com.ibm.wala.cast.loader;
import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
import java.util.Collection;

View File

@ -10,7 +10,6 @@
*****************************************************************************/
package com.ibm.wala.cast.loader;
import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
import java.util.Collection;

View File

@ -27,7 +27,6 @@ import com.ibm.wala.cast.tree.CAst;
import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.impl.CAstImpl;
import com.ibm.wala.cast.util.CAstPrinter;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader;
import com.ibm.wala.classLoader.Module;
import com.ibm.wala.classLoader.ModuleEntry;

View File

@ -12,7 +12,6 @@ package com.ibm.wala.cast.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.ArrayList;

View File

@ -33,7 +33,7 @@ import com.ibm.wala.util.intset.MutableMapping;
import com.ibm.wala.util.intset.OrdinalSetMapping;
/**
* Simple Regression test for a graph-based dataflow problem
* Simple Regression test for a graph-based dataflow problem.
*/
public class GraphDataflowTest extends WalaTestCase {
@ -211,7 +211,7 @@ public class GraphDataflowTest extends WalaTestCase {
StringBuffer result = new StringBuffer("------\n");
for (int i = 0; i < nodes.length; i++) {
String n = nodes[i];
BitVectorVariable varI = (BitVectorVariable) solver.getOut(n);
BitVectorVariable varI = solver.getOut(n);
String s = varI.toString();
result.append("Node " + n + "(" + i + ") = " + s + "\n");
}

View File

@ -608,16 +608,16 @@ public class PrimitivesTest extends WalaTestCase {
M.put(I2, I2);
M.put(I3, I3);
Integer I = (Integer) M.get(new Integer(2));
Integer I = M.get(new Integer(2));
Assert.assertTrue(I != null);
Assert.assertTrue(I.equals(I2));
I = (Integer) M.get(new Integer(4));
I = M.get(new Integer(4));
Assert.assertTrue(I == null);
I = (Integer) M.put(new Integer(2), new Integer(3));
I = M.put(new Integer(2), new Integer(3));
Assert.assertTrue(I.equals(I2));
I = (Integer) M.get(I2);
I = M.get(I2);
Assert.assertTrue(I.equals(I3));
}

View File

@ -383,7 +383,7 @@ public class CallGraphTest extends WalaTestCase {
int count = 0;
for (Iterator<BasicBlockInContext<ISSABasicBlock>> it = icfg.iterator(); it.hasNext();) {
BasicBlockInContext<ISSABasicBlock> bb = it.next();
if (icfg.hasCall((BasicBlockInContext<ISSABasicBlock>) bb)) {
if (icfg.hasCall(bb)) {
count++;
}
}
@ -444,7 +444,7 @@ public class CallGraphTest extends WalaTestCase {
}
final Set<MethodReference> nodes = HashSetFactory.make();
for (Iterator<CGNode> nodesI = cg.iterator(); nodesI.hasNext();) {
nodes.add(((CGNode) nodesI.next()).getMethod().getReference());
nodes.add((nodesI.next()).getMethod().getReference());
}
return new Graph<MethodReference>() {

View File

@ -59,7 +59,7 @@ public class ClassConstantTest extends WalaTestCase {
MethodReference mainMethodRef = MethodReference.findOrCreate(mainClassRef, "main", "([Ljava/lang/String;)V");
Set<CGNode> mainMethodNodes = cg.getNodes(mainMethodRef);
Assert.assertFalse(mainMethodNodes.isEmpty());
CGNode mainMethodNode = (CGNode) mainMethodNodes.iterator().next();
CGNode mainMethodNode = mainMethodNodes.iterator().next();
// Trace.println("main IR:");
// Trace.println(mainMethodNode.getIR());

View File

@ -51,12 +51,12 @@ public class CloneTest extends WalaTestCase {
// Find node corresponding to java.text.MessageFormat.clone()
TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/text/MessageFormat");
MethodReference m = MethodReference.findOrCreate(t, "clone", "()Ljava/lang/Object;");
CGNode node = (CGNode) cg.getNodes(m).iterator().next();
CGNode node = cg.getNodes(m).iterator().next();
// Check there's exactly one target for each super call in
// MessageFormat.clone()
for (Iterator<CallSiteReference> i = node.iterateCallSites(); i.hasNext();) {
CallSiteReference site = (CallSiteReference) i.next();
CallSiteReference site = i.next();
if (site.isSpecial()) {
if (site.getDeclaredTarget().getDeclaringClass().equals(TypeReference.JavaLangObject)) {
Set<CGNode> targets = cg.getPossibleTargets(node, site);

View File

@ -95,7 +95,7 @@ public class ReflectionTest extends WalaTestCase {
Warnings.clear();
CallGraphTest.doCallGraphs(options, new AnalysisCache(), cha, scope);
for (Iterator<Warning> it = Warnings.iterator(); it.hasNext();) {
Warning w = (Warning) it.next();
Warning w = it.next();
if (w.toString().indexOf("com/ibm/jvm") > 0) {
continue;
}
@ -282,7 +282,7 @@ public class ReflectionTest extends WalaTestCase {
if (context instanceof ReceiverInstanceContext && node.getMethod().getReference().equals(newInstanceMr)) {
ReceiverInstanceContext r = (ReceiverInstanceContext) context;
ConstantKey<IMethod> c = (ConstantKey<IMethod>) r.getReceiver();
IMethod ctor = (IMethod) c.getValue();
IMethod ctor = c.getValue();
if (ctor.getSignature().equals(fpInitSig)) {
filePermConstrNewInstanceNode = node;
break;

View File

@ -218,7 +218,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
for (IClass cls : cha) {
Collection<IField> staticFields = cls.getDeclaredStaticFields();
for (Iterator<IField> sfs = staticFields.iterator(); sfs.hasNext();) {
IField sf = (IField) sfs.next();
IField sf = sfs.next();
if (sf.getFieldTypeReference().isReferenceType()) {
escapeAnalysisRoots.add(heapModel.getPointerKeyForStaticField(sf));
}
@ -232,13 +232,13 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
// Thread objects must be constructed somewhere)
Collection<IClass> threads = cha.computeSubClasses(TypeReference.JavaLangThread);
for (Iterator<IClass> clss = threads.iterator(); clss.hasNext();) {
IClass cls = (IClass) clss.next();
IClass cls = clss.next();
for (Iterator<IMethod> ms = cls.getDeclaredMethods().iterator(); ms.hasNext();) {
IMethod m = (IMethod) ms.next();
IMethod m = ms.next();
if (m.isInit()) {
Set<CGNode> nodes = cg.getNodes(m.getReference());
for (Iterator<CGNode> ns = nodes.iterator(); ns.hasNext();) {
CGNode n = (CGNode) ns.next();
CGNode n = ns.next();
escapeAnalysisRoots.add(heapModel.getPointerKeyForLocal(n, 1));
}
}
@ -258,7 +258,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
PointerKey root = rts.next();
OrdinalSet<? extends InstanceKey> objects = pa.getPointsToSet(root);
for (Iterator<? extends InstanceKey> objs = objects.iterator(); objs.hasNext();) {
InstanceKey obj = (InstanceKey) objs.next();
InstanceKey obj = objs.next();
escapingInstanceKeys.add(obj);
}
}
@ -278,7 +278,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
PointerKey fk = heapModel.getPointerKeyForArrayContents(key);
OrdinalSet<? extends InstanceKey> fobjects = pa.getPointsToSet(fk);
for (Iterator<? extends InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
InstanceKey fobj = (InstanceKey) fobjs.next();
InstanceKey fobj = fobjs.next();
if (!escapingInstanceKeys.contains(fobj)) {
newKeys.add(fobj);
}
@ -287,12 +287,12 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
} else {
Collection<IField> fields = type.getAllInstanceFields();
for (Iterator<IField> fs = fields.iterator(); fs.hasNext();) {
IField f = (IField) fs.next();
IField f = fs.next();
if (f.getFieldTypeReference().isReferenceType()) {
PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
OrdinalSet<? extends InstanceKey> fobjects = pa.getPointsToSet(fk);
for (Iterator<? extends InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
InstanceKey fobj = (InstanceKey) fobjs.next();
InstanceKey fobj = fobjs.next();
if (!escapingInstanceKeys.contains(fobj)) {
newKeys.add(fobj);
}
@ -339,7 +339,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
IClass cls = types.next();
if (!cls.isArrayClass()) {
for (Iterator<IField> fs = cls.getAllFields().iterator(); fs.hasNext();) {
IField f = (IField) fs.next();
IField f = fs.next();
if (!f.isVolatile() && !f.isFinal()) {
System.err.println(f.getReference());
}

View File

@ -163,8 +163,7 @@ public class PDFSDG {
private static Graph<Statement> pruneSDG(final SDG sdg) {
Filter<Statement> f = new Filter<Statement>() {
@Override
public boolean accepts(Statement o) {
Statement s = (Statement) o;
public boolean accepts(Statement s) {
if (s.getNode().equals(sdg.getCallGraph().getFakeRootNode())) {
return false;
} else if (s instanceof MethodExitStatement || s instanceof MethodEntryStatement) {

View File

@ -18,7 +18,6 @@ import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.impl.DelegatingContextSelector;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.cfa.DelegatingSSAContextInterpreter;
import com.ibm.wala.util.intset.EmptyIntSet;
import com.ibm.wala.util.intset.IntSet;

View File

@ -309,8 +309,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
TypeAbstraction lhsType = lhs.getType();
TypeAbstraction meet = TypeAbstraction.TOP;
for (int i = 0; i < rhs.length; i++) {
if (rhs[i] != null && ((TypeVariable)rhs[i]).getType() != null) {
TypeVariable r = (TypeVariable) rhs[i];
if (rhs[i] != null && rhs[i].getType() != null) {
TypeVariable r = rhs[i];
meet = meet.meet(r.getType());
}
}
@ -350,7 +350,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
public byte evaluate(TypeVariable lhs, TypeVariable[] rhsOperands) {
TypeAbstraction lhsType = lhs.getType();
TypeVariable rhs = (TypeVariable) rhsOperands[0];
TypeVariable rhs = rhsOperands[0];
TypeAbstraction rhsType = rhs.getType();
if (lhsType.equals(rhsType)) {

View File

@ -14,7 +14,6 @@ import static com.ibm.wala.types.TypeName.ArrayMask;
import static com.ibm.wala.types.TypeName.ElementBits;
import static com.ibm.wala.types.TypeName.PrimitiveMask;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.Collections;

View File

@ -11,7 +11,6 @@
package com.ibm.wala.classLoader;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.NoSuchElementException;

View File

@ -12,7 +12,6 @@
package com.ibm.wala.classLoader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.Iterator;

View File

@ -30,11 +30,7 @@ public class SourceFileModule extends FileModule implements Module, ModuleEntry,
}
public SourceFileModule(File f, SourceFileModule clonedFrom) {
super(f, clonedFrom.getContainer());
if (clonedFrom == null) {
throw new IllegalArgumentException("clonedFrom is null");
}
this.fileName = clonedFrom.fileName;
}

View File

@ -11,7 +11,6 @@
package com.ibm.wala.classLoader;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.Collections;

View File

@ -36,7 +36,7 @@ import com.ibm.wala.util.intset.IntIterator;
import com.ibm.wala.util.intset.IntSet;
/**
* A simple liveness analysis based on flow-insensitive pointer analysis
* A simple liveness analysis based on flow-insensitive pointer analysis.
*/
public class FILiveObjectAnalysis implements ILiveObjectAnalysis {

View File

@ -16,7 +16,7 @@ import com.ibm.wala.util.WalaException;
import com.ibm.wala.util.intset.IntSet;
/**
* Basic interface for liveness analysis of heap-allocated objects
* Basic interface for liveness analysis of heap-allocated objects.
*/
public interface ILiveObjectAnalysis {

View File

@ -14,7 +14,7 @@ import com.ibm.wala.types.MethodReference;
import com.ibm.wala.util.WalaException;
/**
* Basic interface from which to execute and get the results of escape analysis
* Basic interface from which to execute and get the results of escape analysis.
*/
public interface IMethodEscapeAnalysis {

View File

@ -14,7 +14,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.util.WalaException;
/**
* Basic interface from which to execute and get the results of escape analysis
* Basic interface from which to execute and get the results of escape analysis.
*/
public interface INodeEscapeAnalysis extends IMethodEscapeAnalysis {

View File

@ -10,7 +10,6 @@
*******************************************************************************/
package com.ibm.wala.ipa.callgraph.impl;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.Collections;
@ -35,7 +34,7 @@ import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.strings.Atom;
/**
* A synthetic class for the fake root method
* A synthetic class for the fake root method.
*/
public class FakeRootClass extends SyntheticClass {
public static final TypeReference FAKE_ROOT_CLASS = TypeReference.findOrCreate(ClassLoaderReference.Primordial, TypeName

View File

@ -16,7 +16,7 @@ import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
/**
* abstract base class for solver for pointer analysis
* Abstract base class for solver for pointer analysis.
*/
public abstract class AbstractPointsToSolver implements IPointsToSolver {

View File

@ -16,7 +16,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.util.debug.Assertions;
/**
* Abstract base class for {@link InstanceKey} which represents at least some {@link IClass} in some {@link CGNode}
* Abstract base class for {@link InstanceKey} which represents at least some {@link IClass} in some {@link CGNode}.
*/
public abstract class AbstractTypeInNode implements InstanceKeyWithNode {
private final IClass type;

View File

@ -14,7 +14,7 @@ import com.ibm.wala.fixpoint.UnaryOperator;
import com.ibm.wala.fixpoint.UnaryStatement;
/**
* A specialized equation class introduced for efficiency
* A specialized equation class introduced for efficiency.
*/
public final class AssignEquation extends UnaryStatement<PointsToSetVariable> {

View File

@ -30,7 +30,7 @@ import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.functions.Function;
/**
* An instance key which represents a unique set for each concrete type
* An instance key which represents a unique set for each concrete type.
*/
public final class ConcreteTypeKey implements InstanceKey {
private final IClass type;

View File

@ -20,7 +20,7 @@ import com.ibm.wala.util.collections.EmptyIterator;
import com.ibm.wala.util.collections.Pair;
/**
* An instance key which represents a unique, constant object
* An instance key which represents a unique, constant object.
*/
public final class ConstantKey<T> implements InstanceKey {
private final T value;

View File

@ -11,7 +11,7 @@
package com.ibm.wala.ipa.callgraph.propagation;
/**
* An operator in pointer analysis constraints
* An operator in pointer analysis constraints.
*/
public interface IPointerOperator {

View File

@ -35,7 +35,7 @@ import com.ibm.wala.util.Predicate;
import com.ibm.wala.util.collections.HashSetFactory;
/**
* a helper class which can modify a {@link PropagationCallGraphBuilder} to deal with reflective factory methods.
* A helper class which can modify a {@link PropagationCallGraphBuilder} to deal with reflective factory methods.
*/
public class ReflectionHandler {
private final static boolean VERBOSE = false;

View File

@ -13,7 +13,7 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* A key which represents the return value for a node
* A key which represents the return value for a node.
*/
public class ReturnValueKey extends NodeKey {
public ReturnValueKey(CGNode node) {

View File

@ -13,7 +13,7 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.classLoader.IField;
/**
* An pointer key which represents a unique set for each static field
* An pointer key which represents a unique set for each static field.
*/
public final class StaticFieldKey extends AbstractPointerKey {
private final IField field;

View File

@ -16,7 +16,7 @@ import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.ipa.callgraph.ContextKey;
/**
* A context which is a <CGNode, CallSiteReference> pair
* A context which is a <CGNode, CallSiteReference> pair.
*/
public class CallerSiteContext extends CallerContext {

View File

@ -24,8 +24,7 @@ import com.ibm.wala.ssa.ISSABasicBlock;
import com.ibm.wala.ssa.SSAInstruction;
/**
* Default implementation of SSAContextInterpreter for context-insensitive
* analysis
* Default implementation of SSAContextInterpreter for context-insensitive analysis.
*/
public class ContextInsensitiveSSAInterpreter extends ContextInsensitiveRTAInterpreter implements SSAContextInterpreter {

View File

@ -14,7 +14,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.propagation.ReturnValueKey;
/**
* A key which represents the return value for a node
* A key which represents the return value for a node.
*/
public final class ExceptionReturnValueKey extends ReturnValueKey {
ExceptionReturnValueKey(CGNode node) {

View File

@ -23,7 +23,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
/**
* 0-1-CFA Call graph builder, optimized to not disambiguate instances of "uninteresting" types
* 0-1-CFA Call graph builder, optimized to not disambiguate instances of "uninteresting" types.
*/
public class ZeroXCFABuilder extends SSAPropagationCallGraphBuilder {

View File

@ -742,9 +742,6 @@ public class ClassHierarchy implements IClassHierarchy {
public IClass getLeastCommonSuperclass(IClass a, IClass b) {
assert (a.getClassLoader().getLanguage().equals(b.getClassLoader().getLanguage()));
Language lang = a.getClassLoader().getLanguage();
if (a == null) {
throw new IllegalArgumentException("A is null");
}
TypeReference tempA = a.getReference();
if (a.equals(b)) {
return a;

View File

@ -11,7 +11,6 @@
package com.ibm.wala.ipa.summaries;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.HashMap;

View File

@ -2430,7 +2430,7 @@ public class JDTJava2CAstTranslator {
}
private CAstNode visit(DoStatement n, WalkContext context) {
String loopLabel = (String) context.getLabelMap().get(n); // set by visit(LabeledStatement)
String loopLabel = context.getLabelMap().get(n); // set by visit(LabeledStatement)
String token = loopLabel==null? "at_" + n.getStartPosition(): loopLabel;
ASTNode breakTarget = makeBreakOrContinueTarget(n, "breakLabel_" + token);

View File

@ -90,7 +90,7 @@ public class JDTSourceModuleTranslator implements SourceModuleTranslator {
List<Module> modules = scope.getModules(cl);
for (Iterator<Module> iter = modules.iterator(); iter.hasNext();) {
Module m = (Module) iter.next();
Module m = iter.next();
if (buf.length() > 0)
buf.append(File.pathSeparator);

View File

@ -44,7 +44,6 @@ import com.ibm.wala.ide.util.JavaScriptEclipseProjectPath;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.callgraph.Entrypoint;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;

View File

@ -12,14 +12,12 @@ package com.ibm.wala.shrikeBT.tools;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.BitSet;

View File

@ -59,7 +59,7 @@ public class BitVectorUnion extends AbstractMeetOperator<BitVectorVariable> impl
BitVectorVariable U = new BitVectorVariable();
U.copyState(lhs);
for (int i = 0; i < rhs.length; i++) {
BitVectorVariable R = (BitVectorVariable) rhs[i];
BitVectorVariable R = rhs[i];
U.addAll(R);
}
if (!lhs.sameValue(U)) {

View File

@ -53,7 +53,7 @@ public class BooleanUnion extends AbstractMeetOperator<BooleanVariable> implemen
BooleanVariable U = new BooleanVariable();
U.copyState(lhs);
for (int i = 0; i < rhs.length; i++) {
BooleanVariable R = (BooleanVariable) rhs[i];
BooleanVariable R = rhs[i];
if (R != null) {
U.or(R);
}

View File

@ -11,7 +11,7 @@
package com.ibm.wala.util.collections;
/**
* Simple interface for an intensional set definition
* Simple interface for an intensional set definition.
*/
@Deprecated
public interface Filter<T> {

View File

@ -953,7 +953,7 @@ public class MutableSharedBitVectorIntSet implements MutableIntSet {
if (sharedPart == null) {
return MutableSparseIntSet.makeEmpty();
} else {
return (MutableSparseIntSet) new MutableSparseIntSetFactory().makeCopy(sharedPart);
return new MutableSparseIntSetFactory().makeCopy(sharedPart);
}
} else {
if (sharedPart == null) {

View File

@ -23,7 +23,7 @@ public class MutableSharedBitVectorIntSetFactory implements MutableIntSetFactory
*/
@Override
public MutableSharedBitVectorIntSet make(int[] set) {
SparseIntSet s = (SparseIntSet) sparseFactory.make(set);
SparseIntSet s = sparseFactory.make(set);
return new MutableSharedBitVectorIntSet(s);
}
@ -32,7 +32,7 @@ public class MutableSharedBitVectorIntSetFactory implements MutableIntSetFactory
*/
@Override
public MutableSharedBitVectorIntSet parse(String string) throws NumberFormatException {
SparseIntSet s = (SparseIntSet) sparseFactory.parse(string);
SparseIntSet s = sparseFactory.parse(string);
return new MutableSharedBitVectorIntSet(s);
}

View File

@ -271,7 +271,7 @@ public class JavaLauncher extends Launcher {
} else {
for (Iterator<String> it = getXtraClassPath().iterator(); it.hasNext();) {
cp += File.pathSeparatorChar;
cp += (String) it.next();
cp += it.next();
}
return cp.trim();
}