options.setReflectionOptions(ReflectionOptions.valueOf(VulasConfiguration.getGlobal().getConfiguration().getString("vulas.reach.wala.callgraph.reflection")));
options.setEntrypoints(entrypoints); options.setReflectionOptions(ReflectionOptions.NONE); IAnalysisCacheView cache = new AnalysisCacheImpl();
analysisOptions.setReflectionOptions(options.getReflectionOptions());
@Test public void testCornerCases() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = new AllApplicationEntrypoints(scope, cha); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); // this speeds up the test options.setReflectionOptions(ReflectionOptions.NONE); doCallGraphs(options, new AnalysisCacheImpl(), cha, scope); // we expect a warning or two about class Abstract1, which has no concrete // subclasses String ws = Warnings.asString(); Assert.assertTrue("failed to report a warning about Abstract1", ws.indexOf("cornerCases/Abstract1") > -1); // we do not expect a warning about class Abstract2, which has a concrete // subclasses Assert.assertTrue("reported a warning about Abstract2", ws.indexOf("cornerCases/Abstract2") == -1); }
@Test public void testBcelVerifier() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.BCEL, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.BCEL_VERIFIER_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); // this speeds up the test options.setReflectionOptions(ReflectionOptions.NONE); doCallGraphs(options, new AnalysisCacheImpl(), cha, scope); }
options.setReflectionOptions(ReflectionOptions.ONE_FLOW_TO_CASTS_NO_METHOD_INVOKE);
public static Pair<CallGraph, PointerAnalysis<InstanceKey>> makeAPKCallGraph(URI[] androidLibs, File androidAPIJar, String apkFileName, IProgressMonitor monitor, ReflectionOptions policy) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException { AnalysisScope scope = makeDalvikScope(androidLibs, androidAPIJar, apkFileName); final IClassHierarchy cha = ClassHierarchyFactory.make(scope); IAnalysisCacheView cache = new AnalysisCacheImpl(new DexIRFactory()); List<? extends Entrypoint> es = getEntrypoints(cha); assert ! es.isEmpty(); AnalysisOptions options = new AnalysisOptions(scope, es); options.setReflectionOptions(policy); // SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(options, cache, cha, scope, null, makeDefaultInterpreter(options, cache)); SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph callGraph = cgb.makeCallGraph(options, monitor); PointerAnalysis<InstanceKey> ptrAnalysis = cgb.getPointerAnalysis(); return Pair.make(callGraph, ptrAnalysis); }
IAnalysisCacheView cache = new AnalysisCacheImpl(); options.setReflectionOptions(ReflectionOptions.STRING_ONLY); options.setTraceStringConstants(true); options.setUseConstantSpecificKeys(true);