Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8178952

Separate compilation issue with bounded wildcard

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 6-pool, 7-pool, 8-pool, 9
    • tools
    • None

      javac accepts the following program if both classes are compiled from source, but rejects it if B is compiled from source and A is on the classpath. I expected the two cases to be consistent.

      I reproduced with 9-ea+165, but it affects all versions I tried back to 1.6.0-b105.

      === A.java
      import java.util.Map;
      abstract class A {
        interface I<X extends String> {}
        abstract void f(Map<String, I<?>> i);
      }
      === B.java
      import java.util.Map;
      public class B {
        void f(A a, Map<String, A.I<? extends String>> x) {
          a.f(x);
        }
      }
      ===

      $ javac -sourcepath : A.java B.java
      ... OK
      $ javac -sourcepath : B.java
      B.java:4: error: incompatible types: Map<String,I<? extends String>> cannot be converted to Map<String,I<?>>
          a.f(x);
              ^

            vromero Vicente Arturo Romero Zaldivar
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: