8267345: VM crashes during dumping classlist with -Xshare:dump option

Reviewed-by: iklam, ccheung
This commit is contained in:
Yumin Qi 2021-05-20 15:28:08 +00:00
parent e84e18580d
commit 5311c4d454

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -4240,7 +4240,8 @@ void InstanceKlass::log_to_classlist(const ClassFileStream* stream) const {
// For the boot and platform class loaders, skip classes that are not found in the
// java runtime image, such as those found in the --patch-module entries.
// These classes can't be loaded from the archive during runtime.
if (!stream->from_boot_loader_modules_image() && strncmp(stream->source(), "jrt:", 4) != 0) {
if (!stream->from_boot_loader_modules_image() &&
(stream->source() == NULL || strncmp(stream->source(), "jrt:", 4) != 0)) {
skip = true;
}
@ -4254,7 +4255,8 @@ void InstanceKlass::log_to_classlist(const ClassFileStream* stream) const {
ResourceMark rm;
if (skip) {
tty->print_cr("skip writing class %s from source %s to classlist file",
name()->as_C_string(), stream->source());
name()->as_C_string(),
stream->source() != NULL ? stream->source() : "(null)");
} else {
ClassListWriter w;
w.stream()->print_cr("%s", name()->as_C_string());