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

[lworld] Wrong code generated for PrimitiveClass.ref.default

XMLWordPrintable

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

      The following program should print null, but instead ends up with a primitive class instance due to incorrect code generation.

      public primitive class X {

          public static void main(String [] args) {
              Object o = X.ref.default;
              System.out.println(o);
          }
      }


      JEP401 states: "Every type has a default value, used to populate newly-allocated fields and array components of that type. " which affirms that

      X.ref.default should actually be null since that is the default value
      of primitive reference types.

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

              Created:
              Updated:
              Resolved: