< prev index next >

src/share/vm/classfile/systemDictionary.hpp

Print this page




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  27 
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/systemDictionary_ext.hpp"
  30 #include "jvmci/systemDictionary_jvmci.hpp"
  31 #include "oops/objArrayOop.hpp"
  32 #include "oops/symbol.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/reflectionUtils.hpp"
  35 #include "utilities/hashtable.hpp"
  36 #include "utilities/hashtable.inline.hpp"
  37 
  38 // The system dictionary stores all loaded classes and maps:

  39 //
  40 //   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> Klass*
  41 //
  42 // Classes are loaded lazily. The default VM class loader is
  43 // represented as NULL.
  44 
  45 // The underlying data structure is an open hash table with a fixed number
  46 // of buckets. During loading the loader object is locked, (for the VM loader
  47 // a private lock object is used). Class loading can thus be done concurrently,
  48 // but only by different loaders.


  49 //
  50 // During loading a placeholder (name, loader) is temporarily placed in
  51 // a side data structure, and is used to detect ClassCircularityErrors
  52 // and to perform verification during GC.  A GC can occur in the midst
  53 // of class loading, as we call out to Java, have to take locks, etc.
  54 //
  55 // When class loading is finished, a new entry is added to the system
  56 // dictionary and the place holder is removed. Note that the protection
  57 // domain field of the system dictionary has not yet been filled in when
  58 // the "real" system dictionary entry is created.
  59 //
  60 // Clients of this class who are interested in finding if a class has
  61 // been completely loaded -- not classes in the process of being loaded --
  62 // can read the SystemDictionary unlocked. This is safe because
  63 //    - entries are only deleted at safepoints
  64 //    - readers cannot come to a safepoint while actively examining
  65 //         an entry  (an entry cannot be deleted from under a reader)
  66 //    - entries must be fully formed before they are available to concurrent
  67 //         readers (we must ensure write ordering)
  68 //
  69 // Note that placeholders are deleted at any time, as they are removed
  70 // when a class is completely loaded. Therefore, readers as well as writers
  71 // of placeholders must hold the SystemDictionary_lock.
  72 //
  73 
  74 class ClassFileStream;
  75 class Dictionary;
  76 class PlaceholderTable;
  77 class LoaderConstraintTable;
  78 template <MEMFLAGS F> class HashtableBucket;
  79 class ResolutionErrorTable;
  80 class SymbolPropertyTable;


  81 class GCTimer;
  82 
  83 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  84 // They are all "well-known", in the sense that no class loader is allowed
  85 // to provide a different definition.
  86 //
  87 // These klasses must all have names defined in vmSymbols.
  88 
  89 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  90 
  91 // Each well-known class has a short klass name (like object_klass),
  92 // a vmSymbol name (like java_lang_Object), and a flag word
  93 // that makes some minor distinctions, like whether the klass
  94 // is preloaded, optional, release-specific, etc.
  95 // The order of these definitions is significant; it is the order in which
  96 // preloading is actually performed by initialize_preloaded_classes.
  97 
  98 #define WK_KLASSES_DO(do_klass)                                                                                          \
  99   /* well-known classes */                                                                                               \
 100   do_klass(Object_klass,                                java_lang_Object,                          Pre                 ) \


 264   static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS);
 265 
 266 public:
 267 
 268   // Returns a class with a given class name and class loader.
 269   // Loads the class if needed. If not found NULL is returned.
 270   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 271   // Version with null loader and protection domain
 272   static Klass* resolve_or_null(Symbol* class_name, TRAPS);
 273 
 274   // Resolve a superclass or superinterface. Called from ClassFileParser,
 275   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
 276   // "child_name" is the class whose super class or interface is being resolved.
 277   static Klass* resolve_super_or_fail(Symbol* child_name,
 278                                       Symbol* class_name,
 279                                       Handle class_loader,
 280                                       Handle protection_domain,
 281                                       bool is_superclass,
 282                                       TRAPS);
 283 
 284   // Parse new stream. This won't update the system dictionary or
 285   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
 286   // Also used by Unsafe_DefineAnonymousClass
 287   static InstanceKlass* parse_stream(Symbol* class_name,
 288                                      Handle class_loader,
 289                                      Handle protection_domain,
 290                                      ClassFileStream* st,
 291                                      TRAPS) {
 292     return parse_stream(class_name,
 293                         class_loader,
 294                         protection_domain,
 295                         st,
 296                         NULL, // host klass
 297                         NULL, // cp_patches
 298                         THREAD);
 299   }
 300   static InstanceKlass* parse_stream(Symbol* class_name,
 301                                      Handle class_loader,
 302                                      Handle protection_domain,
 303                                      ClassFileStream* st,
 304                                      const InstanceKlass* host_klass,


 331   // Return NULL if the class is not found.
 332   //
 333   // This function is a strict superset of find_instance_or_array_klass.
 334   // This function (the unchecked version) makes a conservative prediction
 335   // of the result of the checked version, assuming successful lookup.
 336   // If both functions return non-null, they must return the same value.
 337   // Also, the unchecked version may sometimes be non-null where the
 338   // checked version is null.  This can occur in several ways:
 339   //   1. No query has yet been made to the class loader.
 340   //   2. The class loader was queried, but chose not to delegate.
 341   //   3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
 342   //   4. Loading was attempted, but there was a linkage error of some sort.
 343   // In all of these cases, the loader constraints on this type are
 344   // satisfied, and it is safe for classes in the given class loader
 345   // to manipulate strongly-typed values of the found class, subject
 346   // to local linkage and access checks.
 347   static Klass* find_constrained_instance_or_array_klass(Symbol* class_name,
 348                                                            Handle class_loader,
 349                                                            TRAPS);
 350 
 351   // Iterate over all klasses in dictionary
 352   // Just the classes from defining class loaders
 353   static void classes_do(void f(Klass*));
 354   // Added for initialize_itable_for_klass to handle exceptions
 355   static void classes_do(void f(Klass*, TRAPS), TRAPS);
 356   // All classes, and their class loaders, including initiating class loaders
 357   static void classes_do(void f(Klass*, ClassLoaderData*));
 358 
 359   // Iterate over all methods in all klasses
 360   static void methods_do(void f(Method*));
 361 
 362   // Garbage collection support
 363 
 364   // This method applies "blk->do_oop" to all the pointers to "system"
 365   // classes and loaders.
 366   static void always_strong_oops_do(OopClosure* blk);
 367 
 368   // Unload (that is, break root links to) all unmarked classes and
 369   // loaders.  Returns "true" iff something was unloaded.
 370   static bool do_unloading(BoolObjectClosure* is_alive,
 371                            GCTimer* gc_timer,
 372                            bool do_cleaning = true);
 373 
 374   // Used by DumpSharedSpaces only to remove classes that failed verification
 375   static void remove_classes_in_error_state();
 376 
 377   static int calculate_systemdictionary_size(int loadedclasses);
 378 
 379   // Applies "f->do_oop" to all root oops in the system dictionary.
 380   static void oops_do(OopClosure* f);
 381   static void roots_oops_do(OopClosure* strong, OopClosure* weak);
 382 
 383   // System loader lock
 384   static oop system_loader_lock()           { return _system_loader_lock_obj; }
 385 
 386 public:
 387   // Sharing support.
 388   static void reorder_dictionary();
 389   static void copy_buckets(char** top, char* end);
 390   static void copy_table(char** top, char* end);
 391   static void set_shared_dictionary(HashtableBucket<mtClass>* t, int length,
 392                                     int number_of_entries);
 393   // Printing
 394   static void print(bool details = true);
 395   static void print_shared(bool details = true);
 396 
 397   // Number of contained klasses
 398   // This is both fully loaded classes and classes in the process
 399   // of being loaded
 400   static int number_of_classes();
 401 
 402   // Monotonically increasing counter which grows as classes are
 403   // loaded or modifications such as hot-swapping or setting/removing
 404   // of breakpoints are performed
 405   static inline int number_of_modifications()     { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
 406   // Needed by evolution and breakpoint code
 407   static inline void notice_modification()        { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications;      }
 408 
 409   // Verification
 410   static void verify();
 411 
 412   // Initialization
 413   static void initialize(TRAPS);
 414 
 415   // Checked fast access to commonly used classes - mostly preloaded
 416   static InstanceKlass* check_klass(InstanceKlass* k) {
 417     assert(k != NULL, "klass not loaded");
 418     return k;
 419   }
 420 
 421   static InstanceKlass* check_klass_Pre(InstanceKlass* k) { return check_klass(k); }


 541   static methodHandle find_dynamic_call_site_invoker(Klass* caller,
 542                                                      Handle bootstrap_method,
 543                                                      Symbol* name,
 544                                                      Symbol* type,
 545                                                      Handle *appendix_result,
 546                                                      Handle *method_type_result,
 547                                                      TRAPS);
 548 
 549   // Utility for printing loader "name" as part of tracing constraints
 550   static const char* loader_name(const oop loader);
 551   static const char* loader_name(const ClassLoaderData* loader_data);
 552 
 553   // Record the error when the first attempt to resolve a reference from a constant
 554   // pool entry to a class fails.
 555   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
 556                                    Symbol* message);
 557   static void delete_resolution_error(ConstantPool* pool);
 558   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
 559                                        Symbol** message);
 560 



 561  protected:
 562 
 563   enum Constants {
 564     _loader_constraint_size = 107,                     // number of entries in constraint table
 565     _resolution_error_size  = 107,                     // number of entries in resolution error table
 566     _invoke_method_size     = 139,                     // number of entries in invoke method table
 567     _nof_buckets            = 1009,                    // number of buckets in hash table for placeholders
 568     _old_default_sdsize     = 1009,                    // backward compat for system dictionary size
 569     _prime_array_size       = 8,                       // array of primes for system dictionary size
 570     _average_depth_goal     = 3                        // goal for lookup length
 571   };
 572 
 573 
 574   // Static variables
 575 
 576   // hashtable sizes for system dictionary to allow growth
 577   // prime numbers for system dictionary size
 578   static int                     _sdgeneration;
 579   static const int               _primelist[_prime_array_size];
 580 
 581   // Hashtable holding loaded classes.
 582   static Dictionary*            _dictionary;
 583 
 584   // Hashtable holding placeholders for classes being loaded.
 585   static PlaceholderTable*       _placeholders;
 586 
 587   // Hashtable holding classes from the shared archive.
 588   static Dictionary*             _shared_dictionary;
 589 
 590   // Monotonically increasing counter which grows with
 591   // _number_of_classes as well as hot-swapping and breakpoint setting
 592   // and removal.
 593   static int                     _number_of_modifications;
 594 
 595   // Lock object for system class loader
 596   static oop                     _system_loader_lock_obj;
 597 
 598   // Constraints on class loaders
 599   static LoaderConstraintTable*  _loader_constraints;
 600 
 601   // Resolution errors
 602   static ResolutionErrorTable*   _resolution_errors;
 603 
 604   // Invoke methods (JSR 292)
 605   static SymbolPropertyTable*    _invoke_method_table;
 606 
 607 public:
 608   // for VM_CounterDecay iteration support
 609   friend class CounterDecay;
 610   static Klass* try_get_next_class();
 611 
 612 protected:
 613   static void validate_protection_domain(InstanceKlass* klass,
 614                                          Handle class_loader,
 615                                          Handle protection_domain, TRAPS);
 616 
 617   friend class VM_PopulateDumpSharedSpace;
 618   friend class TraversePlaceholdersClosure;
 619   static Dictionary*         dictionary() { return _dictionary; }
 620   static Dictionary*         shared_dictionary() { return _shared_dictionary; }
 621   static PlaceholderTable*   placeholders() { return _placeholders; }
 622   static LoaderConstraintTable* constraints() { return _loader_constraints; }
 623   static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
 624   static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
 625 
 626   // Basic loading operations
 627   static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 628   static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 629   static InstanceKlass* handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
 630   // Wait on SystemDictionary_lock; unlocks lockObject before
 631   // waiting; relocks lockObject with correct recursion count
 632   // after waiting, but before reentering SystemDictionary_lock
 633   // to preserve lock order semantics.
 634   static void double_lock_wait(Handle lockObject, TRAPS);
 635   static void define_instance_class(InstanceKlass* k, TRAPS);
 636   static InstanceKlass* find_or_define_instance_class(Symbol* class_name,
 637                                                 Handle class_loader,
 638                                                 InstanceKlass* k, TRAPS);
 639   static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik,


 649   static bool is_parallelDefine(Handle class_loader);
 650 
 651 public:
 652   static InstanceKlass* load_shared_class(Symbol* class_name,
 653                                           Handle class_loader,
 654                                           TRAPS);
 655   static bool is_system_class_loader(oop class_loader);
 656   static bool is_platform_class_loader(oop class_loader);
 657 
 658 protected:
 659   static InstanceKlass* find_shared_class(Symbol* class_name);
 660 
 661   // Setup link to hierarchy
 662   static void add_to_hierarchy(InstanceKlass* k, TRAPS);
 663 
 664   // We pass in the hashtable index so we can calculate it outside of
 665   // the SystemDictionary_lock.
 666 
 667   // Basic find on loaded classes
 668   static InstanceKlass* find_class(int index, unsigned int hash,
 669                                    Symbol* name, ClassLoaderData* loader_data);
 670   static InstanceKlass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
 671 
 672   // Basic find on classes in the midst of being loaded
 673   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
 674 
 675   // Add a placeholder for a class being loaded
 676   static void add_placeholder(int index,
 677                               Symbol* class_name,
 678                               ClassLoaderData* loader_data);
 679   static void remove_placeholder(int index,
 680                                  Symbol* class_name,
 681                                  ClassLoaderData* loader_data);
 682 
 683   // Performs cleanups after resolve_super_or_fail. This typically needs
 684   // to be called on failure.
 685   // Won't throw, but can block.
 686   static void resolution_cleanups(Symbol* class_name,
 687                                   ClassLoaderData* loader_data,
 688                                   TRAPS);
 689 




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  27 
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/systemDictionary_ext.hpp"
  30 #include "jvmci/systemDictionary_jvmci.hpp"
  31 #include "oops/objArrayOop.hpp"
  32 #include "oops/symbol.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/reflectionUtils.hpp"
  35 #include "utilities/hashtable.hpp"
  36 #include "utilities/hashtable.inline.hpp"
  37 
  38 // The dictionary in each ClassLoaderData stores all loaded classes, either
  39 // initiatied by its class loader or defined by its class loader:
  40 //
  41 //   class loader -> ClassLoaderData -> [class, protection domain set]
  42 //
  43 // Classes are loaded lazily. The default VM class loader is
  44 // represented as NULL.
  45 
  46 // The underlying data structure is an open hash table (Dictionary) per
  47 // ClassLoaderData with a fixed number of buckets. During loading the
  48 // class loader object is locked, (for the VM loader a private lock object is used).
  49 // The global SystemDictionary_lock is held for all additions into the ClassLoaderData
  50 // dictionaries.  TODO: fix lock granularity so that class loading can
  51 // be done concurrently, but only by different loaders.
  52 //
  53 // During loading a placeholder (name, loader) is temporarily placed in
  54 // a side data structure, and is used to detect ClassCircularityErrors
  55 // and to perform verification during GC.  A GC can occur in the midst
  56 // of class loading, as we call out to Java, have to take locks, etc.
  57 //
  58 // When class loading is finished, a new entry is added to the dictionary
  59 // of the class loader and the place holder is removed. Note that the protection
  60 // domain field of the dictionary entry has not yet been filled in when
  61 // the "real" dictionary entry is created.
  62 //
  63 // Clients of this class who are interested in finding if a class has
  64 // been completely loaded -- not classes in the process of being loaded --
  65 // can read the dictionary unlocked. This is safe because
  66 //    - entries are only deleted at safepoints
  67 //    - readers cannot come to a safepoint while actively examining
  68 //         an entry  (an entry cannot be deleted from under a reader)
  69 //    - entries must be fully formed before they are available to concurrent
  70 //         readers (we must ensure write ordering)
  71 //
  72 // Note that placeholders are deleted at any time, as they are removed
  73 // when a class is completely loaded. Therefore, readers as well as writers
  74 // of placeholders must hold the SystemDictionary_lock.
  75 //
  76 
  77 class ClassFileStream;
  78 class Dictionary;
  79 class PlaceholderTable;
  80 class LoaderConstraintTable;
  81 template <MEMFLAGS F> class HashtableBucket;
  82 class ResolutionErrorTable;
  83 class SymbolPropertyTable;
  84 class ProtectionDomainCacheTable;
  85 class ProtectionDomainCacheEntry;
  86 class GCTimer;
  87 
  88 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  89 // They are all "well-known", in the sense that no class loader is allowed
  90 // to provide a different definition.
  91 //
  92 // These klasses must all have names defined in vmSymbols.
  93 
  94 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  95 
  96 // Each well-known class has a short klass name (like object_klass),
  97 // a vmSymbol name (like java_lang_Object), and a flag word
  98 // that makes some minor distinctions, like whether the klass
  99 // is preloaded, optional, release-specific, etc.
 100 // The order of these definitions is significant; it is the order in which
 101 // preloading is actually performed by initialize_preloaded_classes.
 102 
 103 #define WK_KLASSES_DO(do_klass)                                                                                          \
 104   /* well-known classes */                                                                                               \
 105   do_klass(Object_klass,                                java_lang_Object,                          Pre                 ) \


 269   static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS);
 270 
 271 public:
 272 
 273   // Returns a class with a given class name and class loader.
 274   // Loads the class if needed. If not found NULL is returned.
 275   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 276   // Version with null loader and protection domain
 277   static Klass* resolve_or_null(Symbol* class_name, TRAPS);
 278 
 279   // Resolve a superclass or superinterface. Called from ClassFileParser,
 280   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
 281   // "child_name" is the class whose super class or interface is being resolved.
 282   static Klass* resolve_super_or_fail(Symbol* child_name,
 283                                       Symbol* class_name,
 284                                       Handle class_loader,
 285                                       Handle protection_domain,
 286                                       bool is_superclass,
 287                                       TRAPS);
 288 
 289   // Parse new stream. This won't update the dictionary or
 290   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
 291   // Also used by Unsafe_DefineAnonymousClass
 292   static InstanceKlass* parse_stream(Symbol* class_name,
 293                                      Handle class_loader,
 294                                      Handle protection_domain,
 295                                      ClassFileStream* st,
 296                                      TRAPS) {
 297     return parse_stream(class_name,
 298                         class_loader,
 299                         protection_domain,
 300                         st,
 301                         NULL, // host klass
 302                         NULL, // cp_patches
 303                         THREAD);
 304   }
 305   static InstanceKlass* parse_stream(Symbol* class_name,
 306                                      Handle class_loader,
 307                                      Handle protection_domain,
 308                                      ClassFileStream* st,
 309                                      const InstanceKlass* host_klass,


 336   // Return NULL if the class is not found.
 337   //
 338   // This function is a strict superset of find_instance_or_array_klass.
 339   // This function (the unchecked version) makes a conservative prediction
 340   // of the result of the checked version, assuming successful lookup.
 341   // If both functions return non-null, they must return the same value.
 342   // Also, the unchecked version may sometimes be non-null where the
 343   // checked version is null.  This can occur in several ways:
 344   //   1. No query has yet been made to the class loader.
 345   //   2. The class loader was queried, but chose not to delegate.
 346   //   3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
 347   //   4. Loading was attempted, but there was a linkage error of some sort.
 348   // In all of these cases, the loader constraints on this type are
 349   // satisfied, and it is safe for classes in the given class loader
 350   // to manipulate strongly-typed values of the found class, subject
 351   // to local linkage and access checks.
 352   static Klass* find_constrained_instance_or_array_klass(Symbol* class_name,
 353                                                            Handle class_loader,
 354                                                            TRAPS);
 355 








 356   // Iterate over all methods in all klasses
 357   static void methods_do(void f(Method*));
 358 
 359   // Garbage collection support
 360 
 361   // This method applies "blk->do_oop" to all the pointers to "system"
 362   // classes and loaders.
 363   static void always_strong_oops_do(OopClosure* blk);
 364 
 365   // Unload (that is, break root links to) all unmarked classes and
 366   // loaders.  Returns "true" iff something was unloaded.
 367   static bool do_unloading(BoolObjectClosure* is_alive,
 368                            GCTimer* gc_timer,
 369                            bool do_cleaning = true);
 370 
 371   // Used by DumpSharedSpaces only to remove classes that failed verification
 372   static void remove_classes_in_error_state();
 373 
 374   static int calculate_systemdictionary_size(int loadedclasses);
 375 
 376   // Applies "f->do_oop" to all root oops in the system dictionary.
 377   static void oops_do(OopClosure* f);
 378   static void roots_oops_do(OopClosure* strong, OopClosure* weak);
 379 
 380   // System loader lock
 381   static oop system_loader_lock()           { return _system_loader_lock_obj; }
 382 
 383 public:
 384   // Sharing support.
 385   static void reorder_dictionary();
 386   static void copy_buckets(char** top, char* end);
 387   static void copy_table(char** top, char* end);
 388   static void set_shared_dictionary(HashtableBucket<mtClass>* t, int length,
 389                                     int number_of_entries);
 390   // Printing
 391   static void print(bool details = true);
 392   static void print_shared(bool details = true);
 393 





 394   // Monotonically increasing counter which grows as classes are
 395   // loaded or modifications such as hot-swapping or setting/removing
 396   // of breakpoints are performed
 397   static inline int number_of_modifications()     { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
 398   // Needed by evolution and breakpoint code
 399   static inline void notice_modification()        { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications;      }
 400 
 401   // Verification
 402   static void verify();
 403 
 404   // Initialization
 405   static void initialize(TRAPS);
 406 
 407   // Checked fast access to commonly used classes - mostly preloaded
 408   static InstanceKlass* check_klass(InstanceKlass* k) {
 409     assert(k != NULL, "klass not loaded");
 410     return k;
 411   }
 412 
 413   static InstanceKlass* check_klass_Pre(InstanceKlass* k) { return check_klass(k); }


 533   static methodHandle find_dynamic_call_site_invoker(Klass* caller,
 534                                                      Handle bootstrap_method,
 535                                                      Symbol* name,
 536                                                      Symbol* type,
 537                                                      Handle *appendix_result,
 538                                                      Handle *method_type_result,
 539                                                      TRAPS);
 540 
 541   // Utility for printing loader "name" as part of tracing constraints
 542   static const char* loader_name(const oop loader);
 543   static const char* loader_name(const ClassLoaderData* loader_data);
 544 
 545   // Record the error when the first attempt to resolve a reference from a constant
 546   // pool entry to a class fails.
 547   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
 548                                    Symbol* message);
 549   static void delete_resolution_error(ConstantPool* pool);
 550   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
 551                                        Symbol** message);
 552 
 553 
 554   static ProtectionDomainCacheEntry* cache_get(Handle protection_domain);
 555 
 556  protected:
 557 
 558   enum Constants {
 559     _loader_constraint_size = 107,                     // number of entries in constraint table
 560     _resolution_error_size  = 107,                     // number of entries in resolution error table
 561     _invoke_method_size     = 139,                     // number of entries in invoke method table
 562     _shared_dictionary_size = 1009,                    // number of entries in shared dictionary
 563     _placeholder_table_size = 1009                     // number of entries in hash table for placeholders


 564   };
 565 
 566 
 567   // Static tables owned by the SystemDictionary








 568 
 569   // Hashtable holding placeholders for classes being loaded.
 570   static PlaceholderTable*       _placeholders;
 571 
 572   // Hashtable holding classes from the shared archive.
 573   static Dictionary*             _shared_dictionary;
 574 
 575   // Monotonically increasing counter which grows with
 576   // loading classes as well as hot-swapping and breakpoint setting
 577   // and removal.
 578   static int                     _number_of_modifications;
 579 
 580   // Lock object for system class loader
 581   static oop                     _system_loader_lock_obj;
 582 
 583   // Constraints on class loaders
 584   static LoaderConstraintTable*  _loader_constraints;
 585 
 586   // Resolution errors
 587   static ResolutionErrorTable*   _resolution_errors;
 588 
 589   // Invoke methods (JSR 292)
 590   static SymbolPropertyTable*    _invoke_method_table;
 591 
 592   // ProtectionDomain cache
 593   static ProtectionDomainCacheTable*   _pd_cache_table;


 594 
 595 protected:
 596   static void validate_protection_domain(InstanceKlass* klass,
 597                                          Handle class_loader,
 598                                          Handle protection_domain, TRAPS);
 599 
 600   friend class VM_PopulateDumpSharedSpace;
 601   friend class TraversePlaceholdersClosure;

 602   static Dictionary*         shared_dictionary() { return _shared_dictionary; }
 603   static PlaceholderTable*   placeholders() { return _placeholders; }
 604   static LoaderConstraintTable* constraints() { return _loader_constraints; }
 605   static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
 606   static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
 607 
 608   // Basic loading operations
 609   static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 610   static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 611   static InstanceKlass* handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
 612   // Wait on SystemDictionary_lock; unlocks lockObject before
 613   // waiting; relocks lockObject with correct recursion count
 614   // after waiting, but before reentering SystemDictionary_lock
 615   // to preserve lock order semantics.
 616   static void double_lock_wait(Handle lockObject, TRAPS);
 617   static void define_instance_class(InstanceKlass* k, TRAPS);
 618   static InstanceKlass* find_or_define_instance_class(Symbol* class_name,
 619                                                 Handle class_loader,
 620                                                 InstanceKlass* k, TRAPS);
 621   static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik,


 631   static bool is_parallelDefine(Handle class_loader);
 632 
 633 public:
 634   static InstanceKlass* load_shared_class(Symbol* class_name,
 635                                           Handle class_loader,
 636                                           TRAPS);
 637   static bool is_system_class_loader(oop class_loader);
 638   static bool is_platform_class_loader(oop class_loader);
 639 
 640 protected:
 641   static InstanceKlass* find_shared_class(Symbol* class_name);
 642 
 643   // Setup link to hierarchy
 644   static void add_to_hierarchy(InstanceKlass* k, TRAPS);
 645 
 646   // We pass in the hashtable index so we can calculate it outside of
 647   // the SystemDictionary_lock.
 648 
 649   // Basic find on loaded classes
 650   static InstanceKlass* find_class(int index, unsigned int hash,
 651                                    Symbol* name, Dictionary* dictionary);
 652   static InstanceKlass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
 653 
 654   // Basic find on classes in the midst of being loaded
 655   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
 656 
 657   // Add a placeholder for a class being loaded
 658   static void add_placeholder(int index,
 659                               Symbol* class_name,
 660                               ClassLoaderData* loader_data);
 661   static void remove_placeholder(int index,
 662                                  Symbol* class_name,
 663                                  ClassLoaderData* loader_data);
 664 
 665   // Performs cleanups after resolve_super_or_fail. This typically needs
 666   // to be called on failure.
 667   // Won't throw, but can block.
 668   static void resolution_cleanups(Symbol* class_name,
 669                                   ClassLoaderData* loader_data,
 670                                   TRAPS);
 671 


< prev index next >