java-callgraph2 icon indicating copy to clipboard operation
java-callgraph2 copied to clipboard

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

Open binghuo15955 opened this issue 2 years ago • 4 comments

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 avatar Nov 21 '23 08:11 binghuo15955

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

binghuo15955 avatar Nov 21 '23 11:11 binghuo15955

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

Adrninistrator avatar Nov 21 '23 12:11 Adrninistrator

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

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

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

binghuo15955 avatar Nov 22 '23 03:11 binghuo15955

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

easonzheng @.***

 

Adrninistrator avatar Nov 22 '23 10:11 Adrninistrator