Integrated: 8325949: Create an internal utility method for creating VarHandle instances

Per Minborg pminborg at openjdk.org
Mon Sep 23 11:00:48 UTC 2024


On Thu, 12 Sep 2024 17:38:44 GMT, Per Minborg <pminborg at 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                          |            10,255 |          10,123 |
> | AtomicBoolean.class                   |             5,364 |            5,134 |
> |AtomicMarkableReference.class |             3,890 |           3,660 |
> 
> ![image](https://github.com/user-attachments/assets/fdcbbdfe-c906-4e50-a48c-4944c53c08cc)
> 
> The new `MethodHandlesInternal.class` file is of size 1,952 bytes.
> 
> In total for `java.base` we have:
> 
> | Build map "jdk"  | Size [Bytes] |
> | ---------------| ------------- |
> | Base                 |     5,906,457 |
> | Patch                |     5,905,487 |
> | Delta                 |                940|
> 
> For 60 billion instances, this represents > 50 TB.
> 
> Tried and passed tier1-3

This pull request has now been integrated.

Changeset: 384deda6
Author:    Per Minborg <pminborg at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/384deda65fd63e23d4caaaa9762f2ac80de78029
Stats:     442 lines in 31 files changed: 125 ins; 210 del; 107 mod

8325949: Create an internal utility method for creating VarHandle instances

Reviewed-by: rriggs

-------------

PR: https://git.openjdk.org/jdk/pull/20972


More information about the core-libs-dev mailing list