# HG changeset patch # User lfoltan # Date 1534767957 14400 # Node ID 3e5d28e6de32a161392def381e5b1c1c8911d0c0 # Parent cdffba164671a2620efc3e2eeccc4135a70c71b8 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation Summary: Clean up VM anonymous class terminology. Reviewed-by: coleenp, dholmes, mchung diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/aot/aotCodeHeap.cpp --- a/src/hotspot/share/aot/aotCodeHeap.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/aot/aotCodeHeap.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -1006,7 +1006,7 @@ InstanceKlass* dyno = InstanceKlass::cast(dyno_klass); - if (!dyno->is_anonymous()) { + if (!dyno->is_unsafe_anonymous()) { if (_klasses_got[dyno_data->_got_index] != dyno) { // compile-time class different from runtime class, fail and deoptimize sweep_dependent_methods(holder_data); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/aot/aotLoader.cpp --- a/src/hotspot/share/aot/aotLoader.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/aot/aotLoader.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -42,7 +42,7 @@ #define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator lib = libraries()->begin(); lib != libraries()->end(); ++lib) void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* thread) { - if (ik->is_anonymous()) { + if (ik->is_unsafe_anonymous()) { // don't even bother return; } @@ -54,7 +54,7 @@ } uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) { - if (ik->is_anonymous()) { + if (ik->is_unsafe_anonymous()) { // don't even bother return 0; } diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/c1/c1_GraphBuilder.cpp --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -1844,8 +1844,8 @@ // invoke-special-super if (bc_raw == Bytecodes::_invokespecial && !target->is_object_initializer()) { ciInstanceKlass* sender_klass = - calling_klass->is_anonymous() ? calling_klass->host_klass() : - calling_klass; + calling_klass->is_unsafe_anonymous() ? calling_klass->unsafe_anonymous_host() : + calling_klass; if (sender_klass->is_interface()) { int index = state()->stack_size() - (target->arg_size_no_receiver() + 1); Value receiver = state()->stack_at(index); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/ci/ciField.cpp --- a/src/hotspot/share/ci/ciField.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/ci/ciField.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -222,9 +222,9 @@ // Even if general trusting is disabled, trust system-built closures in these packages. if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) return true; - // Trust VM anonymous classes. They are private API (sun.misc.Unsafe) and can't be serialized, - // so there is no hacking of finals going on with them. - if (holder->is_anonymous()) + // Trust VM unsafe anonymous classes. They are private API (jdk.internal.misc.Unsafe) + // and can't be serialized, so there is no hacking of finals going on with them. + if (holder->is_unsafe_anonymous()) return true; // Trust final fields in all boxed classes if (holder->is_box_klass()) diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/ci/ciInstanceKlass.cpp --- a/src/hotspot/share/ci/ciInstanceKlass.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/ci/ciInstanceKlass.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -62,7 +62,7 @@ _nonstatic_field_size = ik->nonstatic_field_size(); _has_nonstatic_fields = ik->has_nonstatic_fields(); _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods(); - _is_anonymous = ik->is_anonymous(); + _is_unsafe_anonymous = ik->is_unsafe_anonymous(); _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: _has_injected_fields = -1; _implementor = NULL; // we will fill these lazily @@ -73,13 +73,13 @@ // InstanceKlass are created for both weak and strong metadata. Ensuring this metadata // alive covers the cases where there are weak roots without performance cost. oop holder = ik->holder_phantom(); - if (ik->is_anonymous()) { + if (ik->is_unsafe_anonymous()) { // Though ciInstanceKlass records class loader oop, it's not enough to keep - // VM anonymous classes alive (loader == NULL). Klass holder should be used instead. - // It is enough to record a ciObject, since cached elements are never removed + // VM unsafe anonymous classes alive (loader == NULL). Klass holder should + // be used instead. It is enough to record a ciObject, since cached elements are never removed // during ciObjectFactory lifetime. ciObjectFactory itself is created for // every compilation and lives for the whole duration of the compilation. - assert(holder != NULL, "holder of anonymous class is the mirror which is never null"); + assert(holder != NULL, "holder of unsafe anonymous class is the mirror which is never null"); (void)CURRENT_ENV->get_object(holder); } @@ -122,7 +122,7 @@ _has_nonstatic_fields = false; _nonstatic_fields = NULL; _has_injected_fields = -1; - _is_anonymous = false; + _is_unsafe_anonymous = false; _loader = loader; _protection_domain = protection_domain; _is_shared = false; @@ -615,12 +615,12 @@ return impl; } -ciInstanceKlass* ciInstanceKlass::host_klass() { +ciInstanceKlass* ciInstanceKlass::unsafe_anonymous_host() { assert(is_loaded(), "must be loaded"); - if (is_anonymous()) { + if (is_unsafe_anonymous()) { VM_ENTRY_MARK - Klass* host_klass = get_instanceKlass()->host_klass(); - return CURRENT_ENV->get_instance_klass(host_klass); + Klass* unsafe_anonymous_host = get_instanceKlass()->unsafe_anonymous_host(); + return CURRENT_ENV->get_instance_klass(unsafe_anonymous_host); } return NULL; } diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/ci/ciInstanceKlass.hpp --- a/src/hotspot/share/ci/ciInstanceKlass.hpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/ci/ciInstanceKlass.hpp Mon Aug 20 08:25:57 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -53,7 +53,7 @@ bool _has_subklass; bool _has_nonstatic_fields; bool _has_nonstatic_concrete_methods; - bool _is_anonymous; + bool _is_unsafe_anonymous; ciFlags _flags; jint _nonstatic_field_size; @@ -179,8 +179,8 @@ return _has_nonstatic_concrete_methods; } - bool is_anonymous() { - return _is_anonymous; + bool is_unsafe_anonymous() { + return _is_unsafe_anonymous; } ciInstanceKlass* get_canonical_holder(int offset); @@ -260,7 +260,7 @@ return NULL; } - ciInstanceKlass* host_klass(); + ciInstanceKlass* unsafe_anonymous_host(); bool can_be_instantiated() { assert(is_loaded(), "must be loaded"); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classFileParser.cpp --- a/src/hotspot/share/classfile/classFileParser.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classFileParser.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -2091,7 +2091,7 @@ // Privileged code can use all annotations. Other code silently drops some. const bool privileged = loader_data->is_the_null_class_loader_data() || loader_data->is_platform_class_loader_data() || - loader_data->is_anonymous(); + loader_data->is_unsafe_anonymous(); switch (sid) { case vmSymbols::VM_SYMBOL_ENUM_NAME(reflect_CallerSensitive_signature): { if (_location != _in_method) break; // only allow for methods @@ -5591,7 +5591,7 @@ ik->set_this_class_index(_this_class_index); - if (is_anonymous()) { + if (is_unsafe_anonymous()) { // _this_class_index is a CONSTANT_Class entry that refers to this // anonymous class itself. If this class needs to refer to its own methods or // fields, it would use a CONSTANT_MethodRef, etc, which would reference @@ -5607,9 +5607,9 @@ ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods); ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods); - if (_host_klass != NULL) { - assert (ik->is_anonymous(), "should be the same"); - ik->set_host_klass(_host_klass); + if (_unsafe_anonymous_host != NULL) { + assert (ik->is_unsafe_anonymous(), "should be the same"); + ik->set_unsafe_anonymous_host(_unsafe_anonymous_host); } // Set PackageEntry for this_klass @@ -5760,15 +5760,15 @@ debug_only(ik->verify();) } -// For an anonymous class that is in the unnamed package, move it to its host class's +// For an unsafe anonymous class that is in the unnamed package, move it to its host class's // package by prepending its host class's package name to its class name and setting // its _class_name field. -void ClassFileParser::prepend_host_package_name(const InstanceKlass* host_klass, TRAPS) { +void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS) { ResourceMark rm(THREAD); assert(strrchr(_class_name->as_C_string(), '/') == NULL, - "Anonymous class should not be in a package"); + "Unsafe anonymous class should not be in a package"); const char* host_pkg_name = - ClassLoader::package_from_name(host_klass->name()->as_C_string(), NULL); + ClassLoader::package_from_name(unsafe_anonymous_host->name()->as_C_string(), NULL); if (host_pkg_name != NULL) { size_t host_pkg_len = strlen(host_pkg_name); @@ -5778,7 +5778,7 @@ // Copy host package name and trailing /. strncpy(new_anon_name, host_pkg_name, host_pkg_len); new_anon_name[host_pkg_len] = '/'; - // Append anonymous class name. The anonymous class name can contain odd + // Append unsafe anonymous class name. The unsafe anonymous class name can contain odd // characters. So, do a strncpy instead of using sprintf("%s..."). strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len); @@ -5793,19 +5793,19 @@ // nothing. If the anonymous class is in the unnamed package then move it to its // host's package. If the classes are in different packages then throw an IAE // exception. -void ClassFileParser::fix_anonymous_class_name(TRAPS) { - assert(_host_klass != NULL, "Expected an anonymous class"); +void ClassFileParser::fix_unsafe_anonymous_class_name(TRAPS) { + assert(_unsafe_anonymous_host != NULL, "Expected an unsafe anonymous class"); const jbyte* anon_last_slash = UTF8::strrchr(_class_name->base(), _class_name->utf8_length(), '/'); if (anon_last_slash == NULL) { // Unnamed package - prepend_host_package_name(_host_klass, CHECK); + prepend_host_package_name(_unsafe_anonymous_host, CHECK); } else { - if (!_host_klass->is_same_class_package(_host_klass->class_loader(), _class_name)) { + if (!_unsafe_anonymous_host->is_same_class_package(_unsafe_anonymous_host->class_loader(), _class_name)) { ResourceMark rm(THREAD); THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Host class %s and anonymous class %s are in different packages", - _host_klass->name()->as_C_string(), _class_name->as_C_string())); + _unsafe_anonymous_host->name()->as_C_string(), _class_name->as_C_string())); } } } @@ -5825,14 +5825,14 @@ Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const InstanceKlass* host_klass, + const InstanceKlass* unsafe_anonymous_host, GrowableArray* cp_patches, Publicity pub_level, TRAPS) : _stream(stream), _requested_name(name), _loader_data(loader_data), - _host_klass(host_klass), + _unsafe_anonymous_host(unsafe_anonymous_host), _cp_patches(cp_patches), _num_patched_klasses(0), _max_num_patched_klasses(0), @@ -6140,8 +6140,8 @@ // if this is an anonymous class fix up its name if it's in the unnamed // package. Otherwise, throw IAE if it is in a different package than // its host class. - if (_host_klass != NULL) { - fix_anonymous_class_name(CHECK); + if (_unsafe_anonymous_host != NULL) { + fix_unsafe_anonymous_class_name(CHECK); } // Verification prevents us from creating names with dots in them, this @@ -6166,9 +6166,9 @@ warning("DumpLoadedClassList and CDS are not supported in exploded build"); DumpLoadedClassList = NULL; } else if (SystemDictionaryShared::is_sharing_possible(_loader_data) && - _host_klass == NULL) { + _unsafe_anonymous_host == NULL) { // Only dump the classes that can be stored into CDS archive. - // Anonymous classes such as generated LambdaForm classes are also not included. + // Unsafe anonymous classes such as generated LambdaForm classes are also not included. oop class_loader = _loader_data->class_loader(); ResourceMark rm(THREAD); bool skip = false; diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classFileParser.hpp --- a/src/hotspot/share/classfile/classFileParser.hpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classFileParser.hpp Mon Aug 20 08:25:57 2018 -0400 @@ -82,7 +82,7 @@ const Symbol* _requested_name; Symbol* _class_name; mutable ClassLoaderData* _loader_data; - const InstanceKlass* _host_klass; + const InstanceKlass* _unsafe_anonymous_host; GrowableArray* _cp_patches; // overrides for CP entries int _num_patched_klasses; int _max_num_patched_klasses; @@ -173,8 +173,8 @@ ConstantPool* cp, TRAPS); - void prepend_host_package_name(const InstanceKlass* host_klass, TRAPS); - void fix_anonymous_class_name(TRAPS); + void prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS); + void fix_unsafe_anonymous_class_name(TRAPS); void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS); void set_klass(InstanceKlass* instance); @@ -501,7 +501,7 @@ Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const InstanceKlass* host_klass, + const InstanceKlass* unsafe_anonymous_host, GrowableArray* cp_patches, Publicity pub_level, TRAPS); @@ -524,10 +524,10 @@ u2 this_class_index() const { return _this_class_index; } u2 super_class_index() const { return _super_class_index; } - bool is_anonymous() const { return _host_klass != NULL; } + bool is_unsafe_anonymous() const { return _unsafe_anonymous_host != NULL; } bool is_interface() const { return _access_flags.is_interface(); } - const InstanceKlass* host_klass() const { return _host_klass; } + const InstanceKlass* unsafe_anonymous_host() const { return _unsafe_anonymous_host; } const GrowableArray* cp_patches() const { return _cp_patches; } ClassLoaderData* loader_data() const { return _loader_data; } const Symbol* class_name() const { return _class_name; } diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classLoader.cpp --- a/src/hotspot/share/classfile/classLoader.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classLoader.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -1400,7 +1400,7 @@ name, loader_data, protection_domain, - NULL, // host_klass + NULL, // unsafe_anonymous_host NULL, // cp_patches THREAD); if (HAS_PENDING_EXCEPTION) { @@ -1443,8 +1443,8 @@ assert(DumpSharedSpaces, "sanity"); assert(stream != NULL, "sanity"); - if (ik->is_anonymous()) { - // We do not archive anonymous classes. + if (ik->is_unsafe_anonymous()) { + // We do not archive unsafe anonymous classes. return; } 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()) { diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classLoaderData.hpp --- a/src/hotspot/share/classfile/classLoaderData.hpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classLoaderData.hpp Mon Aug 20 08:25:57 2018 -0400 @@ -92,8 +92,8 @@ static volatile size_t _num_instance_classes; static volatile size_t _num_array_classes; - static ClassLoaderData* add_to_graph(Handle class_loader, bool anonymous); - static ClassLoaderData* add(Handle class_loader, bool anonymous); + static ClassLoaderData* add_to_graph(Handle class_loader, bool is_unsafe_anonymous); + static ClassLoaderData* add(Handle class_loader, bool is_unsafe_anonymous); public: static ClassLoaderData* find_or_create(Handle class_loader); @@ -114,7 +114,7 @@ // Walking classes through the ClassLoaderDataGraph include array classes. It also includes // classes that are allocated but not loaded, classes that have errors, and scratch classes // for redefinition. These classes are removed during the next class unloading. - // Walking the ClassLoaderDataGraph also includes anonymous classes. + // Walking the ClassLoaderDataGraph also includes unsafe anonymous classes. static void classes_do(KlassClosure* klass_closure); static void classes_do(void f(Klass* const)); static void methods_do(void f(Method*)); @@ -238,16 +238,17 @@ // classes in the class loader are allocated. Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. bool _unloading; // true if this class loader goes away - bool _is_anonymous; // if this CLD is for an anonymous class + bool _is_unsafe_anonymous; // CLD is dedicated to one class and that class determines the CLDs lifecycle. + // For example, an unsafe anonymous class. // Remembered sets support for the oops in the class loader data. bool _modified_oops; // Card Table Equivalent (YC/CMS support) bool _accumulated_modified_oops; // Mod Union Equivalent (CMS support) s2 _keep_alive; // if this CLD is kept alive. - // Used for anonymous classes and the boot class + // Used for unsafe anonymous classes and the boot class // loader. _keep_alive does not need to be volatile or - // atomic since there is one unique CLD per anonymous class. + // atomic since there is one unique CLD per unsafe anonymous class. volatile int _claimed; // true if claimed, for example during GC traces. // To avoid applying oop closure more than once. @@ -283,7 +284,7 @@ void set_next(ClassLoaderData* next) { _next = next; } ClassLoaderData* next() const { return _next; } - ClassLoaderData(Handle h_class_loader, bool is_anonymous); + ClassLoaderData(Handle h_class_loader, bool is_unsafe_anonymous); ~ClassLoaderData(); // The CLD are not placed in the Heap, so the Card Table or @@ -337,7 +338,7 @@ Mutex* metaspace_lock() const { return _metaspace_lock; } - bool is_anonymous() const { return _is_anonymous; } + bool is_unsafe_anonymous() const { return _is_unsafe_anonymous; } static void init_null_class_loader_data(); @@ -346,15 +347,15 @@ } // Returns true if this class loader data is for the system class loader. - // (Note that the class loader data may be anonymous.) + // (Note that the class loader data may be unsafe anonymous.) bool is_system_class_loader_data() const; // 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 is_platform_class_loader_data() const; // Returns true if this class loader data is for the boot class loader. - // (Note that the class loader data may be anonymous.) + // (Note that the class loader data may be unsafe anonymous.) inline bool is_boot_class_loader_data() const; bool is_builtin_class_loader_data() const; @@ -372,7 +373,7 @@ return _unloading; } - // Used to refcount an anonymous class's CLD in order to + // Used to refcount an unsafe anonymous class's CLD in order to // indicate their aliveness. void inc_keep_alive(); void dec_keep_alive(); @@ -412,7 +413,7 @@ static ClassLoaderData* class_loader_data(oop loader); static ClassLoaderData* class_loader_data_or_null(oop loader); - static ClassLoaderData* anonymous_class_loader_data(Handle loader); + static ClassLoaderData* unsafe_anonymous_class_loader_data(Handle loader); // Returns Klass* of associated class loader, or NULL if associated loader is 'bootstrap'. // Also works if unloading. diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classLoaderExt.cpp --- a/src/hotspot/share/classfile/classLoaderExt.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classLoaderExt.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -298,7 +298,7 @@ name, loader_data, protection_domain, - NULL, // host_klass + NULL, // unsafe_anonymous_host NULL, // cp_patches THREAD); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp --- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -128,7 +128,7 @@ class LoaderTreeNode : public ResourceObj { - // We walk the CLDG and, for each CLD which is non-anonymous, add + // We walk the CLDG and, for each CLD which is non-unsafe_anonymous, add // a tree node. // To add a node we need its parent node; if the parent node does not yet // exist - because we have not yet encountered the CLD for the parent loader - @@ -219,7 +219,7 @@ if (print_classes) { if (_classes != NULL) { for (LoadedClassInfo* lci = _classes; lci; lci = lci->_next) { - // Non-anonymous classes should live in the primary CLD of its loader + // Non-unsafe anonymous classes should live in the primary CLD of its loader assert(lci->_cld == _cld, "must be"); branchtracker.print(st); @@ -252,12 +252,12 @@ for (LoadedClassInfo* lci = _anon_classes; lci; lci = lci->_next) { branchtracker.print(st); if (lci == _anon_classes) { // first iteration - st->print("%*s ", indentation, "Anonymous Classes:"); + st->print("%*s ", indentation, "Unsafe Anonymous Classes:"); } else { st->print("%*s ", indentation, ""); } st->print("%s", lci->_klass->external_name()); - // For anonymous classes, also print CLD if verbose. Should be a different one than the primary CLD. + // For unsafe anonymous classes, also print CLD if verbose. Should be a different one than the primary CLD. assert(lci->_cld != _cld, "must be"); if (verbose) { st->print(" (Loader Data: " PTR_FORMAT ")", p2i(lci->_cld)); @@ -266,7 +266,7 @@ } branchtracker.print(st); st->print("%*s ", indentation, ""); - st->print_cr("(%u anonymous class%s)", _num_anon_classes, (_num_anon_classes == 1) ? "" : "es"); + st->print_cr("(%u unsafe anonymous class%s)", _num_anon_classes, (_num_anon_classes == 1) ? "" : "es"); // Empty line branchtracker.print(st); @@ -318,14 +318,14 @@ _next = info; } - void add_classes(LoadedClassInfo* first_class, int num_classes, bool anonymous) { - LoadedClassInfo** p_list_to_add_to = anonymous ? &_anon_classes : &_classes; + void add_classes(LoadedClassInfo* first_class, int num_classes, bool is_unsafe_anonymous) { + LoadedClassInfo** p_list_to_add_to = is_unsafe_anonymous ? &_anon_classes : &_classes; // Search tail. while ((*p_list_to_add_to) != NULL) { p_list_to_add_to = &(*p_list_to_add_to)->_next; } *p_list_to_add_to = first_class; - if (anonymous) { + if (is_unsafe_anonymous) { _num_anon_classes += num_classes; } else { _num_classes += num_classes; @@ -420,7 +420,7 @@ LoadedClassCollectClosure lccc(cld); const_cast(cld)->classes_do(&lccc); if (lccc._num_classes > 0) { - info->add_classes(lccc._list, lccc._num_classes, cld->is_anonymous()); + info->add_classes(lccc._list, lccc._num_classes, cld->is_unsafe_anonymous()); } } @@ -480,7 +480,7 @@ assert(info != NULL, "must be"); // Update CLD in node, but only if this is the primary CLD for this loader. - if (cld->is_anonymous() == false) { + if (cld->is_unsafe_anonymous() == false) { assert(info->cld() == NULL, "there should be only one primary CLD per loader"); info->set_cld(cld); } diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/classLoaderStats.cpp --- a/src/hotspot/share/classfile/classLoaderStats.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/classLoaderStats.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -58,7 +58,7 @@ cls = *cls_ptr; } - if (!cld->is_anonymous()) { + if (!cld->is_unsafe_anonymous()) { cls->_cld = cld; } @@ -70,7 +70,7 @@ ClassStatsClosure csc; cld->classes_do(&csc); - if(cld->is_anonymous()) { + if(cld->is_unsafe_anonymous()) { cls->_anon_classes_count += csc._num_classes; } else { cls->_classes_count = csc._num_classes; @@ -79,7 +79,7 @@ ClassLoaderMetaspace* ms = cld->metaspace_or_null(); if (ms != NULL) { - if(cld->is_anonymous()) { + if(cld->is_unsafe_anonymous()) { cls->_anon_chunk_sz += ms->allocated_chunks_bytes(); cls->_anon_block_sz += ms->allocated_blocks_bytes(); } else { diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/defaultMethods.cpp --- a/src/hotspot/share/classfile/defaultMethods.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/defaultMethods.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -885,7 +885,7 @@ ConstantPool* cp = bpool->create_constant_pool(CHECK); if (cp != klass->constants()) { // Copy resolved anonymous class into new constant pool. - if (klass->is_anonymous()) { + if (klass->is_unsafe_anonymous()) { cp->klass_at_put(klass->this_class_index(), klass); } klass->class_loader_data()->add_to_deallocate_list(klass->constants()); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/javaClasses.cpp --- a/src/hotspot/share/classfile/javaClasses.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/javaClasses.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -3786,7 +3786,7 @@ } oop new_resolved_method = k->allocate_instance(CHECK_NULL); new_resolved_method->address_field_put(_vmtarget_offset, (address)m()); - // Add a reference to the loader (actually mirror because anonymous classes will not have + // Add a reference to the loader (actually mirror because unsafe anonymous classes will not have // distinct loaders) to ensure the metadata is kept alive. // This mirror may be different than the one in clazz field. new_resolved_method->obj_field_put(_vmholder_offset, m->method_holder()->java_mirror()); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/klassFactory.cpp --- a/src/hotspot/share/classfile/klassFactory.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/klassFactory.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -183,7 +183,7 @@ Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const InstanceKlass* host_klass, + const InstanceKlass* unsafe_anonymous_host, GrowableArray* cp_patches, TRAPS) { assert(stream != NULL, "invariant"); @@ -201,7 +201,7 @@ THREAD->statistical_info().incr_define_class_count(); // Skip this processing for VM anonymous classes - if (host_klass == NULL) { + if (unsafe_anonymous_host == NULL) { stream = check_class_file_load_hook(stream, name, loader_data, @@ -214,7 +214,7 @@ name, loader_data, protection_domain, - host_klass, + unsafe_anonymous_host, cp_patches, ClassFileParser::BROADCAST, // publicity level CHECK_NULL); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/klassFactory.hpp --- a/src/hotspot/share/classfile/klassFactory.hpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/klassFactory.hpp Mon Aug 20 08:25:57 2018 -0400 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2015, 2018, 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 @@ -72,7 +72,7 @@ Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const InstanceKlass* host_klass, + const InstanceKlass* unsafe_anonymous_host, GrowableArray* cp_patches, TRAPS); public: diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/moduleEntry.hpp --- a/src/hotspot/share/classfile/moduleEntry.hpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/moduleEntry.hpp Mon Aug 20 08:25:57 2018 -0400 @@ -110,7 +110,7 @@ ClassLoaderData* loader_data() const { return _loader_data; } void set_loader_data(ClassLoaderData* cld) { - assert(!cld->is_anonymous(), "Unexpected anonymous class loader data"); + assert(!cld->is_unsafe_anonymous(), "Unexpected unsafe anonymous class loader data"); _loader_data = cld; } diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/systemDictionary.cpp --- a/src/hotspot/share/classfile/systemDictionary.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/systemDictionary.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -988,18 +988,18 @@ Handle class_loader, Handle protection_domain, ClassFileStream* st, - const InstanceKlass* host_klass, + const InstanceKlass* unsafe_anonymous_host, GrowableArray* cp_patches, TRAPS) { EventClassLoad class_load_start_event; ClassLoaderData* loader_data; - if (host_klass != NULL) { - // Create a new CLD for anonymous class, that uses the same class loader - // as the host_klass - guarantee(oopDesc::equals(host_klass->class_loader(), class_loader()), "should be the same"); - loader_data = ClassLoaderData::anonymous_class_loader_data(class_loader); + if (unsafe_anonymous_host != NULL) { + // Create a new CLD for an unsafe anonymous class, that uses the same class loader + // as the unsafe_anonymous_host + guarantee(oopDesc::equals(unsafe_anonymous_host->class_loader(), class_loader()), "should be the same"); + loader_data = ClassLoaderData::unsafe_anonymous_class_loader_data(class_loader); } else { loader_data = ClassLoaderData::class_loader_data(class_loader()); } @@ -1016,12 +1016,12 @@ class_name, loader_data, protection_domain, - host_klass, + unsafe_anonymous_host, cp_patches, CHECK_NULL); - if (host_klass != NULL && k != NULL) { - // Anonymous classes must update ClassLoaderData holder (was host_klass loader) + if (unsafe_anonymous_host != NULL && k != NULL) { + // Unsafe anonymous classes must update ClassLoaderData holder (was unsafe_anonymous_host loader) // so that they can be unloaded when the mirror is no longer referenced. k->class_loader_data()->initialize_holder(Handle(THREAD, k->java_mirror())); @@ -1056,8 +1056,8 @@ post_class_load_event(&class_load_start_event, k, loader_data); } } - assert(host_klass != NULL || NULL == cp_patches, - "cp_patches only found with host_klass"); + assert(unsafe_anonymous_host != NULL || NULL == cp_patches, + "cp_patches only found with unsafe_anonymous_host"); return k; } @@ -1115,7 +1115,7 @@ class_name, loader_data, protection_domain, - NULL, // host_klass + NULL, // unsafe_anonymous_host NULL, // cp_patches CHECK_NULL); } @@ -3010,7 +3010,7 @@ _master_dictionary(master_dictionary) {} void do_cld(ClassLoaderData* cld) { ResourceMark rm; - if (cld->is_anonymous()) { + if (cld->is_unsafe_anonymous()) { return; } if (cld->is_system_class_loader_data() || cld->is_platform_class_loader_data()) { diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/systemDictionary.hpp --- a/src/hotspot/share/classfile/systemDictionary.hpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/systemDictionary.hpp Mon Aug 20 08:25:57 2018 -0400 @@ -298,7 +298,7 @@ class_loader, protection_domain, st, - NULL, // host klass + NULL, // unsafe_anonymous_host NULL, // cp_patches THREAD); } @@ -306,7 +306,7 @@ Handle class_loader, Handle protection_domain, ClassFileStream* st, - const InstanceKlass* host_klass, + const InstanceKlass* unsafe_anonymous_host, GrowableArray* cp_patches, TRAPS); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/systemDictionaryShared.cpp --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -755,11 +755,11 @@ Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) { assert(DumpSharedSpaces, "called at dump time only"); - // Skip anonymous classes, which are not archived as they are not in - // dictionary (see assert_no_anonymoys_classes_in_dictionaries() in + // Skip unsafe anonymous classes, which are not archived as they are not in + // dictionary (see assert_no_unsafe_anonymous_classes_in_dictionaries() in // VM_PopulateDumpSharedSpace::doit()). - if (k->class_loader_data()->is_anonymous()) { - return true; // anonymous classes are not archived, skip + if (k->class_loader_data()->is_unsafe_anonymous()) { + return true; // unsafe anonymous classes are not archived, skip } SharedDictionaryEntry* entry = ((SharedDictionary*)(k->class_loader_data()->dictionary()))->find_entry_for(k); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/classfile/verifier.cpp --- a/src/hotspot/share/classfile/verifier.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/classfile/verifier.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -2823,20 +2823,20 @@ current_class()->super()->name()))) { bool subtype = false; bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; - if (!current_class()->is_anonymous()) { + if (!current_class()->is_unsafe_anonymous()) { subtype = ref_class_type.is_assignable_from( current_type(), this, false, CHECK_VERIFY(this)); } else { - VerificationType host_klass_type = - VerificationType::reference_type(current_class()->host_klass()->name()); - subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this)); + VerificationType unsafe_anonymous_host_type = + VerificationType::reference_type(current_class()->unsafe_anonymous_host()->name()); + subtype = ref_class_type.is_assignable_from(unsafe_anonymous_host_type, this, false, CHECK_VERIFY(this)); // If invokespecial of IMR, need to recheck for same or // direct interface relative to the host class have_imr_indirect = (have_imr_indirect && !is_same_or_direct_interface( - current_class()->host_klass(), - host_klass_type, ref_class_type)); + current_class()->unsafe_anonymous_host(), + unsafe_anonymous_host_type, ref_class_type)); } if (!subtype) { verify_error(ErrorContext::bad_code(bci), @@ -2866,15 +2866,15 @@ } else { // other methods // Ensures that target class is assignable to method class. if (opcode == Bytecodes::_invokespecial) { - if (!current_class()->is_anonymous()) { + if (!current_class()->is_unsafe_anonymous()) { current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); } else { // anonymous class invokespecial calls: check if the - // objectref is a subtype of the host_klass of the current class - // to allow an anonymous class to reference methods in the host_klass + // objectref is a subtype of the unsafe_anonymous_host of the current class + // to allow an anonymous class to reference methods in the unsafe_anonymous_host VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this)); VerificationType hosttype = - VerificationType::reference_type(current_class()->host_klass()->name()); + VerificationType::reference_type(current_class()->unsafe_anonymous_host()->name()); bool subtype = hosttype.is_assignable_from(top, this, false, CHECK_VERIFY(this)); if (!subtype) { verify_error( ErrorContext::bad_type(current_frame->offset(), diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/gc/parallel/psCompactionManager.cpp --- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -153,14 +153,14 @@ // Follow the klass field in the mirror. Klass* klass = java_lang_Class::as_Klass(obj); if (klass != NULL) { - // An anonymous class doesn't have its own class loader, so the call - // to follow_klass will mark and push its java mirror instead of the - // class loader. When handling the java mirror for an anonymous class - // we need to make sure its class loader data is claimed, this is done - // by calling follow_class_loader explicitly. For non-anonymous classes - // the call to follow_class_loader is made when the class loader itself - // is handled. - if (klass->is_instance_klass() && InstanceKlass::cast(klass)->is_anonymous()) { + // An unsafe anonymous class doesn't have its own class loader, + // so the call to follow_klass will mark and push its java mirror instead of the + // class loader. When handling the java mirror for an unsafe anonymous + // class we need to make sure its class loader data is claimed, this is done + // by calling follow_class_loader explicitly. For non-anonymous classes the + // call to follow_class_loader is made when the class loader itself is handled. + if (klass->is_instance_klass() && + InstanceKlass::cast(klass)->is_unsafe_anonymous()) { cm->follow_class_loader(klass->class_loader_data()); } else { cm->follow_klass(klass); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/interpreter/interpreterRuntime.cpp --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -924,11 +924,11 @@ info.call_kind() == CallInfo::vtable_call, ""); } #endif - // Get sender or sender's host_klass, and only set cpCache entry to resolved if + // Get sender or sender's unsafe_anonymous_host, and only set cpCache entry to resolved if // it is not an interface. The receiver for invokespecial calls within interface // methods must be checked for every call. InstanceKlass* sender = pool->pool_holder(); - sender = sender->has_host_klass() ? sender->host_klass() : sender; + sender = sender->is_unsafe_anonymous() ? sender->unsafe_anonymous_host() : sender; switch (info.call_kind()) { case CallInfo::direct_call: diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/interpreter/linkResolver.cpp --- a/src/hotspot/share/interpreter/linkResolver.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/interpreter/linkResolver.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -1167,9 +1167,9 @@ Klass* current_klass = link_info.current_klass(); if (current_klass != NULL && resolved_klass->is_interface()) { InstanceKlass* ck = InstanceKlass::cast(current_klass); - InstanceKlass *klass_to_check = !ck->is_anonymous() ? + InstanceKlass *klass_to_check = !ck->is_unsafe_anonymous() ? ck : - InstanceKlass::cast(ck->host_klass()); + InstanceKlass::cast(ck->unsafe_anonymous_host()); // Disable verification for the dynamically-generated reflection bytecodes. bool is_reflect = klass_to_check->is_subclass_of( SystemDictionary::reflect_MagicAccessorImpl_klass()); @@ -1260,7 +1260,7 @@ // The verifier also checks that the receiver is a subtype of the sender, if the sender is // a class. If the sender is an interface, the check has to be performed at runtime. InstanceKlass* sender = InstanceKlass::cast(current_klass); - sender = sender->is_anonymous() ? sender->host_klass() : sender; + sender = sender->is_unsafe_anonymous() ? sender->unsafe_anonymous_host() : sender; if (sender->is_interface() && recv.not_null()) { Klass* receiver_klass = recv->klass(); if (!receiver_klass->is_subtype_of(sender)) { diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp --- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -161,10 +161,10 @@ if (k->is_instance_klass()) { const InstanceKlass* ik = InstanceKlass::cast(k); - if (ik->is_anonymous()) { + if (ik->is_unsafe_anonymous()) { return; } - assert(!ik->is_anonymous(), "invariant"); + assert(!ik->is_unsafe_anonymous(), "invariant"); const Symbol* name = ik->name(); if (name != NULL) { write_text("Class Name: "); diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/jfr/metadata/metadata.xml --- a/src/hotspot/share/jfr/metadata/metadata.xml Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/jfr/metadata/metadata.xml Mon Aug 20 08:25:57 2018 -0400 @@ -200,7 +200,7 @@ - + @@ -208,7 +208,7 @@ - + @@ -682,11 +682,11 @@ - - - + + + diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/jfr/periodic/jfrPeriodic.cpp --- a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -476,9 +476,9 @@ event.set_classCount(cls->_classes_count); event.set_chunkSize(cls->_chunk_sz); event.set_blockSize(cls->_block_sz); - event.set_anonymousClassCount(cls->_anon_classes_count); - event.set_anonymousChunkSize(cls->_anon_chunk_sz); - event.set_anonymousBlockSize(cls->_anon_block_sz); + event.set_unsafeAnonymousClassCount(cls->_anon_classes_count); + event.set_unsafeAnonymousChunkSize(cls->_anon_chunk_sz); + event.set_unsafeAnonymousBlockSize(cls->_anon_block_sz); event.commit(); return true; } diff -r cdffba164671 -r 3e5d28e6de32 src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp Mon Aug 20 10:04:00 2018 +0200 +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp Mon Aug 20 08:25:57 2018 -0400 @@ -77,7 +77,7 @@ static traceid cld_id(CldPtr cld) { assert(cld != NULL, "invariant"); - return cld->is_anonymous() ? 0 : TRACE_ID(cld); + return cld->is_unsafe_anonymous() ? 0 : TRACE_ID(cld); } static void tag_leakp_klass_artifacts(KlassPtr k, bool class_unload) { @@ -92,7 +92,7 @@ } CldPtr cld = k->class_loader_data(); assert(cld != NULL, "invariant"); - if (!cld->is_anonymous()) { + if (!cld->is_unsafe_anonymous()) { tag_leakp_artifact(cld, class_unload); } } @@ -230,7 +230,7 @@ int write__artifact__classloader(JfrCheckpointWriter* writer, JfrArtifactSet* artifacts, const void* c) { assert(c != NULL, "invariant"); CldPtr cld = (CldPtr)c; - assert(!cld->is_anonymous(), "invariant"); + assert(!cld->is_unsafe_anonymous(), "invariant"); const traceid cld_id = TRACE_ID(cld); // class loader type const Klass* class_loader_klass = cld->class_loader_klass(); @@ -301,9 +301,9 @@ assert(artifacts != NULL, "invaiant"); assert(k != NULL, "invariant"); const InstanceKlass* const ik = (const InstanceKlass*)k; - if (ik->is_anonymous()) { + if (ik->is_unsafe_anonymous()) { CStringEntryPtr entry = - artifacts->map_cstring(JfrSymbolId::anonymous_klass_name_hash_code(ik)); + artifacts->map_cstring(JfrSymbolId::unsafe_anonymous_klass_name_hash_code(ik)); assert(entry != NULL, "invariant"); return write__artifact__cstring__entry__(writer, entry); } @@ -358,7 +358,7 @@ } CldPtr cld = klass->class_loader_data(); assert(cld != NULL, "invariant"); - if (!cld->is_anonymous()) { + if (!cld->is_unsafe_anonymous()) { count += class_loader_symbols(cld); } if (_method_used_predicate(klass)) { @@ -374,9 +374,9 @@ assert(klass != NULL, "invariant"); assert(_predicate(klass), "invariant"); const InstanceKlass* const ik = (const InstanceKlass*)klass; - if (ik->is_anonymous()) { + if (ik->is_unsafe_anonymous()) { CStringEntryPtr entry = - this->_artifacts->map_cstring(JfrSymbolId::anonymous_klass_name_hash_code(ik)); + this->_artifacts->map_cstring(JfrSymbolId::unsafe_anonymous_klass_name_hash_code(ik)); assert(entry != NULL, "invariant"); return _unique_predicate(entry->id()) ? write__artifact__cstring__entry__(this->_writer, entry) : 0; } @@ -432,7 +432,7 @@ template