0N/A/*
4170N/A * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
1879N/A#define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
1879N/A
1879N/A#include "classfile/classFileStream.hpp"
1879N/A#include "classfile/classLoader.hpp"
1879N/A#include "oops/objArrayOop.hpp"
2062N/A#include "oops/symbol.hpp"
1879N/A#include "runtime/java.hpp"
1879N/A#include "runtime/reflectionUtils.hpp"
1879N/A#include "utilities/hashtable.hpp"
3863N/A#include "utilities/hashtable.inline.hpp"
4423N/A#include "trace/traceTime.hpp"
1879N/A
0N/A// The system dictionary stores all loaded classes and maps:
0N/A//
2062N/A// [class name,class loader] -> class i.e. [Symbol*,oop] -> klassOop
0N/A//
0N/A// Classes are loaded lazily. The default VM class loader is
0N/A// represented as NULL.
0N/A
0N/A// The underlying data structure is an open hash table with a fixed number
0N/A// of buckets. During loading the loader object is locked, (for the VM loader
0N/A// a private lock object is used). Class loading can thus be done concurrently,
0N/A// but only by different loaders.
0N/A//
0N/A// During loading a placeholder (name, loader) is temporarily placed in
0N/A// a side data structure, and is used to detect ClassCircularityErrors
0N/A// and to perform verification during GC. A GC can occur in the midst
0N/A// of class loading, as we call out to Java, have to take locks, etc.
0N/A//
0N/A// When class loading is finished, a new entry is added to the system
0N/A// dictionary and the place holder is removed. Note that the protection
0N/A// domain field of the system dictionary has not yet been filled in when
0N/A// the "real" system dictionary entry is created.
0N/A//
0N/A// Clients of this class who are interested in finding if a class has
0N/A// been completely loaded -- not classes in the process of being loaded --
0N/A// can read the SystemDictionary unlocked. This is safe because
0N/A// - entries are only deleted at safepoints
0N/A// - readers cannot come to a safepoint while actively examining
0N/A// an entry (an entry cannot be deleted from under a reader)
0N/A// - entries must be fully formed before they are available to concurrent
0N/A// readers (we must ensure write ordering)
0N/A//
0N/A// Note that placeholders are deleted at any time, as they are removed
0N/A// when a class is completely loaded. Therefore, readers as well as writers
0N/A// of placeholders must hold the SystemDictionary_lock.
0N/A//
0N/A
0N/Aclass Dictionary;
0N/Aclass PlaceholderTable;
0N/Aclass LoaderConstraintTable;
3863N/Atemplate <MEMFLAGS F> class HashtableBucket;
0N/Aclass ResolutionErrorTable;
710N/Aclass SymbolPropertyTable;
4423N/Aclass BoolObjectClosure;
0N/A
132N/A// Certain classes are preloaded, such as java.lang.Object and java.lang.String.
132N/A// They are all "well-known", in the sense that no class loader is allowed
132N/A// to provide a different definition.
132N/A//
132N/A// These klasses must all have names defined in vmSymbols.
132N/A
132N/A#define WK_KLASS_ENUM_NAME(kname) kname##_knum
132N/A
132N/A// Each well-known class has a short klass name (like object_klass),
132N/A// a vmSymbol name (like java_lang_Object), and a flag word
132N/A// that makes some minor distinctions, like whether the klass
132N/A// is preloaded, optional, release-specific, etc.
132N/A// The order of these definitions is significant; it is the order in which
132N/A// preloading is actually performed by initialize_preloaded_classes.
132N/A
4031N/A#define WK_KLASSES_DO(do_klass) \
4031N/A /* well-known classes */ \
4034N/A do_klass(Object_klass, java_lang_Object, Pre ) \
4034N/A do_klass(String_klass, java_lang_String, Pre ) \
4034N/A do_klass(Class_klass, java_lang_Class, Pre ) \
4034N/A do_klass(Cloneable_klass, java_lang_Cloneable, Pre ) \
4034N/A do_klass(ClassLoader_klass, java_lang_ClassLoader, Pre ) \
4034N/A do_klass(Serializable_klass, java_io_Serializable, Pre ) \
4034N/A do_klass(System_klass, java_lang_System, Pre ) \
4034N/A do_klass(Throwable_klass, java_lang_Throwable, Pre ) \
4034N/A do_klass(Error_klass, java_lang_Error, Pre ) \
4034N/A do_klass(ThreadDeath_klass, java_lang_ThreadDeath, Pre ) \
4034N/A do_klass(Exception_klass, java_lang_Exception, Pre ) \
4034N/A do_klass(RuntimeException_klass, java_lang_RuntimeException, Pre ) \
4034N/A do_klass(ProtectionDomain_klass, java_security_ProtectionDomain, Pre ) \
4034N/A do_klass(AccessControlContext_klass, java_security_AccessControlContext, Pre ) \
4034N/A do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre ) \
4034N/A do_klass(NoClassDefFoundError_klass, java_lang_NoClassDefFoundError, Pre ) \
4034N/A do_klass(LinkageError_klass, java_lang_LinkageError, Pre ) \
4034N/A do_klass(ClassCastException_klass, java_lang_ClassCastException, Pre ) \
4034N/A do_klass(ArrayStoreException_klass, java_lang_ArrayStoreException, Pre ) \
4034N/A do_klass(VirtualMachineError_klass, java_lang_VirtualMachineError, Pre ) \
4034N/A do_klass(OutOfMemoryError_klass, java_lang_OutOfMemoryError, Pre ) \
4034N/A do_klass(StackOverflowError_klass, java_lang_StackOverflowError, Pre ) \
4034N/A do_klass(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException, Pre ) \
4034N/A do_klass(Reference_klass, java_lang_ref_Reference, Pre ) \
4031N/A \
4031N/A /* Preload ref klasses and set reference types */ \
4034N/A do_klass(SoftReference_klass, java_lang_ref_SoftReference, Pre ) \
4034N/A do_klass(WeakReference_klass, java_lang_ref_WeakReference, Pre ) \
4031N/A do_klass(FinalReference_klass, java_lang_ref_FinalReference, Pre ) \
4034N/A do_klass(PhantomReference_klass, java_lang_ref_PhantomReference, Pre ) \
4031N/A do_klass(Finalizer_klass, java_lang_ref_Finalizer, Pre ) \
4031N/A \
4034N/A do_klass(Thread_klass, java_lang_Thread, Pre ) \
4034N/A do_klass(ThreadGroup_klass, java_lang_ThreadGroup, Pre ) \
4034N/A do_klass(Properties_klass, java_util_Properties, Pre ) \
4034N/A do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject, Pre ) \
4034N/A do_klass(reflect_Field_klass, java_lang_reflect_Field, Pre ) \
4034N/A do_klass(reflect_Method_klass, java_lang_reflect_Method, Pre ) \
4034N/A do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \
4031N/A \
2771N/A /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
2771N/A /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
2771N/A /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
4031N/A do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \
4031N/A do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
4031N/A do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
4031N/A do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \
4031N/A do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \
4031N/A do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \
4031N/A \
4031N/A /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
4034N/A do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \
4034N/A do_klass(MemberName_klass, java_lang_invoke_MemberName, Pre_JSR292 ) \
4034N/A do_klass(MethodHandleNatives_klass, java_lang_invoke_MethodHandleNatives, Pre_JSR292 ) \
4031N/A do_klass(LambdaForm_klass, java_lang_invoke_LambdaForm, Opt ) \
4034N/A do_klass(MethodType_klass, java_lang_invoke_MethodType, Pre_JSR292 ) \
4034N/A do_klass(BootstrapMethodError_klass, java_lang_BootstrapMethodError, Pre_JSR292 ) \
4034N/A do_klass(CallSite_klass, java_lang_invoke_CallSite, Pre_JSR292 ) \
4034N/A do_klass(ConstantCallSite_klass, java_lang_invoke_ConstantCallSite, Pre_JSR292 ) \
4034N/A do_klass(MutableCallSite_klass, java_lang_invoke_MutableCallSite, Pre_JSR292 ) \
4034N/A do_klass(VolatileCallSite_klass, java_lang_invoke_VolatileCallSite, Pre_JSR292 ) \
4031N/A /* Note: MethodHandle must be first, and VolatileCallSite last in group */ \
4031N/A \
4034N/A do_klass(StringBuffer_klass, java_lang_StringBuffer, Pre ) \
4034N/A do_klass(StringBuilder_klass, java_lang_StringBuilder, Pre ) \
4031N/A \
4031N/A /* It's NULL in non-1.4 JDKs. */ \
4031N/A do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \
4031N/A /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
4031N/A /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
4031N/A do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \
4031N/A \
4031N/A do_klass(PostVMInitHook_klass, sun_misc_PostVMInitHook, Opt ) \
4031N/A \
4031N/A /* Preload boxing klasses */ \
4034N/A do_klass(Boolean_klass, java_lang_Boolean, Pre ) \
4034N/A do_klass(Character_klass, java_lang_Character, Pre ) \
4034N/A do_klass(Float_klass, java_lang_Float, Pre ) \
4034N/A do_klass(Double_klass, java_lang_Double, Pre ) \
4034N/A do_klass(Byte_klass, java_lang_Byte, Pre ) \
4034N/A do_klass(Short_klass, java_lang_Short, Pre ) \
4034N/A do_klass(Integer_klass, java_lang_Integer, Pre ) \
4034N/A do_klass(Long_klass, java_lang_Long, Pre ) \
132N/A /*end*/
132N/A
132N/A
0N/Aclass SystemDictionary : AllStatic {
0N/A friend class VMStructs;
0N/A friend class CompactingPermGenGen;
665N/A friend class SystemDictionaryHandles;
0N/A NOT_PRODUCT(friend class instanceKlassKlass;)
0N/A
0N/A public:
132N/A enum WKID {
132N/A NO_WKID = 0,
132N/A
2771N/A #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
132N/A WK_KLASSES_DO(WK_KLASS_ENUM)
132N/A #undef WK_KLASS_ENUM
132N/A
132N/A WKID_LIMIT,
132N/A
132N/A FIRST_WKID = NO_WKID + 1
132N/A };
132N/A
132N/A enum InitOption {
132N/A Pre, // preloaded; error if not present
4034N/A Pre_JSR292, // preloaded if EnableInvokeDynamic
132N/A
132N/A // Order is significant. Options before this point require resolve_or_fail.
132N/A // Options after this point will use resolve_or_null instead.
132N/A
132N/A Opt, // preload tried; NULL if not present
132N/A Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection
132N/A Opt_Only_JDK15, // preload tried; use only with JDK1.5+
132N/A OPTION_LIMIT,
132N/A CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
132N/A };
132N/A
132N/A
0N/A // Returns a class with a given class name and class loader. Loads the
0N/A // class if needed. If not found a NoClassDefFoundError or a
0N/A // ClassNotFoundException is thrown, depending on the value on the
0N/A // throw_error flag. For most uses the throw_error argument should be set
0N/A // to true.
0N/A
2062N/A static klassOop resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
0N/A // Convenient call for null loader and protection domain.
2062N/A static klassOop resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
0N/Aprivate:
0N/A // handle error translation for resolve_or_null results
2062N/A static klassOop handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
0N/A
0N/Apublic:
0N/A
0N/A // Returns a class with a given class name and class loader.
0N/A // Loads the class if needed. If not found NULL is returned.
2062N/A static klassOop resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
0N/A // Version with null loader and protection domain
2062N/A static klassOop resolve_or_null(Symbol* class_name, TRAPS);
0N/A
0N/A // Resolve a superclass or superinterface. Called from ClassFileParser,
0N/A // parse_interfaces, resolve_instance_class_or_null, load_shared_class
0N/A // "child_name" is the class whose super class or interface is being resolved.
2062N/A static klassOop resolve_super_or_fail(Symbol* child_name,
2062N/A Symbol* class_name,
0N/A Handle class_loader,
0N/A Handle protection_domain,
0N/A bool is_superclass,
0N/A TRAPS);
0N/A
0N/A // Parse new stream. This won't update the system dictionary or
0N/A // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
2062N/A static klassOop parse_stream(Symbol* class_name,
0N/A Handle class_loader,
0N/A Handle protection_domain,
0N/A ClassFileStream* st,
431N/A TRAPS) {
431N/A KlassHandle nullHandle;
431N/A return parse_stream(class_name, class_loader, protection_domain, st, nullHandle, NULL, THREAD);
431N/A }
2062N/A static klassOop parse_stream(Symbol* class_name,
431N/A Handle class_loader,
431N/A Handle protection_domain,
431N/A ClassFileStream* st,
431N/A KlassHandle host_klass,
431N/A GrowableArray<Handle>* cp_patches,
0N/A TRAPS);
0N/A
0N/A // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
2062N/A static klassOop resolve_from_stream(Symbol* class_name, Handle class_loader,
973N/A Handle protection_domain,
973N/A ClassFileStream* st, bool verify, TRAPS);
0N/A
0N/A // Lookup an already loaded class. If not found NULL is returned.
2062N/A static klassOop find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
0N/A
0N/A // Lookup an already loaded instance or array class.
0N/A // Do not make any queries to class loaders; consult only the cache.
0N/A // If not found NULL is returned.
2062N/A static klassOop find_instance_or_array_klass(Symbol* class_name,
0N/A Handle class_loader,
0N/A Handle protection_domain,
0N/A TRAPS);
0N/A
0N/A // Lookup an instance or array class that has already been loaded
0N/A // either into the given class loader, or else into another class
0N/A // loader that is constrained (via loader constraints) to produce
0N/A // a consistent class. Do not take protection domains into account.
0N/A // Do not make any queries to class loaders; consult only the cache.
0N/A // Return NULL if the class is not found.
0N/A //
0N/A // This function is a strict superset of find_instance_or_array_klass.
0N/A // This function (the unchecked version) makes a conservative prediction
0N/A // of the result of the checked version, assuming successful lookup.
0N/A // If both functions return non-null, they must return the same value.
0N/A // Also, the unchecked version may sometimes be non-null where the
0N/A // checked version is null. This can occur in several ways:
0N/A // 1. No query has yet been made to the class loader.
0N/A // 2. The class loader was queried, but chose not to delegate.
0N/A // 3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
0N/A // 4. Loading was attempted, but there was a linkage error of some sort.
0N/A // In all of these cases, the loader constraints on this type are
0N/A // satisfied, and it is safe for classes in the given class loader
0N/A // to manipulate strongly-typed values of the found class, subject
0N/A // to local linkage and access checks.
2062N/A static klassOop find_constrained_instance_or_array_klass(Symbol* class_name,
0N/A Handle class_loader,
0N/A TRAPS);
0N/A
0N/A // Iterate over all klasses in dictionary
0N/A // Just the classes from defining class loaders
0N/A static void classes_do(void f(klassOop));
0N/A // Added for initialize_itable_for_klass to handle exceptions
0N/A static void classes_do(void f(klassOop, TRAPS), TRAPS);
0N/A // All classes, and their class loaders
0N/A static void classes_do(void f(klassOop, oop));
0N/A // All classes, and their class loaders
0N/A // (added for helpers that use HandleMarks and ResourceMarks)
0N/A static void classes_do(void f(klassOop, oop, TRAPS), TRAPS);
0N/A // All entries in the placeholder table and their class loaders
2062N/A static void placeholders_do(void f(Symbol*, oop));
0N/A
0N/A // Iterate over all methods in all klasses in dictionary
0N/A static void methods_do(void f(methodOop));
0N/A
0N/A // Garbage collection support
0N/A
0N/A // This method applies "blk->do_oop" to all the pointers to "system"
0N/A // classes and loaders.
0N/A static void always_strong_oops_do(OopClosure* blk);
0N/A static void always_strong_classes_do(OopClosure* blk);
0N/A // This method applies "blk->do_oop" to all the placeholders.
0N/A static void placeholders_do(OopClosure* blk);
0N/A
0N/A // Unload (that is, break root links to) all unmarked classes and
0N/A // loaders. Returns "true" iff something was unloaded.
0N/A static bool do_unloading(BoolObjectClosure* is_alive);
0N/A
3149N/A static int calculate_systemdictionary_size(int loadedclasses);
3149N/A
0N/A // Applies "f->do_oop" to all root oops in the system dictionary.
0N/A static void oops_do(OopClosure* f);
0N/A
0N/A // System loader lock
0N/A static oop system_loader_lock() { return _system_loader_lock_obj; }
0N/A
0N/Aprivate:
0N/A // Traverses preloaded oops: various system classes. These are
0N/A // guaranteed to be in the perm gen.
0N/A static void preloaded_oops_do(OopClosure* f);
0N/A static void lazily_loaded_oops_do(OopClosure* f);
0N/A
0N/Apublic:
0N/A // Sharing support.
0N/A static void reorder_dictionary();
0N/A static void copy_buckets(char** top, char* end);
0N/A static void copy_table(char** top, char* end);
0N/A static void reverse();
3863N/A static void set_shared_dictionary(HashtableBucket<mtClass>* t, int length,
0N/A int number_of_entries);
0N/A // Printing
0N/A static void print() PRODUCT_RETURN;
0N/A static void print_class_statistics() PRODUCT_RETURN;
0N/A static void print_method_statistics() PRODUCT_RETURN;
0N/A
0N/A // Number of contained klasses
0N/A // This is both fully loaded classes and classes in the process
0N/A // of being loaded
0N/A static int number_of_classes();
0N/A
0N/A // Monotonically increasing counter which grows as classes are
0N/A // loaded or modifications such as hot-swapping or setting/removing
0N/A // of breakpoints are performed
0N/A static inline int number_of_modifications() { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
0N/A // Needed by evolution and breakpoint code
0N/A static inline void notice_modification() { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications; }
0N/A
0N/A // Verification
0N/A static void verify();
0N/A
0N/A#ifdef ASSERT
2062N/A static bool is_internal_format(Symbol* class_name);
0N/A#endif
0N/A
0N/A // Verify class is in dictionary
0N/A static void verify_obj_klass_present(Handle obj,
2062N/A Symbol* class_name,
0N/A Handle class_loader);
0N/A
0N/A // Initialization
0N/A static void initialize(TRAPS);
0N/A
0N/A // Fast access to commonly used classes (preloaded)
0N/A static klassOop check_klass(klassOop k) {
0N/A assert(k != NULL, "preloaded klass not initialized");
0N/A return k;
0N/A }
0N/A
4031N/A static klassOop check_klass_Pre( klassOop k) { return check_klass(k); }
4034N/A static klassOop check_klass_Pre_JSR292(klassOop k) { return EnableInvokeDynamic ? check_klass(k) : k; }
4031N/A static klassOop check_klass_Opt( klassOop k) { return k; }
132N/A static klassOop check_klass_Opt_Only_JDK15(klassOop k) {
132N/A assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
132N/A return k;
132N/A }
132N/A static klassOop check_klass_Opt_Only_JDK14NewRef(klassOop k) {
0N/A assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
132N/A // despite the optional loading, if you use this it must be present:
132N/A return check_klass(k);
0N/A }
0N/A
132N/A static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
132N/A static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
132N/A static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
132N/A int limit = (int)end_id + 1;
132N/A initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
132N/A }
0N/A
132N/Apublic:
2771N/A #define WK_KLASS_DECLARE(name, symbol, option) \
132N/A static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
132N/A WK_KLASSES_DO(WK_KLASS_DECLARE);
132N/A #undef WK_KLASS_DECLARE
0N/A
2771N/A static klassOop well_known_klass(WKID id) {
2771N/A assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
2771N/A return _well_known_klasses[id];
2771N/A }
2771N/A
132N/A // Local definition for direct access to the private array:
147N/A #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
0N/A
0N/A static klassOop box_klass(BasicType t) {
0N/A assert((uint)t < T_VOID+1, "range check");
0N/A return check_klass(_box_klasses[t]);
0N/A }
0N/A static BasicType box_klass_type(klassOop k); // inverse of box_klass
0N/A
0N/A // methods returning lazily loaded klasses
0N/A // The corresponding method to load the class must be called before calling them.
0N/A static klassOop abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); }
0N/A
0N/A static void load_abstract_ownable_synchronizer_klass(TRAPS);
0N/A
0N/Aprivate:
0N/A // Tells whether ClassLoader.loadClassInternal is present
0N/A static bool has_loadClassInternal() { return _has_loadClassInternal; }
0N/A
0N/Apublic:
0N/A // Tells whether ClassLoader.checkPackageAccess is present
0N/A static bool has_checkPackageAccess() { return _has_checkPackageAccess; }
0N/A
1142N/A static bool Class_klass_loaded() { return WK_KLASS(Class_klass) != NULL; }
1142N/A static bool Cloneable_klass_loaded() { return WK_KLASS(Cloneable_klass) != NULL; }
0N/A
0N/A // Returns default system loader
0N/A static oop java_system_loader();
0N/A
0N/A // Compute the default system loader
0N/A static void compute_java_system_loader(TRAPS);
0N/A
0N/Aprivate:
0N/A // Mirrors for primitive classes (created eagerly)
0N/A static oop check_mirror(oop m) {
0N/A assert(m != NULL, "mirror not initialized");
0N/A return m;
0N/A }
0N/A
0N/Apublic:
0N/A // Note: java_lang_Class::primitive_type is the inverse of java_mirror
0N/A
0N/A // Check class loader constraints
2062N/A static bool add_loader_constraint(Symbol* name, Handle loader1,
0N/A Handle loader2, TRAPS);
2062N/A static char* check_signature_loaders(Symbol* signature, Handle loader1,
0N/A Handle loader2, bool is_method, TRAPS);
0N/A
710N/A // JSR 292
3932N/A // find a java.lang.invoke.MethodHandle.invoke* method for a given signature
3932N/A // (asks Java to compute it if necessary, except in a compiler thread)
3932N/A static methodHandle find_method_handle_invoker(Symbol* name,
3932N/A Symbol* signature,
3932N/A KlassHandle accessing_klass,
3932N/A Handle *appendix_result,
4048N/A Handle *method_type_result,
3932N/A TRAPS);
3932N/A // for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic)
3932N/A // (does not ask Java, since this is a low-level intrinsic defined by the JVM)
3932N/A static methodHandle find_method_handle_intrinsic(vmIntrinsics::ID iid,
3932N/A Symbol* signature,
3932N/A TRAPS);
3932N/A // find a java.lang.invoke.MethodType object for a given signature
3932N/A // (asks Java to compute it if necessary, except in a compiler thread)
2062N/A static Handle find_method_handle_type(Symbol* signature,
1428N/A KlassHandle accessing_klass,
1427N/A TRAPS);
3932N/A
2204N/A // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
1522N/A static Handle link_method_handle_constant(KlassHandle caller,
1522N/A int ref_kind, //e.g., JVM_REF_invokeVirtual
1522N/A KlassHandle callee,
2062N/A Symbol* name,
2062N/A Symbol* signature,
1522N/A TRAPS);
3932N/A
726N/A // ask Java to create a dynamic call site, while linking an invokedynamic op
3932N/A static methodHandle find_dynamic_call_site_invoker(KlassHandle caller,
3932N/A Handle bootstrap_method,
3932N/A Symbol* name,
3932N/A Symbol* type,
3932N/A Handle *appendix_result,
4048N/A Handle *method_type_result,
3932N/A TRAPS);
726N/A
0N/A // Utility for printing loader "name" as part of tracing constraints
0N/A static const char* loader_name(oop loader) {
0N/A return ((loader) == NULL ? "<bootloader>" :
0N/A instanceKlass::cast((loader)->klass())->name()->as_C_string() );
0N/A }
0N/A
0N/A // Record the error when the first attempt to resolve a reference from a constant
0N/A // pool entry to a class fails.
2062N/A static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
2062N/A static Symbol* find_resolution_error(constantPoolHandle pool, int which);
0N/A
0N/A private:
0N/A
0N/A enum Constants {
0N/A _loader_constraint_size = 107, // number of entries in constraint table
0N/A _resolution_error_size = 107, // number of entries in resolution error table
710N/A _invoke_method_size = 139, // number of entries in invoke method table
3149N/A _nof_buckets = 1009, // number of buckets in hash table for placeholders
3149N/A _old_default_sdsize = 1009, // backward compat for system dictionary size
3149N/A _prime_array_size = 8, // array of primes for system dictionary size
3149N/A _average_depth_goal = 3 // goal for lookup length
0N/A };
0N/A
0N/A
0N/A // Static variables
0N/A
3149N/A // hashtable sizes for system dictionary to allow growth
3149N/A // prime numbers for system dictionary size
3149N/A static int _sdgeneration;
3149N/A static const int _primelist[_prime_array_size];
3149N/A
0N/A // Hashtable holding loaded classes.
0N/A static Dictionary* _dictionary;
0N/A
0N/A // Hashtable holding placeholders for classes being loaded.
0N/A static PlaceholderTable* _placeholders;
0N/A
0N/A // Hashtable holding classes from the shared archive.
0N/A static Dictionary* _shared_dictionary;
0N/A
0N/A // Monotonically increasing counter which grows with
0N/A // _number_of_classes as well as hot-swapping and breakpoint setting
0N/A // and removal.
0N/A static int _number_of_modifications;
0N/A
0N/A // Lock object for system class loader
0N/A static oop _system_loader_lock_obj;
0N/A
0N/A // Constraints on class loaders
0N/A static LoaderConstraintTable* _loader_constraints;
0N/A
0N/A // Resolution errors
0N/A static ResolutionErrorTable* _resolution_errors;
0N/A
710N/A // Invoke methods (JSR 292)
710N/A static SymbolPropertyTable* _invoke_method_table;
710N/A
0N/Apublic:
0N/A // for VM_CounterDecay iteration support
0N/A friend class CounterDecay;
0N/A static klassOop try_get_next_class();
0N/A
0N/Aprivate:
0N/A static void validate_protection_domain(instanceKlassHandle klass,
0N/A Handle class_loader,
0N/A Handle protection_domain, TRAPS);
0N/A
0N/A friend class VM_PopulateDumpSharedSpace;
0N/A friend class TraversePlaceholdersClosure;
0N/A static Dictionary* dictionary() { return _dictionary; }
0N/A static Dictionary* shared_dictionary() { return _shared_dictionary; }
0N/A static PlaceholderTable* placeholders() { return _placeholders; }
0N/A static LoaderConstraintTable* constraints() { return _loader_constraints; }
0N/A static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
710N/A static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
0N/A
0N/A // Basic loading operations
2062N/A static klassOop resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
2062N/A static klassOop resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
2062N/A static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
0N/A // Wait on SystemDictionary_lock; unlocks lockObject before
0N/A // waiting; relocks lockObject with correct recursion count
0N/A // after waiting, but before reentering SystemDictionary_lock
0N/A // to preserve lock order semantics.
0N/A static void double_lock_wait(Handle lockObject, TRAPS);
0N/A static void define_instance_class(instanceKlassHandle k, TRAPS);
2062N/A static instanceKlassHandle find_or_define_instance_class(Symbol* class_name,
0N/A Handle class_loader,
0N/A instanceKlassHandle k, TRAPS);
2062N/A static instanceKlassHandle load_shared_class(Symbol* class_name,
0N/A Handle class_loader, TRAPS);
0N/A static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
0N/A Handle class_loader, TRAPS);
2062N/A static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
0N/A static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
0N/A static void check_loader_lock_contention(Handle loader_lock, TRAPS);
514N/A static bool is_parallelCapable(Handle class_loader);
1075N/A static bool is_parallelDefine(Handle class_loader);
0N/A
2062N/A static klassOop find_shared_class(Symbol* class_name);
0N/A
0N/A // Setup link to hierarchy
0N/A static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
0N/A
4423N/A // event based tracing
4423N/A static void post_class_load_event(TracingTime start_time, instanceKlassHandle k,
4423N/A Handle initiating_loader);
4423N/A static void post_class_unload_events(BoolObjectClosure* is_alive);
4423N/A
0N/Aprivate:
0N/A // We pass in the hashtable index so we can calculate it outside of
0N/A // the SystemDictionary_lock.
0N/A
0N/A // Basic find on loaded classes
0N/A static klassOop find_class(int index, unsigned int hash,
2062N/A Symbol* name, Handle loader);
2062N/A static klassOop find_class(Symbol* class_name, Handle class_loader);
0N/A
0N/A // Basic find on classes in the midst of being loaded
2062N/A static Symbol* find_placeholder(Symbol* name, Handle loader);
0N/A
0N/A // Updating entry in dictionary
0N/A // Add a completely loaded class
2062N/A static void add_klass(int index, Symbol* class_name,
0N/A Handle class_loader, KlassHandle obj);
0N/A
0N/A // Add a placeholder for a class being loaded
0N/A static void add_placeholder(int index,
2062N/A Symbol* class_name,
0N/A Handle class_loader);
0N/A static void remove_placeholder(int index,
2062N/A Symbol* class_name,
0N/A Handle class_loader);
0N/A
0N/A // Performs cleanups after resolve_super_or_fail. This typically needs
0N/A // to be called on failure.
0N/A // Won't throw, but can block.
2062N/A static void resolution_cleanups(Symbol* class_name,
0N/A Handle class_loader,
0N/A TRAPS);
0N/A
0N/A // Initialization
0N/A static void initialize_preloaded_classes(TRAPS);
0N/A
0N/A // Class loader constraints
0N/A static void check_constraints(int index, unsigned int hash,
0N/A instanceKlassHandle k, Handle loader,
0N/A bool defining, TRAPS);
0N/A static void update_dictionary(int d_index, unsigned int d_hash,
0N/A int p_index, unsigned int p_hash,
0N/A instanceKlassHandle k, Handle loader, TRAPS);
0N/A
0N/A // Variables holding commonly used klasses (preloaded)
132N/A static klassOop _well_known_klasses[];
0N/A
0N/A // Lazily loaded klasses
0N/A static volatile klassOop _abstract_ownable_synchronizer_klass;
0N/A
132N/A // table of box klasses (int_klass, etc.)
0N/A static klassOop _box_klasses[T_VOID+1];
0N/A
0N/A static oop _java_system_loader;
0N/A
0N/A static bool _has_loadClassInternal;
0N/A static bool _has_checkPackageAccess;
4423N/A
4423N/A#if INCLUDE_TRACE
4423N/A static TracingTime _class_unload_time;
4423N/A static BoolObjectClosure* _is_alive;
4423N/A static int _no_of_classes_unloading;
4423N/A static bool _should_write_unload_events;
4423N/A static void class_unload_event(klassOop curklass);
4423N/A#endif
0N/A};
665N/A
665N/Aclass SystemDictionaryHandles : AllStatic {
665N/Apublic:
665N/A #define WK_KLASS_HANDLE_DECLARE(name, ignore_symbol, option) \
665N/A static KlassHandle name() { \
665N/A SystemDictionary::name(); \
665N/A klassOop* loc = &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]; \
665N/A return KlassHandle(loc, true); \
665N/A }
665N/A WK_KLASSES_DO(WK_KLASS_HANDLE_DECLARE);
665N/A #undef WK_KLASS_HANDLE_DECLARE
665N/A
665N/A static KlassHandle box_klass(BasicType t);
665N/A};
1879N/A
1879N/A#endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP