On Fri, 7 Aug 2026 11:33:23 GMT, Alan Bateman <[email protected]> wrote:

>> This current explanation is going to be very hard for most readers to grasp. 
>> We tend to not notice this difficulty because when we read it we already 
>> have a full understanding of what it means and how it is implemented. 
>> Readers without our background are going to have difficulty fulling grasping 
>> what this means.
>
> For now, value objects can be tagged. The important thing that JVMTI agent 
> maintainers needs to understsand is that there isn't an ObjectFree event for 
> value objects so can't be used to know when a value object is GC'ed. There is 
> a sentence in the "Object Tags" section but that's deep in the spec and I 
> think the intention with the "Identity and Value Objects" section was to have 
> a summary of differences in the introduction.
> 
> Yes, it's hard to explain what an object tag means for a value object. The 
> JLS and API docs are moving to use the term "indistinguishable" which makes 
> me wonder if something along these lines could work here:
> 
> "Value objects can be tagged by <jvmti/>, but the tag is associated with the 
> object’s class and field values, as it has no identity. Two value object 
> references are indistinguishable if they are the same class and their fields 
> have indistinguishable values. Indistinguishable value objects have the same 
> tag."

Maybe you can also add something like "Tagging a value object effectively tags 
all indistinguishable value objects", although I think the wording could be 
better.

I think one thing we lost sight of is the text that comes in the just before 
the text being added:

"...but some specific functions will behave differently if invoked upon a Java 
object that does not have identity. Such differences in behavior are described 
by the individual functions and events where they apply."

Yet we are describing the difference here rather than in the tagging section. 
The ObjectFree section does mention it not being call for value objects. If we 
want a summary here, it should be a summary of where there are differences, but 
instead of fully describing each difference, just include a link to the text 
the more fully describes the difference.

Also, I just noticed GetObjectsWithTags, which might need some clarification 
w.r.t. value objects to make it clear it only returns one of each 
indistinguishable value object.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32211#discussion_r3736845548

Reply via email to