Source:
<code>public void testMethodRefs() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope( TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Llambda/MethodRefs"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCacheImpl(), cha, scope, false); Function<String, MethodReference> getTargetRef = <START> (klass) -> { <END> return MethodReference.findOrCreate( TypeReference.findOrCreate( ClassLoaderReference.Application, "Llambda/MethodRefs$" + klass), Atom.findOrCreateUnicodeAtom("target"), Descriptor.findOrCreateUTF8("()V")); }; System.out.println(cg); Assert.assertEquals( "expected C1.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C1")).size()); Assert.assertEquals( "expected C2.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C2")).size()); Assert.assertEquals( "expected C3.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C3")).size()); Assert.assertEquals( "expected C4.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C4")).size()); Assert.assertEquals( "expected C5.target() to *not* be reachable", 0, cg.getNodes(getTargetRef.apply("C5")).size()); }</code><technical_language>expression lambda instead of statement lambda: java (klass) -> MethodReference.findOrCreate( TypeReference.findOrCreate( ClassLoaderReference.Application, "Llambda/MethodRefs$" + klass), Atom.findOrCreateUnicodeAtom("target"), Descriptor.findOrCreateUTF8("()V"));</technical_language>

Target:
public void testMethodRefs() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope( TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Llambda/MethodRefs"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCacheImpl(), cha, scope, false); Function<String, MethodReference> getTargetRef = (klass) -> MethodReference.findOrCreate( TypeReference.findOrCreate( ClassLoaderReference.Application, "Llambda/MethodRefs$" + klass), Atom.findOrCreateUnicodeAtom("target"), Descriptor.findOrCreateUTF8("()V")); System.out.println(cg); Assert.assertEquals( "expected C1.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C1")).size()); Assert.assertEquals( "expected C2.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C2")).size()); Assert.assertEquals( "expected C3.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C3")).size()); Assert.assertEquals( "expected C4.target() to be reachable", 1, cg.getNodes(getTargetRef.apply("C4")).size()); Assert.assertEquals( "expected C5.target() to *not* be reachable", 0, cg.getNodes(getTargetRef.apply("C5")).size()); }