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

src/share/vm/classfile/systemDictionary.hpp

Print this page




  77 class ResolutionErrorTable;
  78 class SymbolPropertyTable;
  79 
  80 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  81 // They are all "well-known", in the sense that no class loader is allowed
  82 // to provide a different definition.
  83 //
  84 // These klasses must all have names defined in vmSymbols.
  85 
  86 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  87 
  88 // Each well-known class has a short klass name (like object_klass),
  89 // a vmSymbol name (like java_lang_Object), and a flag word
  90 // that makes some minor distinctions, like whether the klass
  91 // is preloaded, optional, release-specific, etc.
  92 // The order of these definitions is significant; it is the order in which
  93 // preloading is actually performed by initialize_preloaded_classes.
  94 
  95 #define WK_KLASSES_DO(do_klass)                                                                                          \
  96   /* well-known classes */                                                                                               \
  97   do_klass(Object_klass,                                java_lang_Object,                          Pre_Link            ) \
  98   do_klass(String_klass,                                java_lang_String,                          Pre_Link            ) \
  99   do_klass(Class_klass,                                 java_lang_Class,                           Pre_Link            ) \
 100   do_klass(Cloneable_klass,                             java_lang_Cloneable,                       Pre_Link            ) \
 101   do_klass(ClassLoader_klass,                           java_lang_ClassLoader,                     Pre_Link            ) \
 102   do_klass(Serializable_klass,                          java_io_Serializable,                      Pre_Link            ) \
 103   do_klass(System_klass,                                java_lang_System,                          Pre_Link            ) \
 104   do_klass(Throwable_klass,                             java_lang_Throwable,                       Pre_Link            ) \
 105   do_klass(Error_klass,                                 java_lang_Error,                           Pre_Link            ) \
 106   do_klass(ThreadDeath_klass,                           java_lang_ThreadDeath,                     Pre_Link            ) \
 107   do_klass(Exception_klass,                             java_lang_Exception,                       Pre_Link            ) \
 108   do_klass(RuntimeException_klass,                      java_lang_RuntimeException,                Pre_Link            ) \
 109   do_klass(ProtectionDomain_klass,                      java_security_ProtectionDomain,            Pre_Link            ) \
 110   do_klass(AccessControlContext_klass,                  java_security_AccessControlContext,        Pre_Link            ) \
 111   do_klass(ClassNotFoundException_klass,                java_lang_ClassNotFoundException,          Pre_Link            ) \
 112   do_klass(NoClassDefFoundError_klass,                  java_lang_NoClassDefFoundError,            Pre_Link            ) \
 113   do_klass(LinkageError_klass,                          java_lang_LinkageError,                    Pre_Link            ) \
 114   do_klass(ClassCastException_klass,                    java_lang_ClassCastException,              Pre_Link            ) \
 115   do_klass(ArrayStoreException_klass,                   java_lang_ArrayStoreException,             Pre_Link            ) \
 116   do_klass(VirtualMachineError_klass,                   java_lang_VirtualMachineError,             Pre_Link            ) \
 117   do_klass(OutOfMemoryError_klass,                      java_lang_OutOfMemoryError,                Pre_Link            ) \
 118   do_klass(StackOverflowError_klass,                    java_lang_StackOverflowError,              Pre_Link            ) \
 119   do_klass(IllegalMonitorStateException_klass,          java_lang_IllegalMonitorStateException,    Pre_Link            ) \
 120   do_klass(Reference_klass,                             java_lang_ref_Reference,                   Pre_Link            ) \
 121                                                                                                                          \
 122   /* Preload ref klasses and set reference types */                                                                      \
 123   do_klass(SoftReference_klass,                         java_lang_ref_SoftReference,               Pre_Link            ) \
 124   do_klass(WeakReference_klass,                         java_lang_ref_WeakReference,               Pre_Link            ) \
 125   do_klass(FinalReference_klass,                        java_lang_ref_FinalReference,              Pre                 ) \
 126   do_klass(PhantomReference_klass,                      java_lang_ref_PhantomReference,            Pre_Link            ) \
 127   do_klass(Finalizer_klass,                             java_lang_ref_Finalizer,                   Pre                 ) \
 128                                                                                                                          \
 129   do_klass(Thread_klass,                                java_lang_Thread,                          Pre_Link            ) \
 130   do_klass(ThreadGroup_klass,                           java_lang_ThreadGroup,                     Pre_Link            ) \
 131   do_klass(Properties_klass,                            java_util_Properties,                      Pre_Link            ) \
 132   do_klass(reflect_AccessibleObject_klass,              java_lang_reflect_AccessibleObject,        Pre_Link            ) \
 133   do_klass(reflect_Field_klass,                         java_lang_reflect_Field,                   Pre_Link            ) \
 134   do_klass(reflect_Method_klass,                        java_lang_reflect_Method,                  Pre_Link            ) \
 135   do_klass(reflect_Constructor_klass,                   java_lang_reflect_Constructor,             Pre_Link            ) \
 136                                                                                                                          \
 137   /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */                              \
 138   /* Universe::is_gte_jdk14x_version() is not set up by this point. */                                                   \
 139   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                          \
 140   do_klass(reflect_MagicAccessorImpl_klass,             sun_reflect_MagicAccessorImpl,             Opt                 ) \
 141   do_klass(reflect_MethodAccessorImpl_klass,            sun_reflect_MethodAccessorImpl,            Opt_Only_JDK14NewRef) \
 142   do_klass(reflect_ConstructorAccessorImpl_klass,       sun_reflect_ConstructorAccessorImpl,       Opt_Only_JDK14NewRef) \
 143   do_klass(reflect_DelegatingClassLoader_klass,         sun_reflect_DelegatingClassLoader,         Opt                 ) \
 144   do_klass(reflect_ConstantPool_klass,                  sun_reflect_ConstantPool,                  Opt_Only_JDK15      ) \
 145   do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15      ) \
 146                                                                                                                          \
 147   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */                                            \
 148   do_klass(MethodHandle_klass,                          java_lang_invoke_MethodHandle,             Pre_Link            ) \
 149   do_klass(MemberName_klass,                            java_lang_invoke_MemberName,               Pre                 ) \
 150   do_klass(MethodHandleNatives_klass,                   java_lang_invoke_MethodHandleNatives,      Pre                 ) \
 151   do_klass(LambdaForm_klass,                            java_lang_invoke_LambdaForm,               Opt                 ) \
 152   do_klass(MethodType_klass,                            java_lang_invoke_MethodType,               Pre_Link            ) \
 153   do_klass(BootstrapMethodError_klass,                  java_lang_BootstrapMethodError,            Pre_Link            ) \
 154   do_klass(CallSite_klass,                              java_lang_invoke_CallSite,                 Pre_Link            ) \
 155   do_klass(ConstantCallSite_klass,                      java_lang_invoke_ConstantCallSite,         Pre_Link            ) \
 156   do_klass(MutableCallSite_klass,                       java_lang_invoke_MutableCallSite,          Pre_Link            ) \
 157   do_klass(VolatileCallSite_klass,                      java_lang_invoke_VolatileCallSite,         Pre_Link            ) \
 158   /* Note: MethodHandle must be first, and VolatileCallSite last in group */                                             \
 159                                                                                                                          \
 160   do_klass(StringBuffer_klass,                          java_lang_StringBuffer,                    Pre_Link            ) \
 161   do_klass(StringBuilder_klass,                         java_lang_StringBuilder,                   Pre_Link            ) \
 162                                                                                                                          \
 163   /* It's NULL in non-1.4 JDKs. */                                                                                       \
 164   do_klass(StackTraceElement_klass,                     java_lang_StackTraceElement,               Opt                 ) \
 165   /* Universe::is_gte_jdk14x_version() is not set up by this point. */                                                   \
 166   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                          \
 167   do_klass(nio_Buffer_klass,                            java_nio_Buffer,                           Opt                 ) \
 168                                                                                                                          \
 169   do_klass(DownloadManager_klass,                       sun_jkernel_DownloadManager,               Opt_Kernel          ) \
 170                                                                                                                          \
 171   do_klass(PostVMInitHook_klass,                        sun_misc_PostVMInitHook,                   Opt                 ) \
 172                                                                                                                          \
 173   /* Preload boxing klasses */                                                                                           \
 174   do_klass(Boolean_klass,                               java_lang_Boolean,                         Pre_Link            ) \
 175   do_klass(Character_klass,                             java_lang_Character,                       Pre_Link            ) \
 176   do_klass(Float_klass,                                 java_lang_Float,                           Pre_Link            ) \
 177   do_klass(Double_klass,                                java_lang_Double,                          Pre_Link            ) \
 178   do_klass(Byte_klass,                                  java_lang_Byte,                            Pre_Link            ) \
 179   do_klass(Short_klass,                                 java_lang_Short,                           Pre_Link            ) \
 180   do_klass(Integer_klass,                               java_lang_Integer,                         Pre_Link            ) \
 181   do_klass(Long_klass,                                  java_lang_Long,                            Pre_Link            ) \
 182   /*end*/
 183 
 184 
 185 class SystemDictionary : AllStatic {
 186   friend class VMStructs;
 187   friend class SystemDictionaryHandles;
 188 
 189  public:
 190   enum WKID {
 191     NO_WKID = 0,
 192 
 193     #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
 194     WK_KLASSES_DO(WK_KLASS_ENUM)
 195     #undef WK_KLASS_ENUM
 196 
 197     WKID_LIMIT,
 198 
 199     FIRST_WKID = NO_WKID + 1
 200   };
 201 
 202   enum InitOption {
 203     Pre,                        // preloaded; error if not present
 204     Pre_Link,                   // preloaded; error if not present; link as well-known
 205 
 206     // Order is significant.  Options before this point require resolve_or_fail.
 207     // Options after this point will use resolve_or_null instead.
 208 
 209     Opt,                        // preload tried; NULL if not present
 210     Opt_Only_JDK14NewRef,       // preload tried; use only with NewReflection
 211     Opt_Only_JDK15,             // preload tried; use only with JDK1.5+
 212     Opt_Kernel,                 // preload tried only #ifdef KERNEL
 213     OPTION_LIMIT,
 214     CEIL_LG_OPTION_LIMIT = 4    // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
 215   };
 216 
 217 
 218   // Returns a class with a given class name and class loader.  Loads the
 219   // class if needed. If not found a NoClassDefFoundError or a
 220   // ClassNotFoundException is thrown, depending on the value on the
 221   // throw_error flag.  For most uses the throw_error argument should be set
 222   // to true.
 223 
 224   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);


 263                                KlassHandle host_klass,
 264                                GrowableArray<Handle>* cp_patches,
 265                                TRAPS);
 266 
 267   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
 268   static Klass* resolve_from_stream(Symbol* class_name, Handle class_loader,
 269                                       Handle protection_domain,
 270                                       ClassFileStream* st, bool verify, TRAPS);
 271 
 272   // Lookup an already loaded class. If not found NULL is returned.
 273   static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 274 
 275   // Lookup an already loaded instance or array class.
 276   // Do not make any queries to class loaders; consult only the cache.
 277   // If not found NULL is returned.
 278   static Klass* find_instance_or_array_klass(Symbol* class_name,
 279                                                Handle class_loader,
 280                                                Handle protection_domain,
 281                                                TRAPS);
 282 
 283   // If the given name is known to vmSymbols, return the well-know klass:
 284   static Klass* find_well_known_klass(Symbol* class_name);
 285 
 286   // Lookup an instance or array class that has already been loaded
 287   // either into the given class loader, or else into another class
 288   // loader that is constrained (via loader constraints) to produce
 289   // a consistent class.  Do not take protection domains into account.
 290   // Do not make any queries to class loaders; consult only the cache.
 291   // Return NULL if the class is not found.
 292   //
 293   // This function is a strict superset of find_instance_or_array_klass.
 294   // This function (the unchecked version) makes a conservative prediction
 295   // of the result of the checked version, assuming successful lookup.
 296   // If both functions return non-null, they must return the same value.
 297   // Also, the unchecked version may sometimes be non-null where the
 298   // checked version is null.  This can occur in several ways:
 299   //   1. No query has yet been made to the class loader.
 300   //   2. The class loader was queried, but chose not to delegate.
 301   //   3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
 302   //   4. Loading was attempted, but there was a linkage error of some sort.
 303   // In all of these cases, the loader constraints on this type are
 304   // satisfied, and it is safe for classes in the given class loader
 305   // to manipulate strongly-typed values of the found class, subject


 376   static void verify();
 377 
 378 #ifdef ASSERT
 379   static bool is_internal_format(Symbol* class_name);
 380 #endif
 381 
 382   // Verify class is in dictionary
 383   static void verify_obj_klass_present(Symbol* class_name,
 384                                        ClassLoaderData* loader_data);
 385 
 386   // Initialization
 387   static void initialize(TRAPS);
 388 
 389   // Fast access to commonly used classes (preloaded)
 390   static Klass* check_klass(Klass* k) {
 391     assert(k != NULL, "preloaded klass not initialized");
 392     return k;
 393   }
 394 
 395   static Klass* check_klass_Pre(       Klass* k) { return check_klass(k); }
 396   static Klass* check_klass_Pre_Link(  Klass* k) { return check_klass(k); }
 397   static Klass* check_klass_Opt(       Klass* k) { return k; }
 398   static Klass* check_klass_Opt_Kernel(Klass* k) { return k; } //== Opt
 399   static Klass* check_klass_Opt_Only_JDK15(Klass* k) {
 400     assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
 401     return k;
 402   }
 403   static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) {
 404     assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
 405     // despite the optional loading, if you use this it must be present:
 406     return check_klass(k);
 407   }
 408 
 409   static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
 410   static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
 411   static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
 412     int limit = (int)end_id + 1;
 413     initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
 414   }
 415 
 416   static void check_wk_pre_link_klasses() NOT_DEBUG_RETURN;
 417 
 418 public:
 419   #define WK_KLASS_DECLARE(name, symbol, option) \
 420     static Klass* name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } \
 421     static Klass** name##_addr() {                                                                       \
 422       return &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)];           \
 423     }
 424   WK_KLASSES_DO(WK_KLASS_DECLARE);
 425   #undef WK_KLASS_DECLARE
 426 
 427   static Klass* well_known_klass(WKID id) {
 428     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
 429     return _well_known_klasses[id];
 430   }
 431 
 432   static Klass** well_known_klass_addr(WKID id) {
 433     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
 434     return &_well_known_klasses[id];
 435   }
 436 
 437   // Local definition for direct access to the private array:




  77 class ResolutionErrorTable;
  78 class SymbolPropertyTable;
  79 
  80 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  81 // They are all "well-known", in the sense that no class loader is allowed
  82 // to provide a different definition.
  83 //
  84 // These klasses must all have names defined in vmSymbols.
  85 
  86 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  87 
  88 // Each well-known class has a short klass name (like object_klass),
  89 // a vmSymbol name (like java_lang_Object), and a flag word
  90 // that makes some minor distinctions, like whether the klass
  91 // is preloaded, optional, release-specific, etc.
  92 // The order of these definitions is significant; it is the order in which
  93 // preloading is actually performed by initialize_preloaded_classes.
  94 
  95 #define WK_KLASSES_DO(do_klass)                                                                                          \
  96   /* well-known classes */                                                                                               \
  97   do_klass(Object_klass,                                java_lang_Object,                          Pre                 ) \
  98   do_klass(String_klass,                                java_lang_String,                          Pre                 ) \
  99   do_klass(Class_klass,                                 java_lang_Class,                           Pre                 ) \
 100   do_klass(Cloneable_klass,                             java_lang_Cloneable,                       Pre                 ) \
 101   do_klass(ClassLoader_klass,                           java_lang_ClassLoader,                     Pre                 ) \
 102   do_klass(Serializable_klass,                          java_io_Serializable,                      Pre                 ) \
 103   do_klass(System_klass,                                java_lang_System,                          Pre                 ) \
 104   do_klass(Throwable_klass,                             java_lang_Throwable,                       Pre                 ) \
 105   do_klass(Error_klass,                                 java_lang_Error,                           Pre                 ) \
 106   do_klass(ThreadDeath_klass,                           java_lang_ThreadDeath,                     Pre                 ) \
 107   do_klass(Exception_klass,                             java_lang_Exception,                       Pre                 ) \
 108   do_klass(RuntimeException_klass,                      java_lang_RuntimeException,                Pre                 ) \
 109   do_klass(ProtectionDomain_klass,                      java_security_ProtectionDomain,            Pre                 ) \
 110   do_klass(AccessControlContext_klass,                  java_security_AccessControlContext,        Pre                 ) \
 111   do_klass(ClassNotFoundException_klass,                java_lang_ClassNotFoundException,          Pre                 ) \
 112   do_klass(NoClassDefFoundError_klass,                  java_lang_NoClassDefFoundError,            Pre                 ) \
 113   do_klass(LinkageError_klass,                          java_lang_LinkageError,                    Pre                 ) \
 114   do_klass(ClassCastException_klass,                    java_lang_ClassCastException,              Pre                 ) \
 115   do_klass(ArrayStoreException_klass,                   java_lang_ArrayStoreException,             Pre                 ) \
 116   do_klass(VirtualMachineError_klass,                   java_lang_VirtualMachineError,             Pre                 ) \
 117   do_klass(OutOfMemoryError_klass,                      java_lang_OutOfMemoryError,                Pre                 ) \
 118   do_klass(StackOverflowError_klass,                    java_lang_StackOverflowError,              Pre                 ) \
 119   do_klass(IllegalMonitorStateException_klass,          java_lang_IllegalMonitorStateException,    Pre                 ) \
 120   do_klass(Reference_klass,                             java_lang_ref_Reference,                   Pre                 ) \
 121                                                                                                                          \
 122   /* Preload ref klasses and set reference types */                                                                      \
 123   do_klass(SoftReference_klass,                         java_lang_ref_SoftReference,               Pre                 ) \
 124   do_klass(WeakReference_klass,                         java_lang_ref_WeakReference,               Pre                 ) \
 125   do_klass(FinalReference_klass,                        java_lang_ref_FinalReference,              Pre                 ) \
 126   do_klass(PhantomReference_klass,                      java_lang_ref_PhantomReference,            Pre                 ) \
 127   do_klass(Finalizer_klass,                             java_lang_ref_Finalizer,                   Pre                 ) \
 128                                                                                                                          \
 129   do_klass(Thread_klass,                                java_lang_Thread,                          Pre                 ) \
 130   do_klass(ThreadGroup_klass,                           java_lang_ThreadGroup,                     Pre                 ) \
 131   do_klass(Properties_klass,                            java_util_Properties,                      Pre                 ) \
 132   do_klass(reflect_AccessibleObject_klass,              java_lang_reflect_AccessibleObject,        Pre                 ) \
 133   do_klass(reflect_Field_klass,                         java_lang_reflect_Field,                   Pre                 ) \
 134   do_klass(reflect_Method_klass,                        java_lang_reflect_Method,                  Pre                 ) \
 135   do_klass(reflect_Constructor_klass,                   java_lang_reflect_Constructor,             Pre                 ) \
 136                                                                                                                          \
 137   /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */                              \
 138   /* Universe::is_gte_jdk14x_version() is not set up by this point. */                                                   \
 139   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                          \
 140   do_klass(reflect_MagicAccessorImpl_klass,             sun_reflect_MagicAccessorImpl,             Opt                 ) \
 141   do_klass(reflect_MethodAccessorImpl_klass,            sun_reflect_MethodAccessorImpl,            Opt_Only_JDK14NewRef) \
 142   do_klass(reflect_ConstructorAccessorImpl_klass,       sun_reflect_ConstructorAccessorImpl,       Opt_Only_JDK14NewRef) \
 143   do_klass(reflect_DelegatingClassLoader_klass,         sun_reflect_DelegatingClassLoader,         Opt                 ) \
 144   do_klass(reflect_ConstantPool_klass,                  sun_reflect_ConstantPool,                  Opt_Only_JDK15      ) \
 145   do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15      ) \
 146                                                                                                                          \
 147   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */                                            \
 148   do_klass(MethodHandle_klass,                          java_lang_invoke_MethodHandle,             Pre_JSR292          ) \
 149   do_klass(MemberName_klass,                            java_lang_invoke_MemberName,               Pre_JSR292          ) \
 150   do_klass(MethodHandleNatives_klass,                   java_lang_invoke_MethodHandleNatives,      Pre_JSR292          ) \
 151   do_klass(LambdaForm_klass,                            java_lang_invoke_LambdaForm,               Opt                 ) \
 152   do_klass(MethodType_klass,                            java_lang_invoke_MethodType,               Pre_JSR292          ) \
 153   do_klass(BootstrapMethodError_klass,                  java_lang_BootstrapMethodError,            Pre_JSR292          ) \
 154   do_klass(CallSite_klass,                              java_lang_invoke_CallSite,                 Pre_JSR292          ) \
 155   do_klass(ConstantCallSite_klass,                      java_lang_invoke_ConstantCallSite,         Pre_JSR292          ) \
 156   do_klass(MutableCallSite_klass,                       java_lang_invoke_MutableCallSite,          Pre_JSR292          ) \
 157   do_klass(VolatileCallSite_klass,                      java_lang_invoke_VolatileCallSite,         Pre_JSR292          ) \
 158   /* Note: MethodHandle must be first, and VolatileCallSite last in group */                                             \
 159                                                                                                                          \
 160   do_klass(StringBuffer_klass,                          java_lang_StringBuffer,                    Pre                 ) \
 161   do_klass(StringBuilder_klass,                         java_lang_StringBuilder,                   Pre                 ) \
 162                                                                                                                          \
 163   /* It's NULL in non-1.4 JDKs. */                                                                                       \
 164   do_klass(StackTraceElement_klass,                     java_lang_StackTraceElement,               Opt                 ) \
 165   /* Universe::is_gte_jdk14x_version() is not set up by this point. */                                                   \
 166   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                          \
 167   do_klass(nio_Buffer_klass,                            java_nio_Buffer,                           Opt                 ) \
 168                                                                                                                          \
 169   do_klass(DownloadManager_klass,                       sun_jkernel_DownloadManager,               Opt_Kernel          ) \
 170                                                                                                                          \
 171   do_klass(PostVMInitHook_klass,                        sun_misc_PostVMInitHook,                   Opt                 ) \
 172                                                                                                                          \
 173   /* Preload boxing klasses */                                                                                           \
 174   do_klass(Boolean_klass,                               java_lang_Boolean,                         Pre                 ) \
 175   do_klass(Character_klass,                             java_lang_Character,                       Pre                 ) \
 176   do_klass(Float_klass,                                 java_lang_Float,                           Pre                 ) \
 177   do_klass(Double_klass,                                java_lang_Double,                          Pre                 ) \
 178   do_klass(Byte_klass,                                  java_lang_Byte,                            Pre                 ) \
 179   do_klass(Short_klass,                                 java_lang_Short,                           Pre                 ) \
 180   do_klass(Integer_klass,                               java_lang_Integer,                         Pre                 ) \
 181   do_klass(Long_klass,                                  java_lang_Long,                            Pre                 ) \
 182   /*end*/
 183 
 184 
 185 class SystemDictionary : AllStatic {
 186   friend class VMStructs;
 187   friend class SystemDictionaryHandles;
 188 
 189  public:
 190   enum WKID {
 191     NO_WKID = 0,
 192 
 193     #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
 194     WK_KLASSES_DO(WK_KLASS_ENUM)
 195     #undef WK_KLASS_ENUM
 196 
 197     WKID_LIMIT,
 198 
 199     FIRST_WKID = NO_WKID + 1
 200   };
 201 
 202   enum InitOption {
 203     Pre,                        // preloaded; error if not present
 204     Pre_JSR292,                 // preloaded if EnableInvokeDynamic
 205 
 206     // Order is significant.  Options before this point require resolve_or_fail.
 207     // Options after this point will use resolve_or_null instead.
 208 
 209     Opt,                        // preload tried; NULL if not present
 210     Opt_Only_JDK14NewRef,       // preload tried; use only with NewReflection
 211     Opt_Only_JDK15,             // preload tried; use only with JDK1.5+
 212     Opt_Kernel,                 // preload tried only #ifdef KERNEL
 213     OPTION_LIMIT,
 214     CEIL_LG_OPTION_LIMIT = 4    // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
 215   };
 216 
 217 
 218   // Returns a class with a given class name and class loader.  Loads the
 219   // class if needed. If not found a NoClassDefFoundError or a
 220   // ClassNotFoundException is thrown, depending on the value on the
 221   // throw_error flag.  For most uses the throw_error argument should be set
 222   // to true.
 223 
 224   static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);


 263                                KlassHandle host_klass,
 264                                GrowableArray<Handle>* cp_patches,
 265                                TRAPS);
 266 
 267   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
 268   static Klass* resolve_from_stream(Symbol* class_name, Handle class_loader,
 269                                       Handle protection_domain,
 270                                       ClassFileStream* st, bool verify, TRAPS);
 271 
 272   // Lookup an already loaded class. If not found NULL is returned.
 273   static Klass* find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
 274 
 275   // Lookup an already loaded instance or array class.
 276   // Do not make any queries to class loaders; consult only the cache.
 277   // If not found NULL is returned.
 278   static Klass* find_instance_or_array_klass(Symbol* class_name,
 279                                                Handle class_loader,
 280                                                Handle protection_domain,
 281                                                TRAPS);
 282 



 283   // Lookup an instance or array class that has already been loaded
 284   // either into the given class loader, or else into another class
 285   // loader that is constrained (via loader constraints) to produce
 286   // a consistent class.  Do not take protection domains into account.
 287   // Do not make any queries to class loaders; consult only the cache.
 288   // Return NULL if the class is not found.
 289   //
 290   // This function is a strict superset of find_instance_or_array_klass.
 291   // This function (the unchecked version) makes a conservative prediction
 292   // of the result of the checked version, assuming successful lookup.
 293   // If both functions return non-null, they must return the same value.
 294   // Also, the unchecked version may sometimes be non-null where the
 295   // checked version is null.  This can occur in several ways:
 296   //   1. No query has yet been made to the class loader.
 297   //   2. The class loader was queried, but chose not to delegate.
 298   //   3. ClassLoader.checkPackageAccess rejected a proposed protection domain.
 299   //   4. Loading was attempted, but there was a linkage error of some sort.
 300   // In all of these cases, the loader constraints on this type are
 301   // satisfied, and it is safe for classes in the given class loader
 302   // to manipulate strongly-typed values of the found class, subject


 373   static void verify();
 374 
 375 #ifdef ASSERT
 376   static bool is_internal_format(Symbol* class_name);
 377 #endif
 378 
 379   // Verify class is in dictionary
 380   static void verify_obj_klass_present(Symbol* class_name,
 381                                        ClassLoaderData* loader_data);
 382 
 383   // Initialization
 384   static void initialize(TRAPS);
 385 
 386   // Fast access to commonly used classes (preloaded)
 387   static Klass* check_klass(Klass* k) {
 388     assert(k != NULL, "preloaded klass not initialized");
 389     return k;
 390   }
 391 
 392   static Klass* check_klass_Pre(       Klass* k) { return check_klass(k); }
 393   static Klass* check_klass_Pre_JSR292(Klass* k) { return EnableInvokeDynamic ? check_klass(k) : k; }
 394   static Klass* check_klass_Opt(       Klass* k) { return k; }
 395   static Klass* check_klass_Opt_Kernel(Klass* k) { return k; } //== Opt
 396   static Klass* check_klass_Opt_Only_JDK15(Klass* k) {
 397     assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
 398     return k;
 399   }
 400   static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) {
 401     assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only");
 402     // despite the optional loading, if you use this it must be present:
 403     return check_klass(k);
 404   }
 405 
 406   static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
 407   static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
 408   static void initialize_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
 409     int limit = (int)end_id + 1;
 410     initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
 411   }
 412 


 413 public:
 414   #define WK_KLASS_DECLARE(name, symbol, option) \
 415     static Klass* name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } \
 416     static Klass** name##_addr() {                                                                       \
 417       return &SystemDictionary::_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)];           \
 418     }
 419   WK_KLASSES_DO(WK_KLASS_DECLARE);
 420   #undef WK_KLASS_DECLARE
 421 
 422   static Klass* well_known_klass(WKID id) {
 423     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
 424     return _well_known_klasses[id];
 425   }
 426 
 427   static Klass** well_known_klass_addr(WKID id) {
 428     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
 429     return &_well_known_klasses[id];
 430   }
 431 
 432   // Local definition for direct access to the private array:


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