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

javac is not inducing a notional interface if Object appears in an intersection type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • 10, 11
    • tools
    • b13
    • Verified

      class JDK8148354 {
          interface I {}
          interface J { void foo(); }

          public void test() {
              Object o1 = (I & J) System::gc;
              Object o2 = (Object & J) System::gc; // error
              Object o3 = (Object & I & J) System::gc; // error
          }
      }

      javac believes that Object is not allowed here, but it is:
      - "An intersection type that induces a notional functional interface" is a functional interface type (JLS 9.8)
      - "If Ck is Object, a notional interface is induced" -- where Ck is derived by mapping each intersection component to its most specific superclass type and then choosing the most specific of these class types -- in these cases, that's Object (JLS 4.9)

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: