changeset 59174:0c8de4cd12e5 nestmates

Summary: clean up checks if class loader data's loader is the boot loader Reviewed-by: lfoltan, mchung
author hseigel
date Mon, 02 Mar 2020 20:25:51 +0000
parents 711da7dc077d
children 8cc162bd3671
files src/hotspot/share/classfile/classFileParser.cpp src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp src/hotspot/share/classfile/dictionary.cpp src/hotspot/share/classfile/moduleEntry.cpp src/hotspot/share/classfile/symbolTable.cpp
diffstat 5 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classFileParser.cpp	Fri Feb 28 12:16:11 2020 -0800
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Mon Mar 02 20:25:51 2020 +0000
@@ -5933,8 +5933,8 @@
 }
 
 static bool relax_format_check_for(ClassLoaderData* loader_data) {
-  bool trusted = (loader_data->is_the_null_class_loader_data() ||
-                  SystemDictionary::is_platform_class_loader(loader_data->class_loader()));
+  bool trusted = loader_data->is_boot_class_loader_data() ||
+                 loader_data->is_platform_class_loader_data();
   bool need_verify =
     // verifyAll
     (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
--- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp	Fri Feb 28 12:16:11 2020 -0800
+++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp	Mon Mar 02 20:25:51 2020 +0000
@@ -180,6 +180,7 @@
     if (_cld->is_the_null_class_loader_data()) {
       st->print(" <bootstrap>");
     } else {
+      assert(!_cld->is_shortlived(), "_cld must be the primary cld");
       if (loader_name != NULL) {
         st->print(" \"%s\",", loader_name->as_C_string());
       }
@@ -223,7 +224,7 @@
       if (print_classes) {
         if (_classes != NULL) {
           for (LoadedClassInfo* lci = _classes; lci; lci = lci->_next) {
-            // Hidden and unsafe anonymous classes should live in the primary CLD of its loader
+            // Weak-hidden and unsafe anonymous classes should not live in the primary CLD of their loaders.
             assert(lci->_cld == _cld, "must be");
 
             branchtracker.print(st);
--- a/src/hotspot/share/classfile/dictionary.cpp	Fri Feb 28 12:16:11 2020 -0800
+++ b/src/hotspot/share/classfile/dictionary.cpp	Mon Mar 02 20:25:51 2020 +0000
@@ -354,6 +354,7 @@
 // since been unreferenced, so this entry should be cleared.
 void Dictionary::clean_cached_protection_domains() {
   assert_locked_or_safepoint(SystemDictionary_lock);
+  assert(!loader_data()->is_shortlived(), "class loader data shouldn't be short-lived");
 
   if (loader_data()->is_the_null_class_loader_data()) {
     // Classes in the boot loader are not loaded with protection domains
@@ -482,6 +483,7 @@
   ResourceMark rm;
 
   assert(loader_data() != NULL, "loader data should not be null");
+  assert(!loader_data()->is_shortlived(), "class loader data shouldn't be short-lived");
   st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
                table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
   st->print_cr("^ indicates that initiating loader is different from defining loader");
--- a/src/hotspot/share/classfile/moduleEntry.cpp	Fri Feb 28 12:16:11 2020 -0800
+++ b/src/hotspot/share/classfile/moduleEntry.cpp	Mon Mar 02 20:25:51 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2020, 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
@@ -75,6 +75,7 @@
     const char* loc = location()->as_C_string();
     ClassLoaderData* cld = loader_data();
 
+    assert(!cld->is_shortlived(), "cld for module shouldn't be short-lived");
     if ((cld->is_the_null_class_loader_data() || cld->is_platform_class_loader_data()) &&
         (strncmp(loc, "jrt:/java.", 10) == 0)) {
       return false;
@@ -135,6 +136,7 @@
   // injecting dependencies that require the default read edges for resolution.
   if (this->has_default_read_edges() && !m->is_named()) {
     ClassLoaderData* cld = m->loader_data();
+    assert(!cld->is_shortlived(), "cld for module shouldn't be short-lived");
     if (cld->is_the_null_class_loader_data() || cld->is_system_class_loader_data()) {
       return true; // default read edge
     }
--- a/src/hotspot/share/classfile/symbolTable.cpp	Fri Feb 28 12:16:11 2020 -0800
+++ b/src/hotspot/share/classfile/symbolTable.cpp	Mon Mar 02 20:25:51 2020 +0000
@@ -459,6 +459,8 @@
 void SymbolTable::new_symbols(ClassLoaderData* loader_data, const constantPoolHandle& cp,
                               int names_count, const char** names, int* lengths,
                               int* cp_indices, unsigned int* hashValues) {
+  // Note that c_heap will be true for unsafe anonymous and weak hidden classes
+  // even if their loader is the boot loader because they will have a different cld.
   bool c_heap = !loader_data->is_the_null_class_loader_data();
   for (int i = 0; i < names_count; i++) {
     const char *name = names[i];