On Thu, 29 May 2025 10:15:20 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> Updates the thread dump generated by HotSpotDiagnosticMXBean.dumpThreads and 
>> jcmd Thread.dump_to_file to include thread state and lock information. Also 
>> update the HotSpotDiagnosticMXBean.dumpThreads API description to link to a 
>> description of the JSON format dump as that format is intended to be 
>> parseable/read by tools.
>> 
>> This PR is dependent on 
>> [pull/25425](https://github.com/openjdk/jdk/pull/25425). As noted in that 
>> PR, the changes accumulated in the loom repo, and have been split up to make 
>> it easier to review.
>> 
>> The changes include some re-implementation of ThreadDumper. This is because 
>> it used PrintStream and didn't fail if there was an I/O error, e.g. file 
>> system full. Furthermore, the indentation to pretty print the json was 
>> fragile and hard to maintain so this is changed to use a supporting writer 
>> class to do this.
>> 
>> Test coverage is significantly expanded, including updating the test library 
>> that is used by several tests to parse the thread dump.
>> 
>> Testing: tier1-6
>
> Alan Bateman has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains five additional 
> commits since the last revision:
> 
>  - Temp fixed until fixed in pull/25425
>  - Sync up from loom repo, includes review comments
>  - Merge branch 'pull/25425' into JDK-8356870
>  - Merge branch 'pull/25425' into JDK-8356870
>  - Initial commit

src/java.base/share/classes/jdk/internal/vm/ThreadDumper.java line 307:

> 305:         if (thread.isVirtual()) {
> 306:             jsonWriter.writeProperty("virtual", Boolean.TRUE);
> 307:         }

Q: Is the order of dumped properties important?
The JSON schema lists the `virtual` property after the `state`:

 51                         "tid": {
 52                           "type": "string",
 53                           "description": "The thread identifier."
 54                         },
 55                         "time": {
 56                           "type": "string",
 57                           "description": "The time in ISO 8601 format that 
the thread was sampled."
 58                         },
 59                         "name": {
 60                           "type": "string",
 61                           "description": "The thread name."
 62                         },
 63                         "state": {
 64                           "type": "string",
 65                           "description": "The thread state 
(Thread::getState)."
 66                         },
 67                         "virtual" : {
 68                           "type": "boolean",
 69                           "description": "true for a virtual thread."
 70                         },

The other properties dumped in the `dumpThread()` follow the order defined in 
JSON schema.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25429#discussion_r2116554217

Reply via email to