RFR: 8325949: Create an internal utility method for creating VarHandle instances [v2]

Per Minborg pminborg at openjdk.org
Fri Sep 13 07:50:49 UTC 2024


> 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 |
> 
> ![image](https://github.com/user-attachments/assets/fdcbbdfe-c906-4e50-a48c-4944c53c08cc)
> 
> 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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20972/files
  - new: https://git.openjdk.org/jdk/pull/20972/files/87d7a477..1dee24ab

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20972&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20972&range=00-01

  Stats: 98 lines in 31 files changed: 32 ins; 3 del; 63 mod
  Patch: https://git.openjdk.org/jdk/pull/20972.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20972/head:pull/20972

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


More information about the core-libs-dev mailing list