Tôi gặp sự cố khi biên dịch một lớp chung với lớp bên trong. Lớp mở rộng một lớp chung chung, lớp bên trong cũng có.Lỗi biên dịch thừa kế của lớp bên trong chung mở rộng với các giới hạn
đây giao diện thực hiện:
public interface IndexIterator<Element>
extends Iterator<Element>
{
...
}
Các generic siêu lớp:
public abstract class CompoundCollection<Element, Part extends Collection<Element>>
implements Collection<Element>
{
...
protected class CompoundIterator<Iter extends Iterator<Element>>
implements Iterator<Element>
{
...
}
}
Các lớp con chung với lỗi biên dịch:
public class CompoundList<Element>
extends CompoundCollection<Element, List<Element>>
implements List<Element>
{
...
private class CompoundIndexIterator
extends CompoundIterator<IndexIterator<Element>>
implements IndexIterator<Element>
{
...
}
}
Lỗi này là:
type parameter diergo.collect.IndexIterator<Element> is not within its bound
extends CompoundIterator<IndexIterator<Element>>
^
Điều gì là sai? Mã biên dịch với nhật thực, nhưng không phải với trình biên dịch java 5 (tôi sử dụng kiến với java 5 trên mac và eclipse 3.5). Không, tôi không thể chuyển đổi nó thành một lớp bên trong tĩnh.
Bất kỳ cơ hội nào bạn có thể thử bằng Java 6?Nó có thể là một lỗi trình biên dịch. –
Chỉ cần thử với Java 6. Thông báo lỗi tương tự. Thú vị ... –
@mmyers: ý tưởng tốt @Eval: cảm ơn, cũng đã thử bản thân mình trên máy Mac 1.6 jdk - lỗi tương tự –