[ 
https://issues.apache.org/jira/browse/GROOVY-10156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081472#comment-18081472
 ] 

ASF GitHub Bot commented on GROOVY-10156:
-----------------------------------------

sonarqubecloud[bot] commented on PR #2538:
URL: https://github.com/apache/groovy/pull/2538#issuecomment-4470367515

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_groovy&pullRequest=2538) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [3 New 
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2538&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2538&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_groovy&pullRequest=2538&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2538&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [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
>            Priority: Minor
>              Labels: bytecode, enum
>
> 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)

Reply via email to