Adrninistrator / java-callgraph2

Programs for producing static call graphs for Java programs.
Apache License 2.0
184 stars 66 forks source link

为什么有的时候子类调用父类方法,method_call会有,有的时候却没有? #40

Open binghuo15955 opened 7 months ago

binghuo15955 commented 7 months ago

method_call可以写入的情况:

父类

public abstract class AbstractBaseHandler {
    public final TResponse handle(TRequest request) {
        try {
            init(request);
            preHandle();
            validate();
            doHandle();
            postHandle();
        } catch (RequestValidationFailureException e) {
            handleValidationFailure(e.getMessage(), tags);
        } catch (Exception e) {
            handleError(e, tags);
        } finally {
            clear();
        }
        return response;
    }

子类 childClass继承这个AbstractBaseHandler, Code: childClass.handle(request).

method_call: childClass:handle(java.lang.Object)=> (_CCS)AbstractBaseHandler:handle(java.lang.Object)

method_call不可以写入的情况:

父类

public abstract class AbstractBaseHandlerextends SoaRequestProcessor {
    @Override
    public SoaResponseT process(SoaRequestT soaRequest) throws Exception {
        try {
            return super.process(soaRequest);
        } finally {
            InvokeContext.remove();
        }
    }
}

子类 childClass继承这个AbstractBaseHandler, Code: childClass.process(request).

method_call: childClass:handle(java.lang.Object)=> (_CCS)AbstractBaseHandler:handle(java.lang.Object)

两者的区别:子类的实例化方式,第一种是new或者getBean出来的,第二种是@Autowired自动注入的


问题如题,感谢你的时间

binghuo15955 commented 7 months ago

如果有任何想知道的额外信息,随时评论,我看到会及时回复的!

Adrninistrator commented 7 months ago

麻烦发一下子类初始化和使用的相关代码,子类在new的时候,是不是用的“子类类型 xxx = new @.***的时候,是不是用的“private 父类类型 xxx;”

binghuo15955 commented 7 months ago

麻烦发一下子类初始化和使用的相关代码,子类在new的时候,是不是用的“子类类型 xxx = new @.***的时候,是不是用的“private 父类类型 xxx;”

new的方式,是直接new 子类().process()。这个process是父类方法

依赖注入的话,也是直接@Autowired子类。

Adrninistrator commented 7 months ago

用之前的类似的例子试了一下,没有发现这样的问题,可以麻烦把你的验证的相关的代码都发一下吗  

easonzheng @.***