RFR: 8325949: Create an internal utility method for creating VarHandle instances [v4]
David M. Lloyd
duke at openjdk.org
Tue Sep 17 15:10:07 UTC 2024
On Tue, 17 Sep 2024 13:37:19 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Per Minborg has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Update javadoc
>> - Rename utility class
>
> I think a better approach to this problem might be converting these static final MethodHandle/VarHandle to class-file constants (Constant_MethodHandle for MH, Constant_Dynamic for VH), see JEP 303.
In my projects I usually just use the `ConstantBootstraps` method directly, which avoids the try/catch (but does not avoid needing a lookup). In my mind I imagine eventually writing a tool which post-processes my classes and replaces all `private static final Xxx xxx = ConstantBootstraps.xxx()` with dynamic constants (similarly, I guess, to what @liach suggested). But maybe just using the existing `ConstantBootstraps` methods is a good stepping stone towards a JEP-303 kind of solution.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20972#issuecomment-2356168738
More information about the core-libs-dev
mailing list