Skip to content

VerifyError: Instruction type does not match stack map with for loop in switch #5201

Description

@Nadaron

After switching from eclipse 2025-06 to 2026-06 one of our applications permanently crashes with a java.lang.VerifyError: "Instruction type does not match stack map". I wrote a small test case for the code part where the issue is raised:

import java.util.Collection;
import java.util.Set;

public class Test {

	public static class Dummy {

	}

	public static class ExtendedDummy extends Dummy {

	}

	public static void main(String[] args) {
		test(ExtendedDummy.class, switch ("B") {
		case "A" -> {
			for (int i = 0; i < 10; i++)
				System.out.println(i);

			yield Set.of("NoopA");
		}
		case "B" -> Set.of("NoopB");
		default -> throw new IllegalArgumentException();
		});
	}

	public static <T extends Dummy> void test(Class<T> cls, Collection<String> entities) {
		entities.forEach(e -> System.out.println(e));
	}
}

This crashes in 2026-06 with:

Error: Unable to initialize main Test
Caused by: java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    Test.main([Ljava/lang/String;)V @75: iload_2
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @75
    flags: { }
    locals: { '[Ljava/lang/String;', 'java/lang/String', integer }
    stack: { }
  Stackmap Frame:
    bci: @75
    flags: { }
    locals: { '[Ljava/lang/String;', 'java/lang/String', integer }
    stack: { 'java/lang/Class' }
  Bytecode:
    0000000: 1210 1212 594c b600 14ab 0000 0000 0058
    0000010: 0000 0002 0000 0041 0000 001b 0000 0042
    0000020: 0000 0027 2b12 1ab6 001c 9a00 12a7 0034
    0000030: 2b12 12b6 001c 9a00 23a7 0028 033d a700
    0000040: 0db2 0020 1cb6 0026 8402 011c 100a a1ff
    0000050: f312 2cb8 002e a700 1312 34b8 002e a700
    0000060: 0bbb 0036 59b7 0038 bfb8 0039 b1       
  Stackmap Table:
    full_frame(@36,{Object[#66],Object[#21]},{Object[#67]})
    same_locals_1_stack_item_frame(@48,Object[#67])
    same_locals_1_stack_item_frame(@60,Object[#67])
    append_frame(@65,Integer)
    same_locals_1_stack_item_frame(@75,Object[#67])
    full_frame(@89,{Object[#66],Object[#21]},{Object[#67]})
    same_locals_1_stack_item_frame(@97,Object[#67])
    full_frame(@105,{Object[#66]},{Object[#67],Object[#47]})

It is running fine under with eclipse 2025-06. If you delete the for loop in the switch statement the (unused) case A it it also running in 2026-06.
Used Java version is 21.0.7+6-LTS.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions