< 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 ProtectionDomainCacheTable;
  82 class ProtectionDomainCacheEntry;


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




  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 placeholder 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;


 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,


< prev index next >