src/share/vm/classfile/systemDictionary.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

## src/share/vm/classfile/systemDictionary.hpp

Print this page

     211
     212     WKID_LIMIT,
     213
     214     FIRST_WKID = NO_WKID + 1
     215   };
     216
     217   enum InitOption {
     218     Pre,                        // preloaded; error if not present
     219     Pre_JSR292,                 // preloaded if EnableInvokeDynamic
     220
     221     // Order is significant.  Options before this point require resolve_or_fail.
     222     // Options after this point will use resolve_or_null instead.
     223
     224     Opt,                        // preload tried; NULL if not present
     225     Opt_Only_JDK14NewRef,       // preload tried; use only with NewReflection
     226     Opt_Only_JDK15,             // preload tried; use only with JDK1.5+
     227     OPTION_LIMIT,
     228     CEIL_LG_OPTION_LIMIT = 4    // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
     229   };
     230

     231
     232   // Returns a class with a given class name and class loader.  Loads the
     233   // class if needed. If not found a NoClassDefFoundError or a
     234   // ClassNotFoundException is thrown, depending on the value on the
     235   // throw_error flag.  For most uses the throw_error argument should be set
     236   // to true.
     237
     238   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
     239   // Convenient call for null loader and protection domain.
     240   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
     241 protected:
     242   // handle error translation for resolve_or_null results
     243   static Klass* handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
     244
     245 public:
     246
     247   // Returns a class with a given class name and class loader.
     248   // Loads the class if needed. If not found NULL is returned.
     249   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
     250   // Version with null loader and protection domain
     541     return ((loader) == NULL ? "<bootloader>" :
     542             InstanceKlass::cast((loader)->klass())->name()->as_C_string() );
     543   }
     544   static const char* loader_name(ClassLoaderData* loader_data) {
     545     return (loader_data->class_loader() == NULL ? "<bootloader>" :
     546             InstanceKlass::cast((loader_data->class_loader())->klass())->name()->as_C_string() );
     547   }
     548
     549   // Record the error when the first attempt to resolve a reference from a constant
     550   // pool entry to a class fails.
     551   static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
     552   static void delete_resolution_error(ConstantPool* pool);
     553   static Symbol* find_resolution_error(constantPoolHandle pool, int which);
     554
     555  protected:
     556
     557   enum Constants {
     558     _loader_constraint_size = 107,                     // number of entries in constraint table
     559     _resolution_error_size  = 107,                     // number of entries in resolution error table
     560     _invoke_method_size     = 139,                     // number of entries in invoke method table
     561     _nof_buckets            = 1009,                    // number of buckets in hash table for placeholders
     562     _old_default_sdsize     = 1009,                    // backward compat for system dictionary size
     563     _prime_array_size       = 8,                       // array of primes for system dictionary size
     564     _average_depth_goal     = 3                        // goal for lookup length
     565   };
     566
     567
     568   // Static variables
     569
     570   // hashtable sizes for system dictionary to allow growth
     571   // prime numbers for system dictionary size
     572   static int                     _sdgeneration;
     573   static const int               _primelist[_prime_array_size];
     574
     575   // Hashtable holding loaded classes.
     576   static Dictionary*            _dictionary;
     577
     578   // Hashtable holding placeholders for classes being loaded.
     579   static PlaceholderTable*       _placeholders;
     580
     581   // Hashtable holding classes from the shared archive.
     582   static Dictionary*             _shared_dictionary;
     638   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
     639   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
     640   static bool is_parallelCapable(Handle class_loader);
     641   static bool is_parallelDefine(Handle class_loader);
     642
     643 public:
     644   static instanceKlassHandle load_shared_class(Symbol* class_name,
     645                                                Handle class_loader,
     646                                                TRAPS);
     647   static bool is_ext_class_loader(Handle class_loader);
     648
     649 protected:
     650   static Klass* find_shared_class(Symbol* class_name);
     651
     652   // Setup link to hierarchy
     653   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
     654
     655   // event based tracing
     656   static void post_class_load_event(const Ticks& start_time, instanceKlassHandle k,
     657                                     Handle initiating_loader);
     658   // We pass in the hashtable index so we can calculate it outside of
     659   // the SystemDictionary_lock.
     660
     661   // Basic find on loaded classes
     662   static Klass* find_class(int index, unsigned int hash,
     663                              Symbol* name, ClassLoaderData* loader_data);
     664   static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
     665
     666   // Basic find on classes in the midst of being loaded
     667   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
     668
     669   // Updating entry in dictionary
     670   // Add a completely loaded class
     671   static void add_klass(int index, Symbol* class_name,
     672                         ClassLoaderData* loader_data, KlassHandle obj);
     673
     674   // Add a placeholder for a class being loaded
     675   static void add_placeholder(int index,
     676                               Symbol* class_name,
     677                               ClassLoaderData* loader_data);
     678   static void remove_placeholder(int index,
     679                                  Symbol* class_name,
     680                                  ClassLoaderData* loader_data);
     681
     682   // Performs cleanups after resolve_super_or_fail. This typically needs
     683   // to be called on failure.
     684   // Won't throw, but can block.
     685   static void resolution_cleanups(Symbol* class_name,
     686                                   ClassLoaderData* loader_data,
     687                                   TRAPS);
     688
     689   // Initialization
     690   static void initialize_preloaded_classes(TRAPS);
     691
     692   // Class loader constraints
     693   static void check_constraints(int index, unsigned int hash,
     694                                 instanceKlassHandle k, Handle loader,
     695                                 bool defining, TRAPS);
     696   static void update_dictionary(int d_index, unsigned int d_hash,
     697                                 int p_index, unsigned int p_hash,
     698                                 instanceKlassHandle k, Handle loader,
     699                                 TRAPS);
     700
     701   // Variables holding commonly used klasses (preloaded)
     702   static Klass* _well_known_klasses[];
     703
     704   // Lazily loaded klasses
     705   static Klass* volatile _abstract_ownable_synchronizer_klass;
     706
     707   // table of box klasses (int_klass, etc.)
     708   static Klass* _box_klasses[T_VOID+1];
     709
     710   static oop  _java_system_loader;
     711
     712   static bool _has_loadClassInternal;
     713   static bool _has_checkPackageAccess;
     714 };
     715
     716 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
     211
     212     WKID_LIMIT,
     213
     214     FIRST_WKID = NO_WKID + 1
     215   };
     216
     217   enum InitOption {
     218     Pre,                        // preloaded; error if not present
     219     Pre_JSR292,                 // preloaded if EnableInvokeDynamic
     220
     221     // Order is significant.  Options before this point require resolve_or_fail.
     222     // Options after this point will use resolve_or_null instead.
     223
     224     Opt,                        // preload tried; NULL if not present
     225     Opt_Only_JDK14NewRef,       // preload tried; use only with NewReflection
     226     Opt_Only_JDK15,             // preload tried; use only with JDK1.5+
     227     OPTION_LIMIT,
     228     CEIL_LG_OPTION_LIMIT = 4    // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
     229   };
     230
     231   // The system dictionary
     232   static TwoOopHashtable<Klass*, mtClass>* the_table() { return (TwoOopHashtable<Klass*, mtClass>*)dictionary(); }
     233
     234   // Returns a class with a given class name and class loader.  Loads the
     235   // class if needed. If not found a NoClassDefFoundError or a
     236   // ClassNotFoundException is thrown, depending on the value on the
     237   // throw_error flag.  For most uses the throw_error argument should be set
     238   // to true.
     239
     240   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
     241   // Convenient call for null loader and protection domain.
     242   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
     243 protected:
     244   // handle error translation for resolve_or_null results
     245   static Klass* handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
     246
     247 public:
     248
     249   // Returns a class with a given class name and class loader.
     250   // Loads the class if needed. If not found NULL is returned.
     251   static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
     252   // Version with null loader and protection domain
     543     return ((loader) == NULL ? "<bootloader>" :
     544             InstanceKlass::cast((loader)->klass())->name()->as_C_string() );
     545   }
     546   static const char* loader_name(ClassLoaderData* loader_data) {
     547     return (loader_data->class_loader() == NULL ? "<bootloader>" :
     548             InstanceKlass::cast((loader_data->class_loader())->klass())->name()->as_C_string() );
     549   }
     550
     551   // Record the error when the first attempt to resolve a reference from a constant
     552   // pool entry to a class fails.
     553   static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
     554   static void delete_resolution_error(ConstantPool* pool);
     555   static Symbol* find_resolution_error(constantPoolHandle pool, int which);
     556
     557  protected:
     558
     559   enum Constants {
     560     _loader_constraint_size = 107,                        // number of entries in constraint table
     561     _resolution_error_size  = 107,                        // number of entries in resolution error table
     562     _invoke_method_size     = 139,                        // number of entries in invoke method table
     563     _nof_buckets            = defaultSystemDictionarySize,// number of buckets in hash table for placeholders
     564     _old_default_sdsize     = defaultSystemDictionarySize,// backward compat for system dictionary size
     565     _prime_array_size       = 8,                          // array of primes for system dictionary size
     566     _average_depth_goal     = 3                           // goal for lookup length
     567   };
     568
     569
     570   // Static variables
     571
     572   // hashtable sizes for system dictionary to allow growth
     573   // prime numbers for system dictionary size
     574   static int                     _sdgeneration;
     575   static const int               _primelist[_prime_array_size];
     576
     577   // Hashtable holding loaded classes.
     578   static Dictionary*            _dictionary;
     579
     580   // Hashtable holding placeholders for classes being loaded.
     581   static PlaceholderTable*       _placeholders;
     582
     583   // Hashtable holding classes from the shared archive.
     584   static Dictionary*             _shared_dictionary;
     640   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
     641   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
     642   static bool is_parallelCapable(Handle class_loader);
     643   static bool is_parallelDefine(Handle class_loader);
     644
     645 public:
     646   static instanceKlassHandle load_shared_class(Symbol* class_name,
     647                                                Handle class_loader,
     648                                                TRAPS);
     649   static bool is_ext_class_loader(Handle class_loader);
     650
     651 protected:
     652   static Klass* find_shared_class(Symbol* class_name);
     653
     654   // Setup link to hierarchy
     655   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
     656
     657   // event based tracing
     658   static void post_class_load_event(const Ticks& start_time, instanceKlassHandle k,
     659                                     Handle initiating_loader);

     660
     661   // Basic find on loaded classes
     662   static Klass* find_class(unsigned int hash,
     663                              Symbol* name, ClassLoaderData* loader_data);
     664   static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
     665
     666   // Basic find on classes in the midst of being loaded
     667   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
     668
     669   // Updating entry in dictionary
     670   // Add a completely loaded class
     671   static void add_klass(int index, Symbol* class_name,
     672                         ClassLoaderData* loader_data, KlassHandle obj);
     673
     674   // Add a placeholder for a class being loaded
     675   static void add_placeholder(int index,
     676                               Symbol* class_name,
     677                               ClassLoaderData* loader_data);
     678   static void remove_placeholder(int index,
     679                                  Symbol* class_name,
     680                                  ClassLoaderData* loader_data);
     681
     682   // Performs cleanups after resolve_super_or_fail. This typically needs
     683   // to be called on failure.
     684   // Won't throw, but can block.
     685   static void resolution_cleanups(Symbol* class_name,
     686                                   ClassLoaderData* loader_data,
     687                                   TRAPS);
     688
     689   // Initialization
     690   static void initialize_preloaded_classes(TRAPS);
     691
     692   // Class loader constraints
     693   static void check_constraints(unsigned int hash,
     694                                 instanceKlassHandle k, Handle loader,
     695                                 bool defining, TRAPS);
     696   static void update_dictionary(unsigned int d_hash,
     697                                 unsigned int p_hash,
     698                                 instanceKlassHandle k, Handle loader,
     699                                 TRAPS);
     700
     701   // Variables holding commonly used klasses (preloaded)
     702   static Klass* _well_known_klasses[];
     703
     704   // Lazily loaded klasses
     705   static Klass* volatile _abstract_ownable_synchronizer_klass;
     706
     707   // table of box klasses (int_klass, etc.)
     708   static Klass* _box_klasses[T_VOID+1];
     709
     710   static oop  _java_system_loader;
     711
     712   static bool _has_loadClassInternal;
     713   static bool _has_checkPackageAccess;
     714 };
     715
     716 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP

src/share/vm/classfile/systemDictionary.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File