GROOVY-12223: Introduce hidden class support - #2755
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: 58063be | Previous: 544c016 | Ratio |
|---|---|---|---|
org.apache.groovy.bench.AryBench.java ( {"n":"1000"} ) |
0.11873074707054951 ms/op |
0.059375013802723364 ms/op |
2.00 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2755 +/- ##
==================================================
+ Coverage 69.9742% 70.0142% +0.0399%
- Complexity 35502 35575 +73
==================================================
Files 1557 1558 +1
Lines 131667 131799 +132
Branches 24166 24200 +34
==================================================
+ Hits 92133 92278 +145
+ Misses 31193 31164 -29
- Partials 8341 8357 +16
🚀 New features to boost your workflow:
|
JMH summary — classic (commit
|
| Group | Speedup | Calibrated | n |
|---|---|---|---|
| bench | 0.993 × | 0.987 × | 99 |
| core | 0.995 × | 0.888 × | 83 |
| grails | 0.865 × | 0.829 × | 80 |
Runner calibration (this run vs baseline hardware): bench 1.00× (26 rulers) · core-ag 1.12× (3 rulers) · core-hz 1.12× (3 rulers) · grails-ad 1.12× (3 rulers) · grails-ez 0.99× (3 rulers)
Baseline: dev/bench/jmh/<part>/classic/data.js on gh-pages, trailing 90 days. Daily dashboard · Per-suite raw data
JMH summary — indy (commit
|
| Group | Speedup | Calibrated | n |
|---|---|---|---|
| bench | 0.971 × | 0.990 × | 99 |
| core | 3.061 × | 3.107 × | 83 |
| grails | 4.350 × | 4.220 × | 80 |
Runner calibration (this run vs baseline hardware): bench 0.98× (26 rulers) · core-ag 0.99× (3 rulers) · core-hz 0.98× (3 rulers) · grails-ad 1.13× (3 rulers) · grails-ez 0.96× (3 rulers)
Baseline: dev/bench/jmh/<part>/indy/data.js on gh-pages, trailing 90 days. Daily dashboard · Per-suite raw data
70b0e73 to
a853b33
Compare
There was a problem hiding this comment.
- HiddenClassDefiner contains method used only in tests
- ProxyGeneratorAdapter and ReflectorLoader seems to duplicate work already done in HiddenClassDefiner, while still using HiddenClassDefiner
But the big point for me is MethodHandles.lookup(). It has the javadoc:
Returns a lookup object with full capabilities to emulate all supported bytecode behaviors of the caller. These capabilities include full privilege access to the caller. Factory methods on the lookup object can create direct method handles for any member that the caller has access to via bytecodes, including protected and private fields and methods. This lookup object is created by the original lookup class and has the ORIGINAL bit set. This lookup object is a capability which may be delegated to trusted agents. Do not store it in place where untrusted code can access it.
This method is caller sensitive, which means that it may return different values to different callers. In cases where MethodHandles.lookup is called from a context where there is no caller frame on the stack (e.g. when called directly from a JNI attached thread), IllegalCallerException is thrown. To obtain a lookup object in such a context, use an auxiliary class that will implicitly be identified as the caller, or use publicLookup() to obtain a low-privileged lookup instead.
So if I create a Lookup for HiddenClassDefinerTest in HiddenClassDefinerTest I will get full access. But if I create that in the same class for java.lang.String, I will not get full access. In practice this usually means that unless the class creates the lookup (for example during invokedynamic) it is useless for many things. So if you need private module access, then MethodHandles.lookup() is most likely not the way to go.
Which means I don`t think that the intend of HiddenClassDefiner.privateLookupIn and usuability go hand in hand here.
a853b33 to
58063be
Compare
|
✅ All tests passed ✅🏷️ Commit: 58063be Learn more about TestLens at testlens.app. |



https://issues.apache.org/jira/browse/GROOVY-12223