On Fri, 13 Sep 2024 07:50:49 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. > > Per Minborg has updated the pull request incrementally with one additional > commit since the last revision: > > Rename and reformat src/java.base/share/classes/jdk/internal/reflect/MethodHandlesInternal.java line 50: > 48: private MethodHandlesInternal() {} > 49: > 50: public static VarHandle findVarHandle(MethodHandles.Lookup lookup, Do you think we should create a 3-arg overload like `Lookup lookup, String name, Class<?> type` that calls `findVarHandle(lookup, lookup.lookupClass(), name, type);` for ease of use at many call sites? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20972#discussion_r1758795681