Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当变更行所在方法为接口定义方法时,无法取得注解的接口地址 #46

Open
kandy-wang opened this issue Sep 20, 2023 · 8 comments

Comments

@kandy-wang
Copy link

image
image

@kandy-wang
Copy link
Author

应该是在这个方法中com.adrninistrator.jacg.runner.base.AbstractRunnerGenCallGraph#queryMethodCallFlags的950-953行,查询方法没有向上的调用方法时,默认的callFlags为0,造成com.adrninistrator.jacg.runner.RunnerGenAllGraph4Callee#recordOneCalleeMethod中360-367行判断方法是否有注解未执行。
image

image

@Adrninistrator
Copy link
Owner

Adrninistrator commented Sep 23, 2023 via email

@kandy-wang
Copy link
Author

`package com.example.demo.controller.chain;

import org.springframework.web.bind.annotation.*;

@RestController
public class ChainController {

@RequestMapping("/chain/get_project_id_by_evn")
public String getProjectId(@RequestParam(value = "env", required = false) String evn) {
    if (Character.isLetter(evn.charAt(0))) {
        return "abc";
    }
    return "123";
}

}`
使用com.example.demo.controller.chain.ChainController:11收集向上的调用链,

@Adrninistrator
Copy link
Owner

Adrninistrator commented Sep 23, 2023 via email

@kandy-wang
Copy link
Author

所以这里能否优化一下,毕竟通过代码变更获取接口入口时,经常会有接口定义的方法变更的情况,而无法获取到接口,造成精准推荐时缺少指定的接口。而且并没有生成空文件,只是生成的文件内容缺少方法上的注解
image

@Adrninistrator
Copy link
Owner

前几天通过邮件回复的看起来没有生效,现在的处理是如果发现有指定的方法不存在时会报错,是需要改成不报错并且生成空文件就可以吗

@kandy-wang
Copy link
Author

最好是如果发现指定的方法没有被调用时,检查是否有注解,有注解生成对应的文件,无注解生成空文件

@Adrninistrator
Copy link
Owner

看了一下现在实现的功能,如果指定的需要查找向下或向下的方法不存在或者找不到调用方法时,都是会输出空文件,不会影响其他方法的执行
如果需要知道方法上的注解信息的话,可以用com.adrninistrator.jacg.handler.annotation.AnnotationHandler类的方法来查询,有各种查询指定类或方法的注解信息的功能
参考示例代码:https://github.com/Adrninistrator/java-all-call-graph/blob/main/java-all-call-graph/src/test/java/test/run_by_code/handler/annotation/TestAnnotationHandler.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants