hotspot/src/share/vm/classfile/systemDictionary.hpp
changeset 13728 882756847a04
parent 13391 30245956af37
child 13929 8da0dc50a6e4
equal deleted inserted replaced
13727:caf5eb7dd4a7 13728:882756847a04
    34 #include "utilities/hashtable.hpp"
    34 #include "utilities/hashtable.hpp"
    35 #include "utilities/hashtable.inline.hpp"
    35 #include "utilities/hashtable.inline.hpp"
    36 
    36 
    37 // The system dictionary stores all loaded classes and maps:
    37 // The system dictionary stores all loaded classes and maps:
    38 //
    38 //
    39 //   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> klassOop
    39 //   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> Klass*
    40 //
    40 //
    41 // Classes are loaded lazily. The default VM class loader is
    41 // Classes are loaded lazily. The default VM class loader is
    42 // represented as NULL.
    42 // represented as NULL.
    43 
    43 
    44 // The underlying data structure is an open hash table with a fixed number
    44 // The underlying data structure is an open hash table with a fixed number
   182   /*end*/
   182   /*end*/
   183 
   183 
   184 
   184 
   185 class SystemDictionary : AllStatic {
   185 class SystemDictionary : AllStatic {
   186   friend class VMStructs;
   186   friend class VMStructs;
   187   friend class CompactingPermGenGen;
       
   188   friend class SystemDictionaryHandles;
   187   friend class SystemDictionaryHandles;
   189   NOT_PRODUCT(friend class instanceKlassKlass;)
       
   190 
   188 
   191  public:
   189  public:
   192   enum WKID {
   190   enum WKID {
   193     NO_WKID = 0,
   191     NO_WKID = 0,
   194 
   192 
   221   // class if needed. If not found a NoClassDefFoundError or a
   219   // class if needed. If not found a NoClassDefFoundError or a
   222   // ClassNotFoundException is thrown, depending on the value on the
   220   // ClassNotFoundException is thrown, depending on the value on the
   223   // throw_error flag.  For most uses the throw_error argument should be set
   221   // throw_error flag.  For most uses the throw_error argument should be set
   224   // to true.
   222   // to true.
   225 
   223 
   226   static klassOop resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
   224   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
   227   // Convenient call for null loader and protection domain.
   225   // Convenient call for null loader and protection domain.
   228   static klassOop resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
   226   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
   229 private:
   227 private:
   230   // handle error translation for resolve_or_null results
   228   // handle error translation for resolve_or_null results
   231   static klassOop handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
   229   static Klass* handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
   232 
   230 
   233 public:
   231 public:
   234 
   232 
   235   // Returns a class with a given class name and class loader.
   233   // Returns a class with a given class name and class loader.
   236   // Loads the class if needed. If not found NULL is returned.
   234   // Loads the class if needed. If not found NULL is returned.
   237   static klassOop resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   235   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   238   // Version with null loader and protection domain
   236   // Version with null loader and protection domain
   239   static klassOop resolve_or_null(Symbol* class_name, TRAPS);
   237   static Klass* resolve_or_null(Symbol* class_name, TRAPS);
   240 
   238 
   241   // Resolve a superclass or superinterface. Called from ClassFileParser,
   239   // Resolve a superclass or superinterface. Called from ClassFileParser,
   242   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
   240   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
   243   // "child_name" is the class whose super class or interface is being resolved.
   241   // "child_name" is the class whose super class or interface is being resolved.
   244   static klassOop resolve_super_or_fail(Symbol* child_name,
   242   static Klass* resolve_super_or_fail(Symbol* child_name,
   245                                         Symbol* class_name,
   243                                         Symbol* class_name,
   246                                         Handle class_loader,
   244                                         Handle class_loader,
   247                                         Handle protection_domain,
   245                                         Handle protection_domain,
   248                                         bool is_superclass,
   246                                         bool is_superclass,
   249                                         TRAPS);
   247                                         TRAPS);
   250 
   248 
   251   // Parse new stream. This won't update the system dictionary or
   249   // Parse new stream. This won't update the system dictionary or
   252   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
   250   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
   253   static klassOop parse_stream(Symbol* class_name,
   251   static Klass* parse_stream(Symbol* class_name,
   254                                Handle class_loader,
   252                                Handle class_loader,
   255                                Handle protection_domain,
   253                                Handle protection_domain,
   256                                ClassFileStream* st,
   254                                ClassFileStream* st,
   257                                TRAPS) {
   255                                TRAPS) {
   258     KlassHandle nullHandle;
   256     KlassHandle nullHandle;
   259     return parse_stream(class_name, class_loader, protection_domain, st, nullHandle, NULL, THREAD);
   257     return parse_stream(class_name, class_loader, protection_domain, st, nullHandle, NULL, THREAD);
   260   }
   258   }
   261   static klassOop parse_stream(Symbol* class_name,
   259   static Klass* parse_stream(Symbol* class_name,
   262                                Handle class_loader,
   260                                Handle class_loader,
   263                                Handle protection_domain,
   261                                Handle protection_domain,
   264                                ClassFileStream* st,
   262                                ClassFileStream* st,
   265                                KlassHandle host_klass,
   263                                KlassHandle host_klass,
   266                                GrowableArray<Handle>* cp_patches,
   264                                GrowableArray<Handle>* cp_patches,
   267                                TRAPS);
   265                                TRAPS);
   268 
   266 
   269   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
   267   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
   270   static klassOop resolve_from_stream(Symbol* class_name, Handle class_loader,
   268   static Klass* resolve_from_stream(Symbol* class_name, Handle class_loader,
   271                                       Handle protection_domain,
   269                                       Handle protection_domain,
   272                                       ClassFileStream* st, bool verify, TRAPS);
   270                                       ClassFileStream* st, bool verify, TRAPS);
   273 
   271 
   274   // Lookup an already loaded class. If not found NULL is returned.
   272   // Lookup an already loaded class. If not found NULL is returned.
   275   static klassOop find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   273   static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   276 
   274 
   277   // Lookup an already loaded instance or array class.
   275   // Lookup an already loaded instance or array class.
   278   // Do not make any queries to class loaders; consult only the cache.
   276   // Do not make any queries to class loaders; consult only the cache.
   279   // If not found NULL is returned.
   277   // If not found NULL is returned.
   280   static klassOop find_instance_or_array_klass(Symbol* class_name,
   278   static Klass* find_instance_or_array_klass(Symbol* class_name,
   281                                                Handle class_loader,
   279                                                Handle class_loader,
   282                                                Handle protection_domain,
   280                                                Handle protection_domain,
   283                                                TRAPS);
   281                                                TRAPS);
   284 
   282 
   285   // If the given name is known to vmSymbols, return the well-know klass:
   283   // If the given name is known to vmSymbols, return the well-know klass:
   286   static klassOop find_well_known_klass(Symbol* class_name);
   284   static Klass* find_well_known_klass(Symbol* class_name);
   287 
   285 
   288   // Lookup an instance or array class that has already been loaded
   286   // Lookup an instance or array class that has already been loaded
   289   // either into the given class loader, or else into another class
   287   // either into the given class loader, or else into another class
   290   // loader that is constrained (via loader constraints) to produce
   288   // loader that is constrained (via loader constraints) to produce
   291   // a consistent class.  Do not take protection domains into account.
   289   // a consistent class.  Do not take protection domains into account.
   304   //   4. Loading was attempted, but there was a linkage error of some sort.
   302   //   4. Loading was attempted, but there was a linkage error of some sort.
   305   // In all of these cases, the loader constraints on this type are
   303   // In all of these cases, the loader constraints on this type are
   306   // satisfied, and it is safe for classes in the given class loader
   304   // satisfied, and it is safe for classes in the given class loader
   307   // to manipulate strongly-typed values of the found class, subject
   305   // to manipulate strongly-typed values of the found class, subject
   308   // to local linkage and access checks.
   306   // to local linkage and access checks.
   309   static klassOop find_constrained_instance_or_array_klass(Symbol* class_name,
   307   static Klass* find_constrained_instance_or_array_klass(Symbol* class_name,
   310                                                            Handle class_loader,
   308                                                            Handle class_loader,
   311                                                            TRAPS);
   309                                                            TRAPS);
   312 
   310 
   313   // Iterate over all klasses in dictionary
   311   // Iterate over all klasses in dictionary
   314   //   Just the classes from defining class loaders
   312   //   Just the classes from defining class loaders
   315   static void classes_do(void f(klassOop));
   313   static void classes_do(void f(Klass*));
   316   // Added for initialize_itable_for_klass to handle exceptions
   314   // Added for initialize_itable_for_klass to handle exceptions
   317   static void classes_do(void f(klassOop, TRAPS), TRAPS);
   315   static void classes_do(void f(Klass*, TRAPS), TRAPS);
   318   //   All classes, and their class loaders
   316   //   All classes, and their class loaders
   319   static void classes_do(void f(klassOop, oop));
   317   static void classes_do(void f(Klass*, ClassLoaderData*));
   320   //   All classes, and their class loaders
   318   //   All classes, and their class loaders
   321   //   (added for helpers that use HandleMarks and ResourceMarks)
   319   //   (added for helpers that use HandleMarks and ResourceMarks)
   322   static void classes_do(void f(klassOop, oop, TRAPS), TRAPS);
   320   static void classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS);
   323   // All entries in the placeholder table and their class loaders
   321   // All entries in the placeholder table and their class loaders
   324   static void placeholders_do(void f(Symbol*, oop));
   322   static void placeholders_do(void f(Symbol*));
   325 
   323 
   326   // Iterate over all methods in all klasses in dictionary
   324   // Iterate over all methods in all klasses in dictionary
   327   static void methods_do(void f(methodOop));
   325   static void methods_do(void f(Method*));
   328 
   326 
   329   // Garbage collection support
   327   // Garbage collection support
   330 
   328 
   331   // This method applies "blk->do_oop" to all the pointers to "system"
   329   // This method applies "blk->do_oop" to all the pointers to "system"
   332   // classes and loaders.
   330   // classes and loaders.
   333   static void always_strong_oops_do(OopClosure* blk);
   331   static void always_strong_oops_do(OopClosure* blk);
   334   static void always_strong_classes_do(OopClosure* blk);
   332   static void always_strong_classes_do(KlassClosure* closure);
   335   // This method applies "blk->do_oop" to all the placeholders.
       
   336   static void placeholders_do(OopClosure* blk);
       
   337 
   333 
   338   // Unload (that is, break root links to) all unmarked classes and
   334   // Unload (that is, break root links to) all unmarked classes and
   339   // loaders.  Returns "true" iff something was unloaded.
   335   // loaders.  Returns "true" iff something was unloaded.
   340   static bool do_unloading(BoolObjectClosure* is_alive);
   336   static bool do_unloading(BoolObjectClosure* is_alive);
   341 
   337 
   346 
   342 
   347   // System loader lock
   343   // System loader lock
   348   static oop system_loader_lock()           { return _system_loader_lock_obj; }
   344   static oop system_loader_lock()           { return _system_loader_lock_obj; }
   349 
   345 
   350 private:
   346 private:
   351   //    Traverses preloaded oops: various system classes.  These are
   347   // Extended Redefine classes support (tbi)
   352   //    guaranteed to be in the perm gen.
   348   static void preloaded_classes_do(KlassClosure* f);
   353   static void preloaded_oops_do(OopClosure* f);
   349   static void lazily_loaded_classes_do(KlassClosure* f);
   354   static void lazily_loaded_oops_do(OopClosure* f);
       
   355 
       
   356 public:
   350 public:
   357   // Sharing support.
   351   // Sharing support.
   358   static void reorder_dictionary();
   352   static void reorder_dictionary();
   359   static void copy_buckets(char** top, char* end);
   353   static void copy_buckets(char** top, char* end);
   360   static void copy_table(char** top, char* end);
   354   static void copy_table(char** top, char* end);
   384 #ifdef ASSERT
   378 #ifdef ASSERT
   385   static bool is_internal_format(Symbol* class_name);
   379   static bool is_internal_format(Symbol* class_name);
   386 #endif
   380 #endif
   387 
   381 
   388   // Verify class is in dictionary
   382   // Verify class is in dictionary
   389   static void verify_obj_klass_present(Handle obj,
   383   static void verify_obj_klass_present(Symbol* class_name,
   390                                        Symbol* class_name,
   384                                        ClassLoaderData* loader_data);
   391                                        Handle class_loader);
       
   392 
   385 
   393   // Initialization
   386   // Initialization
   394   static void initialize(TRAPS);
   387   static void initialize(TRAPS);
   395 
   388 
   396   // Fast access to commonly used classes (preloaded)
   389   // Fast access to commonly used classes (preloaded)
   397   static klassOop check_klass(klassOop k) {
   390   static Klass* check_klass(Klass* k) {
   398     assert(k != NULL, "preloaded klass not initialized");
   391     assert(k != NULL, "preloaded klass not initialized");
   399     return k;
   392     return k;
   400   }
   393   }
   401 
   394 
   402   static klassOop check_klass_Pre(klassOop k) { return check_klass(k); }
   395   static Klass* check_klass_Pre(Klass* k) { return check_klass(k); }
   403   static klassOop check_klass_Pre_JSR292(klassOop k) { return EnableInvokeDynamic ? check_klass(k) : k; }
   396   static Klass* check_klass_Pre_JSR292(Klass* k) { return EnableInvokeDynamic ? check_klass(k) : k; }
   404   static klassOop check_klass_Opt(klassOop k) { return k; }
   397   static Klass* check_klass_Opt(Klass* k) { return k; }
   405   static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt
   398   static Klass* check_klass_Opt_Kernel(Klass* k) { return k; } //== Opt
   406   static klassOop check_klass_Opt_Only_JDK15(klassOop k) {
   399   static Klass* check_klass_Opt_Only_JDK15(Klass* k) {
   407     assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
   400     assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
   408     return k;
   401     return k;
   409   }
   402   }
   410   static klassOop check_klass_Opt_Only_JDK14NewRef(klassOop k) {
   403   static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) {
   411     assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
   404     assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
   412     // despite the optional loading, if you use this it must be present:
   405     // despite the optional loading, if you use this it must be present:
   413     return check_klass(k);
   406     return check_klass(k);
   414   }
   407   }
   415 
   408 
   420     initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
   413     initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
   421   }
   414   }
   422 
   415 
   423 public:
   416 public:
   424   #define WK_KLASS_DECLARE(name, symbol, option) \
   417   #define WK_KLASS_DECLARE(name, symbol, option) \
   425     static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
   418     static Klass* name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } \
       
   419     static Klass** name##_addr() {                                                                       \
       
   420       return &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)];           \
       
   421     }
   426   WK_KLASSES_DO(WK_KLASS_DECLARE);
   422   WK_KLASSES_DO(WK_KLASS_DECLARE);
   427   #undef WK_KLASS_DECLARE
   423   #undef WK_KLASS_DECLARE
   428 
   424 
   429   static klassOop well_known_klass(WKID id) {
   425   static Klass* well_known_klass(WKID id) {
   430     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
   426     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
   431     return _well_known_klasses[id];
   427     return _well_known_klasses[id];
   432   }
   428   }
   433 
   429 
       
   430   static Klass** well_known_klass_addr(WKID id) {
       
   431     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
       
   432     return &_well_known_klasses[id];
       
   433   }
       
   434 
   434   // Local definition for direct access to the private array:
   435   // Local definition for direct access to the private array:
   435   #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
   436   #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
   436 
   437 
   437   static klassOop box_klass(BasicType t) {
   438   static Klass* box_klass(BasicType t) {
   438     assert((uint)t < T_VOID+1, "range check");
   439     assert((uint)t < T_VOID+1, "range check");
   439     return check_klass(_box_klasses[t]);
   440     return check_klass(_box_klasses[t]);
   440   }
   441   }
   441   static BasicType box_klass_type(klassOop k);  // inverse of box_klass
   442   static BasicType box_klass_type(Klass* k);  // inverse of box_klass
   442 
   443 
   443   // methods returning lazily loaded klasses
   444   // methods returning lazily loaded klasses
   444   // The corresponding method to load the class must be called before calling them.
   445   // The corresponding method to load the class must be called before calling them.
   445   static klassOop abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); }
   446   static Klass* abstract_ownable_synchronizer_klass() { return check_klass(_abstract_ownable_synchronizer_klass); }
   446 
   447 
   447   static void load_abstract_ownable_synchronizer_klass(TRAPS);
   448   static void load_abstract_ownable_synchronizer_klass(TRAPS);
   448 
   449 
   449 private:
   450 private:
   450   // Tells whether ClassLoader.loadClassInternal is present
   451   // Tells whether ClassLoader.loadClassInternal is present
   451   static bool has_loadClassInternal()       { return _has_loadClassInternal; }
   452   static bool has_loadClassInternal()       { return _has_loadClassInternal; }
   452 
   453 
       
   454   // Returns the class loader data to be used when looking up/updating the
       
   455   // system dictionary.
       
   456   static ClassLoaderData *class_loader_data(Handle class_loader) {
       
   457     return ClassLoaderData::class_loader_data(class_loader());
       
   458   }
       
   459 
   453 public:
   460 public:
   454   // Tells whether ClassLoader.checkPackageAccess is present
   461   // Tells whether ClassLoader.checkPackageAccess is present
   455   static bool has_checkPackageAccess()      { return _has_checkPackageAccess; }
   462   static bool has_checkPackageAccess()      { return _has_checkPackageAccess; }
   456 
   463 
   457   static bool Class_klass_loaded()          { return WK_KLASS(Class_klass) != NULL; }
   464   static bool Class_klass_loaded()          { return WK_KLASS(Class_klass) != NULL; }
   458   static bool Cloneable_klass_loaded()      { return WK_KLASS(Cloneable_klass) != NULL; }
   465   static bool Cloneable_klass_loaded()      { return WK_KLASS(Cloneable_klass) != NULL; }
       
   466   static bool Object_klass_loaded()         { return WK_KLASS(Object_klass) != NULL; }
       
   467   static bool ClassLoader_klass_loaded()    { return WK_KLASS(ClassLoader_klass) != NULL; }
   459 
   468 
   460   // Returns default system loader
   469   // Returns default system loader
   461   static oop java_system_loader();
   470   static oop java_system_loader();
   462 
   471 
   463   // Compute the default system loader
   472   // Compute the default system loader
   464   static void compute_java_system_loader(TRAPS);
   473   static void compute_java_system_loader(TRAPS);
   465 
   474 
       
   475   // Register a new class loader
       
   476   static ClassLoaderData* register_loader(Handle class_loader);
   466 private:
   477 private:
   467   // Mirrors for primitive classes (created eagerly)
   478   // Mirrors for primitive classes (created eagerly)
   468   static oop check_mirror(oop m) {
   479   static oop check_mirror(oop m) {
   469     assert(m != NULL, "mirror not initialized");
   480     assert(m != NULL, "mirror not initialized");
   470     return m;
   481     return m;
   515                                                      TRAPS);
   526                                                      TRAPS);
   516 
   527 
   517   // Utility for printing loader "name" as part of tracing constraints
   528   // Utility for printing loader "name" as part of tracing constraints
   518   static const char* loader_name(oop loader) {
   529   static const char* loader_name(oop loader) {
   519     return ((loader) == NULL ? "<bootloader>" :
   530     return ((loader) == NULL ? "<bootloader>" :
   520             instanceKlass::cast((loader)->klass())->name()->as_C_string() );
   531             InstanceKlass::cast((loader)->klass())->name()->as_C_string() );
       
   532   }
       
   533   static const char* loader_name(ClassLoaderData* loader_data) {
       
   534     return (loader_data->is_the_null_class_loader_data() ? "<bootloader>" :
       
   535             InstanceKlass::cast((loader_data->class_loader())->klass())->name()->as_C_string() );
   521   }
   536   }
   522 
   537 
   523   // Record the error when the first attempt to resolve a reference from a constant
   538   // Record the error when the first attempt to resolve a reference from a constant
   524   // pool entry to a class fails.
   539   // pool entry to a class fails.
   525   static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
   540   static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
       
   541   static void delete_resolution_error(ConstantPool* pool);
   526   static Symbol* find_resolution_error(constantPoolHandle pool, int which);
   542   static Symbol* find_resolution_error(constantPoolHandle pool, int which);
   527 
   543 
   528  private:
   544  private:
   529 
   545 
   530   enum Constants {
   546   enum Constants {
   572   static SymbolPropertyTable*    _invoke_method_table;
   588   static SymbolPropertyTable*    _invoke_method_table;
   573 
   589 
   574 public:
   590 public:
   575   // for VM_CounterDecay iteration support
   591   // for VM_CounterDecay iteration support
   576   friend class CounterDecay;
   592   friend class CounterDecay;
   577   static klassOop try_get_next_class();
   593   static Klass* try_get_next_class();
   578 
   594 
   579 private:
   595 private:
   580   static void validate_protection_domain(instanceKlassHandle klass,
   596   static void validate_protection_domain(instanceKlassHandle klass,
   581                                          Handle class_loader,
   597                                          Handle class_loader,
   582                                          Handle protection_domain, TRAPS);
   598                                          Handle protection_domain, TRAPS);
   589   static LoaderConstraintTable* constraints() { return _loader_constraints; }
   605   static LoaderConstraintTable* constraints() { return _loader_constraints; }
   590   static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
   606   static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
   591   static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
   607   static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
   592 
   608 
   593   // Basic loading operations
   609   // Basic loading operations
   594   static klassOop resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   610   static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   595   static klassOop resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   611   static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   596   static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
   612   static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
   597   // Wait on SystemDictionary_lock; unlocks lockObject before
   613   // Wait on SystemDictionary_lock; unlocks lockObject before
   598   // waiting; relocks lockObject with correct recursion count
   614   // waiting; relocks lockObject with correct recursion count
   599   // after waiting, but before reentering SystemDictionary_lock
   615   // after waiting, but before reentering SystemDictionary_lock
   600   // to preserve lock order semantics.
   616   // to preserve lock order semantics.
   611   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
   627   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
   612   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
   628   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
   613   static bool is_parallelCapable(Handle class_loader);
   629   static bool is_parallelCapable(Handle class_loader);
   614   static bool is_parallelDefine(Handle class_loader);
   630   static bool is_parallelDefine(Handle class_loader);
   615 
   631 
   616   static klassOop find_shared_class(Symbol* class_name);
   632   static Klass* find_shared_class(Symbol* class_name);
   617 
   633 
   618   // Setup link to hierarchy
   634   // Setup link to hierarchy
   619   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
   635   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
   620 
   636 
   621 private:
   637 private:
   622   // We pass in the hashtable index so we can calculate it outside of
   638   // We pass in the hashtable index so we can calculate it outside of
   623   // the SystemDictionary_lock.
   639   // the SystemDictionary_lock.
   624 
   640 
   625   // Basic find on loaded classes
   641   // Basic find on loaded classes
   626   static klassOop find_class(int index, unsigned int hash,
   642   static Klass* find_class(int index, unsigned int hash,
   627                              Symbol* name, Handle loader);
   643                              Symbol* name, ClassLoaderData* loader_data);
   628   static klassOop find_class(Symbol* class_name, Handle class_loader);
   644   static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
   629 
   645 
   630   // Basic find on classes in the midst of being loaded
   646   // Basic find on classes in the midst of being loaded
   631   static Symbol* find_placeholder(Symbol* name, Handle loader);
   647   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
   632 
   648 
   633   // Updating entry in dictionary
   649   // Updating entry in dictionary
   634   // Add a completely loaded class
   650   // Add a completely loaded class
   635   static void add_klass(int index, Symbol* class_name,
   651   static void add_klass(int index, Symbol* class_name,
   636                         Handle class_loader, KlassHandle obj);
   652                         ClassLoaderData* loader_data, KlassHandle obj);
   637 
   653 
   638   // Add a placeholder for a class being loaded
   654   // Add a placeholder for a class being loaded
   639   static void add_placeholder(int index,
   655   static void add_placeholder(int index,
   640                               Symbol* class_name,
   656                               Symbol* class_name,
   641                               Handle class_loader);
   657                               ClassLoaderData* loader_data);
   642   static void remove_placeholder(int index,
   658   static void remove_placeholder(int index,
   643                                  Symbol* class_name,
   659                                  Symbol* class_name,
   644                                  Handle class_loader);
   660                                  ClassLoaderData* loader_data);
   645 
   661 
   646   // Performs cleanups after resolve_super_or_fail. This typically needs
   662   // Performs cleanups after resolve_super_or_fail. This typically needs
   647   // to be called on failure.
   663   // to be called on failure.
   648   // Won't throw, but can block.
   664   // Won't throw, but can block.
   649   static void resolution_cleanups(Symbol* class_name,
   665   static void resolution_cleanups(Symbol* class_name,
   650                                   Handle class_loader,
   666                                   ClassLoaderData* loader_data,
   651                                   TRAPS);
   667                                   TRAPS);
   652 
   668 
   653   // Initialization
   669   // Initialization
   654   static void initialize_preloaded_classes(TRAPS);
   670   static void initialize_preloaded_classes(TRAPS);
   655 
   671 
   657   static void check_constraints(int index, unsigned int hash,
   673   static void check_constraints(int index, unsigned int hash,
   658                                 instanceKlassHandle k, Handle loader,
   674                                 instanceKlassHandle k, Handle loader,
   659                                 bool defining, TRAPS);
   675                                 bool defining, TRAPS);
   660   static void update_dictionary(int d_index, unsigned int d_hash,
   676   static void update_dictionary(int d_index, unsigned int d_hash,
   661                                 int p_index, unsigned int p_hash,
   677                                 int p_index, unsigned int p_hash,
   662                                 instanceKlassHandle k, Handle loader, TRAPS);
   678                                 instanceKlassHandle k, Handle loader,
       
   679                                 TRAPS);
   663 
   680 
   664   // Variables holding commonly used klasses (preloaded)
   681   // Variables holding commonly used klasses (preloaded)
   665   static klassOop _well_known_klasses[];
   682   static Klass* _well_known_klasses[];
   666 
   683 
   667   // Lazily loaded klasses
   684   // Lazily loaded klasses
   668   static volatile klassOop _abstract_ownable_synchronizer_klass;
   685   static Klass* volatile _abstract_ownable_synchronizer_klass;
   669 
   686 
   670   // table of box klasses (int_klass, etc.)
   687   // table of box klasses (int_klass, etc.)
   671   static klassOop _box_klasses[T_VOID+1];
   688   static Klass* _box_klasses[T_VOID+1];
   672 
   689 
   673   static oop  _java_system_loader;
   690   static oop  _java_system_loader;
   674 
   691 
   675   static bool _has_loadClassInternal;
   692   static bool _has_loadClassInternal;
   676   static bool _has_checkPackageAccess;
   693   static bool _has_checkPackageAccess;
   677 };
   694 };
   678 
   695 
   679 class SystemDictionaryHandles : AllStatic {
       
   680 public:
       
   681   #define WK_KLASS_HANDLE_DECLARE(name, ignore_symbol, option) \
       
   682     static KlassHandle name() { \
       
   683       SystemDictionary::name(); \
       
   684       klassOop* loc = &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]; \
       
   685       return KlassHandle(loc, true); \
       
   686     }
       
   687   WK_KLASSES_DO(WK_KLASS_HANDLE_DECLARE);
       
   688   #undef WK_KLASS_HANDLE_DECLARE
       
   689 
       
   690   static KlassHandle box_klass(BasicType t);
       
   691 };
       
   692 
       
   693 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
   696 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP