Possible Java compiler bug! Program does not compile with some compilers

浪子不回头ぞ 提交于 2019-12-01 05:26:12

It's apparently a javac bug you should report. You probably have better luck asking on one of open jdk mailing lists. But it's Thanksgiving so ...

This is not a basic usage of generics though, it's quite complicated.

I've entered your sample into my Eclipse Indigo (3.7.1) and it complained immediately about declaration of Property interface.

Illegal forward reference to type parameter C

And for the line public S get();

The return type is incompatible with PropertyConst.get()

Changing declaration of Property to this

interface Property<C, S extends C > extends PropertyConst<C> {
    @Override
    public S get();
}

fixed both errors, and compiles both in JDT and Sun's 1.6 compiler

Didn't try it out, but in

public class Bug<X extends Property<?, ?> & Anything> {

there is no restraint on both ?'s. One would need something like:

public class Bug<C, X extends Property<C, ? extends C> & Anything> {
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!