我今天遇到了AspectJ编译器的StackOverflow错误,我想我应该在StackOverflow上分享它:-)重现错误我做了一个玩具示例
public abstract class Node<T,Q extends Node<T,Q>> implements WithParent<Q>{
private T content;
//getter and setter for content
}
public aspect WithParentAspect {
private T WithParent<T>.parent;
public T WithParent<T>.getParent() {
return this.parent;
}
public void WithParent<T>.setParent(T parent) {
this.parent=parent;
}
}
public interface WithParent<T> { }
public class StringContentNode extends Node<String, StringContentNode>{
public static void main (String [] args) {
StringContentNode root = new StringContentNode();
StringContentNode leaf = new StringContentNode();
root.setContent("root");
leaf.setContent("leaf");
leaf.setParent(root);
System.out.println(leaf);
System.out.println(leaf.getParent());
}
}
Run Code Online (Sandbox Code Playgroud)
尝试编译此代码会导致以下错误:
java.lang.StackOverflowError
at org.aspectj.weaver.World$TypeMap.put(World.java:1198) …Run Code Online (Sandbox Code Playgroud)