< prev index next >

src/hotspot/share/classfile/systemDictionary.hpp

Print this page

 51 // When class loading is finished, a new entry is added to the dictionary
 52 // of the class loader and the placeholder is removed.
 53 //
 54 // Clients of this class who are interested in finding if a class has
 55 // been completely loaded -- not classes in the process of being loaded --
 56 // can read the dictionary unlocked. This is safe because
 57 //    - entries are only deleted when the class loader is not alive, when the
 58 //      entire dictionary is deleted.
 59 //    - entries must be fully formed before they are available to concurrent
 60 //         readers (we must ensure write ordering)
 61 //
 62 // Note that placeholders are deleted at any time, as they are removed
 63 // when a class is completely loaded. Therefore, readers as well as writers
 64 // of placeholders must hold the SystemDictionary_lock.
 65 //
 66 
 67 class BootstrapInfo;
 68 class ClassFileStream;
 69 class ClassLoadInfo;
 70 class Dictionary;

 71 class PackageEntry;
 72 class GCTimer;
 73 class EventClassLoad;
 74 class Symbol;
 75 
 76 template <class E> class GrowableArray;
 77 
 78 class SystemDictionary : AllStatic {
 79   friend class AOTLinkedClassBulkLoader;
 80   friend class BootstrapInfo;
 81   friend class LambdaProxyClassDictionary;
 82   friend class vmClasses;
 83 
 84  public:
 85 
 86   // Returns a class with a given class name and class loader.  Loads the
 87   // class if needed. If not found a NoClassDefFoundError or a
 88   // ClassNotFoundException is thrown, depending on the value on the
 89   // throw_error flag.  For most uses the throw_error argument should be set
 90   // to true.

 95     return resolve_or_fail(class_name, Handle(), throw_error, THREAD);
 96   }
 97 
 98   // Returns a class with a given class name and class loader.
 99   // Loads the class if needed. If not found null is returned.
100   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, TRAPS);
101   // Version with null loader and protection domain
102   static Klass* resolve_or_null(Symbol* class_name, TRAPS) {
103     return resolve_or_null(class_name, Handle(), THREAD);
104   }
105 
106   static InstanceKlass* resolve_with_circularity_detection(Symbol* class_name,
107                                                            Symbol* next_name,
108                                                            Handle class_loader,
109                                                            bool is_superclass,
110                                                            TRAPS);
111 
112   // Resolve a superclass or superinterface. Called from ClassFileParser,
113   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
114   // "class_name" is the class whose super class or interface is being resolved.
115   static InstanceKlass* resolve_super_or_fail(Symbol* class_name, Symbol* super_name,

116                                               Handle class_loader,
117                                               bool is_superclass, TRAPS) {
118     return resolve_with_circularity_detection(class_name, super_name, class_loader, is_superclass, THREAD);
119   }
120 
121  private:
122   // Parse the stream to create a hidden class.
123   // Used by jvm_lookup_define_class.
124   static InstanceKlass* resolve_hidden_class_from_stream(ClassFileStream* st,
125                                                          Symbol* class_name,
126                                                          Handle class_loader,
127                                                          const ClassLoadInfo& cl_info,
128                                                          TRAPS);
129 
130   // Resolve a class from stream (called by jni_DefineClass and JVM_DefineClass)
131   // This class is added to the SystemDictionary.
132   static InstanceKlass* resolve_class_from_stream(ClassFileStream* st,
133                                                   Symbol* class_name,
134                                                   Handle class_loader,
135                                                   const ClassLoadInfo& cl_info,
136                                                   TRAPS);
137 
138   static oop get_system_class_loader_impl(TRAPS);
139   static oop get_platform_class_loader_impl(TRAPS);
140 
141  public:

