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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3025?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 72.5208%. Comparing base 
([`98c2f9f`](https://app.codecov.io/gh/apache/groovy/commit/98c2f9f106d2ee368278ca33d105e540bf23baf0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`579b43c`](https://app.codecov.io/gh/apache/groovy/commit/579b43c17a1f93850b03d2761b751533b339661f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3025/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/3025?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3025        +/-   ##
   ==================================================
   + Coverage     72.5157%   72.5208%   +0.0052%     
   - Complexity      40761      40777        +16     
   ==================================================
     Files            1644       1644                
     Lines          143027     143043        +16     
     Branches        26899      26903         +4     
   ==================================================
   + Hits           103717     103736        +19     
   + Misses          29759      29753         -6     
   - Partials         9551       9554         +3     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3025?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...roovy/transform/stc/StaticTypeCheckingVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/3025?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Fstc%2FStaticTypeCheckingVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9zdGMvU3RhdGljVHlwZUNoZWNraW5nVmlzaXRvci5qYXZh)
 | `87.4652% <100.0000%> (+0.0029%)` | :arrow_up: |
   | 
[...codehaus/groovy/transform/trait/TraitComposer.java](https://app.codecov.io/gh/apache/groovy/pull/3025?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Ftrait%2FTraitComposer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS90cmFpdC9UcmFpdENvbXBvc2VyLmphdmE=)
 | `82.4841% <100.0000%> (+0.1690%)` | :arrow_up: |
   
   ... and [20 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3025/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>




> Object initializer code dispatches through the meta class: trait $init$ 
> calls, and instance initializer blocks of @CompileStatic classes
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12491
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12491
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Static compilation
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> Code that runs during object construction is dispatched through the 
> meta-class in two places, even in {{@CompileStatic}} classes. Both cost a 
> dynamic dispatch on every instantiation, and in a GraalVM native image both 
> need reflection metadata, or construction fails.
> *Trait initializers.* When a class implements a trait, 
> {{TraitComposer.applyTrait}} adds {{Helper.$init$(this)}} to the class's 
> object initializer without a method target (the {{$static$init$}} call beside 
> it has one):
> {code:groovy}
> trait Greeting { String greeting = 'hello' }
> @CompileStatic class StaticGreeter implements Greeting {}
> class DynamicGreeter implements Greeting {}
> {code}
> * {{StaticGreeter.<init>}}: {{ldc Greeting$Trait$Helper; ldc "$init$"; ... 
> invokestatic ScriptBytecodeAdapter.invokeMethodN}}
> * {{DynamicGreeter.<init>}}: {{invokedynamic 
> invoke:(Class,LDynamicGreeter;)Object}}
> A native image therefore has to register every trait helper's {{$init$}} for 
> reflection, or construction fails with "No signature of static method: 
> $init$".
> *Instance initializer blocks of {{@CompileStatic}} classes.* 
> {{StaticTypeCheckingVisitor.visitObjectInitializerStatements}} checks the 
> statements against a placeholder constructor without a declaring class 
> (GROOVY-5450), so {{StaticCompilationVisitor}} treats them as not statically 
> compiled: it drops the method targets the type checker resolved and compiles 
> anonymous inner classes created there dynamically.
> {code:groovy}
> @CompileStatic
> class C extends Base {
>     { Other.baz(this) }                  // 
> ScriptBytecodeAdapter.invokeMethodN
>     { String s = 'y'; s.toUpperCase() }  // 
> ScriptBytecodeAdapter.invokeMethod0
>     { super.hello() }                    // invokeMethodOnSuper0: 
> MissingMethodException at run time
> }
> {code}
> The same calls in a constructor or field initializer are direct.
> Proposed fix: give the {{$init$}} call its method target, and give the 
> placeholder constructor the class as its declaring class, as field 
> initializers already resolve.
> PR: https://github.com/apache/groovy/pull/3025



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to