From 55a441af3fef7ae3ad83b03d9c7e9c831a781f17 Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Sat, 18 Jul 2026 09:12:08 -0500 Subject: [PATCH] Fix StackMapFrame.CopyTo misrouting frame types 64-65 The encode dispatch in StackMapFrame.CopyTo routed FrameType <= 65 to SameStackMapFrame, but per JVMS 4.7.4 same_frame is only frame_type 0-63; 64-127 is same_locals_1_stack_item_frame. Frame types 64 and 65 therefore hit the (SameStackMapFrame)this cast, which itself asserts FrameType <= 63 and throws, making those frames impossible to re-encode. Correct the boundary to <= 63 so 64-65 fall through to the same_locals_1_stack_item_frame branch, matching the decode/measure paths which already use the correct boundary. Co-Authored-By: Claude Opus 4.8 --- src/IKVM.ByteCode/Decoding/StackMapFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IKVM.ByteCode/Decoding/StackMapFrame.cs b/src/IKVM.ByteCode/Decoding/StackMapFrame.cs index ee2ff56..a045624 100644 --- a/src/IKVM.ByteCode/Decoding/StackMapFrame.cs +++ b/src/IKVM.ByteCode/Decoding/StackMapFrame.cs @@ -217,7 +217,7 @@ public readonly void CopyTo(TConstantView constant where TConstantView : IConstantView where TConstantPool : IConstantPool { - if (FrameType is <= 65) + if (FrameType is <= 63) ((SameStackMapFrame)this).CopyTo(constantView, constantPool, ref encoder); else if (FrameType is >= 64 and <= 127) ((SameLocalsOneStackMapFrame)this).CopyTo(constantView, constantPool, ref encoder);