[
https://issues.apache.org/jira/browse/GROOVY-12595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18135585#comment-18135585
]
ASF GitHub Bot commented on GROOVY-12595:
-----------------------------------------
codecov-commenter commented on PR #3122:
URL: https://github.com/apache/groovy/pull/3122#issuecomment-6539619530
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3122?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:x: Patch coverage is `50.00000%` with `1 line` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 74.0958%. Comparing base
([`cd944a5`](https://app.codecov.io/gh/apache/groovy/commit/cd944a5f0ee353126e6f6a484f574b4b53e555fd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`1f94e3a`](https://app.codecov.io/gh/apache/groovy/commit/1f94e3ac949bf1d9fc4135dbbe8406f538a35ffc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3122?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Patch % | Lines |
|---|---|---|
|
[...groovy/classgen/asm/sc/StaticInvocationWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3122?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticInvocationWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNJbnZvY2F0aW9uV3JpdGVyLmphdmE=)
| 50.0000% | [0 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3122?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/3122?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3122 +/- ##
==================================================
- Coverage 74.1016% 74.0958% -0.0059%
+ Complexity 43596 43593 -3
==================================================
Files 1692 1692
Lines 149245 149246 +1
Branches 28284 28285 +1
==================================================
- Hits 110593 110585 -8
- Misses 28475 28482 +7
- Partials 10177 10179 +2
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3122?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...groovy/classgen/asm/sc/StaticInvocationWriter.java](https://app.codecov.io/gh/apache/groovy/pull/3122?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FStaticInvocationWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9TdGF0aWNJbnZvY2F0aW9uV3JpdGVyLmphdmE=)
| `76.8612% <50.0000%> (+0.2483%)` | :arrow_up: |
... and [14 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3122/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests,
report on failures, and find test suite problems.
- :package: [JS Bundle
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save
yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
> @CompileStatic: calling clone() on an element of a multi-dimensional array
> fails bytecode verification
> ------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12595
> URL: https://issues.apache.org/jira/browse/GROOVY-12595
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Priority: Major
>
> Under {{@CompileStatic}}, calling {{clone()}} directly on an element read
> from an array of arrays generates bytecode that the JVM verifier rejects.
> This happens for both primitive and reference element types.
> {code:groovy}
> import groovy.transform.CompileStatic
> @CompileStatic
> class C {
> static float[] one(float[][] a) { a[0].clone() }
> static String[] two(String[][] a) { a[0].clone() }
> }
> float[][] f = [[1f, 2f] as float[]]
> assert C.one(f) == [1f, 2f] as float[]
> {code}
> Loading {{C}} fails:
> {noformat}
> java.lang.VerifyError: Bad access to protected data in invokevirtual
> Exception Details:
> Location:
> C.one([[F)[F @5: invokevirtual
> Reason:
> Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'C'
> {noformat}
> h3. Generated bytecode
> {noformat}
> 0: aload_0
> 1: iconst_0
> 2: invokestatic
> org/codehaus/groovy/runtime/BytecodeInterface8.objectArrayGet:([Ljava/lang/Object;I)Ljava/lang/Object;
> 5: invokevirtual java/lang/Object.clone:()Ljava/lang/Object; <-- receiver
> is still typed Object; no checkcast [F
> 8: invokedynamic cast:(Ljava/lang/Object;)[F
> {noformat}
> h3. Cause
> The type checker models array {{clone()}} as {{Object#clone()}} (see
> GROOVY-10319). When it computes the receiver cast,
> {{StaticInvocationWriter.CheckcastReceiverExpression#getType()}} skips the
> {{checkcast}} whenever the target is declared on {{Object}}. But
> {{Object#clone()}} is protected, so the verifier only accepts the
> {{invokevirtual}} if the receiver is the calling class or an array type. An
> element read with {{objectArrayGet}} is typed {{Object}} on the stack, so the
> call is rejected.
> These forms are unaffected because the receiver is already typed as the array:
> * {{a.clone()}} where {{a}} is a {{float[]}} or {{float[][]}} parameter or
> local
> * {{float[] b = a[0]; b.clone()}}
> * {{def b = a[0]; b.clone()}}
> h3. Workaround
> Assign the element to a local variable before calling {{clone()}}.
> h3. Affects
> 6.0.0, and current master (7.0.0-SNAPSHOT) and GROOVY_6_0_X.
> h3. Proposed fix
> In {{CheckcastReceiverExpression#getType()}}, keep the array receiver type
> (and so emit {{checkcast}}) when the target is a no-arg {{clone()}} on an
> array, instead of falling back to {{Object}}. Regression test:
> {{ArraysAndCollectionsSTCTest#testArrayCloneOfArrayElement}}, which also runs
> under static compilation via {{ArraysAndCollectionsStaticCompileTest}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)