Skip to content

Commit f2dcff5

Browse files
committedOct 9, 2023
fixed -Xlog:cds+resolve=debug crash when dumping dynamic archive

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed
 

‎src/hotspot/share/oops/constantPool.cpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,15 @@ void ConstantPool::archive_entries() {
521521
}
522522
}
523523

524-
#if 0
525-
static const char* get_type(Klass* buffered_k) {
524+
static const char* get_type(Klass* k) {
526525
const char* type;
527-
Klass* src_k = ArchiveBuilder::current()->get_source_addr(buffered_k);
526+
Klass* src_k;
527+
if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
528+
src_k = ArchiveBuilder::current()->get_source_addr(k);
529+
} else {
530+
src_k = k;
531+
}
532+
528533
if (src_k->is_objArray_klass()) {
529534
src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
530535
assert(!src_k->is_objArray_klass(), "sanity");
@@ -549,7 +554,6 @@ static const char* get_type(Klass* buffered_k) {
549554

550555
return type;
551556
}
552-
#endif
553557

554558
bool ConstantPool::maybe_archive_resolved_klass_at(int cp_index) {
555559
assert(ArchiveBuilder::current()->is_in_buffer_space(this), "must be");
@@ -573,18 +577,10 @@ bool ConstantPool::maybe_archive_resolved_klass_at(int cp_index) {
573577
if (ClassPrelinker::can_archive_resolved_klass(src_cp, cp_index)) {
574578
if (log_is_enabled(Debug, cds, resolve)) {
575579
ResourceMark rm;
576-
#if 0
577-
// FIXME: get_type() fails with runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java
578580
log_debug(cds, resolve)("archived klass CP entry [%3d]: %s %s => %s %s%s", cp_index,
579-
get_type(pool_holder()), pool_holder()->name()->as_C_string(),
580-
get_type(k), k->name()->as_C_string(),
581-
pool_holder()->is_subtype_of(k) ? "" : " (not supertype)");
582-
#else
583-
log_debug(cds, resolve)("archived klass CP entry [%3d]: %s => %s%s", cp_index,
584-
pool_holder()->name()->as_C_string(),
585-
k->name()->as_C_string(),
581+
pool_holder()->name()->as_C_string(), get_type(pool_holder()),
582+
k->name()->as_C_string(), get_type(k),
586583
pool_holder()->is_subtype_of(k) ? "" : " (not supertype)");
587-
#endif
588584
}
589585
return true;
590586
}

‎test/hotspot/jtreg/premain/spring-petclinic/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ ${PC_STATIC_JSA}: ${PC_CLASSLIST}
134134
${PC_DYNAMIC_JSA}: ${PC_STATIC_JSA}
135135
rm -f ${PC_DYNAMIC_JSA} ${PC_DYNAMIC_JSA}.log
136136
${PREMAIN_JAVA} -XX:SharedArchiveFile=${PC_STATIC_JSA} -XX:ArchiveClassesAtExit=${PC_DYNAMIC_JSA} \
137-
-Xlog:cds=debug,cds+class=debug:file=${PC_DYNAMIC_JSA}.log \
137+
-Xlog:cds=debug,cds+class=debug,cds+resolve=debug:file=${PC_DYNAMIC_JSA}.log \
138138
-XX:+RecordTraining ${UNPACKED_CMDLINE}
139139
ls -l ${PC_DYNAMIC_JSA}
140140

0 commit comments

Comments
 (0)
Please sign in to comment.