On Thu, 12 Sep 2024 17:38:44 GMT, Per Minborg <pminb...@openjdk.org> wrote:
> This PR suggests introducing an internal class in `java.base` to simplify the > use of some `MethodHandles.Lookup` operations. > > While the utility of the methods might appear to be limited in classes with > many static `VarHandle`/`MethodHandle` variables, it should be noted that the > class files become smaller and simpler. Here are some examples: > > | Class File | Base [Bytes] | Patch > [Byte] | > | --------------------------------| ------------- | ------------ | > | FutureTask.class | 10255 | > 10154 | > | AtomicBoolean.class | 5364 | > 5161 | > |AtomicMarkableReference.class | 3890 | 3687 | > >  > > The new `MethodHandlesInternal.class` file is of size 2012 bytes. > > In total for `java.base` we have: > > | Build map "jdk" | Size [Bytes] | > | ---------------| ------------- | > | Base | 5963657 | > | Patch | 5962751 | > | Delta | 906| > > For 60 billion instances, this represents 54 TB. I think we can elide the `Lookup` argument to perform a always-full-permission lookup operation to simplify call sequence; or, to elide the `recv` receiver argument as it is almost always `lookup.lookupClass()` (except for a few lazy holders) src/java.base/share/classes/jdk/internal/reflect/MethodHandlesInternal.java line 1: > 1: /* I would argue this is closer to invoke than reflect, so can consider moving to `sun.invoke` or even create a new `jdk.internal.invoke` package. ------------- PR Comment: https://git.openjdk.org/jdk/pull/20972#issuecomment-2347081526 PR Review Comment: https://git.openjdk.org/jdk/pull/20972#discussion_r1757474972