[
https://issues.apache.org/jira/browse/GROOVY-10156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081459#comment-18081459
]
ASF GitHub Bot commented on GROOVY-10156:
-----------------------------------------
testlens-app[bot] commented on PR #2538:
URL: https://github.com/apache/groovy/pull/2538#issuecomment-4469873588
## 🚨 TestLens detected 1 failed tests 🚨
Here is what you can do:
1) Inspect the test failures carefully.
2) If you are convinced that some of the tests are flaky, you can mute them
below.
3) Finally, trigger a rerun by checking the rerun checkbox.
### Test Summary
| Check | Project/Task | Test | Runs |
|---|---|---|---|
| [Build and test / lts \(17,
macos-latest\)](https://github.com/apache/groovy/actions/runs/25985510697/job/76381937292?pr=2538)
| :test | Groovy11362 > testCatchException\(\) | ❌ |
🏷️ Commit: d4955f0f9f749f2e985212d9a002a68a0aebb22e
▶️ Tests: 13590 executed
🟡 Checks: 2/56 completed
### Test Failure
<details>
<summary><strong>Groovy11362 > testCatchException()</strong> (:test in <a
href="https://github.com/apache/groovy/actions/runs/25985510697/job/76381937292?pr=2538">Build
and test / lts (17, macos-latest)</a>)</summary>
```
Assertion failed:
assert bytecode.hasSequence([ 'LOCALVARIABLE this Lscript; L0 L6 0',
'LOCALVARIABLE e Ljava/lang/Exception; L5 L3 1' // not Ljava/lang/Object; ])
| |
| false
// class version 61.0 (61)
// access flags 0x21
public class script extends groovy/lang/Script {
// compiled from: script
// access flags 0x100A
private static synthetic Lorg/codehaus/groovy/reflection/ClassInfo;
$staticClassInfo
// access flags 0x1089
public static transient synthetic Z __$stMC
@Lgroovy/transform/Internal;()
// access flags 0x1
public <init>()V
L0
ALOAD 0
INVOKESPECIAL groovy/lang/Script.<init> ()V
L1
RETURN
LOCALVARIABLE this Lscript; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public <init>(Lgroovy/lang/Binding;)V
L0
ALOAD 0
ALOAD 1
INVOKESPECIAL groovy/lang/Script.<init> (Lgroovy/lang/Binding;)V
L1
RETURN
LOCALVARIABLE this Lscript; L0 L1 0
LOCALVARIABLE context Lgroovy/lang/Binding; L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
// access flags 0x89
public static varargs main([Ljava/lang/String;)V
@Lgroovy/transform/Generated;()
L0
LDC Lorg/codehaus/groovy/runtime/InvokerHelper;.class
LDC Lscript;.class
ALOAD 0
INVOKEDYNAMIC
invoke(Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/String;)Ljava/lang/Object;
[
// handle kind 0x6 : INVOKESTATIC
org/codehaus/groovy/vmplugin/v8/IndyInterface.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;I)Ljava/lang/invoke/CallSite;
// arguments:
"runScript",
0
]
POP
RETURN
L1
LOCALVARIABLE args [Ljava/lang/String; L0 L1 0
MAXSTACK = 3
MAXLOCALS = 1
// access flags 0x1
public run()Ljava/lang/Object;
@Lgroovy/transform/Generated;()
L0
ACONST_NULL
ARETURN
L1
LOCALVARIABLE this Lscript; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
--BEGIN--
// access flags 0x1
public test()V
TRYCATCHBLOCK L0 L1 L1 java/lang/Exception
L0
LINENUMBER 4 L0
ALOAD 0
LDC "f"
INVOKEDYNAMIC invoke(Lscript;Ljava/lang/String;)Ljava/lang/Object; [
// handle kind 0x6 : INVOKESTATIC
org/codehaus/groovy/vmplugin/v8/IndyInterface.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;I)Ljava/lang/invoke/CallSite;
// arguments:
"print",
2
]
POP
GOTO L2
L1
FRAME SAME1 java/lang/Exception
ASTORE 1
L3
GOTO L2
L2
LINENUMBER 7 L2
FRAME SAME
RETURN
LOCALVARIABLE this Lscript; L0 L2 0
LOCALVARIABLE e Ljava/lang/Exception; L3 L3 1
MAXSTACK = 2
MAXLOCALS = 2
--END--
// access flags 0x1004
protected synthetic $getStaticMetaClass()Lgroovy/lang/MetaClass;
ALOAD 0
INVOKEVIRTUAL java/lang/Object.getClass ()Ljava/lang/Class;
LDC Lscript;.class
IF_ACMPEQ L0
ALOAD 0
INVOKESTATIC
org/codehaus/groovy/runtime/ScriptBytecodeAdapter.initMetaClass
(Ljava/lang/Object;)Lgroovy/lang/MetaClass;
ARETURN
L0
FRAME SAME
GETSTATIC script.$staticClassInfo :
Lorg/codehaus/groovy/reflection/ClassInfo;
ASTORE 1
ALOAD 1
IFNONNULL L1
ALOAD 0
INVOKEVIRTUAL java/lang/Object.getClass ()Ljava/lang/Class;
INVOKESTATIC org/codehaus/groovy/reflection/ClassInfo.getClassInfo
(Ljava/lang/Class;)Lorg/codehaus/groovy/reflection/ClassInfo;
DUP
ASTORE 1
PUTSTATIC script.$staticClassInfo :
Lorg/codehaus/groovy/reflection/ClassInfo;
L1
FRAME APPEND [org/codehaus/groovy/reflection/ClassInfo]
ALOAD 1
INVOKEVIRTUAL org/codehaus/groovy/reflection/ClassInfo.getMetaClass
()Lgroovy/lang/MetaClass;
ARETURN
MAXSTACK = 2
MAXLOCALS = 2
}
at
org.codehaus.groovy.runtime.InvokerHelper.createAssertError(InvokerHelper.java:400)
at bugs.Groovy11362.testCatchException(Groovy11362.groovy:36)
```
</details>
### Muted Tests
> [!NOTE]
> Checks are currently running using the configuration below.
Select tests to mute in this pull request:
🔲 Groovy11362 > testCatchException\(\) <!
> 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)