diff --git a/com.ibm.wala.cast.java.ecj/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.java.ecj/.settings/org.eclipse.jdt.core.prefs index 201e24b39..42ad03810 100644 --- a/com.ibm.wala.cast.java.ecj/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.java.ecj/.settings/org.eclipse.jdt.core.prefs @@ -9,8 +9,13 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=error diff --git a/com.ibm.wala.cast.java.ecj/src/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java b/com.ibm.wala.cast.java.ecj/src/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java index ed84f57ce..44fb0c268 100644 --- a/com.ibm.wala.cast.java.ecj/src/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java +++ b/com.ibm.wala.cast.java.ecj/src/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java @@ -289,8 +289,11 @@ public abstract class JDTJava2CAstTranslator { private final T fSourcePosition; + private final T fNamePos; + public ClassEntity(ITypeBinding jdtType, String name, Collection quals, Collection entities, - T pos) { + T pos, T namePos) { + fNamePos = namePos; fName = name; fQuals = quals; fEntities = entities; @@ -396,6 +399,11 @@ public abstract class JDTJava2CAstTranslator { return fTypeDict.new JdtJavaType(fJdtType); } + @Override + public Position getNamePosition() { + return fNamePos; + } + } private static boolean isInterface(AbstractTypeDeclaration decl) { @@ -405,7 +413,7 @@ public abstract class JDTJava2CAstTranslator { private CAstEntity visitTypeDecl(AbstractTypeDeclaration n, WalkContext context) { return createClassDeclaration(n, n.bodyDeclarations(), null, n.resolveBinding(), n.getName().getIdentifier(), n.getModifiers(), - isInterface(n), n instanceof AnnotationTypeDeclaration, context); + isInterface(n), n instanceof AnnotationTypeDeclaration, context, makePosition(n.getName())); } /** @@ -416,10 +424,11 @@ public abstract class JDTJava2CAstTranslator { * @param typeBinding * @param name Used in creating default constructor, and passed into new ClassEntity() * @param context + * @param namePos */ private CAstEntity createClassDeclaration(ASTNode n, List bodyDecls, List enumConstants, ITypeBinding typeBinding, String name, int modifiers, - boolean isInterface, boolean isAnnotation, WalkContext context) { + boolean isInterface, boolean isAnnotation, WalkContext context, T namePos) { final List memberEntities = new ArrayList<>(); // find and collect all initializers (type Initializer) and field initializers (type VariableDeclarationFragment). @@ -465,7 +474,7 @@ public abstract class JDTJava2CAstTranslator { IVariableBinding fieldBinding = fieldFrag.resolveBinding(); memberEntities.add(new FieldEntity(fieldFrag.getName().getIdentifier(), fieldBinding.getType(), quals, makePosition(fieldFrag.getStartPosition(), fieldFrag.getStartPosition() + fieldFrag.getLength()), - handleAnnotations(fieldBinding))); + handleAnnotations(fieldBinding), makePosition(fieldFrag.getName()))); } } else if (decl instanceof Initializer) { // Initializers are inserted into constructors when making constructors. @@ -526,12 +535,12 @@ public abstract class JDTJava2CAstTranslator { Collection quals = JDT2CAstUtils.mapModifiersToQualifiers(modifiers, isInterface, isAnnotation); - return new ClassEntity(typeBinding, name, quals, memberEntities, makePosition(n)); + return new ClassEntity(typeBinding, name, quals, memberEntities, makePosition(n), namePos); } private CAstEntity visit(AnonymousClassDeclaration n, WalkContext context) { return createClassDeclaration(n, n.bodyDeclarations(), null, n.resolveBinding(), - JDT2CAstUtils.anonTypeName(n.resolveBinding()), 0 /* no modifiers */, false, false, context); + JDT2CAstUtils.anonTypeName(n.resolveBinding()), 0 /* no modifiers */, false, false, context, null); } private CAstNode visit(TypeDeclarationStatement n, WalkContext context) { @@ -1106,6 +1115,15 @@ public abstract class JDTJava2CAstTranslator { SingleVariableDeclaration p = (SingleVariableDeclaration) fDecl.parameters().get(arg); return makePosition(p); } + + @Override + public Position getNamePosition() { + if (fDecl == null) { + return null; + } else { + return makePosition(fDecl); + } + } } // //////////////////////////////////// @@ -1158,13 +1176,16 @@ public abstract class JDTJava2CAstTranslator { private final T position; + private final T namePos; + private final Set annotations; - private FieldEntity(String name, ITypeBinding type, Collection quals, T position, Set annotations) { + private FieldEntity(String name, ITypeBinding type, Collection quals, T position, Set annotations, T namePos) { super(); this.type = type; this.quals = quals; this.name = name; + this.namePos = namePos; this.position = position; this.annotations = annotations; } @@ -1261,6 +1282,13 @@ public abstract class JDTJava2CAstTranslator { @Override public Position getPosition(int arg) { + return namePos; + } + + + @Override + public Position getNamePosition() { + // TODO Auto-generated method stub return null; } } @@ -3045,6 +3073,11 @@ public abstract class JDTJava2CAstTranslator { public Position getPosition(int arg) { return null; } + + @Override + public Position getNamePosition() { + return null; + } } // ///////////////////////////// @@ -3340,7 +3373,7 @@ public abstract class JDTJava2CAstTranslator { */ private CAstEntity visit(EnumConstantDeclaration decl, WalkContext context) { return new FieldEntity(decl.getName().getIdentifier(), decl.resolveVariable().getType(), enumQuals, makePosition(decl - .getStartPosition(), decl.getStartPosition() + decl.getLength()), null); + .getStartPosition(), decl.getStartPosition() + decl.getLength()), null, makePosition(decl.getName())); } /** @@ -3489,10 +3522,9 @@ public abstract class JDTJava2CAstTranslator { } private CAstEntity visit(EnumDeclaration n, WalkContext context) { - // JDT contains correct type info / class / subclass info for the enum return createClassDeclaration(n, n.bodyDeclarations(), n.enumConstants(), n.resolveBinding(), n.getName().getIdentifier(), n - .resolveBinding().getModifiers(), false, false, context); + .resolveBinding().getModifiers(), false, false, context, makePosition(n.getName())); } /** diff --git a/com.ibm.wala.cast.java.test/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.java.test/.settings/org.eclipse.jdt.core.prefs index 4aedc64f8..0c52ae802 100644 --- a/com.ibm.wala.cast.java.test/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.java.test/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js.html.nu_validator/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js.html.nu_validator/.settings/org.eclipse.jdt.core.prefs index e34d86827..75406200d 100644 --- a/com.ibm.wala.cast.js.html.nu_validator/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js.html.nu_validator/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js.nodejs.test/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js.nodejs.test/.settings/org.eclipse.jdt.core.prefs index c3c668c66..b2029a149 100644 --- a/com.ibm.wala.cast.js.nodejs.test/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js.nodejs.test/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js.nodejs/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js.nodejs/.settings/org.eclipse.jdt.core.prefs index 3fa024056..60395a5f7 100644 --- a/com.ibm.wala.cast.js.nodejs/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js.nodejs/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js.rhino.test/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js.rhino.test/.settings/org.eclipse.jdt.core.prefs index e177f3042..aac706b75 100644 --- a/com.ibm.wala.cast.js.rhino.test/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js.rhino.test/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java index 197c2038a..dfdd6c5dc 100644 --- a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java +++ b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java @@ -409,7 +409,9 @@ public class RhinoToAstTranslator implements TranslatorToCAst { private final CAstSourcePositionMap pos; private final Position entityPosition; - + + private final Position namePosition; + private final Position[] paramPositions; private ScriptOrFnEntity(AstNode n, Map> subs, CAstNode ast, CAstControlFlowMap map, CAstSourcePositionMap pos, String name) { @@ -418,6 +420,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst { if (n instanceof FunctionNode) { FunctionNode f = (FunctionNode) n; + namePosition = makePosition(f.getFunctionName()); f.flattenSymbolTable(false); int i = 0; arguments = new String[f.getParamCount() + 2]; @@ -436,6 +439,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst { } else { paramPositions = new Position[0]; arguments = new String[0]; + namePosition = null; } kind = (n instanceof FunctionNode) ? CAstEntity.FUNCTION_ENTITY : CAstEntity.SCRIPT_ENTITY; this.subs = subs; @@ -538,6 +542,11 @@ public class RhinoToAstTranslator implements TranslatorToCAst { public Position getPosition(int arg) { return paramPositions[arg]; } + + @Override + public Position getNamePosition() { + return namePosition; + } } private CAstEntity walkEntity(final AstNode n, List body, String name, WalkContext child) { @@ -569,18 +578,22 @@ public class RhinoToAstTranslator implements TranslatorToCAst { } private Position makePosition(AstNode n) { - URL url = ((SourceModule)sourceModule).getURL(); - int line = n.getLineno(); - Position pos = new RangePosition(url, line, n.getAbsolutePosition(), n.getAbsolutePosition()+n.getLength()); + if (n != null) { + URL url = ((SourceModule)sourceModule).getURL(); + int line = n.getLineno(); + Position pos = new RangePosition(url, line, n.getAbsolutePosition(), n.getAbsolutePosition()+n.getLength()); - if (sourceModule instanceof MappedSourceModule) { - Position np = ((MappedSourceModule) sourceModule).getMapping().getIncludedPosition(pos); - if (np != null) { - return np; + if (sourceModule instanceof MappedSourceModule) { + Position np = ((MappedSourceModule) sourceModule).getMapping().getIncludedPosition(pos); + if (np != null) { + return np; + } } - } - return pos; + return pos; + } else { + return null; + } } protected CAstNode noteSourcePosition(WalkContext context, CAstNode n, AstNode p) { diff --git a/com.ibm.wala.cast.js.test.data/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js.test.data/.settings/org.eclipse.jdt.core.prefs index 0c68a61dc..a698e5967 100644 --- a/com.ibm.wala.cast.js.test.data/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js.test.data/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.ibm.wala.cast.js.test/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js.test/.settings/org.eclipse.jdt.core.prefs index df7470c57..5de732f1e 100644 --- a/com.ibm.wala.cast.js.test/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js.test/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.js/.settings/org.eclipse.jdt.core.prefs index 00846337f..8491c879c 100644 --- a/com.ibm.wala.cast.js/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.js/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/ExtractedFunction.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/ExtractedFunction.java index 22e473323..98114aead 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/ExtractedFunction.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/correlations/extraction/ExtractedFunction.java @@ -191,4 +191,9 @@ class ExtractedFunction implements CAstEntity { public Position getPosition(int arg) { return null; } + + @Override + public Position getNamePosition() { + return null; + } } diff --git a/com.ibm.wala.cast.test/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.test/.settings/org.eclipse.jdt.core.prefs index 1a368b053..f179826c9 100644 --- a/com.ibm.wala.cast.test/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.test/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestConstantCollector.java b/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestConstantCollector.java index 9befd2269..37d1e9412 100644 --- a/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestConstantCollector.java +++ b/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestConstantCollector.java @@ -130,6 +130,12 @@ public class TestConstantCollector { // TODO Auto-generated method stub return null; } + + @Override + public Position getNamePosition() { + // TODO Auto-generated method stub + return null; + } }; } diff --git a/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestNativeTranslator.java b/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestNativeTranslator.java index 7f772265a..255a4df33 100644 --- a/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestNativeTranslator.java +++ b/com.ibm.wala.cast.test/harness-src/java/com/ibm/wala/cast/test/TestNativeTranslator.java @@ -148,6 +148,12 @@ public class TestNativeTranslator { // TODO Auto-generated method stub return null; } + + @Override + public Position getNamePosition() { + // TODO Auto-generated method stub + return null; + } }; } } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java index af89e4d8c..b4ccb6a59 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java @@ -504,6 +504,8 @@ public abstract class AstTranslator extends CAstVisitor entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Lpack/ocamljavaMain"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); + options.setUseConstantSpecificKeys(true); IAnalysisCacheView cache = new AnalysisCacheImpl(); - SSAPropagationCallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); - + SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); + MethodHandles.analyzeMethodHandles(options, builder); CallGraph cg = builder.makeCallGraph(options, null); + System.err.println(cg); + instrument(F.getAbsolutePath()); run("pack.ocamljavaMain", null, args); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/KawaCallGraphTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/KawaCallGraphTest.java index 8d0111d01..d69b52927 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/KawaCallGraphTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/KawaCallGraphTest.java @@ -53,6 +53,7 @@ public class KawaCallGraphTest extends DynamicCallGraphTestBase { Set color = getNodes(CG, "Lchess", "startingColor", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); assert ! color.isEmpty(); + System.out.println(CG); } @Test @@ -78,7 +79,7 @@ public class KawaCallGraphTest extends DynamicCallGraphTestBase { AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); IAnalysisCacheView cache = new AnalysisCacheImpl(); - options.setReflectionOptions(ReflectionOptions.NONE); + options.setReflectionOptions(ReflectionOptions.STRING_ONLY); options.setTraceStringConstants(true); options.setUseConstantSpecificKeys(true); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java index e9305eae1..ca9af8fc3 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java @@ -29,6 +29,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.impl.Everywhere; import com.ibm.wala.ipa.callgraph.propagation.ConstantKey; @@ -278,9 +279,8 @@ public class ReflectionTest extends WalaTestCase { for (CGNode node : mainChildren) { Context context = node.getContext(); - if (context instanceof ReceiverInstanceContext && node.getMethod().getReference().equals(newInstanceMr)) { - ReceiverInstanceContext r = (ReceiverInstanceContext) context; - ConstantKey c = (ConstantKey) r.getReceiver(); + if (context.isA(ReceiverInstanceContext.class) && node.getMethod().getReference().equals(newInstanceMr)) { + ConstantKey c = (ConstantKey) context.get(ContextKey.RECEIVER); IMethod ctor = c.getValue(); if (ctor.getSignature().equals(fpInitSig)) { filePermConstrNewInstanceNode = node; @@ -377,6 +377,7 @@ public class ReflectionTest extends WalaTestCase { TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer"); MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;"); Set nodes = cg.getNodes(mr); + System.err.println(cg); Assert.assertFalse(nodes.isEmpty()); } diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/shrike/DynamicCallGraphTestBase.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/shrike/DynamicCallGraphTestBase.java index 36eb91e99..14e1c99c5 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/shrike/DynamicCallGraphTestBase.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/shrike/DynamicCallGraphTestBase.java @@ -208,7 +208,7 @@ public abstract class DynamicCallGraphTestBase extends WalaTestCase { if (! filter.test(callerRef)) { continue loop; } - Assert.assertEquals(callerMethod, 1, nodes.size()); + Assert.assertEquals(callerRef.toString(), 1, nodes.size()); caller = nodes.iterator().next(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java index 9e64176c6..517dcfd90 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Map; +import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; @@ -21,6 +22,8 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ipa.summaries.SyntheticIR; import com.ibm.wala.ssa.DefUse; @@ -63,7 +66,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter { /** BEGIN Custom change: caching */ - final JavaTypeContext context = (JavaTypeContext) node.getContext(); + final Context context = node.getContext(); final IMethod method = node.getMethod(); final String hashKey = method.toString() + "@" + context.toString(); @@ -97,7 +100,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter { if (node == null) { throw new IllegalArgumentException("node is null"); } - if (!(node.getContext() instanceof JavaTypeContext)) { + if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return ClassFactoryContextSelector.isClassFactory(node.getMethod().getReference()); @@ -112,8 +115,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter { throw new IllegalArgumentException("node is null"); } assert understands(node); - JavaTypeContext context = (JavaTypeContext) node.getContext(); - TypeReference tr = context.getType().getTypeReference(); + TypeReference tr = ((TypeAbstraction)node.getContext().get(ContextKey.RECEIVER)).getTypeReference(); if (tr != null) { return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr)); } @@ -129,12 +131,12 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter { return EmptyIterator.instance(); } - private static SSAInstruction[] makeStatements(JavaTypeContext context) { - SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); + private static SSAInstruction[] makeStatements(Context context) { + SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory(); ArrayList statements = new ArrayList<>(); // vn1 is the string parameter int retValue = 2; - TypeReference tr = context.getType().getTypeReference(); + TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference(); if (tr != null) { SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr); statements.add(l); @@ -149,7 +151,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter { return result; } - private static IR makeIR(IMethod method, JavaTypeContext context) { + private static IR makeIR(IMethod method, Context context) { SSAInstruction instrs[] = makeStatements(context); return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextSelector.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextSelector.java index 89edac7f8..9ebaa5549 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextSelector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextSelector.java @@ -13,10 +13,12 @@ package com.ibm.wala.analysis.reflection; import com.ibm.wala.analysis.typeInference.PointType; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.IClassLoader; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.Context; import com.ibm.wala.ipa.callgraph.ContextSelector; +import com.ibm.wala.ipa.callgraph.propagation.ConstantKey; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.IR; @@ -103,19 +105,35 @@ class ClassFactoryContextSelector implements ContextSelector { return new JavaTypeContext(new PointType(klass)); } } + int nameVn = callee.isStatic()? 0: 1; + if (receiver != null && receiver.length > nameVn) { + if (receiver[nameVn] instanceof ConstantKey) { + ConstantKey ik = (ConstantKey) receiver[nameVn]; + if (ik.getConcreteType().getReference().equals(TypeReference.JavaLangString)) { + String className = StringStuff.deployment2CanonicalTypeString(ik.getValue().toString()); + for(IClassLoader cl : caller.getClassHierarchy().getLoaders()) { + TypeReference t = TypeReference.findOrCreate(cl.getReference(), className); + IClass klass = caller.getClassHierarchy().lookupClass(t); + if (klass != null) { + return new JavaTypeContext(new PointType(klass)); + } + } + } + } + } } return null; } private static final IntSet thisParameter = IntSetUtil.make(new int[]{0}); - private static final IntSet firstParameter = IntSetUtil.make(new int[]{1}); + private static final IntSet firstParameter = IntSetUtil.make(new int[]{0, 1}); @Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { if (isClassFactory(site.getDeclaredTarget())) { SSAAbstractInvokeInstruction[] invokeInstructions = caller.getIR().getCalls(site); - if (invokeInstructions.length != 1) { + if (invokeInstructions.length >= 1) { if (invokeInstructions[0].isStatic()) { return thisParameter; } else { diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java index c42f31fc5..d22e26b46 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java @@ -13,6 +13,7 @@ package com.ibm.wala.analysis.reflection; import java.util.Iterator; import java.util.Map; +import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; @@ -20,6 +21,8 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ipa.summaries.SyntheticIR; @@ -81,7 +84,7 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp } /** BEGIN Custom change: caching */ - final JavaTypeContext context = (JavaTypeContext) node.getContext(); + final Context context = node.getContext(); final IMethod method = node.getMethod(); final String hashKey = method.toString() + "@" + context.toString(); @@ -112,7 +115,7 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp if (node == null) { throw new IllegalArgumentException("node is null"); } - if (!(node.getContext() instanceof JavaTypeContext)) { + if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return node.getMethod().getReference().equals(CLASS_NEW_INSTANCE_REF); @@ -124,8 +127,8 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp throw new IllegalArgumentException("node is null"); } assert understands(node); - JavaTypeContext context = (JavaTypeContext) node.getContext(); - TypeReference tr = context.getType().getTypeReference(); + Context context = node.getContext(); + TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference(); if (tr != null) { return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr)); } @@ -138,9 +141,9 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp return EmptyIterator.instance(); } - private IR makeIR(IMethod method, JavaTypeContext context) { - SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); - TypeReference tr = context.getType().getTypeReference(); + private IR makeIR(IMethod method, Context context) { + SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory(); + TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference(); if (tr != null) { SpecializedMethod m = new SpecializedMethod(method, method.getDeclaringClass(), method.isStatic(), false); IClass klass = cha.lookupClass(tr); diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java index 3759f56a8..daf18b0f3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Map; +import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; @@ -21,6 +22,8 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ipa.summaries.SyntheticIR; import com.ibm.wala.ssa.DefUse; @@ -59,7 +62,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter { } /** BEGIN Custom change: caching */ - final JavaTypeContext context = (JavaTypeContext) node.getContext(); + final Context context = node.getContext(); final IMethod method = node.getMethod(); final String hashKey = method.toString() + "@" + context.toString(); @@ -90,7 +93,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter { if (node == null) { throw new IllegalArgumentException("node is null"); } - if (!(node.getContext() instanceof JavaTypeContext)) { + if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return node.getMethod().getReference().equals(GetClassContextSelector.GET_CLASS); @@ -106,12 +109,12 @@ public class GetClassContextInterpeter implements SSAContextInterpreter { return EmptyIterator.instance(); } - private static SSAInstruction[] makeStatements(JavaTypeContext context) { + private static SSAInstruction[] makeStatements(Context context) { ArrayList statements = new ArrayList<>(); int nextLocal = 2; int retValue = nextLocal++; - TypeReference tr = context.getType().getTypeReference(); - SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); + TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference(); + SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory(); if (tr != null) { SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr); statements.add(l); @@ -126,7 +129,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter { return result; } - private static IR makeIR(IMethod method, JavaTypeContext context) { + private static IR makeIR(IMethod method, Context context) { SSAInstruction instrs[] = makeStatements(context); return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContext.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContext.java index 22e7e0734..4d8b96ef6 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContext.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContext.java @@ -83,10 +83,17 @@ public class GetMethodContext implements Context { this.name = name; } + class NameItem implements ContextItem { + String name() { return getName(); } + }; + @Override public ContextItem get(ContextKey name) { + if (name == ContextKey.RECEIVER) { return type; + } else if (name == ContextKey.NAME) { + return new NameItem(); } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContextInterpreter.java index 6abe51ebf..bb1b368e9 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetMethodContextInterpreter.java @@ -15,6 +15,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; +import com.ibm.wala.analysis.reflection.GetMethodContext.NameItem; +import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; @@ -22,6 +24,8 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ipa.summaries.SyntheticIR; import com.ibm.wala.ssa.ConstantValue; @@ -79,15 +83,15 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter { System.err.println("generating IR for " + node); } IMethod method = node.getMethod(); - GetMethodContext context = (GetMethodContext) node.getContext(); + Context context = node.getContext(); Map constants = HashMapFactory.make(); if (method.getReference().equals(GET_METHOD)) { - Atom name = Atom.findOrCreateAsciiAtom(context.getName()); + Atom name = Atom.findOrCreateAsciiAtom(((NameItem)(context.get(ContextKey.NAME))).name()); SSAInstruction instrs[] = makeGetMethodStatements(context,constants,name); return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants); } if (method.getReference().equals(GET_DECLARED_METHOD)) { - Atom name = Atom.findOrCreateAsciiAtom(context.getName()); + Atom name = Atom.findOrCreateAsciiAtom(((NameItem)(context.get(ContextKey.NAME))).name()); SSAInstruction instrs[] = makeGetDeclaredMethodStatements(context,constants,name); return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants); } @@ -117,7 +121,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter { if (node == null) { throw new IllegalArgumentException("node is null"); } - if (!(node.getContext() instanceof GetMethodContext)) { + if (!(node.getContext().isA(GetMethodContext.class))) { return false; } MethodReference mRef = node.getMethod().getReference(); @@ -190,13 +194,13 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter { ( MethodReference ref, Collection returnValues, - GetMethodContext context, + Context context, Map constants ) { ArrayList statements = new ArrayList<>(); int nextLocal = ref.getNumberOfParameters() + 2; - IClass cls = context.getType().getType(); - SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); + SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory(); if (cls != null) { for (IMethod m : returnValues) { int c = nextLocal++; @@ -219,11 +223,11 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter { private static SSAInstruction[] makeGetMethodStatements ( - GetMethodContext context, + Context context, Map constants, Atom name ) { - IClass cls = context.getType().getType(); + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getParticularMethodStatements(GET_METHOD, null, context, constants); } else { @@ -234,8 +238,8 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter { /** * Create statements for {@link Class#getDeclaredMethod(String, Class...)}. */ - private static SSAInstruction[] makeGetDeclaredMethodStatements(GetMethodContext context, Map constants,Atom name) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetDeclaredMethodStatements(Context context, Map constants,Atom name) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants); } else { diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java index 840653a43..56e5fe611 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java @@ -15,6 +15,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; +import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; @@ -22,6 +23,8 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ipa.summaries.SyntheticIR; import com.ibm.wala.ssa.ConstantValue; @@ -106,7 +109,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { } /** BEGIN Custom change: caching */ - final JavaTypeContext context = (JavaTypeContext) node.getContext(); + final Context context = node.getContext(); final IMethod method = node.getMethod(); final String hashKey = method.toString() + "@" + context.toString(); @@ -128,7 +131,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { return getIR(node); } - private static IR makeIR(IMethod method, JavaTypeContext context) { + private static IR makeIR(IMethod method, Context context) { Map constants = HashMapFactory.make(); if (method.getReference().equals(GET_CONSTRUCTOR)) { SSAInstruction instrs[] = makeGetCtorStatements(context, constants); @@ -192,7 +195,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { if (node == null) { throw new IllegalArgumentException("node is null"); } - if (!(node.getContext() instanceof JavaTypeContext)) { + if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } MethodReference mRef = node.getMethod().getReference(); @@ -207,8 +210,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { throw new IllegalArgumentException("node is null"); } assert understands(node); - JavaTypeContext context = (JavaTypeContext) node.getContext(); - TypeReference tr = context.getType().getTypeReference(); + Context context = node.getContext(); + TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference(); if (tr != null) { return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr)); } @@ -280,13 +283,13 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { * * @param returnValues the possible return values for this method. */ - private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection returnValues, JavaTypeContext context, + private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection returnValues, Context context, Map constants) { ArrayList statements = new ArrayList<>(); int nextLocal = ref.getNumberOfParameters() + 2; int retValue = nextLocal++; - IClass cls = context.getType().getType(); - SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); + SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory(); if (cls != null) { TypeReference arrType = ref.getReturnType(); NewSiteReference site = new NewSiteReference(retValue, arrType); @@ -328,11 +331,11 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { * @param returnValues the possible return values for this method. */ private static SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection returnValues, - JavaTypeContext context, Map constants) { + Context context, Map constants) { ArrayList statements = new ArrayList<>(); int nextLocal = ref.getNumberOfParameters() + 2; - IClass cls = context.getType().getType(); - SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory(); + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); + SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory(); if (cls != null) { for (IMethod m : returnValues) { int c = nextLocal++; @@ -356,8 +359,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { /** * create statements for getConstructor() */ - private static SSAInstruction[] makeGetCtorStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetCtorStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getParticularMethodStatements(GET_CONSTRUCTOR, null, context, constants); } else { @@ -366,8 +369,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { } // TODO - private static SSAInstruction[] makeGetCtorsStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetCtorsStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants); } else { @@ -375,8 +378,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { } } - private static SSAInstruction[] makeGetMethodStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetMethodStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getParticularMethodStatements(GET_METHOD, null, context, constants); } else { @@ -384,8 +387,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { } } - private static SSAInstruction[] makeGetMethodsStatments(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetMethodsStatments(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getMethodArrayStatements(GET_METHODS, null, context, constants); } else { @@ -396,8 +399,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { /** * create statements for getConstructor() */ - private static SSAInstruction[] makeGetDeclCtorStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetDeclCtorStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getParticularMethodStatements(GET_DECLARED_CONSTRUCTOR, null, context, constants); } else { @@ -405,8 +408,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { } } - private static SSAInstruction[] makeGetDeclCtorsStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetDeclCtorsStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants); } else { @@ -417,8 +420,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { /** * create statements for getDeclaredMethod() */ - private static SSAInstruction[] makeGetDeclaredMethodStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetDeclaredMethodStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants); } else { @@ -429,8 +432,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { /** * create statements for getDeclaredMethod() */ - private static SSAInstruction[] makeGetDeclaredMethodsStatements(JavaTypeContext context, Map constants) { - IClass cls = context.getType().getType(); + private static SSAInstruction[] makeGetDeclaredMethodsStatements(Context context, Map constants) { + IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType(); if (cls == null) { return getMethodArrayStatements(GET_DECLARED_METHODS, null, context, constants); } else { diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java index c30eca9f5..706b0eb42 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java @@ -20,6 +20,8 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; import com.ibm.wala.ipa.callgraph.propagation.ConstantKey; import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; @@ -69,8 +71,8 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret if (DEBUG) { System.err.println("generating IR for " + node); } - ReceiverInstanceContext recv = (ReceiverInstanceContext) node.getContext(); - ConstantKey c = (ConstantKey) recv.getReceiver(); + Context recv = node.getContext(); + ConstantKey c = (ConstantKey) recv.get(ContextKey.RECEIVER); IMethod m = (IMethod) c.getValue(); /** BEGIN Custom change: caching */ final IMethod method = node.getMethod(); @@ -109,11 +111,11 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret if (node == null) { throw new IllegalArgumentException("node is null"); } - if (!(node.getContext() instanceof ReceiverInstanceContext)) { + if (!(node.getContext().isA(ReceiverInstanceContext.class))) { return false; } - ReceiverInstanceContext r = (ReceiverInstanceContext) node.getContext(); - if (!(r.getReceiver() instanceof ConstantKey)) { + Context r = node.getContext(); + if (!(r.get(ContextKey.RECEIVER) instanceof ConstantKey)) { return false; } return node.getMethod().getReference().equals(METHOD_INVOKE) || node.getMethod().getReference().equals(CTOR_NEW_INSTANCE); @@ -146,7 +148,7 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret * @param method is something like Method.invoke or Construction.newInstance * @param target is the method being called reflectively */ - private IR makeIR(IMethod method, IMethod target, ReceiverInstanceContext context) { + private IR makeIR(IMethod method, IMethod target, Context recv) { SSAInstructionFactory insts = method.getDeclaringClass().getClassLoader().getInstructionFactory(); SpecializedMethod m = new SpecializedMethod(method, method.getDeclaringClass(), method.isStatic(), false); @@ -225,7 +227,7 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret SSAInstruction[] instrs = new SSAInstruction[m.allInstructions.size()]; m.allInstructions. toArray(instrs); - return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants); + return new SyntheticIR(method, recv, new InducedCFG(instrs, method, recv), instrs, SSAOptions.defaultOptions(), constants); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/java7/MethodHandles.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/java7/MethodHandles.java index d17320051..51713291e 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/java7/MethodHandles.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/java7/MethodHandles.java @@ -55,6 +55,7 @@ import com.ibm.wala.util.collections.HashMapFactory; import com.ibm.wala.util.collections.MapIterator; import com.ibm.wala.util.intset.IntSet; import com.ibm.wala.util.intset.IntSetUtil; +import com.ibm.wala.util.intset.MutableIntSet; public class MethodHandles { @@ -270,7 +271,9 @@ public class MethodHandles { @Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { - return isFindStatic(site.getDeclaredTarget())? params: self; + MutableIntSet x = IntSetUtil.makeMutableCopy(base.getRelevantParameters(caller, site)); + x.addAll(isFindStatic(site.getDeclaredTarget())? params: self); + return x; } } @@ -392,7 +395,7 @@ public class MethodHandles { @Override public boolean understands(CGNode node) { - return isFindStatic(node) && node.getContext() instanceof FindContext; + return isFindStatic(node) && node.getContext().isA(FindContext.class); } @Override @@ -401,7 +404,7 @@ public class MethodHandles { MethodSummary code = new MethodSummary(node.getMethod().getReference()); SummarizedMethod m = new SummarizedMethod(node.getMethod().getReference(), code, node.getMethod().getDeclaringClass()); SSAInstructionFactory insts = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().instructionFactory(); - assert node.getContext() instanceof FindContext; + assert node.getContext().isA(FindContext.class); @SuppressWarnings("unchecked") IClass cls = node.getClassHierarchy().lookupClass(((HandlesItem)node.getContext().get(CLASS_KEY)).item); @@ -427,7 +430,7 @@ public class MethodHandles { @Override public boolean understands(CGNode node) { - return (isInvoke(node) || isType(node)) && node.getContext() instanceof MethodContext; + return (isInvoke(node) || isType(node)) && node.getContext().isA(MethodContext.class); } @Override @@ -436,7 +439,7 @@ public class MethodHandles { MethodSummary code = new MethodSummary(node.getMethod().getReference()); SummarizedMethod m = new SummarizedMethod(node.getMethod().getReference(), code, node.getMethod().getDeclaringClass()); SSAInstructionFactory insts = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().instructionFactory(); - assert node.getContext() instanceof MethodContext; + assert node.getContext().isA(MethodContext.class); MethodReference ref = ((MethodContext)node.getContext()).method; boolean isStatic = node.getClassHierarchy().resolveMethod(ref).isStatic(); boolean isVoid = ref.getReturnType().equals(TypeReference.Void); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisOptions.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisOptions.java index 6d6264cb0..321ef34a4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisOptions.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisOptions.java @@ -74,6 +74,7 @@ public class AnalysisOptions { ONE_FLOW_TO_CASTS_APPLICATION_GET_METHOD("one_flow_to_casts_application_get_method", 1, false, false, true), MULTI_FLOW_TO_CASTS_APPLICATION_GET_METHOD("multi_flow_to_casts_application_get_method", 100, false, false, true), NO_STRING_CONSTANTS("no_string_constants", Integer.MAX_VALUE, false, true, false), + STRING_ONLY("string_constants", 0, true, false, true), NONE("none", 0, true, true, true); private final String name; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/Context.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/Context.java index 7fbf6810a..bf0f928c1 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/Context.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/Context.java @@ -18,9 +18,16 @@ package com.ibm.wala.ipa.callgraph; * As another example, for CPA, there would be name for each parameter slot ("zero","one","two"), and the Context provides a mapping * from this name to a set of types. eg. "one" -> {java.lang.String, java.lang.Date} */ -public interface Context { +public interface Context extends ContextItem { /** * @return the objects corresponding to a given name */ ContextItem get(ContextKey name); + + /** + * @return whether this context has a specific type + */ + default boolean isA(Class type) { + return type.isInstance(this); + } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/ContextKey.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/ContextKey.java index d4f3486c6..fcade3ec4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/ContextKey.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/ContextKey.java @@ -21,6 +21,18 @@ public interface ContextKey { public final static ContextKey CALLER = new ContextKey() { }; + /** + * A property of contexts that might be generally useful: the "target" method. + */ + public final static ContextKey TARGET = new ContextKey() { + }; + + /** + * A property of contexts that might be generally useful: the "name". + */ + public final static ContextKey NAME = new ContextKey() { + }; + /** * A property of contexts that might be generally useful: the "call site" method ... used for call-string context schemes. */ diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/DelegatingContext.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/DelegatingContext.java index e42cbf50e..8bee8632d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/DelegatingContext.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/DelegatingContext.java @@ -70,6 +70,9 @@ public class DelegatingContext implements Context { return "DelegatingContext [A=" + A + ", B=" + B + "]"; } - + @Override + public boolean isA(Class type) { + return A.isA(type) || B.isA(type); + } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/BasicCallGraph.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/BasicCallGraph.java index b098de037..de9c70a26 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/BasicCallGraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/BasicCallGraph.java @@ -17,11 +17,14 @@ import java.util.Map; import java.util.Set; import com.ibm.wala.analysis.reflection.JavaTypeContext; +import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.Context; +import com.ibm.wala.ipa.callgraph.ContextKey; +import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeBT.IInvokeInstruction; @@ -369,10 +372,10 @@ public abstract class BasicCallGraph extends AbstractNumberedGraph im for(CGNode n : this) { String nm = n.getMethod().getDeclaringClass().getName().toString() + "/" + n.getMethod().getName() + "/" + n.getContext().getClass().toString(); - if (n.getContext() instanceof ReceiverInstanceContext) { - nm = nm + "/" + ((ReceiverInstanceContext)n.getContext()).getReceiver().getConcreteType().getName(); + if (n.getContext().isA(ReceiverInstanceContext.class)) { + nm = nm + "/" + ((InstanceKey)n.getContext().get(ContextKey.RECEIVER)).getConcreteType().getName(); } else if (n.getContext() instanceof JavaTypeContext) { - nm = nm + "/" + ((JavaTypeContext)n.getContext()).getType().getTypeReference().getName(); + nm = nm + "/" + ((TypeAbstraction)n.getContext().get(ContextKey.RECEIVER)).getTypeReference().getName(); } do { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/DelegatingContextSelector.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/DelegatingContextSelector.java index 5c9329c61..c26737aa0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/DelegatingContextSelector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/DelegatingContextSelector.java @@ -15,6 +15,7 @@ import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.Context; import com.ibm.wala.ipa.callgraph.ContextSelector; +import com.ibm.wala.ipa.callgraph.DelegatingContext; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.util.intset.IntSet; @@ -56,7 +57,12 @@ public class DelegatingContextSelector implements ContextSelector { if (DEBUG) { System.err.println(("Case A " + A.getClass() + " " + C)); } - return C; + Context CB = B.getCalleeTarget(caller, site, callee, receiver); + if (CB != null) { + return new DelegatingContext(C, CB); + } else { + return C; + } } } Context C = B.getCalleeTarget(caller, site, callee, receiver); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java index 6e3192a2d..58a87347e 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java @@ -75,7 +75,8 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory { CGNode nodeToUse = node; // disallow recursion in contexts. - if (node.getContext() instanceof ReceiverInstanceContext || node.getContext() instanceof CallerContext) { + if (node.getContext().isA(ReceiverInstanceContext.class) || + node.getContext().isA(CallerContext.class)) { IMethod m = node.getMethod(); CGNode n = ContainerContextSelector.findNodeRecursiveMatchingContext(m, node.getContext()); if (n != null) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java index 8d403695c..737efc726 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java @@ -720,7 +720,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder(CG.fst, CG.snd, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE)); diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java index d9c9ff22c..d76a12b95 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/dex/instructions/Invoke.java @@ -108,6 +108,7 @@ public abstract class Invoke extends Instruction { String clazzName, String methodName, String descriptor, int[] args, Opcode opcode, DexIMethod method) { super(instLoc, clazzName, methodName, descriptor, args, opcode, method); + assert descriptor.contains("("); } @Override diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java index f7a3b1986..3a5f1da65 100644 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java +++ b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ssa/DexSSABuilder.java @@ -788,7 +788,6 @@ public class DexSSABuilder extends AbstractIntRegisterMachine { Language lang = dexCFG.getMethod().getDeclaringClass().getClassLoader().getLanguage(); // TODO: check that the signature needed by findOrCreate can use the descriptor - MethodReference m = MethodReference.findOrCreate(lang, loader, instruction.clazzName, instruction.methodName, instruction.descriptor); diff --git a/com.ibm.wala.ide.tests/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.ide.tests/.settings/org.eclipse.jdt.core.prefs index 32b41283b..d0869ded7 100644 --- a/com.ibm.wala.ide.tests/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.ide.tests/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.ide/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.ide/.settings/org.eclipse.jdt.core.prefs index bc4294e02..be78a7ae7 100644 --- a/com.ibm.wala.ide/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.ide/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 diff --git a/com.ibm.wala.scandroid/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.scandroid/.settings/org.eclipse.jdt.core.prefs index 474bdc4c2..5de989e02 100644 --- a/com.ibm.wala.scandroid/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.scandroid/.settings/org.eclipse.jdt.core.prefs @@ -9,8 +9,13 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error diff --git a/com.ibm.wala.util/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.util/.settings/org.eclipse.jdt.core.prefs index 198f44739..f371837a5 100644 --- a/com.ibm.wala.util/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.util/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8