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

j.l.Record need to mention that canonical constructor may not be public

XMLWordPrintable

    • b27

      With JEP 384 intergated the specification for j.l.Record still says:
      "A record class has the following mandated members: a public canonical constructor, whose descriptor is the same as the record descriptor"

      However as experiments show, canonical constructor may not be public.
      The following code since JDK15 b24

      public class Test {
          public static void main(String[] args) {
              System.err.println( R.class.getConstructors().length);
              System.err.println( PubR.class.getConstructors().length);
          }
          record R(int i) { }
          public record PubR(int i) {}
      }


      started to print

      0
      1

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

              Created:
              Updated:
              Resolved: