< prev index next >

src/hotspot/share/classfile/systemDictionary.hpp

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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_CLASSFILE_SYSTEMDICTIONARY_HPP
  26 #define SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
  27 
  28 #include "classfile/classLoaderData.hpp"
  29 #include "oops/objArrayOop.hpp"
  30 #include "oops/symbol.hpp"
  31 #include "runtime/java.hpp"
  32 #include "runtime/mutexLocker.hpp"
  33 #include "runtime/reflectionUtils.hpp"
  34 #include "runtime/signature.hpp"
  35 #include "utilities/hashtable.hpp"
  36 















































  37 // The dictionary in each ClassLoaderData stores all loaded classes, either
  38 // initiatied by its class loader or defined by its class loader:
  39 //
  40 //   class loader -> ClassLoaderData -> [class, protection domain set]
  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 (Dictionary) per
  46 // ClassLoaderData with a fixed number of buckets. During loading the
  47 // class loader object is locked, (for the VM loader a private lock object is used).
  48 // The global SystemDictionary_lock is held for all additions into the ClassLoaderData
  49 // dictionaries.  TODO: fix lock granularity so that class loading can
  50 // be done concurrently, but only by different loaders.
  51 //
  52 // During loading a placeholder (name, loader) is temporarily placed in
  53 // a side data structure, and is used to detect ClassCircularityErrors
  54 // and to perform verification during GC.  A GC can occur in the midst
  55 // of class loading, as we call out to Java, have to take locks, etc.
  56 //


 251   static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS);
 252 
 253 public:
 254 
 255   // Returns a class with a given class name and class loader.
 256   // Loads the class if needed. If not found NULL is returned.
 257   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 258   // Version with null loader and protection domain
 259   static Klass* resolve_or_null(Symbol* class_name, TRAPS);
 260 
 261   // Resolve a superclass or superinterface. Called from ClassFileParser,
 262   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
 263   // "child_name" is the class whose super class or interface is being resolved.
 264   static InstanceKlass* resolve_super_or_fail(Symbol* child_name,
 265                                               Symbol* class_name,
 266                                               Handle class_loader,
 267                                               Handle protection_domain,
 268                                               bool is_superclass,
 269                                               TRAPS);
 270 
 271   // Parse new stream. This won't update the dictionary or
 272   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
 273   // Also used by Unsafe_DefineAnonymousClass
 274   static InstanceKlass* parse_stream(Symbol* class_name,
 275                                      Handle class_loader,
 276                                      Handle protection_domain,
 277                                      ClassFileStream* st,
 278                                      TRAPS) {
 279     return parse_stream(class_name,
 280                         class_loader,
 281                         protection_domain,
 282                         st,
 283                         NULL, // unsafe_anonymous_host
 284                         NULL, // cp_patches
 285                         THREAD);
 286   }
 287   static InstanceKlass* parse_stream(Symbol* class_name,
 288                                      Handle class_loader,
 289                                      Handle protection_domain,
 290                                      ClassFileStream* st,
 291                                      const InstanceKlass* unsafe_anonymous_host,
 292                                      GrowableArray<Handle>* cp_patches,
 293                                      TRAPS);
 294 
 295   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
 296   static InstanceKlass* resolve_from_stream(Symbol* class_name,
 297                                             Handle class_loader,
 298                                             Handle protection_domain,
 299                                             ClassFileStream* st,
 300                                             TRAPS);
 301 
 302   // Lookup an already loaded class. If not found NULL is returned.
 303   static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 304 
 305   // Lookup an already loaded instance or array class.
 306   // Do not make any queries to class loaders; consult only the cache.
 307   // If not found NULL is returned.
 308   static Klass* find_instance_or_array_klass(Symbol* class_name,
 309                                                Handle class_loader,
 310                                                Handle protection_domain,
 311                                                TRAPS);
 312 




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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_CLASSFILE_SYSTEMDICTIONARY_HPP
  26 #define SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
  27 
  28 #include "classfile/classLoaderData.hpp"
  29 #include "oops/objArrayOop.hpp"
  30 #include "oops/symbol.hpp"
  31 #include "runtime/java.hpp"
  32 #include "runtime/mutexLocker.hpp"
  33 #include "runtime/reflectionUtils.hpp"
  34 #include "runtime/signature.hpp"
  35 #include "utilities/hashtable.hpp"
  36 
  37 class ClassInstanceInfo : public StackObj {
  38  private:
  39   InstanceKlass* _dynamic_nest_host;
  40   Handle _class_data;
  41 
  42  public:
  43   ClassInstanceInfo() {
  44     _dynamic_nest_host = NULL;
  45     _class_data = Handle();
  46   }
  47   ClassInstanceInfo(InstanceKlass* dynamic_nest_host, Handle class_data) {
  48     _dynamic_nest_host = dynamic_nest_host;
  49     _class_data = class_data;
  50   }
  51 
  52   InstanceKlass* dynamic_nest_host() const { return _dynamic_nest_host; }
  53   Handle class_data() const { return _class_data; }
  54   friend class ClassLoadInfo;
  55 };
  56 
  57 class ClassLoadInfo : public StackObj {
  58  private:
  59   Handle                 _protection_domain;
  60   const InstanceKlass*   _unsafe_anonymous_host;
  61   GrowableArray<Handle>* _cp_patches;
  62   ClassInstanceInfo      _class_hidden_info;
  63   bool                   _is_hidden;
  64   bool                   _is_weak_hidden;
  65   bool                   _can_access_vm_annotations;
  66 
  67  public:
  68   ClassLoadInfo();
  69   ClassLoadInfo(Handle protection_domain);
  70   ClassLoadInfo(Handle protection_domain, const InstanceKlass* unsafe_anonymous_host,
  71                 GrowableArray<Handle>* cp_patches, InstanceKlass* dynamic_nest_host,
  72                 Handle class_data, bool is_hidden, bool is_weak_hidden,
  73                 bool can_access_vm_annotations);
  74 
  75   Handle protection_domain()             const { return _protection_domain; }
  76   const InstanceKlass* unsafe_anonymous_host() const { return _unsafe_anonymous_host; }
  77   GrowableArray<Handle>* cp_patches()    const { return _cp_patches; }
  78   const ClassInstanceInfo* class_hidden_info_ptr() const { return &_class_hidden_info; }
  79   bool is_hidden()                       const { return _is_hidden; }
  80   bool is_weak_hidden()                  const { return _is_weak_hidden; }
  81   bool can_access_vm_annotations()       const { return _can_access_vm_annotations; }
  82 };
  83 
  84 // The dictionary in each ClassLoaderData stores all loaded classes, either
  85 // initiatied by its class loader or defined by its class loader:
  86 //
  87 //   class loader -> ClassLoaderData -> [class, protection domain set]
  88 //
  89 // Classes are loaded lazily. The default VM class loader is
  90 // represented as NULL.
  91 
  92 // The underlying data structure is an open hash table (Dictionary) per
  93 // ClassLoaderData with a fixed number of buckets. During loading the
  94 // class loader object is locked, (for the VM loader a private lock object is used).
  95 // The global SystemDictionary_lock is held for all additions into the ClassLoaderData
  96 // dictionaries.  TODO: fix lock granularity so that class loading can
  97 // be done concurrently, but only by different loaders.
  98 //
  99 // During loading a placeholder (name, loader) is temporarily placed in
 100 // a side data structure, and is used to detect ClassCircularityErrors
 101 // and to perform verification during GC.  A GC can occur in the midst
 102 // of class loading, as we call out to Java, have to take locks, etc.
 103 //


 298   static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS);
 299 
 300 public:
 301 
 302   // Returns a class with a given class name and class loader.
 303   // Loads the class if needed. If not found NULL is returned.
 304   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 305   // Version with null loader and protection domain
 306   static Klass* resolve_or_null(Symbol* class_name, TRAPS);
 307 
 308   // Resolve a superclass or superinterface. Called from ClassFileParser,
 309   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
 310   // "child_name" is the class whose super class or interface is being resolved.
 311   static InstanceKlass* resolve_super_or_fail(Symbol* child_name,
 312                                               Symbol* class_name,
 313                                               Handle class_loader,
 314                                               Handle protection_domain,
 315                                               bool is_superclass,
 316                                               TRAPS);
 317 
















 318   static InstanceKlass* parse_stream(Symbol* class_name,
 319                                      Handle class_loader,

 320                                      ClassFileStream* st,
 321                                      const ClassLoadInfo& cl_info,

 322                                      TRAPS);
 323 
 324   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
 325   static InstanceKlass* resolve_from_stream(Symbol* class_name,
 326                                             Handle class_loader,
 327                                             Handle protection_domain,
 328                                             ClassFileStream* st,
 329                                             TRAPS);
 330 
 331   // Lookup an already loaded class. If not found NULL is returned.
 332   static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 333 
 334   // Lookup an already loaded instance or array class.
 335   // Do not make any queries to class loaders; consult only the cache.
 336   // If not found NULL is returned.
 337   static Klass* find_instance_or_array_klass(Symbol* class_name,
 338                                                Handle class_loader,
 339                                                Handle protection_domain,
 340                                                TRAPS);
 341 


< prev index next >