142   // Resolve either a hidden or normal class from a stream of bytes, based on ClassLoadInfo
143   static InstanceKlass* resolve_from_stream(ClassFileStream* st,
144                                             Symbol* class_name,
145                                             Handle class_loader,
146                                             const ClassLoadInfo& cl_info,
147                                             TRAPS);
148 
149   // Lookup an already loaded class. If not found null is returned.
150   static InstanceKlass* find_instance_klass(Thread* current, Symbol* class_name,
151                                             Handle class_loader);
152 
153   // Lookup an already loaded instance or array class.
154   // Do not make any queries to class loaders; consult only the cache.
155   // If not found null is returned.
156   static Klass* find_instance_or_array_klass(Thread* current, Symbol* class_name,
157                                              Handle class_loader);
158 
159   // Lookup an instance or array class that has already been loaded
160   // either into the given class loader, or else into another class
161   // loader that is constrained (via loader constraints) to produce

 51 // When class loading is finished, a new entry is added to the dictionary
 52 // of the class loader and the placeholder is removed.
 53 //
 54 // Clients of this class who are interested in finding if a class has
 55 // been completely loaded -- not classes in the process of being loaded --
 56 // can read the dictionary unlocked. This is safe because
 57 //    - entries are only deleted when the class loader is not alive, when the
 58 //      entire dictionary is deleted.
 59 //    - entries must be fully formed before they are available to concurrent
 60 //         readers (we must ensure write ordering)
 61 //
 62 // Note that placeholders are deleted at any time, as they are removed
 63 // when a class is completely loaded. Therefore, readers as well as writers
 64 // of placeholders must hold the SystemDictionary_lock.
 65 //
 66 
 67 class BootstrapInfo;
 68 class ClassFileStream;
 69 class ClassLoadInfo;
 70 class Dictionary;
 71 class AllFieldStream;
 72 class PackageEntry;
 73 class GCTimer;
 74 class EventClassLoad;
 75 class Symbol;
 76 
 77 template <class E> class GrowableArray;
 78 
 79 class SystemDictionary : AllStatic {
 80   friend class AOTLinkedClassBulkLoader;
 81   friend class BootstrapInfo;
 82   friend class LambdaProxyClassDictionary;
 83   friend class vmClasses;
 84 
 85  public:
 86 
 87   // Returns a class with a given class name and class loader.  Loads the
 88   // class if needed. If not found a NoClassDefFoundError or a
 89   // ClassNotFoundException is thrown, depending on the value on the
 90   // throw_error flag.  For most uses the throw_error argument should be set
 91   // to true.

 96     return resolve_or_fail(class_name, Handle(), throw_error, THREAD);
 97   }
 98 
 99   // Returns a class with a given class name and class loader.
100   // Loads the class if needed. If not found null is returned.
101   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, TRAPS);
102   // Version with null loader and protection domain
103   static Klass* resolve_or_null(Symbol* class_name, TRAPS) {
104     return resolve_or_null(class_name, Handle(), THREAD);
105   }
106 
107   static InstanceKlass* resolve_with_circularity_detection(Symbol* class_name,
108                                                            Symbol* next_name,
109                                                            Handle class_loader,
110                                                            bool is_superclass,
111                                                            TRAPS);
112 
113   // Resolve a superclass or superinterface. Called from ClassFileParser,
114   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
115   // "class_name" is the class whose super class or interface is being resolved.
116   static InstanceKlass* resolve_with_circularity_detection_or_fail(Symbol* class_name,
117                                               Symbol* super_name,
118                                               Handle class_loader,
119                                               bool is_superclass, TRAPS) {
120     return resolve_with_circularity_detection(class_name, super_name, class_loader, is_superclass, THREAD);
121   }
122 
123  private:
124   // Parse the stream to create a hidden class.
125   // Used by jvm_lookup_define_class.
126   static InstanceKlass* resolve_hidden_class_from_stream(ClassFileStream* st,
127                                                          Symbol* class_name,
128                                                          Handle class_loader,
129                                                          const ClassLoadInfo& cl_info,
130                                                          TRAPS);
131 
132   // Resolve a class from stream (called by jni_DefineClass and JVM_DefineClass)
133   // This class is added to the SystemDictionary.
134   static InstanceKlass* resolve_class_from_stream(ClassFileStream* st,
135                                                   Symbol* class_name,
136                                                   Handle class_loader,
137                                                   const ClassLoadInfo& cl_info,
138                                                   TRAPS);
139 
140   static oop get_system_class_loader_impl(TRAPS);
141   static oop get_platform_class_loader_impl(TRAPS);
142 
143  public:
144 
145   // Resolve either a hidden or normal class from a stream of bytes, based on ClassLoadInfo
146   static InstanceKlass* resolve_from_stream(ClassFileStream* st,
147                                             Symbol* class_name,
148                                             Handle class_loader,
149                                             const ClassLoadInfo& cl_info,
150                                             TRAPS);
151 
152   // Lookup an already loaded class. If not found null is returned.
153   static InstanceKlass* find_instance_klass(Thread* current, Symbol* class_name,
154                                             Handle class_loader);
155 
156   // Lookup an already loaded instance or array class.
157   // Do not make any queries to class loaders; consult only the cache.
158   // If not found null is returned.
159   static Klass* find_instance_or_array_klass(Thread* current, Symbol* class_name,
160                                              Handle class_loader);
161 
162   // Lookup an instance or array class that has already been loaded
163   // either into the given class loader, or else into another class
164   // loader that is constrained (via loader constraints) to produce
< prev index next >