| Summary: | [12] Inconsistent stackmap frames with switch expression | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jay Arthanareeswaran <jarthana> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | manoj.palat |
| Version: | 4.10 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
@Jay: Codegen is pending - see bug 542838 [Issue raised there specifically is the same] *** This bug has been marked as a duplicate of bug 542838 *** |
The following code throws an exception when run: public class Switch { public static long foo(String s) { long promoted = switch(s){ case "1" -> 1; // trouble here! default -> 0; }; return promoted; } public static void main(String[] args) { System.out.println(foo("1")); } } The error is: Error: Unable to initialize main class Switch Caused by: java.lang.VerifyError: Inconsistent stackmap frames at branch target 40 Exception Details: Location: Switch.foo(Ljava/lang/String;)J @6: lookupswitch Reason: Current frame's stack size doesn't match stackmap. Current Frame: bci: @6 flags: { } locals: { 'java/lang/String', top, top, 'java/lang/String' } stack: { integer } Stackmap Frame: bci: @40 flags: { } locals: { 'java/lang/String', top, top, 'java/lang/String' } stack: { long, long_2nd } Bytecode: 0000000: 2a59 4eb6 0010 ab00 0000 0022 0000 0001 0000010: 0000 0031 0000 0012 2d12 16b6 0018 9a00 0000020: 06a7 0007 0aa7 0004 0940 1fad Stackmap Table: full_frame(@24,{Object[#17],Top,Top,Object[#17]},{}) same_frame(@36) same_locals_1_stack_item_frame(@40,Long) full_frame(@41,{Object[#17]},{Long,Long})