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

Compiler regression error on multi-level abstract generic class with intersection types

XMLWordPrintable

    • Fix Understood

      FULL PRODUCT VERSION :
      java version "1.6.0_37"
      Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
      Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b109)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b51, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      This code used to compile in JDK 1.6.0_37, but does not compiles in JDK 1.7.0_45 nor in JDK 1.8.0-ea-b109:

      interface A {}

      abstract class B<X> {
          abstract X m();
      }

      abstract class C<Y> extends B<Y> {
          @Override
          abstract Y m();
      }

      class MyBug<Z extends C<?> & A> {}


      REGRESSION. Last worked in version 6u43

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.6.0_37"
      Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
      Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b109)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b51, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the program using JDK 1.7.0 or JDK 8 EA b109.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code should compile in JDK 7 and JDK 8, as it used to compile in JDK 6.
      ACTUAL -
      error: m() in C cannot override m() in B
      class MyBug<Z extends C<?> & A> {}
        return type CAP#1 is not compatible with CAP#2
        where Y,X are type-variables:
          Y extends Object declared in class C
          X extends Object declared in class B
        where CAP#1,CAP#2 are fresh type-variables:
          CAP#1 extends Object from capture of ?
          CAP#2 extends Object from capture of ?
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      interface A {}

      abstract class B<X> {
          abstract X m();
      }

      abstract class C<Y> extends B<Y> {
          @Override
          abstract Y m();
      }

      class MyBug<Z extends C<?> & A> {}

      ---------- END SOURCE ----------

            dlsmith Dan Smith
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: