< prev index next >

src/hotspot/share/classfile/systemDictionary.hpp

Print this page

 58 // can read the dictionary unlocked. This is safe because
 59 //    - entries are only deleted when the class loader is not alive, when the
 60 //      entire dictionary is deleted.
 61 //    - entries must be fully formed before they are available to concurrent
 62 //         readers (we must ensure write ordering)
 63 //
 64 // Note that placeholders are deleted at any time, as they are removed
 65 // when a class is completely loaded. Therefore, readers as well as writers
 66 // of placeholders must hold the SystemDictionary_lock.
 67 //
 68 
 69 class BootstrapInfo;
 70 class ClassFileStream;
 71 class ClassLoadInfo;
 72 class Dictionary;
 73 class PackageEntry;
 74 class GCTimer;
 75 class EventClassLoad;
 76 class Symbol;
 77 


 78 class SystemDictionary : AllStatic {
 79   friend class BootstrapInfo;

 80   friend class vmClasses;
 81   friend class VMStructs;
 82 
 83  public:
 84 
 85   // Returns a class with a given class name and class loader.  Loads the
 86   // class if needed. If not found a NoClassDefFoundError or a
 87   // ClassNotFoundException is thrown, depending on the value on the
 88   // throw_error flag.  For most uses the throw_error argument should be set
 89   // to true.
 90 
 91   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
 92   // Convenient call for null loader and protection domain.
 93   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS) {
 94     return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
 95   }
 96 
 97   // Returns a class with a given class name and class loader.
 98   // Loads the class if needed. If not found null is returned.
 99   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);

214   static void set_platform_loader(ClassLoaderData *cld);
215 
216   static Symbol* check_signature_loaders(Symbol* signature, Klass* klass_being_linked,
217                                          Handle loader1, Handle loader2, bool is_method);
218 
219   // JSR 292
220   // find a java.lang.invoke.MethodHandle.invoke* method for a given signature
221   // (asks Java to compute it if necessary, except in a compiler thread)
222   static Method* find_method_handle_invoker(Klass* klass,
223                                             Symbol* name,
224                                             Symbol* signature,
225                                             Klass* accessing_klass,
226                                             Handle *appendix_result,
227                                             TRAPS);
228   // for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic)
229   // (does not ask Java, since this is a low-level intrinsic defined by the JVM)
230   static Method* find_method_handle_intrinsic(vmIntrinsicID iid,
231                                               Symbol* signature,
232                                               TRAPS);
233 



234   // compute java_mirror (java.lang.Class instance) for a type ("I", "[[B", "LFoo;", etc.)
235   // Either the accessing_klass or the CL/PD can be non-null, but not both.
236   static Handle    find_java_mirror_for_type(Symbol* signature,
237                                              Klass* accessing_klass,
238                                              Handle class_loader,
239                                              Handle protection_domain,
240                                              SignatureStream::FailureMode failure_mode,
241                                              TRAPS);
242   static Handle    find_java_mirror_for_type(Symbol* signature,
243                                              Klass* accessing_klass,
244                                              SignatureStream::FailureMode failure_mode,
245                                              TRAPS) {
246     // callee will fill in CL/PD from AK, if they are needed
247     return find_java_mirror_for_type(signature, accessing_klass, Handle(), Handle(),
248                                      failure_mode, THREAD);
249   }
250 
251   // find a java.lang.invoke.MethodType object for a given signature
252   // (asks Java to compute it if necessary, except in a compiler thread)
253   static Handle    find_method_handle_type(Symbol* signature,

267                                                Symbol* signature,
268                                                TRAPS);
269 
270   // ask Java to compute a constant by invoking a BSM given a Dynamic_info CP entry
271   static void      invoke_bootstrap_method(BootstrapInfo& bootstrap_specifier, TRAPS);
272 
273   // Record the error when the first attempt to resolve a reference from a constant
274   // pool entry to a class fails.
275   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
276                                    Symbol* message, Symbol* cause = nullptr, Symbol* cause_msg = nullptr);
277   static void delete_resolution_error(ConstantPool* pool);
278   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
279                                        Symbol** message, Symbol** cause, Symbol** cause_msg);
280 
281 
282   // Record a nest host resolution/validation error
283   static void add_nest_host_error(const constantPoolHandle& pool, int which,
284                                   const char* message);
285   static const char* find_nest_host_error(const constantPoolHandle& pool, int which);
286 


