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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3095?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 `78.94737%` with `4 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 73.6741%. Comparing base 
([`5b077f9`](https://app.codecov.io/gh/apache/groovy/commit/5b077f9dcf610898e3415f1f1cebbaab8eecab61?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`8097c3a`](https://app.codecov.io/gh/apache/groovy/commit/8097c3a573edff216c0ab91ec51d8e9e3ed81903?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.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3095?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...vy/vmplugin/v8/IndyGuardsFiltersAndSignatures.java](https://app.codecov.io/gh/apache/groovy/pull/3095?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv8%2FIndyGuardsFiltersAndSignatures.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L0luZHlHdWFyZHNGaWx0ZXJzQW5kU2lnbmF0dXJlcy5qYXZh)
 | 40.0000% | [1 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3095?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...java/org/codehaus/groovy/vmplugin/v8/Selector.java](https://app.codecov.io/gh/apache/groovy/pull/3095?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv8%2FSelector.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L1NlbGVjdG9yLmphdmE=)
 | 92.8571% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3095?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/3095/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/3095?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3095        +/-   ##
   ==================================================
   + Coverage     73.6711%   73.6741%   +0.0030%     
   - Complexity      42584      42592         +8     
   ==================================================
     Files            1678       1678                
     Lines          146907     146920        +13     
     Branches        27790      27794         +4     
   ==================================================
   + Hits           108228     108242        +14     
   + Misses          28528      28522         -6     
   - Partials        10151      10156         +5     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3095?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...java/org/codehaus/groovy/vmplugin/v8/Selector.java](https://app.codecov.io/gh/apache/groovy/pull/3095?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv8%2FSelector.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L1NlbGVjdG9yLmphdmE=)
 | `81.1352% <92.8571%> (-0.1043%)` | :arrow_down: |
   | 
[...vy/vmplugin/v8/IndyGuardsFiltersAndSignatures.java](https://app.codecov.io/gh/apache/groovy/pull/3095?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv8%2FIndyGuardsFiltersAndSignatures.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L0luZHlHdWFyZHNGaWx0ZXJzQW5kU2lnbmF0dXJlcy5qYXZh)
 | `87.9518% <40.0000%> (-3.0738%)` | :arrow_down: |
   
   ... and [16 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3095/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>




> Class loaders of discarded scripts stay reachable through method handle 
> caches on JDK 17
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12579
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12579
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {{MethodHandle.asType}} caches its result on the handle converted. JDK 17 
> keeps that cache as a strong reference to the last conversion; JDK 18 and 
> later keep a conversion strongly only when the handle's own types keep the 
> classes of the new type reachable. Linking an indy call site converts handles 
> to the call site type, so on JDK 17 a handle that outlives the call site 
> keeps the classes of that type, and their class loader, reachable:
> * a cast converts {{MethodHandles.identity(Object.class)}}, which the JDK 
> shares across the JVM;
> * {{catchException}} converts the JDK's shared argument-array collector to 
> the type of its target, which every linked method call goes through;
> * the guard and filter handles in static fields of the runtime ({{IS_NULL}}, 
> {{NON_NULL}}, {{UNWRAP_METHOD}}, and the handle being cast at the end of 
> linking).
> A script in a {{GroovyClassLoader}} that casts to its own class is therefore 
> never released on JDK 17:
> {code:groovy}
> import java.lang.ref.WeakReference
> import groovy.transform.CompileStatic
> @CompileStatic
> WeakReference<ClassLoader> runDiscarded() {
>     def loader = new GroovyClassLoader(this.class.classLoader)
>     Script script = (Script) loader.parseClass('''
>         class Holder { String label = 'h'; Holder self(Holder o) { o ?: this 
> } }
>         def held = new Holder()
>         Holder holder = held
>         holder.self(null).label
>     ''').getDeclaredConstructor().newInstance()
>     script.run()
>     script = null
>     loader.close()
>     new WeakReference<ClassLoader>(loader)
> }
> @CompileStatic
> boolean collected(WeakReference<ClassLoader> ref) {
>     for (int i = 0; i < 100; i++) {
>         System.gc()
>         if (i % 50 == 10) {
>             try { List<byte[]> hog = []; while (true) hog << new byte[(int) 
> Math.max(1024L, Runtime.runtime.freeMemory() >> 2)] } catch (OutOfMemoryError 
> ignored) { }
>         }
>         if (ref.get() == null) return true
>         Thread.sleep(10)
>     }
>     false
> }
> println "collected: ${collected(runDiscarded())}" // -Xmx256m: false on JDK 
> 17, true on JDK 21
> {code}
> The class loader cleanup that the integration guide documents ends with such 
> a cast, so on JDK 17 it does not release the class loader of the Groovy copy 
> it cleans up either.
> PR: https://github.com/apache/groovy/pull/3095



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

Reply via email to