Coder Social home page Coder Social logo

Comments (2)

Adrninistrator avatar Adrninistrator commented on July 18, 2024

写了一个测试代码:

public class TestLambda {
    public void testList() {
        List<String> list = new ArrayList<>();
        list.forEach(e -> testString(e));
    }

    private void testString(String data) {
        System.out.println(data);
    }
}

生成的方法调用关系如下:

M:1 test.call_graph.lambda.TestLambda:<init>() (O)java.lang.Object:<init>() 13 1
M:6 test.call_graph.lambda.TestLambda:testList() (O)java.util.ArrayList:<init>() 20 1
M:7 test.call_graph.lambda.TestLambda:testList() (D)java.util.function.Consumer:accept(test.call_graph.lambda.TestLambda) 21 1
M:8 test.call_graph.lambda.TestLambda:testList() (LM)test.call_graph.lambda.TestLambda:lambda$testList$1(java.lang.String) 21 1
M:9 test.call_graph.lambda.TestLambda:testList() (I)java.util.List:forEach(java.util.function.Consumer) 21 1
M:10 test.call_graph.lambda.TestLambda:testString(java.lang.String) (M)java.io.PrintStream:println(java.lang.String) 25 1
M:11 test.call_graph.lambda.TestLambda:lambda$testList$1(java.lang.String) (O)test.call_graph.lambda.TestLambda:testString(java.lang.String) 21 1

需要关注的调用关系如下:

M:8 test.call_graph.lambda.TestLambda:testList() (LM)test.call_graph.lambda.TestLambda:lambda$testList$1(java.lang.String) 21 1
M:11 test.call_graph.lambda.TestLambda:lambda$testList$1(java.lang.String) (O)test.call_graph.lambda.TestLambda:testString(java.lang.String) 21 1
M:10 test.call_graph.lambda.TestLambda:testString(java.lang.String) (M)java.io.PrintStream:println(java.lang.String) 25 1

可以看到,以下调用链是可以关联起来的

TestLambda:testList
TestLambda:lambda$testList$1
TestLambda:testString

testList方法需要通过lambda$testList$1方法再关联到testString,不知道这个能不能满足你的要求

from java-callgraph2.

ziping95 avatar ziping95 commented on July 18, 2024

可以满足,感谢

from java-callgraph2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.