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

Allow NameAndType constants with special method names

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • 24
    • 21
    • hotspot

    Description

      JVMS (4.4.6) says that the 'name' portion of a NameAndType may represent "either a valid unqualified name denoting a field or method, or the special method name <init>", while the 'descriptor' portion may be "a valid field descriptor or method descriptor".

      Per 4.2.2, names that include '<' are valid unqualified field names. This includes the names '<init>' and '<clinit>', which should be fully usable as names of fields.

      During format checking of a NameAndType constant (setting aside whether it is referenced by any other constant), HotSpot seems to consider the name and descriptor in tandem, and enforce different rules for the name based on the descriptor. Some examples:

      <init>:()I --> CFE
      <clinit>:()I --> CFE
      <clinit>:()V --> no error
      <finit>:()I --> CFE

      This is inconsistent with the spec, and should be cleaned up. Given a standalone NameAndType, any valid unqualified name should be accepted for 'name', and any valid field or method descriptor should be accepted for 'descriptor'.

      *References* to NameAndType constants enforce some additional constraints:

      - From a Fieldref, the descriptor must be a field descriptor

      - From a Methodref, the name must be a valid method name and must not be '<clinit>'. The descriptor must be a method descriptor, and if the name is '<init>', the descriptor must return 'V'.

      - Same for InterfaceMethodref.

      - From a Dynamic, the descriptor must be a field descriptor

      - From an InvokeDynamic, the descriptor must be a method descriptor. (Should the name be restricted? I think so, but the spec doesn't say so for now, so that's a separate issue.)

      Attachments

        Issue Links

          Activity

            People

              matsaave Matias Saavedra Silva
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: