On Tue, 17 Sep 2024 13:37:19 GMT, Chen Liang <li...@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

Reply via email to