我需要对 java 解析器生成的 AST 做一些操作。我的问题是我想检查一个类初始化周期问题是否存在。
一个例子是,
class mark1 {
public static final int x = mark2.p * 5;
//Do some operations here
}
class mark2 {
public static final int p = mark1.x + 100;
//Do some operations here
}
类的初始化顺序可能会有所不同,从而导致计算 mark1.x 和 mark2.p 的不同值。我正在尝试使用 javaparser 生成的 AST 来实现它,但没有得到可行的解决方案。