JDK-6360967 : conditional operators seem to be confused about (lower) bounded wildcards
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-12-08
  • Updated: 2010-04-02
  • Resolved: 2005-12-19
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The following piece of code contains an error, but logically seems to be correct.
###
import java.util.Map;

class GenericsTest {
    <A> void a(Map<? super A, ? super A> map) {
        a(map);
    }
}
###
Logically, the method call should be fine. There is a generic type A defining the interdependency between the map's key and value type. But the argument used to call the method cannot be used to call it another time. javac produces the following output:
###
[...]>javac GenericsTest.java
GenericsTest.java:6: <A>a(java.util.Map<? super A,? super A>) in GenericsTest cannot be applied to (java.util.Map<capture of ? super A,capture of ? super A>)
                a(map);
                ^
1 error
###


REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION Thank you for noticing Tobias_Riemenschneider, I thought I had deja vu ;-)
19-12-2005