Handle eclipse special case string switch
See original GitHub issueCFR version
6d817c99333c3f691aeb00aa68cb71047ecf359e
Compiler
OpenJDK 8
Description
Decompiler outputs too many labels for this simple code. Also seems like string switches are not decoded, even when the option is set to true.
while (true) {
switch (string) {
case "apples":
System.out.println("apples");
break;
case "pears":
System.out.println("pears");
break;
}
}
gets decompiled to
block4: while (true) {
block6: {
String string = SwitchInLoop.string;
switch (string.hashCode()) {
case -1411061671: {
if (string.equals("apples")) break;
continue block4;
}
case 106540109: {
if (!string.equals("pears")) {
continue block4;
}
break block6;
}
}
System.out.println("apples");
continue;
}
System.out.println("pears");
}
Example
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
String in Switch Case in Java - GeeksforGeeks
It provides an easy way to dispatch execution to different parts of code based on the value of the expression. Basically, the expression...
Read more >The switch Statement (The Java™ Tutorials > Learning the ...
A switch works with the byte , short , char , and int primitive data types. It also works with enumerated types (discussed...
Read more >Compiler error for string switch case label - java - Stack Overflow
The whole case label statement is marked in red line by eclipse "case PreferenceType.FIRST.toString():" and when I hover the mouse over the case...
Read more >Java Switch Statement With Strings (With and Without break)
Learn how switch statements work in java with a step-by-step example using strings and how the break statement affects the flow of execution ......
Read more >Java12/Examples - Eclipsepedia
Switch expression, Enhanced switch statement and Multi-constant case labels are Preview features in Java 12. They are not enabled by default and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Again caused by me being lazy with the API, works now
@GraxCode, for the example jar file you provided with this issue or for a different class? For me the jar file decompiles fine.