RFR: 8353835: Implement JEP 500: Prepare to Make Final Mean Final [v7]
Alan Bateman
alanb at openjdk.org
Tue Oct 7 08:01:54 UTC 2025
On Tue, 7 Oct 2025 01:42:15 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:
> I believe the filter can be simplified to this
>
> ```
> @StackFilter({"java.lang.reflect.Field", "java.lang.reflect.ReflectAccess", "java.lang.invoke.MethodHandles$Lookup"})
> ```
>
> and then set the offset to 4 or 5 in PlatformEventType::determineStackTraceOffset() to skip the offer method. This is cheaper and probably more robust. It will also make the place where the mutation happens the top frame, similar to other events, which works well for tooling.
The APIs are in Field and Lookup so having the API method as the top frame is useful. It would be possible to reduce the filter to `{ "java.lang.reflect.ReflectAccess", "java.lang.invoke.MethodHandles$Lookup::unreflectField" }` with determineStackTraceOffset returning 6 but it's too fiddly and requires knowing about two "faraway places" when doing any refactoring. Mutating final fields is the slow path so performance is not a concern. So I think the trade-off to keep it as maintainable as possible is okay. The test checks the top frame and also scans the StackFilter to ensure the class is visible and that any filter value with a method name at least names a method that is declared in the class.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25115#issuecomment-3375647041
More information about the hotspot-dev
mailing list