RFR: 8358318: JFR: Tighten up PlatformTracer initialization

Erik Gahlin egahlin at openjdk.org
Mon Jun 2 11:46:53 UTC 2025


On Mon, 2 Jun 2025 11:19:52 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> Started as SonarCloud complaint that MethodSetting.apply initializes a static field. But I think there is a larger problem here, which I completely missed during [JDK-8352738](https://bugs.openjdk.org/browse/JDK-8352738) review: the `PlatformTracer` initialization can technically run several times, AFAICS. This PR tightens up the initialization. It also allows us to call `ensureInitialized` from other places, if we ever find a need.
> 
> Additional testing:
>  - [x] Linux x86_64 server fastdebug, `jdk_jfr`

All event settings modifications happen with the "metadata" lock, so only one thread at a time can modify the state in MethodSetting. I think it's sufficient to remove volatile in that class. It's misleading. 

See:
https://github.com/openjdk/jdk/blob/83cb0c6de5988de526545d0926c2c6ef60efc1c7/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java#L225

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

PR Comment: https://git.openjdk.org/jdk/pull/25584#issuecomment-2930235431


More information about the hotspot-jfr-dev mailing list