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

4.2.2: Fix misleading note about <init> in interfaces

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 18
    • Component/s: specification
    • Labels:
    • Subcomponent:
      vm

      Description

      JVMS 4.2.2 has an old note which suggests that an interface can have an <init> method:

      -----
      Note that a field name or interface method name may be `<init>` or `<clinit>`, but no method invocation instruction may reference `<clinit>` and only the invokespecial instruction (§invokespecial) may reference `<init>`.
      -----

      This note has been out of date since JVMS9, which prohibited `<init>` methods in interfaces (see 2.9.1 and 4.6). In addition, the note is trying to make the point that field names are less constrained than method names, but the point is neither necessary nor well made. (A field name like `<hello>` would make it more clearly, because `<hello>` is forbidden as a method name in both classes and interfaces.) Finally, there is no point in highlighting that an interface method name may be <clinit>, because it's true for a method in a class as well. The most useful thing to say is simply:

      -----
      Note that no method invocation instruction may reference `<clinit>`, and only the invokespecial instruction (§invokespecial) may reference `<init>`.
      -----

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              abuckley Alex Buckley
              Reporter:
              abuckley Alex Buckley
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: