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

4.9.1: Prohibit the ret opcode in the code array of >= 51.0 class files

    XMLWordPrintable

    Details

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

      Description

      JVMS 4.9.1 "Static Constraints" says "If the class file version number is 51.0 or above, then neither the jsr opcode or the jsr_w opcode may appear in the code array." The ret opcode should be added to this constraint because HotSpot issues a VerifyError with the following message when it encounters a ret opcode in a class file with version 51.0 or above:

      exception: Bad instruction: a9
      Exception Details:
        Location:
          primArray.castToByteArray([I)[B @1: ret

      More specifically, in a >=51.0 class file, HotSpot treats jsr (a8), jsr_w (c9), and ret (a9) the same as the three reserved opcodes (ca, fe, ff) and the numerous undocumented opcodes (cb-fd): there are no type-checking rules for any of these opcodes, so they are unrecognized and cause VerifyErrors. This is a valid way to "implement" the first bullet of 4.9.1.

      The constraint about jsr/jsr_w/ret should mirror the constraint about reserved/undocumented opcodes, as follows: "If the class file version number is 51.0 or above, then instances of instructions using the jsr, jsr_w, or ret opcodes must not appear in the code array."

        Attachments

          Activity

            People

            Assignee:
            abuckley Alex Buckley
            Reporter:
            hseigel Harold Seigel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: