JDK-8308903 : Print detailed info for Java objects in -Xlog:cds+map
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-05-25
  • Updated: 2023-07-31
  • Resolved: 2023-07-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b08Fixed
Related Reports
Relates :  
Description
Today, we can see the raw bytes of every archived Java object. For example, you can see the bytes for a  java.util.concurrent.ConcurrentHashMap like this (you need to adjust the parameters to the "head" command, or just open cds.map in an editor)

$ java -Xshare:dump  -Xlog:cds+map=trace:file=cds.map:none:filesize=0

$ grep -n '@@ Object java.util.concurrent.ConcurrentHashMap$' cds.map | head -1
631494:0x00000007bfce62b0: @@ Object java.util.concurrent.ConcurrentHashMap

$ grep -n . cds.map | head -636620 | tail -4
636617:0x00000007bfcfb9d8: @@ Object java.util.concurrent.ConcurrentHashMap
636618:0x00000007bfcfb9d8:   bbcb1801 0000005a 000652c0 00000000 00000000 00000600 000002fa 00000000
636619:0x00000007bfcfb9f8:   00000000 00000000 f7f9f743 00000000 00000000 00000000 00000000 00000000 
636620:0x00000007bfcfba18: @@ Object [Ljava.util.concurrent.ConcurrentHashMap$Node;

Since compressed oops are used, it's hard to see the oop fields in the java.util.concurrent.ConcurrentHashMap. It would be better to print out a more detailed view of the object (e.g., something like oopDesc::print()).


Comments
Changeset: 8008e27c Author: Ioi Lam <iklam@openjdk.org> Date: 2023-07-24 17:56:42 +0000 URL: https://git.openjdk.org/jdk/commit/8008e27c55030b397e2040bc3cf8408e47edf412
24-07-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14841 Date: 2023-07-12 00:39:30 +0000
12-07-2023

Example (-XX:+UseCompressedOops) 0x00000007ffc001b8: @@ Object (0xfff80037) java.lang.String 0x00000007ffc001b8: f6ab8d01 0000006f 00010290 88d47c5b 00010000 fff8003a - klass: 'java/lang/String' 0x0000000800010290 - ---- fields (total size 3 words): - private 'hash' 'I' @12 -1999340453 (0x88d47c5b) - private final 'coder' 'B' @16 0 (0x00) - private 'hashIsZero' 'Z' @17 false (0x00) - injected 'flags' 'B' @18 1 (0x01) - private final 'value' '[B' @20 0x00000007ffc001d0 (0xfff8003a) [B length: 6 0x00000007ffc001d0: @@ Object (0xfff8003a) [B length: 6 0x00000007ffc001d0: 3b708001 00000069 000024c8 00000006 5252414e 0000574f - klass: {type array byte} 0x00000008000024c8 - 0: 4e N - 1: 41 A - 2: 52 R - 3: 52 R - 4: 4f O - 5: 57 W
06-07-2023

Example (-XX:-UseCompressedOops) 0x00000000100001f0: @@ Object java.lang.String 0x00000000100001f0: 0000006ff6ab8d01 88d47c5b00010290 0000000000010000 0000000010000210 - klass: 'java/lang/String' 0x0000000800010290 - ---- fields (total size 4 words): - private 'hash' 'I' @12 -1999340453 (0x88d47c5b) - private final 'coder' 'B' @16 0 (0x00) - private 'hashIsZero' 'Z' @17 false (0x00) - injected 'flags' 'B' @18 1 (0x01) - private final 'value' '[B' @24 0x0000000010000210 [B length: 6 0x0000000010000210: @@ Object [B length: 6 0x0000000010000210: 000000693b708001 00000006000024c8 0000574f5252414e - klass: {type array byte} 0x00000008000024c8 - 0: 4e N - 1: 41 A - 2: 52 R - 3: 52 R - 4: 4f O - 5: 57 W
06-07-2023