RFR: 8368199: Add @AOTSafeClassInitializer to jdk.internal.access.SharedSecrets
Ioi Lam
iklam at openjdk.org
Sat Oct 18 04:06:00 UTC 2025
On Sat, 18 Oct 2025 02:48:42 GMT, Chen Liang <liach at openjdk.org> wrote:
>> By annotating `SharedSecrets` as `@AOTSafeClassInitializer`, we can avoid using the `@AOTRuntimeSetup` annotations in a few JDK core classes. This simplifies the implementation. It also brings us closer to the goal of making the AOT cache as a true snapshot of the JVM state that just needs to be resumed in the production run.
>
> src/java.base/share/classes/jdk/internal/access/SharedSecrets.java line 69:
>
>> 67: public class SharedSecrets {
>> 68: // This field is not necessarily stable
>> 69: private static JavaAWTFontAccess javaAWTFontAccess;
>
> Does aot initialization work with this field?
I think this field is safe. There are two places that could set it, but they will always set it to an instance of `JavaAWTFontAccessImpl`, which is stateless.
https://github.com/openjdk/jdk/blob/eff6439e75d79c67370e79638024296e01101b48/src/java.desktop/share/classes/java/awt/font/NumericShaper.java#L148-L149
https://github.com/openjdk/jdk/blob/eff6439e75d79c67370e79638024296e01101b48/src/java.desktop/share/classes/java/awt/font/TextAttribute.java#L251-L252
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27880#discussion_r2441561760
More information about the security-dev
mailing list