小编Ema*_*sco的帖子

AspectJ编译器错误导致StackOverflowError

我今天遇到了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)

java stack-overflow aspectj compiler-bug

9
推荐指数
1
解决办法
285
查看次数

标签 统计

aspectj ×1

compiler-bug ×1

java ×1

stack-overflow ×1