annotate src/share/vm/classfile/systemDictionary.hpp @ 147:83c868b757c0

6701024: SAJDI functionality is broken Summary: back out sa-related changes to 6652736, use concrete expressions for WKK names in the SA Reviewed-by: never, sundar
author jrose
date Wed, 14 May 2008 00:41:06 -0700
parents 60b728ec77c1
children d1605aabd0a1
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 // The system dictionary stores all loaded classes and maps:
duke@0 26 //
duke@0 27 // [class name,class loader] -> class i.e. [symbolOop,oop] -> klassOop
duke@0 28 //
duke@0 29 // Classes are loaded lazily. The default VM class loader is
duke@0 30 // represented as NULL.
duke@0 31
duke@0 32 // The underlying data structure is an open hash table with a fixed number
duke@0 33 // of buckets. During loading the loader object is locked, (for the VM loader
duke@0 34 // a private lock object is used). Class loading can thus be done concurrently,
duke@0 35 // but only by different loaders.
duke@0 36 //
duke@0 37 // During loading a placeholder (name, loader) is temporarily placed in
duke@0 38 // a side data structure, and is used to detect ClassCircularityErrors
duke@0 39 // and to perform verification during GC. A GC can occur in the midst
duke@0 40 // of class loading, as we call out to Java, have to take locks, etc.
duke@0 41 //
duke@0 42 // When class loading is finished, a new entry is added to the system
duke@0 43 // dictionary and the place holder is removed. Note that the protection
duke@0 44 // domain field of the system dictionary has not yet been filled in when
duke@0 45 // the "real" system dictionary entry is created.
duke@0 46 //
duke@0 47 // Clients of this class who are interested in finding if a class has
duke@0 48 // been completely loaded -- not classes in the process of being loaded --
duke@0 49 // can read the SystemDictionary unlocked. This is safe because
duke@0 50 // - entries are only deleted at safepoints
duke@0 51 // - readers cannot come to a safepoint while actively examining
duke@0 52 // an entry (an entry cannot be deleted from under a reader)
duke@0 53 // - entries must be fully formed before they are available to concurrent
duke@0 54 // readers (we must ensure write ordering)
duke@0 55 //
duke@0 56 // Note that placeholders are deleted at any time, as they are removed
duke@0 57 // when a class is completely loaded. Therefore, readers as well as writers
duke@0 58 // of placeholders must hold the SystemDictionary_lock.
duke@0 59 //
duke@0 60
duke@0 61 class Dictionary;
duke@0 62 class PlaceholderTable;
duke@0 63 class LoaderConstraintTable;
duke@0 64 class HashtableBucket;
duke@0 65 class ResolutionErrorTable;
duke@0 66
jrose@132 67 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
jrose@132 68 // They are all "well-known", in the sense that no class loader is allowed
jrose@132 69 // to provide a different definition.
jrose@132 70 //
jrose@132 71 // These klasses must all have names defined in vmSymbols.
jrose@132 72
jrose@132 73 #define WK_KLASS_ENUM_NAME(kname) kname##_knum
jrose@132 74
jrose@132 75 // Each well-known class has a short klass name (like object_klass),
jrose@132 76 // a vmSymbol name (like java_lang_Object), and a flag word
jrose@132 77 // that makes some minor distinctions, like whether the klass
jrose@132 78 // is preloaded, optional, release-specific, etc.
jrose@132 79 // The order of these definitions is significant; it is the order in which
jrose@132 80 // preloading is actually performed by initialize_preloaded_classes.
jrose@132 81
jrose@132 82 #define WK_KLASSES_DO(template) \
jrose@132 83 /* well-known classes */ \
jrose@132 84 template(object_klass, java_lang_Object, Pre) \
jrose@132 85 template(string_klass, java_lang_String, Pre) \
jrose@132 86 template(class_klass, java_lang_Class, Pre) \
jrose@132 87 template(cloneable_klass, java_lang_Cloneable, Pre) \
jrose@132 88 template(classloader_klass, java_lang_ClassLoader, Pre) \
jrose@132 89 template(serializable_klass, java_io_Serializable, Pre) \
jrose@132 90 template(system_klass, java_lang_System, Pre) \
jrose@132 91 template(throwable_klass, java_lang_Throwable, Pre) \
jrose@132 92 template(error_klass, java_lang_Error, Pre) \
jrose@132 93 template(threaddeath_klass, java_lang_ThreadDeath, Pre) \
jrose@132 94 template(exception_klass, java_lang_Exception, Pre) \
jrose@132 95 template(runtime_exception_klass, java_lang_RuntimeException, Pre) \
jrose@132 96 template(protectionDomain_klass, java_security_ProtectionDomain, Pre) \
jrose@132 97 template(AccessControlContext_klass, java_security_AccessControlContext, Pre) \
jrose@132 98 template(classNotFoundException_klass, java_lang_ClassNotFoundException, Pre) \
jrose@132 99 template(noClassDefFoundError_klass, java_lang_NoClassDefFoundError, Pre) \
jrose@132 100 template(linkageError_klass, java_lang_LinkageError, Pre) \
jrose@132 101 template(ClassCastException_klass, java_lang_ClassCastException, Pre) \
jrose@132 102 template(ArrayStoreException_klass, java_lang_ArrayStoreException, Pre) \
jrose@132 103 template(virtualMachineError_klass, java_lang_VirtualMachineError, Pre) \
jrose@132 104 template(OutOfMemoryError_klass, java_lang_OutOfMemoryError, Pre) \
jrose@132 105 template(StackOverflowError_klass, java_lang_StackOverflowError, Pre) \
jrose@132 106 template(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException, Pre) \
jrose@132 107 template(reference_klass, java_lang_ref_Reference, Pre) \
jrose@132 108 \
jrose@132 109 /* Preload ref klasses and set reference types */ \
jrose@132 110 template(soft_reference_klass, java_lang_ref_SoftReference, Pre) \
jrose@132 111 template(weak_reference_klass, java_lang_ref_WeakReference, Pre) \
jrose@132 112 template(final_reference_klass, java_lang_ref_FinalReference, Pre) \
jrose@132 113 template(phantom_reference_klass, java_lang_ref_PhantomReference, Pre) \
jrose@132 114 template(finalizer_klass, java_lang_ref_Finalizer, Pre) \
jrose@132 115 \
jrose@132 116 template(thread_klass, java_lang_Thread, Pre) \
jrose@132 117 template(threadGroup_klass, java_lang_ThreadGroup, Pre) \
jrose@132 118 template(properties_klass, java_util_Properties, Pre) \
jrose@132 119 template(reflect_accessible_object_klass, java_lang_reflect_AccessibleObject, Pre) \
jrose@132 120 template(reflect_field_klass, java_lang_reflect_Field, Pre) \
jrose@132 121 template(reflect_method_klass, java_lang_reflect_Method, Pre) \
jrose@132 122 template(reflect_constructor_klass, java_lang_reflect_Constructor, Pre) \
jrose@132 123 \
jrose@132 124 /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
jrose@132 125 /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
jrose@132 126 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
jrose@132 127 template(reflect_magic_klass, sun_reflect_MagicAccessorImpl, Opt) \
jrose@132 128 template(reflect_method_accessor_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
jrose@132 129 template(reflect_constructor_accessor_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
jrose@132 130 template(reflect_delegating_classloader_klass, sun_reflect_DelegatingClassLoader, Opt) \
jrose@132 131 template(reflect_constant_pool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15) \
jrose@132 132 template(reflect_unsafe_static_field_accessor_impl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \
jrose@132 133 \
jrose@132 134 template(vector_klass, java_util_Vector, Pre) \
jrose@132 135 template(hashtable_klass, java_util_Hashtable, Pre) \
jrose@132 136 template(stringBuffer_klass, java_lang_StringBuffer, Pre) \
jrose@132 137 \
jrose@132 138 /* It's NULL in non-1.4 JDKs. */ \
jrose@132 139 template(stackTraceElement_klass, java_lang_StackTraceElement, Opt) \
jrose@132 140 /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
jrose@132 141 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
jrose@132 142 template(java_nio_Buffer_klass, java_nio_Buffer, Opt) \
jrose@132 143 \
jrose@132 144 /* If this class isn't present, it won't be referenced. */ \
jrose@132 145 template(sun_misc_AtomicLongCSImpl_klass, sun_misc_AtomicLongCSImpl, Opt) \
jrose@132 146 \
jrose@132 147 template(sun_jkernel_DownloadManager_klass, sun_jkernel_DownloadManager, Opt_Kernel) \
jrose@132 148 \
jrose@132 149 /* Preload boxing klasses */ \
jrose@132 150 template(boolean_klass, java_lang_Boolean, Pre) \
jrose@132 151 template(char_klass, java_lang_Character, Pre) \
jrose@132 152 template(float_klass, java_lang_Float, Pre) \
jrose@132 153 template(double_klass, java_lang_Double, Pre) \
jrose@132 154 template(byte_klass, java_lang_Byte, Pre) \
jrose@132 155 template(short_klass, java_lang_Short, Pre) \
jrose@132 156 template(int_klass, java_lang_Integer, Pre) \
jrose@132 157 template(long_klass, java_lang_Long, Pre) \
jrose@132 158 /*end*/
jrose@132 159
jrose@132 160
duke@0 161 class SystemDictionary : AllStatic {
duke@0 162 friend class VMStructs;
duke@0 163 friend class CompactingPermGenGen;
duke@0 164 NOT_PRODUCT(friend class instanceKlassKlass;)
duke@0 165
duke@0 166 public:
jrose@132 167 enum WKID {
jrose@132 168 NO_WKID = 0,
jrose@132 169
jrose@132 170 #define WK_KLASS_ENUM(name, ignore_s, ignore_o) WK_KLASS_ENUM_NAME(name),
jrose@132 171 WK_KLASSES_DO(WK_KLASS_ENUM)
jrose@132 172 #undef WK_KLASS_ENUM
jrose@132 173
jrose@132 174 WKID_LIMIT,
jrose@132 175
jrose@132 176 FIRST_WKID = NO_WKID + 1
jrose@132 177 };
jrose@132 178
jrose@132 179 enum InitOption {
jrose@132 180 Pre, // preloaded; error if not present
jrose@132 181
jrose@132 182 // Order is significant. Options before this point require resolve_or_fail.
jrose@132 183 // Options after this point will use resolve_or_null instead.
jrose@132 184
jrose@132 185 Opt, // preload tried; NULL if not present
jrose@132 186 Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection
jrose@132 187 Opt_Only_JDK15, // preload tried; use only with JDK1.5+
jrose@132 188 Opt_Kernel, // preload tried only #ifdef KERNEL
jrose@132 189 OPTION_LIMIT,
jrose@132 190 CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
jrose@132 191 };
jrose@132 192
jrose@132 193
duke@0 194 // Returns a class with a given class name and class loader. Loads the
duke@0 195 // class if needed. If not found a NoClassDefFoundError or a
duke@0 196 // ClassNotFoundException is thrown, depending on the value on the
duke@0 197 // throw_error flag. For most uses the throw_error argument should be set
duke@0 198 // to true.
duke@0 199
duke@0 200 static klassOop resolve_or_fail(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
duke@0 201 // Convenient call for null loader and protection domain.
duke@0 202 static klassOop resolve_or_fail(symbolHandle class_name, bool throw_error, TRAPS);
duke@0 203 private:
duke@0 204 // handle error translation for resolve_or_null results
duke@0 205 static klassOop handle_resolution_exception(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
duke@0 206
duke@0 207 public:
duke@0 208
duke@0 209 // Returns a class with a given class name and class loader.
duke@0 210 // Loads the class if needed. If not found NULL is returned.
duke@0 211 static klassOop resolve_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
duke@0 212 // Version with null loader and protection domain
duke@0 213 static klassOop resolve_or_null(symbolHandle class_name, TRAPS);
duke@0 214
duke@0 215 // Resolve a superclass or superinterface. Called from ClassFileParser,
duke@0 216 // parse_interfaces, resolve_instance_class_or_null, load_shared_class
duke@0 217 // "child_name" is the class whose super class or interface is being resolved.
duke@0 218 static klassOop resolve_super_or_fail(symbolHandle child_name,
duke@0 219 symbolHandle class_name,
duke@0 220 Handle class_loader,
duke@0 221 Handle protection_domain,
duke@0 222 bool is_superclass,
duke@0 223 TRAPS);
duke@0 224
duke@0 225 // Parse new stream. This won't update the system dictionary or
duke@0 226 // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
duke@0 227 static klassOop parse_stream(symbolHandle class_name,
duke@0 228 Handle class_loader,
duke@0 229 Handle protection_domain,
duke@0 230 ClassFileStream* st,
duke@0 231 TRAPS);
duke@0 232
duke@0 233 // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
duke@0 234 static klassOop resolve_from_stream(symbolHandle class_name, Handle class_loader, Handle protection_domain, ClassFileStream* st, TRAPS);
duke@0 235
duke@0 236 // Lookup an already loaded class. If not found NULL is returned.
duke@0 237 static klassOop find(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
duke@0 238
duke@0 239 // Lookup an already loaded instance or array class.
duke@0 240 // Do not make any queries to class loaders; consult only the cache.
duke@0 241 // If not found NULL is returned.
duke@0 242 static klassOop find_instance_or_array_klass(symbolHandle class_name,
duke@0 243 Handle class_loader,
duke@0 244 Handle protection_domain,
duke@0 245 TRAPS);
duke@0 246
jrose@132 247 // If the given name is known to vmSymbols, return the well-know klass:
jrose@132 248 static klassOop find_well_known_klass(symbolOop class_name);
jrose@132 249
duke@0 250 // Lookup an instance or array class that has already been loaded
duke@0 251 // either into the given class loader, or else into another class
duke@0 252 // loader that is constrained (via loader constraints) to produce
duke@0 253 // a consistent class. Do not take protection domains into account.
duke@0 254 // Do not make any queries to class loaders; consult only the cache.
duke@0 255 // Return NULL if the class is not found.
duke@0 256 //
duke@0 257 // This function is a strict superset of find_instance_or_array_klass.
duke@0 258 // This function (the unchecked version) makes a conservative prediction
duke@0 259 // of the result of the checked version, assuming successful lookup.
duke@0 260 // If both functions return non-null, they must return the same value.
duke@0 261 // Also, the unchecked version may sometimes be non-null where the
duke@0 262 // checked version is null. This can occur in several ways:
duke@0 263 // 1. No query has yet been made to the class loader.
duke@0 264 // 2. The class loader was queried, but chose not to delegate.
duke@0 265 // 3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
duke@0 266 // 4. Loading was attempted, but there was a linkage error of some sort.
duke@0 267 // In all of these cases, the loader constraints on this type are
duke@0 268 // satisfied, and it is safe for classes in the given class loader
duke@0 269 // to manipulate strongly-typed values of the found class, subject
duke@0 270 // to local linkage and access checks.
duke@0 271 static klassOop find_constrained_instance_or_array_klass(symbolHandle class_name,
duke@0 272 Handle class_loader,
duke@0 273 TRAPS);
duke@0 274
duke@0 275 // Iterate over all klasses in dictionary
duke@0 276 // Just the classes from defining class loaders
duke@0 277 static void classes_do(void f(klassOop));
duke@0 278 // Added for initialize_itable_for_klass to handle exceptions
duke@0 279 static void classes_do(void f(klassOop, TRAPS), TRAPS);
duke@0 280 // All classes, and their class loaders
duke@0 281 static void classes_do(void f(klassOop, oop));
duke@0 282 // All classes, and their class loaders
duke@0 283 // (added for helpers that use HandleMarks and ResourceMarks)
duke@0 284 static void classes_do(void f(klassOop, oop, TRAPS), TRAPS);
duke@0 285 // All entries in the placeholder table and their class loaders
duke@0 286 static void placeholders_do(void f(symbolOop, oop));
duke@0 287
duke@0 288 // Iterate over all methods in all klasses in dictionary
duke@0 289 static void methods_do(void f(methodOop));
duke@0 290
duke@0 291 // Garbage collection support
duke@0 292
duke@0 293 // This method applies "blk->do_oop" to all the pointers to "system"
duke@0 294 // classes and loaders.
duke@0 295 static void always_strong_oops_do(OopClosure* blk);
duke@0 296 static void always_strong_classes_do(OopClosure* blk);
duke@0 297 // This method applies "blk->do_oop" to all the placeholders.
duke@0 298 static void placeholders_do(OopClosure* blk);
duke@0 299
duke@0 300 // Unload (that is, break root links to) all unmarked classes and
duke@0 301 // loaders. Returns "true" iff something was unloaded.
duke@0 302 static bool do_unloading(BoolObjectClosure* is_alive);
duke@0 303
duke@0 304 // Applies "f->do_oop" to all root oops in the system dictionary.
duke@0 305 static void oops_do(OopClosure* f);
duke@0 306
duke@0 307 // System loader lock
duke@0 308 static oop system_loader_lock() { return _system_loader_lock_obj; }
duke@0 309
duke@0 310 private:
duke@0 311 // Traverses preloaded oops: various system classes. These are
duke@0 312 // guaranteed to be in the perm gen.
duke@0 313 static void preloaded_oops_do(OopClosure* f);
duke@0 314 static void lazily_loaded_oops_do(OopClosure* f);
duke@0 315
duke@0 316 public:
duke@0 317 // Sharing support.
duke@0 318 static void reorder_dictionary();
duke@0 319 static void copy_buckets(char** top, char* end);
duke@0 320 static void copy_table(char** top, char* end);
duke@0 321 static void reverse();
duke@0 322 static void set_shared_dictionary(HashtableBucket* t, int length,
duke@0 323 int number_of_entries);
duke@0 324 // Printing
duke@0 325 static void print() PRODUCT_RETURN;
duke@0 326 static void print_class_statistics() PRODUCT_RETURN;
duke@0 327 static void print_method_statistics() PRODUCT_RETURN;
duke@0 328
duke@0 329 // Number of contained klasses
duke@0 330 // This is both fully loaded classes and classes in the process
duke@0 331 // of being loaded
duke@0 332 static int number_of_classes();
duke@0 333
duke@0 334 // Monotonically increasing counter which grows as classes are
duke@0 335 // loaded or modifications such as hot-swapping or setting/removing
duke@0 336 // of breakpoints are performed
duke@0 337 static inline int number_of_modifications() { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
duke@0 338 // Needed by evolution and breakpoint code
duke@0 339 static inline void notice_modification() { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications; }
duke@0 340
duke@0 341 // Verification
duke@0 342 static void verify();
duke@0 343
duke@0 344 #ifdef ASSERT
duke@0 345 static bool is_internal_format(symbolHandle class_name);
duke@0 346 #endif
duke@0 347
duke@0 348 // Verify class is in dictionary
duke@0 349 static void verify_obj_klass_present(Handle obj,
duke@0 350 symbolHandle class_name,
duke@0 351 Handle class_loader);
duke@0 352
duke@0 353 // Initialization
duke@0 354 static void initialize(TRAPS);
duke@0 355
duke@0 356 // Fast access to commonly used classes (preloaded)
duke@0 357 static klassOop check_klass(klassOop k) {
duke@0 358 assert(k != NULL, "preloaded klass not initialized");
duke@0 359 return k;
duke@0 360 }
duke@0 361
jrose@132 362 static klassOop check_klass_Pre(klassOop k) { return check_klass(k); }
jrose@132 363 static klassOop check_klass_Opt(klassOop k) { return k; }
jrose@132 364 static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt
jrose@132 365 static klassOop check_klass_Opt_Only_JDK15(klassOop k) {
jrose@132 366 assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
jrose@132 367 return k;
jrose@132 368 }
jrose@132 369 static klassOop check_klass_Opt_Only_JDK14NewRef(klassOop k) {
duke@0 370 assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
jrose@132 371 // despite the optional loading, if you use this it must be present:
jrose@132 372 return check_klass(k);
duke@0 373 }
duke@0 374
jrose@132 375 static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
jrose@132 376 static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
jrose@132 377 static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
jrose@132 378 int limit = (int)end_id + 1;
jrose@132 379 initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
jrose@132 380 }
duke@0 381
jrose@132 382 public:
jrose@132 383 #define WK_KLASS_DECLARE(name, ignore_symbol, option) \
jrose@132 384 static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
jrose@132 385 WK_KLASSES_DO(WK_KLASS_DECLARE);
jrose@132 386 #undef WK_KLASS_DECLARE
duke@0 387
jrose@132 388 // Local definition for direct access to the private array:
jrose@147 389 #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
duke@0 390
duke@0 391 static klassOop box_klass(BasicType t) {
duke@0 392 assert((uint)t < T_VOID+1, "range check");
duke@0 393 return check_klass(_box_klasses[t]);
duke@0 394 }
duke@0 395 static BasicType box_klass_type(klassOop k); // inverse of box_klass
duke@0 396
duke@0 397 // methods returning lazily loaded klasses
duke@0 398 // The corresponding method to load the class must be called before calling them.
duke@0 399 static klassOop abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); }
duke@0 400
duke@0 401 static void load_abstract_ownable_synchronizer_klass(TRAPS);
duke@0 402
duke@0 403 private:
duke@0 404 // Tells whether ClassLoader.loadClassInternal is present
duke@0 405 static bool has_loadClassInternal() { return _has_loadClassInternal; }
duke@0 406
duke@0 407 public:
duke@0 408 // Tells whether ClassLoader.checkPackageAccess is present
duke@0 409 static bool has_checkPackageAccess() { return _has_checkPackageAccess; }
duke@0 410
jrose@132 411 static bool class_klass_loaded() { return WK_KLASS(class_klass) != NULL; }
jrose@132 412 static bool cloneable_klass_loaded() { return WK_KLASS(cloneable_klass) != NULL; }
duke@0 413
duke@0 414 // Returns default system loader
duke@0 415 static oop java_system_loader();
duke@0 416
duke@0 417 // Compute the default system loader
duke@0 418 static void compute_java_system_loader(TRAPS);
duke@0 419
duke@0 420 private:
duke@0 421 // Mirrors for primitive classes (created eagerly)
duke@0 422 static oop check_mirror(oop m) {
duke@0 423 assert(m != NULL, "mirror not initialized");
duke@0 424 return m;
duke@0 425 }
duke@0 426
duke@0 427 public:
duke@0 428 // Note: java_lang_Class::primitive_type is the inverse of java_mirror
duke@0 429
duke@0 430 // Check class loader constraints
duke@0 431 static bool add_loader_constraint(symbolHandle name, Handle loader1,
duke@0 432 Handle loader2, TRAPS);
duke@0 433 static char* check_signature_loaders(symbolHandle signature, Handle loader1,
duke@0 434 Handle loader2, bool is_method, TRAPS);
duke@0 435
duke@0 436 // Utility for printing loader "name" as part of tracing constraints
duke@0 437 static const char* loader_name(oop loader) {
duke@0 438 return ((loader) == NULL ? "<bootloader>" :
duke@0 439 instanceKlass::cast((loader)->klass())->name()->as_C_string() );
duke@0 440 }
duke@0 441
duke@0 442 // Record the error when the first attempt to resolve a reference from a constant
duke@0 443 // pool entry to a class fails.
duke@0 444 static void add_resolution_error(constantPoolHandle pool, int which, symbolHandle error);
duke@0 445 static symbolOop find_resolution_error(constantPoolHandle pool, int which);
duke@0 446
duke@0 447 private:
duke@0 448
duke@0 449 enum Constants {
duke@0 450 _loader_constraint_size = 107, // number of entries in constraint table
duke@0 451 _resolution_error_size = 107, // number of entries in resolution error table
duke@0 452 _nof_buckets = 1009 // number of buckets in hash table
duke@0 453 };
duke@0 454
duke@0 455
duke@0 456 // Static variables
duke@0 457
duke@0 458 // Hashtable holding loaded classes.
duke@0 459 static Dictionary* _dictionary;
duke@0 460
duke@0 461 // Hashtable holding placeholders for classes being loaded.
duke@0 462 static PlaceholderTable* _placeholders;
duke@0 463
duke@0 464 // Hashtable holding classes from the shared archive.
duke@0 465 static Dictionary* _shared_dictionary;
duke@0 466
duke@0 467 // Monotonically increasing counter which grows with
duke@0 468 // _number_of_classes as well as hot-swapping and breakpoint setting
duke@0 469 // and removal.
duke@0 470 static int _number_of_modifications;
duke@0 471
duke@0 472 // Lock object for system class loader
duke@0 473 static oop _system_loader_lock_obj;
duke@0 474
duke@0 475 // Constraints on class loaders
duke@0 476 static LoaderConstraintTable* _loader_constraints;
duke@0 477
duke@0 478 // Resolution errors
duke@0 479 static ResolutionErrorTable* _resolution_errors;
duke@0 480
duke@0 481 public:
duke@0 482 // for VM_CounterDecay iteration support
duke@0 483 friend class CounterDecay;
duke@0 484 static klassOop try_get_next_class();
duke@0 485
duke@0 486 private:
duke@0 487 static void validate_protection_domain(instanceKlassHandle klass,
duke@0 488 Handle class_loader,
duke@0 489 Handle protection_domain, TRAPS);
duke@0 490
duke@0 491 friend class VM_PopulateDumpSharedSpace;
duke@0 492 friend class TraversePlaceholdersClosure;
duke@0 493 static Dictionary* dictionary() { return _dictionary; }
duke@0 494 static Dictionary* shared_dictionary() { return _shared_dictionary; }
duke@0 495 static PlaceholderTable* placeholders() { return _placeholders; }
duke@0 496 static LoaderConstraintTable* constraints() { return _loader_constraints; }
duke@0 497 static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
duke@0 498
duke@0 499 // Basic loading operations
duke@0 500 static klassOop resolve_instance_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
duke@0 501 static klassOop resolve_array_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
duke@0 502 static instanceKlassHandle handle_parallel_super_load(symbolHandle class_name, symbolHandle supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
duke@0 503 // Wait on SystemDictionary_lock; unlocks lockObject before
duke@0 504 // waiting; relocks lockObject with correct recursion count
duke@0 505 // after waiting, but before reentering SystemDictionary_lock
duke@0 506 // to preserve lock order semantics.
duke@0 507 static void double_lock_wait(Handle lockObject, TRAPS);
duke@0 508 static void define_instance_class(instanceKlassHandle k, TRAPS);
duke@0 509 static instanceKlassHandle find_or_define_instance_class(symbolHandle class_name,
duke@0 510 Handle class_loader,
duke@0 511 instanceKlassHandle k, TRAPS);
duke@0 512 static instanceKlassHandle load_shared_class(symbolHandle class_name,
duke@0 513 Handle class_loader, TRAPS);
duke@0 514 static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
duke@0 515 Handle class_loader, TRAPS);
duke@0 516 static instanceKlassHandle load_instance_class(symbolHandle class_name, Handle class_loader, TRAPS);
duke@0 517 static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
duke@0 518 static void check_loader_lock_contention(Handle loader_lock, TRAPS);
duke@0 519
duke@0 520 static klassOop find_shared_class(symbolHandle class_name);
duke@0 521
duke@0 522 // Setup link to hierarchy
duke@0 523 static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
duke@0 524
duke@0 525 private:
duke@0 526 // We pass in the hashtable index so we can calculate it outside of
duke@0 527 // the SystemDictionary_lock.
duke@0 528
duke@0 529 // Basic find on loaded classes
duke@0 530 static klassOop find_class(int index, unsigned int hash,
duke@0 531 symbolHandle name, Handle loader);
duke@0 532
duke@0 533 // Basic find on classes in the midst of being loaded
duke@0 534 static symbolOop find_placeholder(int index, unsigned int hash,
duke@0 535 symbolHandle name, Handle loader);
duke@0 536
duke@0 537 // Basic find operation of loaded classes and classes in the midst
duke@0 538 // of loading; used for assertions and verification only.
duke@0 539 static oop find_class_or_placeholder(symbolHandle class_name,
duke@0 540 Handle class_loader);
duke@0 541
duke@0 542 // Updating entry in dictionary
duke@0 543 // Add a completely loaded class
duke@0 544 static void add_klass(int index, symbolHandle class_name,
duke@0 545 Handle class_loader, KlassHandle obj);
duke@0 546
duke@0 547 // Add a placeholder for a class being loaded
duke@0 548 static void add_placeholder(int index,
duke@0 549 symbolHandle class_name,
duke@0 550 Handle class_loader);
duke@0 551 static void remove_placeholder(int index,
duke@0 552 symbolHandle class_name,
duke@0 553 Handle class_loader);
duke@0 554
duke@0 555 // Performs cleanups after resolve_super_or_fail. This typically needs
duke@0 556 // to be called on failure.
duke@0 557 // Won't throw, but can block.
duke@0 558 static void resolution_cleanups(symbolHandle class_name,
duke@0 559 Handle class_loader,
duke@0 560 TRAPS);
duke@0 561
duke@0 562 // Initialization
duke@0 563 static void initialize_preloaded_classes(TRAPS);
duke@0 564
duke@0 565 // Class loader constraints
duke@0 566 static void check_constraints(int index, unsigned int hash,
duke@0 567 instanceKlassHandle k, Handle loader,
duke@0 568 bool defining, TRAPS);
duke@0 569 static void update_dictionary(int d_index, unsigned int d_hash,
duke@0 570 int p_index, unsigned int p_hash,
duke@0 571 instanceKlassHandle k, Handle loader, TRAPS);
duke@0 572
duke@0 573 // Variables holding commonly used klasses (preloaded)
jrose@132 574 static klassOop _well_known_klasses[];
duke@0 575
duke@0 576 // Lazily loaded klasses
duke@0 577 static volatile klassOop _abstract_ownable_synchronizer_klass;
duke@0 578
jrose@132 579 // table of box klasses (int_klass, etc.)
duke@0 580 static klassOop _box_klasses[T_VOID+1];
duke@0 581
duke@0 582 static oop _java_system_loader;
duke@0 583
duke@0 584 static bool _has_loadClassInternal;
duke@0 585 static bool _has_checkPackageAccess;
duke@0 586 };