Community
Participate
Working Groups
The following code crashes when compiled with Java 17 plugin public class Test { public static void main(String[] args) { Map<String, String> map = new HashMap<>(); map.put("key1", "value1"); map.put("key2", "value2"); for(Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator(); iter.hasNext();) { Map.Entry<String, String> entry = iter.next(); switch(entry.getKey()) { case "key1": break; case "key2": break; } } } } When you first assign entry.getKey to a local variable and use that one in the switch it works fine
Ursache: java.lang.VerifyError: Bad type on operand stack Exception Details: Location: Test.main([Ljava/lang/String;)V @64: invokevirtual Reason: Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/lang/String' Current Frame: bci: @64 flags: { } locals: { '[Ljava/lang/String;', 'java/util/Map', 'java/util/Iterator', 'java/util/Map$Entry', 'java/lang/Object' } stack: { 'java/lang/Object' } Bytecode: 0000000: bb00 1059 b700 124c 2b12 1312 15b9 0017 0000010: 0300 572b 121d 121f b900 1703 0057 2bb9 0000020: 0021 0100 b900 2501 004d a700 492c b900 0000030: 2b01 00c0 0031 4e2d b900 3301 0059 3a04 0000040: b600 36ab 0000 0030 0000 0002 0032 2db2 0000050: 0000 0019 0032 2db3 0000 0026 1904 1213 0000060: b600 3c9a 0010 a700 0d19 0412 1db6 003c 0000070: 9a00 032c b900 4001 009a ffb4 b1 Stackmap Table: append_frame(@45,Object[#24],Object[#44]) append_frame(@92,Object[#49],Object[#55]) same_frame(@105) chop_frame(@115,2)
I believe this was dixed in recent builds. Could you please try 4.22 M1? https://download.eclipse.org/eclipse/downloads/drops4/S-4.22M1-202109291800/
Works on 4.22 master. I assume duplicate of bug 576093. *** This bug has been marked as a duplicate of bug 576093 ***