8388113: [lworld] JDI and JDWP spec update: ObjectReference summary, Value class clarification, strict field initialization clarification#2639
Conversation
|
👋 Welcome back cjplummer! A progress list of the required criteria for merging this PR into |
|
@plummercj This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 61 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
| * ObjectReference to a value object under construction (while in the "larval" | ||
| * state). For example, the JDI user could fetch 'this' after hitting a | ||
| * breakpoint in the value object contructor. This could lead to confusing | ||
| * behavior for the JDI user. In particlar, the value object may change after |
There was a problem hiding this comment.
Fixed. thank you.
dholmes-ora
left a comment
There was a problem hiding this comment.
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.
| * breakpoint in the value object contructor. This could lead to confusing | ||
| * behavior for the JDI user. In particular, the value object may change after | ||
| * the ObjectReference is obtained, even though value objects are considered | ||
| * to be immutable. Because of this, if 'this' is fetched from a value object |
There was a problem hiding this comment.
| * to be immutable. Because of this, if 'this' is fetched from a value object | |
| * to be immutable. Consequently, if 'this' is fetched from a value object |
There was a problem hiding this comment.
I assume this edit is no longer relevant after your earlier suggested rewrite of this section.
| * <div class="preview-block"> | ||
| * <div class="preview-comment"> | ||
| * <h2><a id=valueObjects>Value Objects</a></h2> | ||
| * When preview features are enabled, JDI supports value objects and classes |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It's not a given. JDI does not implement the Java language nor a Java Virtual Machine, so it is not beholden to either spec. References to the JLS and JVMS (which already exist in the JDI javadoc) are used in places to aid in specifying JDI behavior.
There was a problem hiding this comment.
Not sure what "beholden to the spec" actually means in this context, but to say JDI value object support is "consistent with JLS/JVMS" really doesn't tell you anything IMO. The main point here is simply that you can obtain an ObjectReference for a value object, just like any identity object. The only, very important, difference, is that it is a snapshot of the value object at that point in time. And whilst the value object is immutable, different ObjectReferences obtained during construction could capture different initalization states.
There was a problem hiding this comment.
Your summary is correct. I was just trying to provide more context and understanding. I can take a stab at a more succinct version that makes no spec references.
There was a problem hiding this comment.
...but keep in mind that I'm also trying to satisfy Joe's requests:
Additional comment: for JDI, I recommend including a short discussion of objects of value classes somewhere in the API; this would supplement the links to Class.isValue already in the patch.
And
my request is posed from the perspective of a reader of the JDI docs who is trying to find out how JDI works with respect to value classes. Value classes differ on == semantics, no locking, etc. So besides the point changes in various methods reflecting those updates, I think a brief paragraph (which could potentially be linked to from elsewhere in the JDI javadoc) explaining those points would be useful.
I don't want this to end up being reduced to just restating what is in StackFrame::thisObject(), which seems to be where your suggestions are headed.
There was a problem hiding this comment.
I am somewhat at odds with Joe's requests. I understand where they are coming from but they are based on the "what's new" view of spec reading. When value objects are new it is understandable to ask "where are all the places where value objects need special handling". But to me that is where the JEP and/or release notes come into play. The spec's do not have these "what's new" sections. If they have overview sections then we can certainly add some mention of value objects (as done for JNI and JVMTI) but in minimal ways. Obviously it is necessary to explain what an ObjectReference means for a value object, but that is all that is needed within the ObjectReference spec.
| * below. In particular, two value objects are considered to be the same if both | ||
| * refer to statewise-equivalent value objects (x == y has the value {@code true}). |
There was a problem hiding this comment.
Did you mean "two ObjectReferences are considered to be the same if ..." ?
There was a problem hiding this comment.
I was referring to debuggee side value objects in this case. ObjectReferences are identity objects so two ObjectReferences are only "the same" if they are literally the same heap objects, just like with any other identity object. As noted below, ObjectReferences are considered to be equal (Object.equals()) if "==" of the target VM objects evaluates to true.
There was a problem hiding this comment.
Then I don't understand the original sentence - it makes it sound like there are additional value objects. Did you just mean to state what the value object equality (edit: not identity) check is? i.e.
In particular, two value objects are considered to be the same if they are state-wise equivalent (
x == yhas the value true)
There was a problem hiding this comment.
Yes, if by "identity" check you mean what is done for "==".
There was a problem hiding this comment.
Sorry typo: s/identity/equality/
| * {@jvms value-objects-6.5 if_acmp_cond} of the | ||
| * <cite>The Java Virtual Machine Specification</cite>. | ||
| * <p> | ||
| * Where JDI does differ from the JLS is in allowing the user to obtain an |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Ok. I'll work on this.
There was a problem hiding this comment.
After re-reviewing you comments, it seem the only thing you really want in this section is to say "JDI supports value objects" and then mention the constructor warning you've written above. The latter isn't really adding any value since it is already explained in ObjectRefernece.thisObject(), so then this section boils down to "JDI supports value objects".
There was a problem hiding this comment.
No, I want ObjectReference to explain how an ObjectReference that mirrors a value object differs from one that mirrors an identity object. If that duplicates what is said in StackFrame.thisObject() then maybe thisObject is not where it should be being described. Or maybe it is worth noting in both places. But it certainly has to be noted in ObjectReference IMO.
dholmes-ora
left a comment
There was a problem hiding this comment.
This all seems fine to me. Thanks
plummercj
left a comment
There was a problem hiding this comment.
Thank you everyone for the reviews!
/integrate
|
Going to push as commit a0662f9.
Your commit was automatically rebased without conflicts. |
|
@plummercj Pushed as commit a0662f9. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
I see this has already been integrated but it is problematic to use "If preview features are enabled" in the JDI spec without clarifying that it means preview features in the target VM are enabled. Whether preview features are enabled or not in the current VM is not really relevant. It gets more complicated when the JDK version used for the front-end (JDI) is different to the JDK version in the back-end (target VM), and more complicated again once JDI is "upgraded" or copied into the JDK used by the IDE/debugger. It's a similar discussion to that in JDK-8387726 which is why we decided that the simplest is for StackFrame.thisObject to link to Class.isValue instead of "If preview features are enabled". |
The following spec edits were made (no code changes):
The JBS issue contains screenshots of the rendered relevant javadoc.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2639/head:pull/2639$ git checkout pull/2639Update a local copy of the PR:
$ git checkout pull/2639$ git pull https://git.openjdk.org/valhalla.git pull/2639/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2639View PR using the GUI difftool:
$ git pr show -t 2639Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2639.diff
Using Webrev
Link to Webrev Comment