< prev index next >

src/hotspot/share/classfile/systemDictionary.hpp

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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


  56 //
  57 // When class loading is finished, a new entry is added to the dictionary
  58 // of the class loader and the placeholder is removed. Note that the protection
  59 // domain field of the dictionary entry has not yet been filled in when
  60 // the "real" dictionary entry is created.
  61 //
  62 // Clients of this class who are interested in finding if a class has
  63 // been completely loaded -- not classes in the process of being loaded --
  64 // can read the dictionary unlocked. This is safe because
  65 //    - entries are only deleted at safepoints
  66 //    - readers cannot come to a safepoint while actively examining
  67 //         an entry  (an entry cannot be deleted from under a reader)
  68 //    - entries must be fully formed before they are available to concurrent
  69 //         readers (we must ensure write ordering)
  70 //
  71 // Note that placeholders are deleted at any time, as they are removed
  72 // when a class is completely loaded. Therefore, readers as well as writers
  73 // of placeholders must hold the SystemDictionary_lock.
  74 //
  75 
  76 class BootstrapInfo;
  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;
  86 class GCTimer;
  87 class OopStorage;
  88 
  89 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  90 
  91 // Certain classes, such as java.lang.Object and java.lang.String,
  92 // are "well-known", in the sense that no class loader is allowed
  93 // to provide a different definition.
  94 //
  95 // Each well-known class has a short klass name (like object_klass),
  96 // and a vmSymbol name (like java_lang_Object).


 160   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */                                   \
 161   do_klass(DirectMethodHandle_klass,                    java_lang_invoke_DirectMethodHandle                   ) \
 162   do_klass(MethodHandle_klass,                          java_lang_invoke_MethodHandle                         ) \
 163   do_klass(VarHandle_klass,                             java_lang_invoke_VarHandle                            ) \
 164   do_klass(MemberName_klass,                            java_lang_invoke_MemberName                           ) \
 165   do_klass(ResolvedMethodName_klass,                    java_lang_invoke_ResolvedMethodName                   ) \
 166   do_klass(MethodHandleNatives_klass,                   java_lang_invoke_MethodHandleNatives                  ) \
 167   do_klass(LambdaForm_klass,                            java_lang_invoke_LambdaForm                           ) \
 168   do_klass(MethodType_klass,                            java_lang_invoke_MethodType                           ) \
 169   do_klass(BootstrapMethodError_klass,                  java_lang_BootstrapMethodError                        ) \
 170   do_klass(CallSite_klass,                              java_lang_invoke_CallSite                             ) \
 171   do_klass(Context_klass,                               java_lang_invoke_MethodHandleNatives_CallSiteContext  ) \
 172   do_klass(ConstantCallSite_klass,                      java_lang_invoke_ConstantCallSite                     ) \
 173   do_klass(MutableCallSite_klass,                       java_lang_invoke_MutableCallSite                      ) \
 174   do_klass(VolatileCallSite_klass,                      java_lang_invoke_VolatileCallSite                     ) \
 175   /* Note: MethodHandle must be first, and VolatileCallSite last in group */                                    \
 176                                                                                                                 \
 177   do_klass(AssertionStatusDirectives_klass,             java_lang_AssertionStatusDirectives                   ) \
 178   do_klass(StringBuffer_klass,                          java_lang_StringBuffer                                ) \
 179   do_klass(StringBuilder_klass,                         java_lang_StringBuilder                               ) \
 180   do_klass(UnsafeConstants_klass,                       jdk_internal_misc_UnsafeConstants                     ) \
 181   do_klass(internal_Unsafe_klass,                       jdk_internal_misc_Unsafe                              ) \
 182   do_klass(module_Modules_klass,                        jdk_internal_module_Modules                           ) \
 183                                                                                                                 \
 184   /* support for CDS */                                                                                         \
 185   do_klass(ByteArrayInputStream_klass,                  java_io_ByteArrayInputStream                          ) \
 186   do_klass(URL_klass,                                   java_net_URL                                          ) \
 187   do_klass(Jar_Manifest_klass,                          java_util_jar_Manifest                                ) \
 188   do_klass(jdk_internal_loader_ClassLoaders_klass,      jdk_internal_loader_ClassLoaders                      ) \
 189   do_klass(jdk_internal_loader_ClassLoaders_AppClassLoader_klass,      jdk_internal_loader_ClassLoaders_AppClassLoader) \
 190   do_klass(jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass, jdk_internal_loader_ClassLoaders_PlatformClassLoader) \
 191   do_klass(CodeSource_klass,                            java_security_CodeSource                              ) \
 192                                                                                                                 \
 193   do_klass(StackTraceElement_klass,                     java_lang_StackTraceElement                           ) \
 194                                                                                                                 \
 195   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                 \
 196   do_klass(nio_Buffer_klass,                            java_nio_Buffer                                       ) \
 197                                                                                                                 \
 198   /* Stack Walking */                                                                                           \
 199   do_klass(StackWalker_klass,                           java_lang_StackWalker                                 ) \
 200   do_klass(AbstractStackWalker_klass,                   java_lang_StackStreamFactory_AbstractStackWalker      ) \
 201   do_klass(StackFrameInfo_klass,                        java_lang_StackFrameInfo                              ) \
 202   do_klass(LiveStackFrameInfo_klass,                    java_lang_LiveStackFrameInfo                          ) \
 203                                                                                                                 \
 204   /* support for stack dump lock analysis */                                                                    \
 205   do_klass(java_util_concurrent_locks_AbstractOwnableSynchronizer_klass, java_util_concurrent_locks_AbstractOwnableSynchronizer) \
 206                                                                                                                 \
 207   /* boxing klasses */                                                                                          \
 208   do_klass(Boolean_klass,                               java_lang_Boolean                                     ) \
 209   do_klass(Character_klass,                             java_lang_Character                                   ) \
 210   do_klass(Float_klass,                                 java_lang_Float                                       ) \
 211   do_klass(Double_klass,                                java_lang_Double                                      ) \
 212   do_klass(Byte_klass,                                  java_lang_Byte                                        ) \
 213   do_klass(Short_klass,                                 java_lang_Short                                       ) \
 214   do_klass(Integer_klass,                               java_lang_Integer                                     ) \
 215   do_klass(Long_klass,                                  java_lang_Long                                        ) \
 216                                                                                                                 \



 217   /*end*/
 218 
 219 
 220 class SystemDictionary : AllStatic {
 221   friend class BootstrapInfo;
 222   friend class VMStructs;
 223   friend class SystemDictionaryHandles;
 224 
 225  public:
 226   enum WKID {
 227     NO_WKID = 0,
 228 
 229     #define WK_KLASS_ENUM(name, symbol) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
 230     WK_KLASSES_DO(WK_KLASS_ENUM)
 231     #undef WK_KLASS_ENUM
 232 
 233     WKID_LIMIT,
 234 





 235     FIRST_WKID = NO_WKID + 1
 236   };
 237 
 238   // Returns a class with a given class name and class loader.  Loads the
 239   // class if needed. If not found a NoClassDefFoundError or a
 240   // ClassNotFoundException is thrown, depending on the value on the
 241   // throw_error flag.  For most uses the throw_error argument should be set
 242   // to true.
 243 
 244   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
 245   // Convenient call for null loader and protection domain.
 246   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
 247 protected:
 248   // handle error translation for resolve_or_null results
 249   static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS);
 250 
 251 public:
 252 
 253   // Returns a class with a given class name and class loader.
 254   // Loads the class if needed. If not found NULL is returned.


 338 
 339   static void methods_do(void f(Method*));
 340 
 341   // Garbage collection support
 342 
 343   // Unload (that is, break root links to) all unmarked classes and
 344   // loaders.  Returns "true" iff something was unloaded.
 345   static bool do_unloading(GCTimer* gc_timer);
 346 
 347   // Applies "f->do_oop" to all root oops in the system dictionary.
 348   static void oops_do(OopClosure* f);
 349 
 350   // System loader lock
 351   static oop system_loader_lock()           { return _system_loader_lock_obj; }
 352 
 353   // Protection Domain Table
 354   static ProtectionDomainCacheTable* pd_cache_table() { return _pd_cache_table; }
 355 
 356 public:
 357   // Printing
 358   static void print();
 359   static void print_on(outputStream* st);
 360   static void dump(outputStream* st, bool verbose);
 361 
 362   // Monotonically increasing counter which grows as classes are
 363   // loaded or modifications such as hot-swapping or setting/removing
 364   // of breakpoints are performed
 365   static inline int number_of_modifications()     { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
 366   // Needed by evolution and breakpoint code
 367   static inline void notice_modification()        { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications;      }
 368 
 369   // Verification
 370   static void verify();
 371 
 372   // Initialization
 373   static void initialize(TRAPS);
 374 
 375   // Checked fast access to the well-known classes -- so that you don't try to use them
 376   // before they are resolved.
 377   static InstanceKlass* check_klass(InstanceKlass* k) {
 378     assert(k != NULL, "klass not loaded");


 507   // find a java.lang.invoke.MethodType object for a given signature
 508   // (asks Java to compute it if necessary, except in a compiler thread)
 509   static Handle    find_method_handle_type(Symbol* signature,
 510                                            Klass* accessing_klass,
 511                                            TRAPS);
 512 
 513   // find a java.lang.Class object for a given signature
 514   static Handle    find_field_handle_type(Symbol* signature,
 515                                           Klass* accessing_klass,
 516                                           TRAPS);
 517 
 518   // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
 519   static Handle    link_method_handle_constant(Klass* caller,
 520                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
 521                                                Klass* callee,
 522                                                Symbol* name,
 523                                                Symbol* signature,
 524                                                TRAPS);
 525 
 526   // ask Java to compute a constant by invoking a BSM given a Dynamic_info CP entry
 527   static void      invoke_bootstrap_method(BootstrapInfo& bootstrap_specifier, TRAPS);














 528 
 529   // Record the error when the first attempt to resolve a reference from a constant
 530   // pool entry to a class fails.
 531   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
 532                                    Symbol* message);
 533   static void delete_resolution_error(ConstantPool* pool);
 534   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
 535                                        Symbol** message);
 536 
 537 
 538   static ProtectionDomainCacheEntry* cache_get(Handle protection_domain);
 539 
 540  protected:
 541 
 542   enum Constants {
 543     _loader_constraint_size = 107,                     // number of entries in constraint table
 544     _resolution_error_size  = 107,                     // number of entries in resolution error table
 545     _invoke_method_size     = 139,                     // number of entries in invoke method table
 546     _placeholder_table_size = 1009                     // number of entries in hash table for placeholders
 547   };


 664 
 665   // Class loader constraints
 666   static void check_constraints(unsigned int hash,
 667                                 InstanceKlass* k, Handle loader,
 668                                 bool defining, TRAPS);
 669   static void update_dictionary(unsigned int d_hash,
 670                                 int p_index, unsigned int p_hash,
 671                                 InstanceKlass* k, Handle loader,
 672                                 TRAPS);
 673 
 674   static InstanceKlass* _well_known_klasses[];
 675 
 676   // table of box klasses (int_klass, etc.)
 677   static InstanceKlass* _box_klasses[T_VOID+1];
 678 
 679 private:
 680   static oop  _java_system_loader;
 681   static oop  _java_platform_loader;
 682 
 683   static bool _has_checkPackageAccess;
 684 
 685 public:
 686   static TableStatistics placeholders_statistics();
 687   static TableStatistics loader_constraints_statistics();
 688   static TableStatistics protection_domain_cache_statistics();
 689 };
 690 
 691 #endif // SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 "jvmci/systemDictionary_jvmci.hpp"
  30 #include "oops/objArrayOop.hpp"
  31 #include "oops/symbol.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/mutexLocker.hpp"
  34 #include "runtime/reflectionUtils.hpp"
  35 #include "runtime/signature.hpp"
  36 #include "utilities/hashtable.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


  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;
  86 class GCTimer;
  87 class OopStorage;
  88 
  89 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  90 
  91 // Certain classes, such as java.lang.Object and java.lang.String,
  92 // are "well-known", in the sense that no class loader is allowed
  93 // to provide a different definition.
  94 //
  95 // Each well-known class has a short klass name (like object_klass),
  96 // and a vmSymbol name (like java_lang_Object).


 160   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */                                   \
 161   do_klass(DirectMethodHandle_klass,                    java_lang_invoke_DirectMethodHandle                   ) \
 162   do_klass(MethodHandle_klass,                          java_lang_invoke_MethodHandle                         ) \
 163   do_klass(VarHandle_klass,                             java_lang_invoke_VarHandle                            ) \
 164   do_klass(MemberName_klass,                            java_lang_invoke_MemberName                           ) \
 165   do_klass(ResolvedMethodName_klass,                    java_lang_invoke_ResolvedMethodName                   ) \
 166   do_klass(MethodHandleNatives_klass,                   java_lang_invoke_MethodHandleNatives                  ) \
 167   do_klass(LambdaForm_klass,                            java_lang_invoke_LambdaForm                           ) \
 168   do_klass(MethodType_klass,                            java_lang_invoke_MethodType                           ) \
 169   do_klass(BootstrapMethodError_klass,                  java_lang_BootstrapMethodError                        ) \
 170   do_klass(CallSite_klass,                              java_lang_invoke_CallSite                             ) \
 171   do_klass(Context_klass,                               java_lang_invoke_MethodHandleNatives_CallSiteContext  ) \
 172   do_klass(ConstantCallSite_klass,                      java_lang_invoke_ConstantCallSite                     ) \
 173   do_klass(MutableCallSite_klass,                       java_lang_invoke_MutableCallSite                      ) \
 174   do_klass(VolatileCallSite_klass,                      java_lang_invoke_VolatileCallSite                     ) \
 175   /* Note: MethodHandle must be first, and VolatileCallSite last in group */                                    \
 176                                                                                                                 \
 177   do_klass(AssertionStatusDirectives_klass,             java_lang_AssertionStatusDirectives                   ) \
 178   do_klass(StringBuffer_klass,                          java_lang_StringBuffer                                ) \
 179   do_klass(StringBuilder_klass,                         java_lang_StringBuilder                               ) \

 180   do_klass(internal_Unsafe_klass,                       jdk_internal_misc_Unsafe                              ) \
 181   do_klass(module_Modules_klass,                        jdk_internal_module_Modules                           ) \
 182                                                                                                                 \
 183   /* support for CDS */                                                                                         \
 184   do_klass(ByteArrayInputStream_klass,                  java_io_ByteArrayInputStream                          ) \
 185   do_klass(URL_klass,                                   java_net_URL                                          ) \
 186   do_klass(Jar_Manifest_klass,                          java_util_jar_Manifest                                ) \
 187   do_klass(jdk_internal_loader_ClassLoaders_klass,      jdk_internal_loader_ClassLoaders                      ) \
 188   do_klass(jdk_internal_loader_ClassLoaders_AppClassLoader_klass,      jdk_internal_loader_ClassLoaders_AppClassLoader) \
 189   do_klass(jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass, jdk_internal_loader_ClassLoaders_PlatformClassLoader) \
 190   do_klass(CodeSource_klass,                            java_security_CodeSource                              ) \
 191                                                                                                                 \
 192   do_klass(StackTraceElement_klass,                     java_lang_StackTraceElement                           ) \
 193                                                                                                                 \
 194   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                 \
 195   do_klass(nio_Buffer_klass,                            java_nio_Buffer                                       ) \
 196                                                                                                                 \
 197   /* Stack Walking */                                                                                           \
 198   do_klass(StackWalker_klass,                           java_lang_StackWalker                                 ) \
 199   do_klass(AbstractStackWalker_klass,                   java_lang_StackStreamFactory_AbstractStackWalker      ) \
 200   do_klass(StackFrameInfo_klass,                        java_lang_StackFrameInfo                              ) \
 201   do_klass(LiveStackFrameInfo_klass,                    java_lang_LiveStackFrameInfo                          ) \
 202                                                                                                                 \
 203   /* support for stack dump lock analysis */                                                                    \
 204   do_klass(java_util_concurrent_locks_AbstractOwnableSynchronizer_klass, java_util_concurrent_locks_AbstractOwnableSynchronizer) \
 205                                                                                                                 \
 206   /* boxing klasses */                                                                                          \
 207   do_klass(Boolean_klass,                               java_lang_Boolean                                     ) \
 208   do_klass(Character_klass,                             java_lang_Character                                   ) \
 209   do_klass(Float_klass,                                 java_lang_Float                                       ) \
 210   do_klass(Double_klass,                                java_lang_Double                                      ) \
 211   do_klass(Byte_klass,                                  java_lang_Byte                                        ) \
 212   do_klass(Short_klass,                                 java_lang_Short                                       ) \
 213   do_klass(Integer_klass,                               java_lang_Integer                                     ) \
 214   do_klass(Long_klass,                                  java_lang_Long                                        ) \
 215                                                                                                                 \
 216   /* JVMCI classes. These are loaded on-demand. */                                                              \
 217   JVMCI_WK_KLASSES_DO(do_klass)                                                                                 \
 218                                                                                                                 \
 219   /*end*/
 220 
 221 
 222 class SystemDictionary : AllStatic {

 223   friend class VMStructs;
 224   friend class SystemDictionaryHandles;
 225 
 226  public:
 227   enum WKID {
 228     NO_WKID = 0,
 229 
 230     #define WK_KLASS_ENUM(name, symbol) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
 231     WK_KLASSES_DO(WK_KLASS_ENUM)
 232     #undef WK_KLASS_ENUM
 233 
 234     WKID_LIMIT,
 235 
 236 #if INCLUDE_JVMCI
 237     FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(JVMCI_klass),
 238     LAST_JVMCI_WKID  = WK_KLASS_ENUM_NAME(Value_klass),
 239 #endif
 240 
 241     FIRST_WKID = NO_WKID + 1
 242   };
 243 
 244   // Returns a class with a given class name and class loader.  Loads the
 245   // class if needed. If not found a NoClassDefFoundError or a
 246   // ClassNotFoundException is thrown, depending on the value on the
 247   // throw_error flag.  For most uses the throw_error argument should be set
 248   // to true.
 249 
 250   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
 251   // Convenient call for null loader and protection domain.
 252   static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
 253 protected:
 254   // handle error translation for resolve_or_null results
 255   static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS);
 256 
 257 public:
 258 
 259   // Returns a class with a given class name and class loader.
 260   // Loads the class if needed. If not found NULL is returned.


 344 
 345   static void methods_do(void f(Method*));
 346 
 347   // Garbage collection support
 348 
 349   // Unload (that is, break root links to) all unmarked classes and
 350   // loaders.  Returns "true" iff something was unloaded.
 351   static bool do_unloading(GCTimer* gc_timer);
 352 
 353   // Applies "f->do_oop" to all root oops in the system dictionary.
 354   static void oops_do(OopClosure* f);
 355 
 356   // System loader lock
 357   static oop system_loader_lock()           { return _system_loader_lock_obj; }
 358 
 359   // Protection Domain Table
 360   static ProtectionDomainCacheTable* pd_cache_table() { return _pd_cache_table; }
 361 
 362 public:
 363   // Printing
 364   static void print() { return print_on(tty); }
 365   static void print_on(outputStream* st);
 366   static void dump(outputStream* st, bool verbose);
 367 
 368   // Monotonically increasing counter which grows as classes are
 369   // loaded or modifications such as hot-swapping or setting/removing
 370   // of breakpoints are performed
 371   static inline int number_of_modifications()     { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; }
 372   // Needed by evolution and breakpoint code
 373   static inline void notice_modification()        { assert_locked_or_safepoint(Compile_lock); ++_number_of_modifications;      }
 374 
 375   // Verification
 376   static void verify();
 377 
 378   // Initialization
 379   static void initialize(TRAPS);
 380 
 381   // Checked fast access to the well-known classes -- so that you don't try to use them
 382   // before they are resolved.
 383   static InstanceKlass* check_klass(InstanceKlass* k) {
 384     assert(k != NULL, "klass not loaded");


 513   // find a java.lang.invoke.MethodType object for a given signature
 514   // (asks Java to compute it if necessary, except in a compiler thread)
 515   static Handle    find_method_handle_type(Symbol* signature,
 516                                            Klass* accessing_klass,
 517                                            TRAPS);
 518 
 519   // find a java.lang.Class object for a given signature
 520   static Handle    find_field_handle_type(Symbol* signature,
 521                                           Klass* accessing_klass,
 522                                           TRAPS);
 523 
 524   // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
 525   static Handle    link_method_handle_constant(Klass* caller,
 526                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
 527                                                Klass* callee,
 528                                                Symbol* name,
 529                                                Symbol* signature,
 530                                                TRAPS);
 531 
 532   // ask Java to compute a constant by invoking a BSM given a Dynamic_info CP entry
 533   static Handle    link_dynamic_constant(Klass* caller,
 534                                          int condy_index,
 535                                          Handle bootstrap_specifier,
 536                                          Symbol* name,
 537                                          Symbol* type,
 538                                          TRAPS);
 539 
 540   // ask Java to create a dynamic call site, while linking an invokedynamic op
 541   static methodHandle find_dynamic_call_site_invoker(Klass* caller,
 542                                                      int indy_index,
 543                                                      Handle bootstrap_method,
 544                                                      Symbol* name,
 545                                                      Symbol* type,
 546                                                      Handle *appendix_result,
 547                                                      TRAPS);
 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(const constantPoolHandle& pool, int which, Symbol* error,
 552                                    Symbol* message);
 553   static void delete_resolution_error(ConstantPool* pool);
 554   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
 555                                        Symbol** message);
 556 
 557 
 558   static ProtectionDomainCacheEntry* cache_get(Handle protection_domain);
 559 
 560  protected:
 561 
 562   enum Constants {
 563     _loader_constraint_size = 107,                     // number of entries in constraint table
 564     _resolution_error_size  = 107,                     // number of entries in resolution error table
 565     _invoke_method_size     = 139,                     // number of entries in invoke method table
 566     _placeholder_table_size = 1009                     // number of entries in hash table for placeholders
 567   };


 684 
 685   // Class loader constraints
 686   static void check_constraints(unsigned int hash,
 687                                 InstanceKlass* k, Handle loader,
 688                                 bool defining, TRAPS);
 689   static void update_dictionary(unsigned int d_hash,
 690                                 int p_index, unsigned int p_hash,
 691                                 InstanceKlass* k, Handle loader,
 692                                 TRAPS);
 693 
 694   static InstanceKlass* _well_known_klasses[];
 695 
 696   // table of box klasses (int_klass, etc.)
 697   static InstanceKlass* _box_klasses[T_VOID+1];
 698 
 699 private:
 700   static oop  _java_system_loader;
 701   static oop  _java_platform_loader;
 702 
 703   static bool _has_checkPackageAccess;





 704 };
 705 
 706 #endif // SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
< prev index next >