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

[lworld] Javac fails to implicitly type abstract classes as implementing IdentityObject

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • tools
    • generic
    • generic

      JEP 401 (https://openjdk.java.net/jeps/401) states:

      // --
      An abstract class can similarly be declared to implement either IdentityObject or PrimitiveObject; or, if it declares a field, an instance initializer, a non-empty constructor, or a synchronized method, it implicitly implements IdentityObject (perhaps with a warning). Otherwise, the abstract class extends neither interface and can be extended by both kinds of concrete classes.

      // --

      So this code should compile:

      public abstract class X {
          int f;
          void foo(X x) {
              IdentityObject i = x;
          }
      }

      but as of now we get:

      X.java:4: error: incompatible types: X cannot be converted to IdentityObject
              IdentityObject i = x;
                                 ^
      1 error

            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: