bug fixes and assertions for reflection corner cases
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2727 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
bf8e4d8b58
commit
9b266acea0
|
@ -87,8 +87,9 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
|||
if (node == null) {
|
||||
throw new IllegalArgumentException("node is null");
|
||||
}
|
||||
if (!(node.getContext() instanceof JavaTypeContext))
|
||||
if (!(node.getContext() instanceof JavaTypeContext)) {
|
||||
return false;
|
||||
}
|
||||
return node.getMethod().getReference().equals(CLASS_NEW_INSTANCE_REF);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,10 @@ class ClassNewInstanceContextSelector implements ContextSelector {
|
|||
public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey receiver) {
|
||||
if (callee.getReference().equals(ClassNewInstanceContextInterpreter.CLASS_NEW_INSTANCE_REF) && isTypeConstant(receiver)) {
|
||||
IClass c = (IClass) ((ConstantKey) receiver).getValue();
|
||||
if (!c.isAbstract() && !c.isInterface()) {
|
||||
return new JavaTypeContext(new PointType(c));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -329,10 +329,6 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
return cache.getSSACache().findOrCreateDU(m, node.getContext(), options.getSSAOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @author sfink
|
||||
*
|
||||
*/
|
||||
protected class SpecializedFactoryMethod extends SpecializedMethod {
|
||||
|
||||
/**
|
||||
|
@ -486,8 +482,6 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
SSAInvokeInstruction s = new SSAInvokeInstruction(params, exc, site);
|
||||
calls.add(s);
|
||||
allInstructions.add(s);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -521,7 +515,6 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
}
|
||||
|
||||
private void addStatementsForSetOfTypes(Iterator it) {
|
||||
|
||||
if (!it.hasNext()) { // Uh. No types. Hope the caller reported a warning.
|
||||
SSAReturnInstruction r = new SSAReturnInstruction(nextLocal, false);
|
||||
allInstructions.add(r);
|
||||
|
@ -530,7 +523,7 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
for (; it.hasNext();) {
|
||||
IClass klass = (IClass) it.next();
|
||||
TypeReference T = klass.getReference();
|
||||
if (klass.isAbstract() || typesAllocated.contains(T)) {
|
||||
if (klass.isAbstract() || klass.isInterface() || typesAllocated.contains(T)) {
|
||||
continue;
|
||||
}
|
||||
typesAllocated.add(T);
|
||||
|
|
|
@ -37,6 +37,7 @@ public class PointType extends TypeAbstraction {
|
|||
this.type = type;
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(type.getReference().isReferenceType());
|
||||
Assertions._assert(!type.isInterface());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue