Fix 19 Eclipse warnings about unnecessary casts

This commit is contained in:
Ben Liblit 2017-03-18 00:41:04 -05:00
parent fe9f7a793a
commit e52d872e3e
14 changed files with 21 additions and 22 deletions

View File

@ -88,7 +88,7 @@ public class JDTIdentityMapper {
* This method canonicalizes the TypeReferences
*/
public TypeReference getTypeRef(ITypeBinding type) {
type = JDT2CAstUtils.getErasedType((ITypeBinding) type, fAst); // GENERICS: erasure...
type = JDT2CAstUtils.getErasedType(type, fAst); // GENERICS: erasure...
if (!fTypeMap.containsKey(type.getKey())) {
TypeName typeName = TypeName.string2TypeName(typeToTypeID(type));

View File

@ -548,7 +548,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
// TODO 1.6: enums of course...
AbstractTypeDeclaration decl = n.getDeclaration();
assert decl instanceof TypeDeclaration : "Local enum declaration not yet supported";
CAstEntity classEntity = visitTypeDecl((TypeDeclaration) decl, context);
CAstEntity classEntity = visitTypeDecl(decl, context);
// these statements doin't actually do anything, just define a type
final CAstNode lcdNode = makeNode(context, fFactory, n, CAstNode.EMPTY);

View File

@ -288,15 +288,15 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
if (isStatic()) {
types = new TypeReference[argCount];
for (int i = 0; i < argCount; i++) {
types[i] = TypeReference.findOrCreate(JavaSourceLoaderImpl.this.getReference(), ((CAstType) type.getArgumentTypes()
.get(i)).getName());
types[i] = TypeReference.findOrCreate(JavaSourceLoaderImpl.this.getReference(), type.getArgumentTypes()
.get(i).getName());
}
} else {
types = new TypeReference[argCount + 1];
types[0] = cls.getReference();
for (int i = 0; i < argCount; i++) {
types[i + 1] = TypeReference.findOrCreate(JavaSourceLoaderImpl.this.getReference(), ((CAstType) type.getArgumentTypes()
.get(i)).getName());
types[i + 1] = TypeReference.findOrCreate(JavaSourceLoaderImpl.this.getReference(), type.getArgumentTypes()
.get(i).getName());
}
}

View File

@ -240,7 +240,7 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
return (String)v;
} else if (v instanceof Double) {
String result = v.toString();
if (((double) Math.round((Double)v)) == ((Double)v).doubleValue()) {
if ((Math.round((Double)v)) == ((Double)v).doubleValue()) {
result = Long.toString(Math.round((Double)v));
}
return result;

View File

@ -20,7 +20,7 @@ public class Slice6 {
messages = new Vector<Integer>();
messages.add(5);
int message = (Integer) messages.elementAt(0);
int message = messages.elementAt(0);
sendMessage(message);
}

View File

@ -56,7 +56,7 @@ public class PDFCallGraph {
Collection<String> result = HashSetFactory.make();
for (int i = 0; i < directories.length; i++) {
for (Iterator<File> it = FileUtil.listFiles(directories[i], ".*\\.jar", true).iterator(); it.hasNext();) {
File f = (File) it.next();
File f = it.next();
result.add(f.getAbsolutePath());
}
}

View File

@ -88,7 +88,7 @@ public class SummarizedMethodWithNames extends SummarizedMethod {
throws NullPointerException {
super(ref, summary.getMethodSummary(), declaringClass);
this.summary = summary.getMethodSummary();
this.localNames = ((VolatileMethodSummary)summary).getLocalNames();
this.localNames = summary.getLocalNames();
if (DEBUG && this.localNames.isEmpty()) {
System.err.println("Local names are empty for " + ref);
}

View File

@ -101,7 +101,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
}
public Instruction[] getInstructions() {
return (Instruction[])dexMethod.getDexInstructions();
return dexMethod.getDexInstructions();
}
@ -417,7 +417,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
if (pei == null) {
throw new IllegalArgumentException("pei is null");
}
switch (((Instruction) pei).getOpcode()) {
switch (pei.getOpcode()) {
//TODO: Make sure all the important cases and exceptions are covered.
case AGET:
case AGET_WIDE:

View File

@ -674,7 +674,7 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < instructions().size(); i++) {
handlers[i] = (ExceptionHandler[])temp_array.get(i).toArray(new ExceptionHandler[temp_array.get(i).size()]);
handlers[i] = temp_array.get(i).toArray(new ExceptionHandler[temp_array.get(i).size()]);
/*
System.out.println("i: " + i);
@ -3148,7 +3148,7 @@ public class DexIMethod implements IBytecodeMethod {
}
public Instruction[] getDexInstructions() {
return (Instruction[]) instructions().toArray(new Instruction[instructions().size()]);
return instructions().toArray(new Instruction[instructions().size()]);
}

View File

@ -138,7 +138,7 @@ public class WDexClassLoaderImpl extends ClassLoaderImpl {
private Set<ModuleEntry> getDexFiles(Module M) {
HashSet<ModuleEntry> result = HashSetFactory.make();
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
ModuleEntry entry = (ModuleEntry) it.next();
ModuleEntry entry = it.next();
if (entry instanceof DexModuleEntry) {
result.add(entry);
}

View File

@ -486,7 +486,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
int i = 0;
while (iae.hasNext())
{
ArrayElement ae = (ArrayElement)iae.next();
ArrayElement ae = iae.next();
int ElementWidth = ae.elementWidth;
int index = symbolTable.getConstant(i);
@ -508,9 +508,9 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
if (t.equals(TypeReference.Char))
value = symbolTable.getConstant(Character.toString(byte_buffer.getChar()));
else if (t.equals(TypeReference.Byte))
value = symbolTable.getConstant((int)byte_buffer.get());
value = symbolTable.getConstant(byte_buffer.get());
else if (t.equals(TypeReference.Short))
value = symbolTable.getConstant((int)byte_buffer.getShort());
value = symbolTable.getConstant(byte_buffer.getShort());
else if (t.equals(TypeReference.Int))
value = symbolTable.getConstant(byte_buffer.getInt());
else if (t.equals(TypeReference.Long))

View File

@ -87,7 +87,6 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
import com.ibm.wala.ipa.cfg.BasicBlockInContext;
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ssa.IRFactory;
import com.ibm.wala.ssa.ISSABasicBlock;
import com.ibm.wala.ssa.SSACFG;
import com.ibm.wala.ssa.SSACFG.BasicBlock;
@ -145,7 +144,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
}
analysisOptions.setReflectionOptions(options.getReflectionOptions());
AnalysisCache cache = new AnalysisCacheImpl((IRFactory<IMethod>) new DexIRFactory());
AnalysisCache cache = new AnalysisCacheImpl(new DexIRFactory());
SSAPropagationCallGraphBuilder cgb;

View File

@ -288,7 +288,7 @@ public class EntryPoints {
private static String getTagValue(String sTag, Element eElement) {
NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
Node nValue = (Node) nlList.item(0);
Node nValue = nlList.item(0);
return nValue.getNodeValue();
}

View File

@ -330,7 +330,7 @@ public final class ClassReader implements ClassConstants {
* @return the unsigned 8-bit value at offset i in the class data
*/
public int getUnsignedByte(int i) {
return ((int) bytes[i]) & 0xff;
return bytes[i] & 0xff;
}
/**