VerifyError when using the record pattern

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 20
    • Component/s: hotspot
    • None

      As reported here:

      https://mail.openjdk.org/pipermail/jdk-dev/2025-November/010641.html

      I think I found a bug.

      ```
      Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 206
      Exception Details:
        Location:
          org/arcane418/StatusService.statusScan(Ljava/util/concurrent/atomic/AtomicBoolean;Ljava/util/concurrent/CompletableFuture;)V @206: aload_3
        Reason:
          Type top (current frame, locals[5]) is not assignable to 'org/arcane418/Status$InternalError' (stack map, locals[5])
        Current Frame:
          bci: @130
          flags: { }
          locals: { 'org/arcane418/StatusService', 'java/util/concurrent/atomic/AtomicBoolean', 'java/util/concurrent/CompletableFuture', 'org/arcane418/Status', integer }
          stack: { integer }
        Stackmap Frame:
          bci: @206
          flags: { }
          locals: { 'org/arcane418/StatusService', 'java/util/concurrent/atomic/AtomicBoolean', 'java/util/concurrent/CompletableFuture', 'org/arcane418/Status', integer, 'org/arcane418/Status$InternalError' }
          stack: { }
        Bytecode:
          0000000: 2bb6 0024 9900 0c2c b200 2ab6 0030 57b1
          0000010: 1400 36b8 0038 b800 3ea7 0011 4e2b 04b6
          0000020: 0046 2cb2 002a b600 3057 2ab4 0010 b600
          0000030: 4a3a 0519 05c1 0050 9900 3219 05c0 0050
          0000040: 4e2d b600 523a 0619 063a 042a b400 0abb
          0000050: 0056 59bb 0058 5919 04b7 005a 125d b700
          0000060: 5fb9 0062 0200 57a7 ff99 2ab4 0010 b600
          0000070: 4a59 b800 6757 4e03 3604 2d15 04ba 006d
          0000080: 0000 aa00 0000 001a 0000 0000 0000 0002
          0000090: 0000 0024 0000 004c 0000 0055 bb00 7159
          00000a0: 0101 b700 73bf 2dc0 0050 3a05 2ab4 000a
          00000b0: bb00 5659 bb00 5859 1905 b600 52b7 005a
          00000c0: 1276 b700 5fb9 0062 0200 57a7 ff35 2dc0
          00000d0: 0078 3a06 a700 262d c000 7a3a 072a b400
          00000e0: 0abb 0056 59bb 007c 59b7 007e 1276 b700
          00000f0: 5fb9 0062 0200 57a7 ff09 a7ff 064e bb00
          0000100: 7159 2db6 0081 2db7 0073 bf
        Exception Handler Table:
          bci [16, 25] => handler: 28
          bci [66, 69] => handler: 253
        Stackmap Table:
          same_frame(@0)
          same_frame(@16)
          same_locals_1_stack_item_frame(@28,Object[#68])
          same_frame(@42)
          same_frame(@106)
          append_frame(@122,Object[#159],Integer)
          same_frame(@156)
          same_frame(@166)
          append_frame(@206,Object[#80])
          same_frame(@215)
          chop_frame(@250,3)
          same_locals_1_stack_item_frame(@253,Object[#127])

      at org.arcane418.Main.main(Main.java:10)

      ```
      I have prepared a draft to reproduce it: `https://github.com/Arcane561/compiler-error`

      Application Entry point Main.java.

      Please pay attention to the statusScan method in StatusService. If you remove the record pattern and replace it with the type pattern (instanceof Status.InternalError err) then no error occurs. Also, if you remove the switch, the error disappears.

      openjdk 25.0.1 2025-09-16
      OpenJDK Runtime Environment (build 25.0.1)
      OpenJDK 64-Bit Server VM (build 25.0.1, mixed mode, sharing)

            Assignee:
            Unassigned
            Reporter:
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: