Summary: | [1.5] wrong errors when using type bounds | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tom Hofmann <eclipse> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED DUPLICATE | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | markus.kell.r |
Version: | 3.0 | ||
Target Milestone: | 3.1 M4 | ||
Hardware: | PC | ||
OS: | Linux-GTK | ||
Whiteboard: |
Description
Tom Hofmann
2004-09-17 10:20:44 EDT
Looks like the subtype relationship check between the wildcard lower bound and the argument's type should just go the other way 'round. With following test case: import java.util.List; public class Test { public void write(List<? super Exception> list) { list.add(new RuntimeException()); // JDT fails, Javac works list.add(new IllegalMonitorStateException()); // JDT fails, Javac works Exception exc = new Exception(); list.add(exc); // both works list.add(new Object()); // JDT works, Javac fails list.add(new Throwable()); // JDT works, Javac fails list.add(new Exception()); // both works } } javac reports following errors: Test.java:11: cannot find symbol symbol : method add(java.lang.Object) location: interface java.util.List<capture of ? super java.lang.Exception> list.add(new Object()); // JDT works, Javac fails ^ Test.java:12: cannot find symbol symbol : method add(java.lang.Throwable) location: interface java.util.List<capture of ? super java.lang.Exception> list.add(new Throwable()); // JDT works, Javac fails ^ 2 errors |