Community
Participate
Working Groups
build I20040930 1) create the following classes public class Z { } public class Y { public <T extends Z> void add(Class<T> t, T l) {} public void add(String s, String s2) {} } public class X { Y var2 = null; void bar(Z l) { var2.add(l.getClass(), l); } } 2) compile There is only one error inside the problem view but there is two error markers at the same line inside the editor.
Using build I200410260800... now editor and problems view behave identically. Both reports one error: ---------- 1. ERROR in D:\usr\OTI\workspaces\dvpt\v31\HEAD\_Bug\X.java (at line 4) var2.add(l.getClass(), l); ^^^^^^^^^^^^^^^^^^^^^^^^^ Bound mismatch: The method add(Class<? extends Z>, ? extends Z) of type Y is not applicable for the arguments (Class<? extends Z>, Z). The wildcard parameter ? extends Z has no lower bound, and may actually be more restrictive than argument Z ---------- 1 problem (1 error)
Leave opened as this error does not seem really accurate...
javac reports following error: X.java:4: cannot find symbol symbol : method add(java.lang.Class<capture of ? extends Z>,Z) location: class Y var2.add(l.getClass(), l); ^ 1 error
Closing, this error is expected. Cannot invoke a method with wildcard parameters with no lower bound. Inference is computing such a substitute for T, but this is irrelevant. Unless the spec allows this, will not change current behavior to remain compliant.