< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com


 892     _shared_jar_manifests = oopFactory::new_objArray(
 893         SystemDictionary::Jar_Manifest_klass(), size, CHECK);
 894   }
 895 }
 896 
 897 void SystemDictionaryShared::allocate_shared_data_arrays(int size, TRAPS) {
 898   allocate_shared_protection_domain_array(size, CHECK);
 899   allocate_shared_jar_url_array(size, CHECK);
 900   allocate_shared_jar_manifest_array(size, CHECK);
 901 }
 902 
 903 // This function is called for loading only UNREGISTERED classes
 904 InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
 905                                                           Handle class_loader,
 906                                                           Handle protection_domain,
 907                                                           const ClassFileStream* cfs,
 908                                                           TRAPS) {
 909   if (!UseSharedSpaces) {
 910     return NULL;
 911   }
 912   if (class_name == NULL) {  // don't do this for anonymous classes
 913     return NULL;
 914   }
 915   if (class_loader.is_null() ||
 916       SystemDictionary::is_system_class_loader(class_loader()) ||
 917       SystemDictionary::is_platform_class_loader(class_loader())) {
 918     // Do nothing for the BUILTIN loaders.
 919     return NULL;
 920   }
 921 
 922   const RunTimeSharedClassInfo* record = find_record(&_unregistered_dictionary, &_dynamic_unregistered_dictionary, class_name);
 923   if (record == NULL) {
 924     return NULL;
 925   }
 926 
 927   int clsfile_size  = cfs->length();
 928   int clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
 929 
 930   if (!record->matches(clsfile_size, clsfile_crc32)) {
 931     return NULL;
 932   }


1071   p->_verifier_constraint_flags = NULL;
1072   _dumptime_table->remove(k);
1073 }
1074 
1075 bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) {
1076   while (k) {
1077     if (k->name()->equals("jdk/internal/event/Event")) {
1078       return true;
1079     }
1080     k = k->java_super();
1081   }
1082   return false;
1083 }
1084 
1085 void SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
1086   ResourceMark rm;
1087   log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
1088 }
1089 
1090 bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
1091   if (k->class_loader_data()->is_unsafe_anonymous()) {
1092     warn_excluded(k, "Unsafe anonymous class");
1093     return true; // unsafe anonymous classes are not archived, skip
1094   }
1095   if (k->is_in_error_state()) {
1096     warn_excluded(k, "In error state");
1097     return true;
1098   }
1099   if (k->has_been_redefined()) {
1100     warn_excluded(k, "Has been redefined");
1101     return true;
1102   }
1103   if (k->shared_classpath_index() < 0 && is_builtin(k)) {
1104     // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
1105     // agent during dump time).
1106     warn_excluded(k, "Unsupported location");
1107     return true;
1108   }
1109   if (k->signers() != NULL) {
1110     // We cannot include signed classes in the archive because the certificates
1111     // used during dump time may be different than those used during
1112     // runtime (due to expiration, etc).
1113     warn_excluded(k, "Signed JAR");




 892     _shared_jar_manifests = oopFactory::new_objArray(
 893         SystemDictionary::Jar_Manifest_klass(), size, CHECK);
 894   }
 895 }
 896 
 897 void SystemDictionaryShared::allocate_shared_data_arrays(int size, TRAPS) {
 898   allocate_shared_protection_domain_array(size, CHECK);
 899   allocate_shared_jar_url_array(size, CHECK);
 900   allocate_shared_jar_manifest_array(size, CHECK);
 901 }
 902 
 903 // This function is called for loading only UNREGISTERED classes
 904 InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
 905                                                           Handle class_loader,
 906                                                           Handle protection_domain,
 907                                                           const ClassFileStream* cfs,
 908                                                           TRAPS) {
 909   if (!UseSharedSpaces) {
 910     return NULL;
 911   }
 912   if (class_name == NULL) {  // don't do this for hidden and unsafe anonymous classes
 913     return NULL;
 914   }
 915   if (class_loader.is_null() ||
 916       SystemDictionary::is_system_class_loader(class_loader()) ||
 917       SystemDictionary::is_platform_class_loader(class_loader())) {
 918     // Do nothing for the BUILTIN loaders.
 919     return NULL;
 920   }
 921 
 922   const RunTimeSharedClassInfo* record = find_record(&_unregistered_dictionary, &_dynamic_unregistered_dictionary, class_name);
 923   if (record == NULL) {
 924     return NULL;
 925   }
 926 
 927   int clsfile_size  = cfs->length();
 928   int clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
 929 
 930   if (!record->matches(clsfile_size, clsfile_crc32)) {
 931     return NULL;
 932   }


1071   p->_verifier_constraint_flags = NULL;
1072   _dumptime_table->remove(k);
1073 }
1074 
1075 bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) {
1076   while (k) {
1077     if (k->name()->equals("jdk/internal/event/Event")) {
1078       return true;
1079     }
1080     k = k->java_super();
1081   }
1082   return false;
1083 }
1084 
1085 void SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
1086   ResourceMark rm;
1087   log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
1088 }
1089 
1090 bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
1091   if (k->is_hidden() || k->is_unsafe_anonymous()) {
1092     warn_excluded(k, "Hidden or Unsafe anonymous class");
1093     return true; // hidden and unsafe anonymous classes are not archived, skip
1094   }
1095   if (k->is_in_error_state()) {
1096     warn_excluded(k, "In error state");
1097     return true;
1098   }
1099   if (k->has_been_redefined()) {
1100     warn_excluded(k, "Has been redefined");
1101     return true;
1102   }
1103   if (k->shared_classpath_index() < 0 && is_builtin(k)) {
1104     // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
1105     // agent during dump time).
1106     warn_excluded(k, "Unsupported location");
1107     return true;
1108   }
1109   if (k->signers() != NULL) {
1110     // We cannot include signed classes in the archive because the certificates
1111     // used during dump time may be different than those used during
1112     // runtime (due to expiration, etc).
1113     warn_excluded(k, "Signed JAR");


< prev index next >