On Sat, 11 Jul 2026 19:37:28 GMT, Chris Plummer <[email protected]> wrote:

>> I would be good to have an overview section of the JDI support for value 
>> objects. The ObjectReference javadoc seems like a good place for this. 
>> 
>> The JBS issue contains screenshots of the rendered relevant javadoc.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chris Plummer has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   fix comment typo

If there is something special about the interaction of ObjectReferences and 
value objects then that should simply be stated at the appropriate location. 
This reads like a "what's new" section for value objects but I think it says 
far too much and is not something you would want to keep in this form once 
value objects are out of preview.

src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java line 58:

> 56:  *      <div class="preview-comment">
> 57:  * <h2><a id=valueObjects>Value Objects</a></h2>
> 58:  * When preview features are enabled, JDI supports value objects and 
> classes

This whole paragraph seems excessive when there is nothing special to say about 
value objects here. You shouldn't have to say that JDI follows JLS and JVMS as 
that is a given, except where otherwise noted.

src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java line 62:

> 60:  * <cite>The Java Virtual Machine Specification</cite>, with one 
> exception noted
> 61:  * below. In particular, two value objects are considered to be the same 
> if both
> 62:  * refer to statewise-equivalent value objects (x == y has the value 
> {@code true}).

Did you mean "two ObjectReferences are considered to be the same if ..." ?

src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java line 72:

> 70:  * <cite>The Java Virtual Machine Specification</cite>.
> 71:  * <p>
> 72:  * Where JDI does differ from the JLS is in allowing the user to obtain an

I don't think this conversational style is suitable for this kind of API spec. 
The spec should just say what happens, not what it differs from. I would phrase 
more succinctly as:
> If an ObjectReference is obtained for a value object under construction, then 
> it is a snapshot of the value object at that point in time. Any further 
> changes to the initialization state of the value object will not be reflected 
> in the initial ObjectReference.

src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java line 78:

> 76:  * behavior for the JDI user. In particular, the value object may change 
> after
> 77:  * the ObjectReference is obtained, even though value objects are 
> considered
> 78:  * to be immutable. Because of this, if 'this' is fetched from a value 
> object

Suggestion:

 * to be immutable. Consequently, if 'this' is fetched from a value object

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

PR Review: 
https://git.openjdk.org/valhalla/pull/2639#pullrequestreview-4680825218
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2639#discussion_r3567178264
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2639#discussion_r3567179443
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2639#discussion_r3567188204
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2639#discussion_r3567171404

Reply via email to