< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.hpp

Print this page


 115 public:
 116   enum LoaderType {
 117     LT_BUILTIN,
 118     LT_UNREGISTERED
 119   };
 120 
 121   enum {
 122     FROM_FIELD_IS_PROTECTED = 1 << 0,
 123     FROM_IS_ARRAY           = 1 << 1,
 124     FROM_IS_OBJECT          = 1 << 2
 125   };
 126 
 127   int             _id;
 128   int             _clsfile_size;
 129   int             _clsfile_crc32;
 130   void*           _verifier_constraints; // FIXME - use a union here to avoid type casting??
 131   void*           _verifier_constraint_flags;
 132 
 133   // See "Identifying the loader_type of archived classes" comments above.
 134   LoaderType loader_type() const {
 135     Klass* k = (Klass*)literal();
 136 
 137     if ((k->shared_classpath_index() != UNREGISTERED_INDEX)) {
 138       return LT_BUILTIN;
 139     } else {
 140       return LT_UNREGISTERED;
 141     }
 142   }
 143 
 144   SharedDictionaryEntry* next() {
 145     return (SharedDictionaryEntry*)(DictionaryEntry::next());
 146   }
 147 
 148   bool is_builtin() const {
 149     return loader_type() == LT_BUILTIN;
 150   }
 151   bool is_unregistered() const {
 152     return loader_type() == LT_UNREGISTERED;
 153   }
 154 
 155   void add_verification_constraint(Symbol* name,
 156          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object);
 157   int finalize_verification_constraints();
 158   void check_verification_constraints(InstanceKlass* klass, TRAPS);
 159   void metaspace_pointers_do(MetaspaceClosure* it) NOT_CDS_RETURN;
 160 };
 161 
 162 class SharedDictionary : public Dictionary {
 163   SharedDictionaryEntry* get_entry_for_builtin_loader(const Symbol* name) const;
 164   SharedDictionaryEntry* get_entry_for_unregistered_loader(const Symbol* name,
 165                                                            int clsfile_size,
 166                                                            int clsfile_crc32) const;
 167 
 168   // Convenience functions
 169   SharedDictionaryEntry* bucket(int index) const {
 170     return (SharedDictionaryEntry*)(Dictionary::bucket(index));
 171   }
 172 
 173 public:
 174   SharedDictionaryEntry* find_entry_for(Klass* klass);
 175   void finalize_verification_constraints();
 176 
 177   bool add_non_builtin_klass(const Symbol* class_name,
 178                              ClassLoaderData* loader_data,
 179                              InstanceKlass* obj);
 180 
 181   void update_entry(Klass* klass, int id);
 182 
 183   Klass* find_class_for_builtin_loader(const Symbol* name) const;
 184   Klass* find_class_for_unregistered_loader(const Symbol* name,
 185                                             int clsfile_size,
 186                                             int clsfile_crc32) const;
 187   bool class_exists_for_unregistered_loader(const Symbol* name) {
 188     return (get_entry_for_unregistered_loader(name, -1, -1) != NULL);
 189   }
 190 };
 191 
 192 class SystemDictionaryShared: public SystemDictionary {
 193 private:
 194   // These _shared_xxxs arrays are used to initialize the java.lang.Package and
 195   // java.security.ProtectionDomain objects associated with each shared class.
 196   //
 197   // See SystemDictionaryShared::init_security_info for more info.
 198   static objArrayOop _shared_protection_domains;
 199   static objArrayOop _shared_jar_urls;
 200   static objArrayOop _shared_jar_manifests;
 201 
 202   static InstanceKlass* load_shared_class_for_builtin_loader(
 203                                                Symbol* class_name,
 204                                                Handle class_loader,


 300   // Check if sharing is supported for the class loader.
 301   static bool is_sharing_possible(ClassLoaderData* loader_data);
 302   static bool is_shared_class_visible_for_classloader(InstanceKlass* ik,
 303                                                       Handle class_loader,
 304                                                       const char* pkg_string,
 305                                                       Symbol* pkg_name,
 306                                                       PackageEntry* pkg_entry,
 307                                                       ModuleEntry* mod_entry,
 308                                                       TRAPS);
 309   static PackageEntry* get_package_entry(Symbol* pkg,
 310                                          ClassLoaderData *loader_data) {
 311     if (loader_data != NULL) {
 312       PackageEntryTable* pkgEntryTable = loader_data->packages();
 313       return pkgEntryTable->lookup_only(pkg);
 314     }
 315     return NULL;
 316   }
 317 
 318   static bool add_non_builtin_klass(Symbol* class_name, ClassLoaderData* loader_data,
 319                                     InstanceKlass* k, TRAPS);
 320   static Klass* dump_time_resolve_super_or_fail(Symbol* child_name,
 321                                                 Symbol* class_name,
 322                                                 Handle class_loader,
 323                                                 Handle protection_domain,
 324                                                 bool is_superclass,
 325                                                 TRAPS);
 326 
 327   static size_t dictionary_entry_size() {
 328     return (DumpSharedSpaces) ? sizeof(SharedDictionaryEntry) : sizeof(DictionaryEntry);
 329   }
 330   static void init_shared_dictionary_entry(Klass* k, DictionaryEntry* entry) NOT_CDS_RETURN;
 331   static bool is_builtin(DictionaryEntry* ent) {
 332     // Can't use virtual function is_builtin because DictionaryEntry doesn't initialize
 333     // vtable because it's not constructed properly.
 334     SharedDictionaryEntry* entry = (SharedDictionaryEntry*)ent;
 335     return entry->is_builtin();
 336   }
 337 
 338   // For convenient access to the SharedDictionaryEntry's of the archived classes.
 339   static SharedDictionary* shared_dictionary() {
 340     assert(!DumpSharedSpaces, "not for dumping");
 341     return (SharedDictionary*)SystemDictionary::shared_dictionary();
 342   }
 343 
 344   static SharedDictionary* boot_loader_dictionary() {
 345     return (SharedDictionary*)ClassLoaderData::the_null_class_loader_data()->dictionary();
 346   }
 347 
 348   static void update_shared_entry(Klass* klass, int id) {
 349     assert(DumpSharedSpaces, "sanity");
 350     assert((SharedDictionary*)(klass->class_loader_data()->dictionary()) != NULL, "sanity");
 351     ((SharedDictionary*)(klass->class_loader_data()->dictionary()))->update_entry(klass, id);
 352   }
 353 
 354   static void set_shared_class_misc_info(Klass* k, ClassFileStream* cfs);
 355 
 356   static InstanceKlass* lookup_from_stream(const Symbol* class_name,
 357                                            Handle class_loader,
 358                                            Handle protection_domain,
 359                                            const ClassFileStream* st,
 360                                            TRAPS);
 361   // "verification_constraints" are a set of checks performed by
 362   // VerificationType::is_reference_assignable_from when verifying a shared class during
 363   // dump time.
 364   //
 365   // With AppCDS, it is possible to override archived classes by calling
 366   // ClassLoader.defineClass() directly. SystemDictionary::load_shared_class() already
 367   // ensures that you cannot load a shared class if its super type(s) are changed. However,
 368   // we need an additional check to ensure that the verification_constraints did not change
 369   // between dump time and runtime.
 370   static bool add_verification_constraint(Klass* k, Symbol* name,
 371                   Symbol* from_name, bool from_field_is_protected,
 372                   bool from_is_array, bool from_is_object) NOT_CDS_RETURN_(false);
 373   static void finalize_verification_constraints() NOT_CDS_RETURN;
 374   static void check_verification_constraints(InstanceKlass* klass,
 375                                               TRAPS) NOT_CDS_RETURN;
 376 };
 377 
 378 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP


 115 public:
 116   enum LoaderType {
 117     LT_BUILTIN,
 118     LT_UNREGISTERED
 119   };
 120 
 121   enum {
 122     FROM_FIELD_IS_PROTECTED = 1 << 0,
 123     FROM_IS_ARRAY           = 1 << 1,
 124     FROM_IS_OBJECT          = 1 << 2
 125   };
 126 
 127   int             _id;
 128   int             _clsfile_size;
 129   int             _clsfile_crc32;
 130   void*           _verifier_constraints; // FIXME - use a union here to avoid type casting??
 131   void*           _verifier_constraint_flags;
 132 
 133   // See "Identifying the loader_type of archived classes" comments above.
 134   LoaderType loader_type() const {
 135     InstanceKlass* k = instance_klass();
 136 
 137     if ((k->shared_classpath_index() != UNREGISTERED_INDEX)) {
 138       return LT_BUILTIN;
 139     } else {
 140       return LT_UNREGISTERED;
 141     }
 142   }
 143 
 144   SharedDictionaryEntry* next() {
 145     return (SharedDictionaryEntry*)(DictionaryEntry::next());
 146   }
 147 
 148   bool is_builtin() const {
 149     return loader_type() == LT_BUILTIN;
 150   }
 151   bool is_unregistered() const {
 152     return loader_type() == LT_UNREGISTERED;
 153   }
 154 
 155   void add_verification_constraint(Symbol* name,
 156          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object);
 157   int finalize_verification_constraints();
 158   void check_verification_constraints(InstanceKlass* klass, TRAPS);
 159   void metaspace_pointers_do(MetaspaceClosure* it) NOT_CDS_RETURN;
 160 };
 161 
 162 class SharedDictionary : public Dictionary {
 163   SharedDictionaryEntry* get_entry_for_builtin_loader(const Symbol* name) const;
 164   SharedDictionaryEntry* get_entry_for_unregistered_loader(const Symbol* name,
 165                                                            int clsfile_size,
 166                                                            int clsfile_crc32) const;
 167 
 168   // Convenience functions
 169   SharedDictionaryEntry* bucket(int index) const {
 170     return (SharedDictionaryEntry*)(Dictionary::bucket(index));
 171   }
 172 
 173 public:
 174   SharedDictionaryEntry* find_entry_for(InstanceKlass* klass);
 175   void finalize_verification_constraints();
 176 
 177   bool add_non_builtin_klass(const Symbol* class_name,
 178                              ClassLoaderData* loader_data,
 179                              InstanceKlass* obj);
 180 
 181   void update_entry(InstanceKlass* klass, int id);
 182 
 183   InstanceKlass* find_class_for_builtin_loader(const Symbol* name) const;
 184   InstanceKlass* find_class_for_unregistered_loader(const Symbol* name,
 185                                             int clsfile_size,
 186                                             int clsfile_crc32) const;
 187   bool class_exists_for_unregistered_loader(const Symbol* name) {
 188     return (get_entry_for_unregistered_loader(name, -1, -1) != NULL);
 189   }
 190 };
 191 
 192 class SystemDictionaryShared: public SystemDictionary {
 193 private:
 194   // These _shared_xxxs arrays are used to initialize the java.lang.Package and
 195   // java.security.ProtectionDomain objects associated with each shared class.
 196   //
 197   // See SystemDictionaryShared::init_security_info for more info.
 198   static objArrayOop _shared_protection_domains;
 199   static objArrayOop _shared_jar_urls;
 200   static objArrayOop _shared_jar_manifests;
 201 
 202   static InstanceKlass* load_shared_class_for_builtin_loader(
 203                                                Symbol* class_name,
 204                                                Handle class_loader,


 300   // Check if sharing is supported for the class loader.
 301   static bool is_sharing_possible(ClassLoaderData* loader_data);
 302   static bool is_shared_class_visible_for_classloader(InstanceKlass* ik,
 303                                                       Handle class_loader,
 304                                                       const char* pkg_string,
 305                                                       Symbol* pkg_name,
 306                                                       PackageEntry* pkg_entry,
 307                                                       ModuleEntry* mod_entry,
 308                                                       TRAPS);
 309   static PackageEntry* get_package_entry(Symbol* pkg,
 310                                          ClassLoaderData *loader_data) {
 311     if (loader_data != NULL) {
 312       PackageEntryTable* pkgEntryTable = loader_data->packages();
 313       return pkgEntryTable->lookup_only(pkg);
 314     }
 315     return NULL;
 316   }
 317 
 318   static bool add_non_builtin_klass(Symbol* class_name, ClassLoaderData* loader_data,
 319                                     InstanceKlass* k, TRAPS);
 320   static InstanceKlass* dump_time_resolve_super_or_fail(Symbol* child_name,
 321                                                 Symbol* class_name,
 322                                                 Handle class_loader,
 323                                                 Handle protection_domain,
 324                                                 bool is_superclass,
 325                                                 TRAPS);
 326 
 327   static size_t dictionary_entry_size() {
 328     return (DumpSharedSpaces) ? sizeof(SharedDictionaryEntry) : sizeof(DictionaryEntry);
 329   }
 330   static void init_shared_dictionary_entry(InstanceKlass* k, DictionaryEntry* entry) NOT_CDS_RETURN;
 331   static bool is_builtin(DictionaryEntry* ent) {
 332     // Can't use virtual function is_builtin because DictionaryEntry doesn't initialize
 333     // vtable because it's not constructed properly.
 334     SharedDictionaryEntry* entry = (SharedDictionaryEntry*)ent;
 335     return entry->is_builtin();
 336   }
 337 
 338   // For convenient access to the SharedDictionaryEntry's of the archived classes.
 339   static SharedDictionary* shared_dictionary() {
 340     assert(!DumpSharedSpaces, "not for dumping");
 341     return (SharedDictionary*)SystemDictionary::shared_dictionary();
 342   }
 343 
 344   static SharedDictionary* boot_loader_dictionary() {
 345     return (SharedDictionary*)ClassLoaderData::the_null_class_loader_data()->dictionary();
 346   }
 347 
 348   static void update_shared_entry(InstanceKlass* klass, int id) {
 349     assert(DumpSharedSpaces, "sanity");
 350     assert((SharedDictionary*)(klass->class_loader_data()->dictionary()) != NULL, "sanity");
 351     ((SharedDictionary*)(klass->class_loader_data()->dictionary()))->update_entry(klass, id);
 352   }
 353 
 354   static void set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs);
 355 
 356   static InstanceKlass* lookup_from_stream(const Symbol* class_name,
 357                                            Handle class_loader,
 358                                            Handle protection_domain,
 359                                            const ClassFileStream* st,
 360                                            TRAPS);
 361   // "verification_constraints" are a set of checks performed by
 362   // VerificationType::is_reference_assignable_from when verifying a shared class during
 363   // dump time.
 364   //
 365   // With AppCDS, it is possible to override archived classes by calling
 366   // ClassLoader.defineClass() directly. SystemDictionary::load_shared_class() already
 367   // ensures that you cannot load a shared class if its super type(s) are changed. However,
 368   // we need an additional check to ensure that the verification_constraints did not change
 369   // between dump time and runtime.
 370   static bool add_verification_constraint(InstanceKlass* k, Symbol* name,
 371                   Symbol* from_name, bool from_field_is_protected,
 372                   bool from_is_array, bool from_is_object) NOT_CDS_RETURN_(false);
 373   static void finalize_verification_constraints() NOT_CDS_RETURN;
 374   static void check_verification_constraints(InstanceKlass* klass,
 375                                               TRAPS) NOT_CDS_RETURN;
 376 };
 377 
 378 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
< prev index next >