From 14010876dc7ed0e2ce05225198ded35e0d1ab0ba Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Tue, 13 Jun 2023 15:54:31 +0000 Subject: [PATCH] 8309753: Include array classes in the output of -XX:+PrintSharedArchiveAndExit Reviewed-by: iklam, matsaave --- src/hotspot/share/classfile/systemDictionaryShared.cpp | 4 ++++ src/hotspot/share/oops/arrayKlass.cpp | 10 ++++++++++ src/hotspot/share/oops/arrayKlass.hpp | 1 + .../jtreg/runtime/cds/PrintSharedArchiveAndExit.java | 8 +++++--- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 790b263215a..754e5543e20 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -1357,6 +1357,10 @@ public: ResourceMark rm; _st->print_cr("%4d: %s %s", _index++, record->_klass->external_name(), class_loader_name_for_shared(record->_klass)); + if (record->_klass->array_klasses() != nullptr) { + record->_klass->array_klasses()->cds_print_value_on(_st); + _st->cr(); + } } int index() const { return _index; } }; diff --git a/src/hotspot/share/oops/arrayKlass.cpp b/src/hotspot/share/oops/arrayKlass.cpp index 1243786aff2..9a1820c3017 100644 --- a/src/hotspot/share/oops/arrayKlass.cpp +++ b/src/hotspot/share/oops/arrayKlass.cpp @@ -183,6 +183,16 @@ void ArrayKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle p ak->restore_unshareable_info(loader_data, protection_domain, CHECK); } } + +void ArrayKlass::cds_print_value_on(outputStream* st) const { + assert(is_klass(), "must be klass"); + st->print(" - array: %s", internal_name()); + if (_higher_dimension != nullptr) { + ArrayKlass* ak = ArrayKlass::cast(higher_dimension()); + st->cr(); + ak->cds_print_value_on(st); + } +} #endif // INCLUDE_CDS // Printing diff --git a/src/hotspot/share/oops/arrayKlass.hpp b/src/hotspot/share/oops/arrayKlass.hpp index f94e038510b..bf879202399 100644 --- a/src/hotspot/share/oops/arrayKlass.hpp +++ b/src/hotspot/share/oops/arrayKlass.hpp @@ -119,6 +119,7 @@ class ArrayKlass: public Klass { virtual void remove_unshareable_info(); virtual void remove_java_mirror(); void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS); + void cds_print_value_on(outputStream* st) const; #endif // Printing diff --git a/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java b/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java index e1933548359..3e2e9c0d011 100644 --- a/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java +++ b/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,21 +43,23 @@ public class PrintSharedArchiveAndExit { // (1) With a valid archive opts = (new CDSOptions()) .setUseVersion(false) - .addSuffix( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, + .addSuffix("-XX:SharedArchiveFile=./" + archiveName, "-XX:+PrintSharedArchiveAndExit", "-version"); CDSTestUtils.run(opts) .assertNormalExit(output -> { output.shouldContain("archive is valid"); + output.shouldContain("[Ljava.lang.Object;"); output.shouldNotContain("java version"); // Should not print JVM version }); opts = (new CDSOptions()) .setUseVersion(false) - .addSuffix( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, + .addSuffix("-XX:SharedArchiveFile=./" + archiveName, "-XX:+PrintSharedArchiveAndExit"); CDSTestUtils.run(opts) .assertNormalExit(output -> { output.shouldContain("archive is valid"); + output.shouldContain("[Ljava.lang.Object;"); output.shouldNotContain("Usage:"); // Should not print JVM help message }); }