On Mon, 27 Apr 2026 08:23:57 GMT, Markus Grönlund <[email protected]> wrote:
> > > Attempting to add an injected field did not work because you cannot > > > reflect an injected field, not even using Unsafe. So I cannot read the > > > value of an injected field from Java. Either we go with the encoding in > > > the slot field, or I will add a separate non-final field "jfrEpoch" to > > > java.lang.reflect.Field. Thoughts? > > > > > > I assume an injected field would be feasible if all the access were via JVM > > funtions rather than reflect/Unsafe but that would add complexity as it > > might end up needing instrinics. In that case, an explicit field would be > > better so the slot field is not overridden. > > Yes, we can do an intrinsic too, if we really want to tuck this away. I can > look into that alternative as well, since I already built similar intrinsics > to read the jfrEpoch, which are currently in use for virtual threads. Ok, let's try this design, which can be generalized more broadly: we inject a field into those classes that need this support. The JfrEpochGeneration class will get an intrinsic to read and potentially cas-update any instance passed to it. ------------- PR Comment: https://git.openjdk.org/jdk/pull/30922#issuecomment-4325526661