287 protected:
288   static InstanceKlass* _well_known_klasses[];
289 
290 private:
291   // table of box klasses (int_klass, etc.)
292   static InstanceKlass* _box_klasses[T_VOID+1];
293 
294   static OopHandle  _java_system_loader;
295   static OopHandle  _java_platform_loader;
296 
297 private:
298   // Basic loading operations
299   static InstanceKlass* resolve_instance_class_or_null(Symbol* class_name,
300                                                        Handle class_loader,
301                                                        Handle protection_domain, TRAPS);
302   static Klass* resolve_array_class_or_null(Symbol* class_name,
303                                             Handle class_loader,
304                                             Handle protection_domain, TRAPS);
305   static void define_instance_class(InstanceKlass* k, Handle class_loader, TRAPS);
306   static InstanceKlass* find_or_define_helper(Symbol* class_name,

310   static InstanceKlass* load_instance_class(Symbol* class_name,
311                                             Handle class_loader, TRAPS);
312 
313   // Class loader constraints
314   static void check_constraints(InstanceKlass* k, ClassLoaderData* loader,
315                                 bool defining, TRAPS);
316   static void update_dictionary(JavaThread* current, InstanceKlass* k, ClassLoaderData* loader_data);
317 
318   static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik,
319                                       PackageEntry* pkg_entry,
320                                       Handle class_loader);
321   static bool is_shared_class_visible_impl(Symbol* class_name,
322                                            InstanceKlass* ik,
323                                            PackageEntry* pkg_entry,
324                                            Handle class_loader);
325   static bool check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super,
326                                             Handle class_loader,  Handle protection_domain,
327                                             bool is_superclass, TRAPS);
328   static bool check_shared_class_super_types(InstanceKlass* ik, Handle class_loader,
329                                                Handle protection_domain, TRAPS);
330   // Second part of load_shared_class
331   static void load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) NOT_CDS_RETURN;
332 
333 protected:
334   // Used by SystemDictionaryShared
335 



336   static bool add_loader_constraint(Symbol* name, Klass* klass_being_linked,  Handle loader1,
337                                     Handle loader2);
338   static void post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld);
339   static InstanceKlass* load_shared_lambda_proxy_class(InstanceKlass* ik,
340                                                        Handle class_loader,
341                                                        Handle protection_domain,
342                                                        PackageEntry* pkg_entry,
343                                                        TRAPS);
344   static InstanceKlass* load_shared_class(InstanceKlass* ik,
345                                           Handle class_loader,
346                                           Handle protection_domain,
347                                           const ClassFileStream *cfs,
348                                           PackageEntry* pkg_entry,
349                                           TRAPS);
350   static Handle get_loader_lock_or_null(Handle class_loader);
351   static InstanceKlass* find_or_define_instance_class(Symbol* class_name,
352                                                       Handle class_loader,
353                                                       InstanceKlass* k, TRAPS);
354 public:
355   static bool is_system_class_loader(oop class_loader);

 58 // can read the dictionary unlocked. This is safe because
 59 //    - entries are only deleted when the class loader is not alive, when the
 60 //      entire dictionary is deleted.
 61 //    - entries must be fully formed before they are available to concurrent
 62 //         readers (we must ensure write ordering)
 63 //
 64 // Note that placeholders are deleted at any time, as they are removed
 65 // when a class is completely loaded. Therefore, readers as well as writers
 66 // of placeholders must hold the SystemDictionary_lock.
 67 //
 68 
 69 class BootstrapInfo;
 70 class ClassFileStream;
 71 class ClassLoadInfo;
 72 class Dictionary;
 73 class PackageEntry;
 74 class GCTimer;
 75 class EventClassLoad;
 76 class Symbol;
 77 
 78 template <class E> class GrowableArray;
 79 
 80 class SystemDictionary : AllStatic {
 81   friend class BootstrapInfo;
 82   friend class ClassPrelinker;
 83   friend class vmClasses;
 84   friend class VMStructs;
 85 
 86  public:
 87 
 88   // Returns a class with a given class name and class loader.  Loads the
 89   // class if needed. If not found a NoClassDefFoundError or a
 90   // ClassNotFoundException is thrown, depending on the value on the
 91   // throw_error flag.  For most uses the throw_error argument should be set
 92   // to true.
 93 
 94   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
 95   // Convenient call for null loader and protection domain.
 96   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS) {
 97     return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
 98   }
 99 
100   // Returns a class with a given class name and class loader.
101   // Loads the class if needed. If not found null is returned.
102   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);

