[
https://issues.apache.org/jira/browse/GROOVY-10156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081498#comment-18081498
]
ASF GitHub Bot commented on GROOVY-10156:
-----------------------------------------
sonarqubecloud[bot] commented on PR #2538:
URL: https://github.com/apache/groovy/pull/2538#issuecomment-4470908634
## [](https://sonarcloud.io/dashboard?id=apache_groovy&pullRequest=2538)
**Quality Gate passed**
Issues
 [0 New
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2538&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2538&issueStatuses=ACCEPTED)
Measures
 [0 Security
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_groovy&pullRequest=2538&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [93.8% Coverage on New
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2538&metric=new_coverage&view=list)
 [0.0% Duplication on New
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2538&metric=new_duplicated_lines_density&view=list)
<!
> Unreachable bytecode in switch statement
> ----------------------------------------
>
> Key: GROOVY-10156
> URL: https://issues.apache.org/jira/browse/GROOVY-10156
> Project: Groovy
> Issue Type: Improvement
> Components: Compiler
> Affects Versions: 3.0.8
> Environment: JVM: 11.0.11 (Oracle Corporation 11.0.11+9-LTS-194)
> OS: Mac OS X 10.16 x86_64
> Reporter: Damir Murat
> Assignee: Daniel Sun
> Priority: Minor
> Labels: bytecode, enum
> Fix For: 6.0.0-alpha-2
>
>
> When switching over an enum, and for two or more case branches, groovy
> generates unreachable bytecode for each case branch except the last one.
> For example
> {code:java}
> package mypackage
> import groovy.transform.CompileStatic
> @CompileStatic
> class SwitchDemo {
> void mySwitchMethod(MyEnum myEnum) {
> switch (myEnum) {
> case MyEnum.ONE:
> println "ONE"
> break
> case MyEnum.TWO:
> println "TWO"
> break
> case MyEnum.THREE:
> println "TWO"
> break
> default:
> println "default"
> break
> }
> }
> }
> @CompileStatic
> enum MyEnum {
> ONE, TWO, THREE
> }
> {code}
> generates bytecode sequences like
> {code:java}
> ...
> L8
> L9
> LINENUMBER 12 L9
> GOTO L10
> L3
> L11
> LINENUMBER 12 L11
> ALOAD 2
> GETSTATIC mypackage/MyEnum.TWO : Lmypackage/MyEnum;
> INVOKESTATIC org/codehaus/groovy/runtime/ScriptBytecodeAdapter.isCase
> (Ljava/lang/Object;Ljava/lang/Object;)Z
> IFEQ L12
> L10
> ...
> {code}
> It looks like the first four lines above are not necessary. This results in
> {noformat}
> nop, nop, athrow
> {noformat}
> sequences in generated java bytecode.
> It would be great if this can be cleaned up and fixed. My scenario is related
> to JaCoCo reports which are not accurate and a bit confusing for switch
> statements.
> Tnx
--
This message was sent by Atlassian Jira
(v8.20.10#820010)