在运行时获取 Java 类的依赖项列表的最有效方法是什么?
使用它(基于 ASM ByteCode Manipulator 3.3.1),我可以执行以下操作:
final Collection<Class<?>> classes =
getClassesUsedBy(MyService.class.getName(), "com");
Run Code Online (Sandbox Code Playgroud)
这返回对BasicServiceand的引用IService,但错过了ContainerValue,这就是问题所在。我尝试了 ASM 代码,但不知道如何获取 ContainerValue。
package com.foo.bar;
public class MyService extends BasicService implements IService {
public String invoke(){
return new ContainerValue("bar").toString();
}
Run Code Online (Sandbox Code Playgroud)
附带说明一下,如果我将ContainerValue返回类型设置为 on invoke,它就可以工作。
除了使用 ASM 获取类的依赖项列表之外,还有其他选择吗?到底为什么这么难?