javac generates wrong ldc instruction for dynamic constant loads

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 22
    • Affects Version/s: 11, 17, 21, 22
    • Component/s: tools
    • b22

      From JVMS description of "ldc"/"ldc_w" opcode:

      ```
       If the run-time constant pool entry is a numeric constant of type int or float, then the value of that numeric constant is pushed onto the operand stack as an int or float, respectively.
      ```

      That is, we cannot use ldc to load a two-slot constant. We need to use ldc2_w for that. Unfortunately, javac always emits ldc/ldc_w for all dynamic constants, regardless of their type. This can lead to verifier errors.

            Assignee:
            Maurizio Cimadamore
            Reporter:
            Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: