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:
sjfink 2008-03-21 15:31:29 +00:00
parent bf8e4d8b58
commit 9b266acea0
4 changed files with 9 additions and 12 deletions

View File

@ -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);
}

View File

@ -33,11 +33,13 @@ 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();
return new JavaTypeContext(new PointType(c));
if (!c.isAbstract() && !c.isInterface()) {
return new JavaTypeContext(new PointType(c));
}
}
return null;
}
private boolean isTypeConstant(InstanceKey instance) {
if (instance instanceof ConstantKey) {
ConstantKey c = (ConstantKey) instance;

View File

@ -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,9 +482,7 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
SSAInvokeInstruction s = new SSAInvokeInstruction(params, exc, site);
calls.add(s);
allInstructions.add(s);
} else {
}
}
}
private int addOriginalStatements(SummarizedMethod m) {
@ -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);

View File

@ -37,6 +37,7 @@ public class PointType extends TypeAbstraction {
this.type = type;
if (Assertions.verifyAssertions) {
Assertions._assert(type.getReference().isReferenceType());
Assertions._assert(!type.isInterface());
}
}