diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classLoaderData.cpp --- a/src/hotspot/share/classfile/classLoaderData.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classLoaderData.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -141,16 +141,16 @@ _name_and_id = SymbolTable::new_symbol(cl_instance_name_and_id, CATCH); } -ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous) : +ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_unsafe_anonymous) : _metaspace(NULL), _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true, Monitor::_safepoint_check_never)), - _unloading(false), _is_anonymous(is_anonymous), + _unloading(false), _is_unsafe_anonymous(is_unsafe_anonymous), _modified_oops(true), _accumulated_modified_oops(false), - // An anonymous class loader data doesn't have anything to keep - // it from being unloaded during parsing of the anonymous class. + // An unsafe anonymous class loader data doesn't have anything to keep + // it from being unloaded during parsing of the unsafe anonymous class. // The null-class-loader should always be kept alive. - _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0), + _keep_alive((is_unsafe_anonymous || h_class_loader.is_null()) ? 1 : 0), _claimed(0), _handles(), _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), @@ -164,14 +164,14 @@ _class_loader_klass = h_class_loader->klass(); } - if (!is_anonymous) { - // The holder is initialized later for anonymous classes, and before calling anything + if (!is_unsafe_anonymous) { + // The holder is initialized later for unsafe anonymous classes, and before calling anything // that call class_loader(). initialize_holder(h_class_loader); - // A ClassLoaderData created solely for an anonymous class should never have a + // A ClassLoaderData created solely for an unsafe anonymous class should never have a // ModuleEntryTable or PackageEntryTable created for it. The defining package - // and module for an anonymous class will be found in its host class. + // and module for an unsafe anonymous class will be found in its host class. _packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size); if (h_class_loader.is_null()) { // Create unnamed module for boot loader @@ -287,20 +287,20 @@ return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0; } -// Anonymous classes have their own ClassLoaderData that is marked to keep alive +// Unsafe anonymous classes have their own ClassLoaderData that is marked to keep alive // while the class is being parsed, and if the class appears on the module fixup list. -// Due to the uniqueness that no other class shares the anonymous class' name or -// ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while +// Due to the uniqueness that no other class shares the unsafe anonymous class' name or +// ClassLoaderData, no other non-GC thread has knowledge of the unsafe anonymous class while // it is being defined, therefore _keep_alive is not volatile or atomic. void ClassLoaderData::inc_keep_alive() { - if (is_anonymous()) { + if (is_unsafe_anonymous()) { assert(_keep_alive >= 0, "Invalid keep alive increment count"); _keep_alive++; } } void ClassLoaderData::dec_keep_alive() { - if (is_anonymous()) { + if (is_unsafe_anonymous()) { assert(_keep_alive > 0, "Invalid keep alive decrement count"); _keep_alive--; } @@ -402,20 +402,20 @@ // Do not need to record dependency if the dependency is to a class whose // class loader data is never freed. (i.e. the dependency's class loader // is one of the three builtin class loaders and the dependency is not - // anonymous.) + // unsafe anonymous.) if (to_cld->is_permanent_class_loader_data()) { return; } oop to; - if (to_cld->is_anonymous()) { - // Just return if an anonymous class is attempting to record a dependency - // to itself. (Note that every anonymous class has its own unique class + if (to_cld->is_unsafe_anonymous()) { + // Just return if an unsafe anonymous class is attempting to record a dependency + // to itself. (Note that every unsafe anonymous class has its own unique class // loader data.) if (to_cld == from_cld) { return; } - // Anonymous class dependencies are through the mirror. + // Unsafe anonymous class dependencies are through the mirror. to = k->java_mirror(); } else { to = to_cld->class_loader(); @@ -640,7 +640,7 @@ const int _default_loader_dictionary_size = 107; Dictionary* ClassLoaderData::create_dictionary() { - assert(!is_anonymous(), "anonymous class loader data do not have a dictionary"); + assert(!is_unsafe_anonymous(), "unsafe anonymous class loader data do not have a dictionary"); int size; bool resizable = false; if (_the_null_class_loader_data == NULL) { @@ -677,7 +677,7 @@ // Unloading support bool ClassLoaderData::is_alive() const { - bool alive = keep_alive() // null class loader and incomplete anonymous klasses. + bool alive = keep_alive() // null class loader and incomplete unsafe anonymous klasses. || (_holder.peek() != NULL); // and not cleaned by the GC weak handle processing. return alive; @@ -767,13 +767,13 @@ // Returns true if this class loader data is for the app class loader // or a user defined system class loader. (Note that the class loader -// data may be anonymous.) +// data may be unsafe anonymous.) bool ClassLoaderData::is_system_class_loader_data() const { return SystemDictionary::is_system_class_loader(class_loader()); } // Returns true if this class loader data is for the platform class loader. -// (Note that the class loader data may be anonymous.) +// (Note that the class loader data may be unsafe anonymous.) bool ClassLoaderData::is_platform_class_loader_data() const { return SystemDictionary::is_platform_class_loader(class_loader()); } @@ -781,7 +781,7 @@ // Returns true if the class loader for this class loader data is one of // the 3 builtin (boot application/system or platform) class loaders, // including a user-defined system class loader. Note that if the class -// loader data is for an anonymous class then it may get freed by a GC +// loader data is for an unsafe anonymous class then it may get freed by a GC // even if its class loader is one of these loaders. bool ClassLoaderData::is_builtin_class_loader_data() const { return (is_boot_class_loader_data() || @@ -790,10 +790,10 @@ } // Returns true if this class loader data is a class loader data -// that is not ever freed by a GC. It must be one of the builtin -// class loaders and not anonymous. +// that is not ever freed by a GC. It must be the CLD for one of the builtin +// class loaders and not the CLD for an unsafe anonymous class. bool ClassLoaderData::is_permanent_class_loader_data() const { - return is_builtin_class_loader_data() && !is_anonymous(); + return is_builtin_class_loader_data() && !is_unsafe_anonymous(); } ClassLoaderMetaspace* ClassLoaderData::metaspace_non_null() { @@ -810,8 +810,8 @@ if (this == the_null_class_loader_data()) { assert (class_loader() == NULL, "Must be"); metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::BootMetaspaceType); - } else if (is_anonymous()) { - metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType); + } else if (is_unsafe_anonymous()) { + metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::UnsafeAnonymousMetaspaceType); } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType); } else { @@ -962,8 +962,8 @@ } } -// These anonymous class loaders are to contain classes used for JSR292 -ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(Handle loader) { +// These CLDs are to contain unsafe anonymous classes used for JSR292 +ClassLoaderData* ClassLoaderData::unsafe_anonymous_class_loader_data(Handle loader) { // Add a new class loader data to the graph. return ClassLoaderDataGraph::add(loader, true); } @@ -1005,8 +1005,8 @@ // loader data: 0xsomeaddr of 'bootstrap' out->print("loader data: " INTPTR_FORMAT " of %s", p2i(this), loader_name_and_id()); } - if (is_anonymous()) { - out->print(" anonymous"); + if (is_unsafe_anonymous()) { + out->print(" unsafe anonymous"); } } @@ -1014,7 +1014,7 @@ void ClassLoaderData::print_on(outputStream* out) const { out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: %s {", p2i(this), p2i(_class_loader.ptr_raw()), loader_name_and_id()); - if (is_anonymous()) out->print(" anonymous"); + if (is_unsafe_anonymous()) out->print(" unsafe anonymous"); if (claimed()) out->print(" claimed"); if (is_unloading()) out->print(" unloading"); out->print(" metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null())); @@ -1032,8 +1032,8 @@ assert_locked_or_safepoint(_metaspace_lock); oop cl = class_loader(); - guarantee(this == class_loader_data(cl) || is_anonymous(), "Must be the same"); - guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || is_anonymous(), "must be"); + guarantee(this == class_loader_data(cl) || is_unsafe_anonymous(), "Must be the same"); + guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || is_unsafe_anonymous(), "must be"); // Verify the integrity of the allocated space. if (metaspace_or_null() != NULL) { @@ -1069,14 +1069,14 @@ // Add a new class loader data node to the list. Assign the newly created // ClassLoaderData into the java/lang/ClassLoader object as a hidden field -ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool is_anonymous) { +ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool is_unsafe_anonymous) { NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the // ClassLoaderData in the graph since the CLD // contains oops in _handles that must be walked. - ClassLoaderData* cld = new ClassLoaderData(loader, is_anonymous); + ClassLoaderData* cld = new ClassLoaderData(loader, is_unsafe_anonymous); - if (!is_anonymous) { + if (!is_unsafe_anonymous) { // First, Atomically set it ClassLoaderData* old = java_lang_ClassLoader::cmpxchg_loader_data(cld, loader(), NULL); if (old != NULL) { @@ -1109,8 +1109,8 @@ } while (true); } -ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous) { - ClassLoaderData* loader_data = add_to_graph(loader, is_anonymous); +ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_unsafe_anonymous) { + ClassLoaderData* loader_data = add_to_graph(loader, is_unsafe_anonymous); // Initialize _name and _name_and_id after the loader data is added to the // CLDG because adding the Symbol for _name and _name_and_id might safepoint. if (loader.not_null()) {