RFR: 8261269: When using clhsdb to "inspect" a java object, clhsdb prints "Oop for..." twice

Serguei Spitsyn sspitsyn at openjdk.java.net
Wed Feb 17 23:32:38 UTC 2021


On Tue, 16 Feb 2021 07:28:45 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

> See CR for details. In brief, fixed the `inspect` command to remove duplicate output:
> 
> hsdb> inspect 0x00000007fef00770
> instance of Oop for java/lang/Class @ 0x00000007fef00770 @ 0x00000007fef00770 (size = 160)
> in: Oop for java/io/BufferedInputStream @ 0x0000000082005b08 Oop for java/io/BufferedInputStream @ 0x0000000082005b08
> out: Oop for java/io/PrintStream @ 0x0000000082007b60 Oop for java/io/PrintStream @ 0x0000000082007b60
> err: Oop for java/io/PrintStream @ 0x000000008200e0c8 Oop for java/io/PrintStream @ 0x000000008200e0c8 
> It should be:
> 
> hsdb> inspect 0x00000007fef00770
> instance of Oop for java/lang/Class @ 0x00000007fef00770 (size = 160)
> in: Oop for java/io/BufferedInputStream @ 0x0000000082005b08
> out: Oop for java/io/PrintStream @ 0x0000000082007b60
> err: Oop for java/io/PrintStream @ 0x000000008200e0c8

It looks good to me.
One side comment about the test. It is not easy to read the code with the same pattern (e.g. "Oop for java/io/BufferedInputStream") repeated several times. I understand, you prefer to make it more explicit but it'd be more readable if a predefined pattern is used like below:
    String pattern = "Oop for java/io/BufferedInputStream";
+            expStrMap.put(cmd, List.of("instance of Oop for java/lang/Class @ " + examineResult,
+                                       "in: " + pattern + @"));
. . .
+            unexpStrMap.put(cmd, List.of(
+                    "instance of Oop for java/lang/Class @ "  + examineResult + " @ " + examineResult,
+                    "in: " + pattern + " .* " + pattern));

Just an opinion with no pressure. It is up to you.

Thanks,
Serguei

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

Marked as reviewed by sspitsyn (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2582


More information about the serviceability-dev mailing list