217   static void set_platform_loader(ClassLoaderData *cld);
218 
219   static Symbol* check_signature_loaders(Symbol* signature, Klass* klass_being_linked,
220                                          Handle loader1, Handle loader2, bool is_method);
221 
222   // JSR 292
223   // find a java.lang.invoke.MethodHandle.invoke* method for a given signature
224   // (asks Java to compute it if necessary, except in a compiler thread)
225   static Method* find_method_handle_invoker(Klass* klass,
226                                             Symbol* name,
227                                             Symbol* signature,
228                                             Klass* accessing_klass,
229                                             Handle *appendix_result,
230                                             TRAPS);
231   // for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic)
232   // (does not ask Java, since this is a low-level intrinsic defined by the JVM)
233   static Method* find_method_handle_intrinsic(vmIntrinsicID iid,
234                                               Symbol* signature,
235                                               TRAPS);
236 
237   static void get_all_method_handle_intrinsics(GrowableArray<Method*>* methods) NOT_CDS_RETURN;
238   static void restore_archived_method_handle_intrinsics() NOT_CDS_RETURN;
239 
240   // compute java_mirror (java.lang.Class instance) for a type ("I", "[[B", "LFoo;", etc.)
241   // Either the accessing_klass or the CL/PD can be non-null, but not both.
242   static Handle    find_java_mirror_for_type(Symbol* signature,
243                                              Klass* accessing_klass,
244                                              Handle class_loader,
245                                              Handle protection_domain,
246                                              SignatureStream::FailureMode failure_mode,
247                                              TRAPS);
248   static Handle    find_java_mirror_for_type(Symbol* signature,
249                                              Klass* accessing_klass,
250                                              SignatureStream::FailureMode failure_mode,
251                                              TRAPS) {
252     // callee will fill in CL/PD from AK, if they are needed
253     return find_java_mirror_for_type(signature, accessing_klass, Handle(), Handle(),
254                                      failure_mode, THREAD);
255   }
256 
257   // find a java.lang.invoke.MethodType object for a given signature
258   // (asks Java to compute it if necessary, except in a compiler thread)
259   static Handle    find_method_handle_type(Symbol* signature,

273                                                Symbol* signature,
274                                                TRAPS);
275 
276   // ask Java to compute a constant by invoking a BSM given a Dynamic_info CP entry
277   static void      invoke_bootstrap_method(BootstrapInfo& bootstrap_specifier, TRAPS);
278 
279   // Record the error when the first attempt to resolve a reference from a constant
280   // pool entry to a class fails.
281   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
282                                    Symbol* message, Symbol* cause = nullptr, Symbol* cause_msg = nullptr);
283   static void delete_resolution_error(ConstantPool* pool);
284   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
285                                        Symbol** message, Symbol** cause, Symbol** cause_msg);
286 
287 
288   // Record a nest host resolution/validation error
289   static void add_nest_host_error(const constantPoolHandle& pool, int which,
290                                   const char* message);
291   static const char* find_nest_host_error(const constantPoolHandle& pool, int which);
292 
293   static void preload_class(JavaThread* current,  InstanceKlass* k,
294                             ClassLoaderData* loader_data) NOT_CDS_RETURN;
295 protected:
296   static InstanceKlass* _well_known_klasses[];
297 
298 private:
299   // table of box klasses (int_klass, etc.)
300   static InstanceKlass* _box_klasses[T_VOID+1];
301 
302   static OopHandle  _java_system_loader;
303   static OopHandle  _java_platform_loader;
304 
305 private:
306   // Basic loading operations
307   static InstanceKlass* resolve_instance_class_or_null(Symbol* class_name,
308                                                        Handle class_loader,
309                                                        Handle protection_domain, TRAPS);
310   static Klass* resolve_array_class_or_null(Symbol* class_name,
311                                             Handle class_loader,
312                                             Handle protection_domain, TRAPS);
313   static void define_instance_class(InstanceKlass* k, Handle class_loader, TRAPS);
314   static InstanceKlass* find_or_define_helper(Symbol* class_name,

318   static InstanceKlass* load_instance_class(Symbol* class_name,
319                                             Handle class_loader, TRAPS);
320 
321   // Class loader constraints
322   static void check_constraints(InstanceKlass* k, ClassLoaderData* loader,
323                                 bool defining, TRAPS);
324   static void update_dictionary(JavaThread* current, InstanceKlass* k, ClassLoaderData* loader_data);
325 
326   static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik,
327                                       PackageEntry* pkg_entry,
328                                       Handle class_loader);
329   static bool is_shared_class_visible_impl(Symbol* class_name,
330                                            InstanceKlass* ik,
331                                            PackageEntry* pkg_entry,
332                                            Handle class_loader);
333   static bool check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super,
334                                             Handle class_loader,  Handle protection_domain,
335                                             bool is_superclass, TRAPS);
336   static bool check_shared_class_super_types(InstanceKlass* ik, Handle class_loader,
337                                                Handle protection_domain, TRAPS);
338   static void restore_archived_method_handle_intrinsics_impl(TRAPS);

339 
340 protected:
341   // Used by SystemDictionaryShared
342 
343   // Second part of load_shared_class
344   static void load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) NOT_CDS_RETURN;
345 
346   static bool add_loader_constraint(Symbol* name, Klass* klass_being_linked,  Handle loader1,
347                                     Handle loader2);
348   static void post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld);
349   static InstanceKlass* load_shared_lambda_proxy_class(InstanceKlass* ik,
350                                                        Handle class_loader,
351                                                        Handle protection_domain,
352                                                        PackageEntry* pkg_entry,
353                                                        TRAPS);
354   static InstanceKlass* load_shared_class(InstanceKlass* ik,
355                                           Handle class_loader,
356                                           Handle protection_domain,
357                                           const ClassFileStream *cfs,
358                                           PackageEntry* pkg_entry,
359                                           TRAPS);
360   static Handle get_loader_lock_or_null(Handle class_loader);
361   static InstanceKlass* find_or_define_instance_class(Symbol* class_name,
362                                                       Handle class_loader,
363                                                       InstanceKlass* k, TRAPS);
364 public:
365   static bool is_system_class_loader(oop class_loader);
< prev index next >