--- old/src/share/vm/classfile/systemDictionary.cpp 2017-07-19 11:08:09.332308965 -0400 +++ new/src/share/vm/classfile/systemDictionary.cpp 2017-07-19 11:08:09.052407908 -0400 @@ -342,13 +342,13 @@ #endif // INCLUDE_CDS // Double-check, if child class is already loaded, just return super-class,interface - // Don't add a placedholder if already loaded, i.e. already in system dictionary + // Don't add a placedholder if already loaded, i.e. already in appropriate class loader + // dictionary. // Make sure there's a placeholder for the *child* before resolving. // Used as a claim that this thread is currently loading superclass/classloader // Used here for ClassCircularity checks and also for heap verification - // (every InstanceKlass in the heap needs to be in the system dictionary - // or have a placeholder). - // Must check ClassCircularity before checking if super class is already loaded + // (every InstanceKlass needs to be in its class loader dictionary or have a placeholder). + // Must check ClassCircularity before checking if super class is already loaded. // // We might not already have a placeholder if this child_name was // first seen via resolve_from_stream (jni_DefineClass or JVM_DefineClass); @@ -445,6 +445,7 @@ // This handle and the class_loader handle passed in keeps this class from // being unloaded through several GC points. + // The class_loader handle passed in is the initiating loader. Handle mirror(THREAD, klass->java_mirror()); InstanceKlass* system_loader = SystemDictionary::ClassLoader_klass(); @@ -479,7 +480,6 @@ dictionary->add_protection_domain(d_index, d_hash, klass, protection_domain, THREAD); } -} // We only get here if this thread finds that another thread // has already claimed the placeholder token for the current operation, @@ -952,12 +952,7 @@ return NULL; } - Dictionary* dictionary = loader_data->dictionary_or_null(); - // If ClassLoaderData has no dictionary, the class won't be found in it - if (dictionary == NULL) { - return NULL; - } - + Dictionary* dictionary = loader_data->dictionary(); unsigned int d_hash = dictionary->compute_hash(class_name); int d_index = dictionary->hash_to_index(d_hash); return dictionary->find(d_index, d_hash, class_name, @@ -1045,7 +1040,7 @@ // deoptimizations. add_to_hierarchy(k, CHECK_NULL); // No exception, but can block - // But, do not add to system dictionary. + // But, do not add to dictionary. // compiled code dependencies need to be validated anyway notice_modification(); @@ -1818,10 +1813,7 @@ VerifyAfterGC, "too expensive"); #endif - Dictionary* dictionary = loader_data->dictionary_or_null(); - if (dictionary == NULL) { - return NULL; - } + Dictionary* dictionary = loader_data->dictionary(); unsigned int d_hash = dictionary->compute_hash(class_name); int d_index = dictionary->hash_to_index(d_hash); return find_class(d_index, d_hash, class_name, dictionary); @@ -1851,14 +1843,6 @@ // ---------------------------------------------------------------------------- // GC support -// Following roots during mark-sweep is separated in two phases. -// -// The first phase follows preloaded classes and all other system -// classes, since these will never get unloaded anyway. -// -// The second phase removes (unloads) unreachable classes from the -// system dictionary and follows the remaining classes' contents. - void SystemDictionary::always_strong_oops_do(OopClosure* blk) { roots_oops_do(blk, NULL); } @@ -1871,7 +1855,7 @@ template void do_oop_work(T* p) { oop obj = oopDesc::load_decode_heap_oop(p); - guarantee(_is_alive->do_object_b(obj), "Oop in system dictionary must be live"); + guarantee(_is_alive->do_object_b(obj), "Oop in protection domain cache table must be live"); } public: @@ -1906,7 +1890,7 @@ { GCTraceTime(Debug, gc, phases) t("ProtectionDomainCacheTable", gc_timer); - // Oops referenced by the system dictionary may get unreachable independently + // Oops referenced by the protection domain cache table may get unreachable independently // of the class loader (eg. cached protection domain oops). So we need to // explicitly unlink them here. _pd_cache_table->unlink(is_alive); @@ -1930,7 +1914,6 @@ strong->do_oop(&_system_loader_lock_obj); CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);) - // Adjust dictionary // Do strong roots marking if the closures are the same. if (strong == weak || !ClassUnloading) { // Only the protection domain oops contain references into the heap. Iterate @@ -2156,9 +2139,9 @@ // Constraints on class loaders. The details of the algorithm can be // found in the OOPSLA'98 paper "Dynamic Class Loading in the Java // Virtual Machine" by Sheng Liang and Gilad Bracha. The basic idea is -// that the system dictionary needs to maintain a set of contraints that +// that the dictionary needs to maintain a set of contraints that // must be satisfied by all classes in the dictionary. -// if defining is true, then LinkageError if already in systemDictionary +// if defining is true, then LinkageError if already in dictionary // if initiating loader, then ok if InstanceKlass matches existing entry void SystemDictionary::check_constraints(int d_index, unsigned int d_hash, @@ -2178,7 +2161,7 @@ // if different InstanceKlass - duplicate class definition, // else - ok, class loaded by a different thread in parallel, // we should only have found it if it was done loading and ok to use - // system dictionary only holds instance classes, placeholders + // dictionary only holds instance classes, placeholders // also holds array classes assert(check->is_instance_klass(), "noninstance in systemdictionary"); @@ -2219,7 +2202,7 @@ } -// Update system dictionary - done after check_constraint and add_to_hierachy +// Update class loader data dictionary - done after check_constraint and add_to_hierachy // have been called. void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash, int p_index, unsigned int p_hash, @@ -2254,19 +2237,19 @@ } } - // Make a new system dictionary entry. + // Make a new dictionary entry. Dictionary* dictionary = loader_data->dictionary(); InstanceKlass* sd_check = find_class(d_index, d_hash, name, dictionary); if (sd_check == NULL) { dictionary->add_klass(d_index, d_hash, name, k); notice_modification(); } - #ifdef ASSERT +#ifdef ASSERT sd_check = find_class(d_index, d_hash, name, dictionary); - assert (sd_check != NULL, "should have entry in system dictionary"); + assert (sd_check != NULL, "should have entry in dictionary"); // Note: there may be a placeholder entry: for circularity testing // or for parallel defines - #endif +#endif SystemDictionary_lock->notify_all(); } } @@ -2853,7 +2836,7 @@ guarantee(constraints() != NULL, "Verify of loader constraints failed"); guarantee(placeholders()->number_of_entries() >= 0, - "Verify of system dictionary failed"); + "Verify of placeholders failed"); // Verify dictionary ClassLoaderDataGraph::verify_dictionary();