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

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

codecov-commenter commented on PR #3291:
URL: https://github.com/apache/groovy/pull/3291#issuecomment-6786981473

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3291?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 `33.33333%` with `2 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 74.4448%. Comparing base 
([`856b28a`](https://app.codecov.io/gh/apache/groovy/commit/856b28a961ca5964568c77034b98b6adde2e8f99?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`8c55e57`](https://app.codecov.io/gh/apache/groovy/commit/8c55e5721b0c0cddb3b80f3728225b7ec9983c60?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3291?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/3291?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=)
 | 33.3333% | [0 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3291?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>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3291/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/3291?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3291        +/-   ##
   ==================================================
   + Coverage     74.4429%   74.4448%   +0.0020%     
   - Complexity      44774      44782         +8     
   ==================================================
     Files            1702       1702                
     Lines          151891     151891                
     Branches        29091      29091                
   ==================================================
   + Hits           113072     113075         +3     
   + Misses          28413      28407         -6     
   - Partials        10406      10409         +3     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3291?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/3291?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=)
 | `77.5281% <33.3333%> (ø)` | |
   
   ... and [8 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3291/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
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 7.0.0-alpha-1, 6.0.1
>
>
> 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)

Reply via email to