/* * Copyright (c) 2016, 2022, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
template <class T> class Array; class ClassLoaderData; class MetaspaceClosure; class ModuleClosure;
// A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule. // It contains: // - Symbol* containing the module's name. // - pointer to the java.lang.Module for this module. // - pointer to the java.security.ProtectionDomain shared by classes defined to this module. // - ClassLoaderData*, class loader of this module. // - a growable array containing other module entries that this module can read. // - a flag indicating if this module can read all unnamed modules. // // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either // data structure. This lock must be taken on all accesses to either table. class ModuleEntry : public CHeapObj<mtModule> { private:
OopHandle _module; // java.lang.Module
OopHandle _shared_pd; // java.security.ProtectionDomain, cached // for shared classes from this module
Symbol* _name; // name of this module
ClassLoaderData* _loader_data;
GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module
Symbol* _version; // module version number
Symbol* _location; // module location
CDS_ONLY(int _shared_path_index;) // >=0 if classes in this module are in CDS archive bool _can_read_all_unnamed; bool _has_default_read_edges; // JVMTI redefine/retransform support bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules bool _is_open; // whether the packages in the module are all unqualifiedly exported bool _is_patched; // whether the module is patched via --patch-module
CDS_JAVA_HEAP_ONLY(int _archived_module_index;)
JFR_ONLY(DEFINE_TRACE_ID_FIELD;) enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read.
// The shared ProtectionDomain reference is set once the VM loads a shared class // originated from the current Module. The referenced ProtectionDomain object is // created by the ClassLoader when loading a class (shared or non-shared) from the // Module for the first time. This ProtectionDomain object is used for all // classes from the Module loaded by the same ClassLoader.
oop shared_protection_domain(); void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd);
void set_is_patched() {
_is_patched = true;
CDS_ONLY(_shared_path_index = -1); // Mark all shared classes in this module invisible.
} bool is_patched() { return _is_patched;
}
// iteration support for readability void module_reads_do(ModuleClosure* const f);
// Purge dead weak references out of reads list when any given class loader is unloaded. void purge_reads(); void delete_reads();
// Special handling for unnamed module, one per class loader static ModuleEntry* create_unnamed_module(ClassLoaderData* cld); static ModuleEntry* create_boot_unnamed_module(ClassLoaderData* cld); static ModuleEntry* new_unnamed_module_entry(Handle module_handle, ClassLoaderData* cld);
void print(outputStream* st = tty); void verify();
// Iterator interface class ModuleClosure: public StackObj { public: virtualvoid do_module(ModuleEntry* module) = 0;
};
// The ModuleEntryTable is a Hashtable containing a list of all modules defined // by a particular class loader. Each module is represented as a ModuleEntry node. // // Each ModuleEntryTable contains a _javabase_module field which allows for the // creation of java.base's ModuleEntry very early in bootstrapping before the // corresponding JVM_DefineModule call for java.base occurs during module system // initialization. Setting up java.base's ModuleEntry early enables classes, // loaded prior to the module system being initialized to be created with their // PackageEntry node's correctly pointing at java.base's ModuleEntry. No class // outside of java.base is allowed to be loaded pre-module system initialization. // class ModuleEntryTable : public CHeapObj<mtModule> { private: static ModuleEntry* _javabase_module;
ResourceHashtable<SymbolHandle, ModuleEntry*, 109, AnyObj::C_HEAP, mtModule,
SymbolHandle::compute_hash> _table;
public:
ModuleEntryTable();
~ModuleEntryTable();
// Create module in loader's module entry table. Assume Module_lock // has been locked by caller.
ModuleEntry* locked_create_entry(Handle module_handle, bool is_open,
Symbol* module_name,
Symbol* module_version,
Symbol* module_location,
ClassLoaderData* loader_data);
// Only lookup module within loader's module entry table.
ModuleEntry* lookup_only(Symbol* name);
// purge dead weak references out of reads list void purge_all_module_reads();
// Special handling for java.base static ModuleEntry* javabase_moduleEntry() { return _javabase_module; } staticvoid set_javabase_moduleEntry(ModuleEntry* java_base) {
assert(_javabase_module == NULL, "_javabase_module is already defined");
_javabase_module = java_base;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.