[
https://issues.apache.org/jira/browse/GROOVY-12361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18111961#comment-18111961
]
ASF GitHub Bot commented on GROOVY-12361:
-----------------------------------------
codecov-commenter commented on PR #2882:
URL: https://github.com/apache/groovy/pull/2882#issuecomment-5555531678
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2882?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 `72.72727%` with `3 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 71.0971%. Comparing base
([`d4a2eb9`](https://app.codecov.io/gh/apache/groovy/commit/d4a2eb9440a18a8ae9758a462c840433ab8df6bf?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`14df823`](https://app.codecov.io/gh/apache/groovy/commit/14df8237a520f1a8a377a6b529ae9f55cacc8f2a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2882?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/internal/runtime/invoke/InvokerFactory.java](https://app.codecov.io/gh/apache/groovy/pull/2882?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Finternal%2Fruntime%2Finvoke%2FInvokerFactory.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9pbnRlcm5hbC9ydW50aW1lL2ludm9rZS9JbnZva2VyRmFjdG9yeS5qYXZh)
| 72.7273% | [1 Missing and 2 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2882?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/2882?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2882 +/- ##
==================================================
+ Coverage 71.0969% 71.0971% +0.0001%
- Complexity 37347 37352 +5
==================================================
Files 1579 1579
Lines 135477 135488 +11
Branches 25104 25108 +4
==================================================
+ Hits 96320 96328 +8
- Misses 30480 30481 +1
- Partials 8677 8679 +2
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2882?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...groovy/internal/runtime/invoke/InvokerFactory.java](https://app.codecov.io/gh/apache/groovy/pull/2882?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Finternal%2Fruntime%2Finvoke%2FInvokerFactory.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9pbnRlcm5hbC9ydW50aW1lL2ludm9rZS9JbnZva2VyRmFjdG9yeS5qYXZh)
| `92.3077% <72.7273%> (-3.4906%)` | :arrow_down: |
... and [8 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2882/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>
> CachedMethod DirectInvoker: trampoline for a hidden declaring class throws
> NoClassDefFoundError on first invoke
> ---------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12361
> URL: https://issues.apache.org/jira/browse/GROOVY-12361
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
> The generated {{DirectInvoker}} trampoline from GROOVY-12325 names the target
> method's declaring class in its bytecode ({{CHECKCAST}} on the receiver,
> {{INVOKEVIRTUAL}}/{{INVOKEINTERFACE}} on the declaring type, or the
> {{invokeExact}} descriptor on the classData path). When that declaring class
> is a *hidden class* (JEP 371), the name is not resolvable by any class
> loader: the trampoline defines and initialises fine, but the first call
> through it fails with {{NoClassDefFoundError}}. The error escapes
> {{CachedMethod.invoke}} as-is because generation is sticky-successful and the
> failure only happens at invocation time.
> Groovy itself produces hidden declaring classes: {{ProxyGeneratorAdapter}}
> defines its proxies as hidden nestmates (GROOVY-12223) whenever the
> superclass is on the same loader as Groovy, so any map-as-abstract-class
> coercion of an application-classpath type is affected once the method has
> been invoked {{groovy.cachedmethod.invoker.threshold}} times (default 1000).
> h3. Reproducer
> Precompile so that {{Shape}} sits next to the Groovy jar on the application
> class path (a script compiled by {{GroovyClassLoader}} gets an ordinary,
> non-hidden proxy and does not reproduce):
> {code:groovy}
> abstract class Shape { abstract String name() }
> class ProxyRepro {
> static void main(String[] args) {
> def s = [name: { 'circle' }] as Shape
> println "hidden proxy: " + s.getClass().isHidden()
> // two cold call sites share the CachedMethod; its hit count reaches
> the
> // trampoline threshold while each indy site is still below its own
> 600.times { assert s.name() == 'circle' }
> 600.times { assert s.name() == 'circle' }
> println "ok"
> }
> }
> {code}
> {noformat}
> $ java -cp groovy-6.0.0-SNAPSHOT.jar
> org.codehaus.groovy.tools.FileSystemCompiler -d out ProxyRepro.groovy
> $ java -cp groovy-6.0.0-SNAPSHOT.jar:out ProxyRepro
> hidden proxy: true
> Exception in thread "main" java.lang.NoClassDefFoundError:
> Shape1_groovyProxy/0x0000007001120000
> at
> org.codehaus.groovy.reflection.CachedMethod.invokeGenerated(CachedMethod.java:491)
> at
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:452)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:298)
> at
> org.codehaus.groovy.vmplugin.v8.IndyInterface.invokeColdReflective(IndyInterface.java:650)
> ...
> {noformat}
> A single call site masks the bug because the indy site promotes to the full
> method-handle chain at the same hit count (1000) and stops going through
> {{CachedMethod.invoke}}; two sites sharing the method, any MOP-path
> invocation ({{invokeMethod}}, categories, per-instance metaclass,
> {{@Delegate}} etc.), or {{-Dgroovy.cachedmethod.invoker.threshold=0}} exposes
> it. Setting either {{-Dgroovy.indy.cold.reflection=false}} or
> {{-Dgroovy.cachedmethod.invoker.disable=true}} avoids it. JDK 21, Groovy
> master (6.0.0-SNAPSHOT).
> h3. Fix
> {{InvokerFactory.tryCreate}} should decline (sticky null, so
> {{CachedMethod.invoke}} stays reflective) when the declaring class, the
> return type or any parameter type (array components included) {{isHidden()}}.
> All four define steps are affected, including Step 3 (classData), whose
> {{invokeExact}} descriptor also names the type.
> {{InvokerFactoryTest.testDefineStepsFallsThroughToClassDataForHiddenNonPublicHost}}
> currently asserts the opposite and even notes that the resulting trampoline
> must not be invoked; it needs to assert {{null}} instead. A fix with tests is
> available on branch {{groovy12354spike}} (the {{allTypesNameable}} gate).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)