< prev index next >

src/hotspot/share/classfile/verifier.cpp

Print this page




 148   // is IMPORTANT:
 149   if (klass->java_mirror() != NULL) {
 150     klass->java_mirror()->identity_hash();
 151   }
 152 
 153   if (!is_eligible_for_verification(klass, should_verify_class)) {
 154     return true;
 155   }
 156 
 157   // Timer includes any side effects of class verification (resolution,
 158   // etc), but not recursive calls to Verifier::verify().
 159   JavaThread* jt = (JavaThread*)THREAD;
 160   PerfClassTraceTime timer(ClassLoader::perf_class_verify_time(),
 161                            ClassLoader::perf_class_verify_selftime(),
 162                            ClassLoader::perf_classes_verified(),
 163                            jt->get_thread_stat()->perf_recursion_counts_addr(),
 164                            jt->get_thread_stat()->perf_timers_addr(),
 165                            PerfClassTraceTime::CLASS_VERIFY);
 166 
 167   // If the class should be verified, first see if we can use the split
 168   // verifier.  If not, or if verification fails and can failover, then
 169   // call the inference verifier.
 170   Symbol* exception_name = NULL;
 171   const size_t message_buffer_len = klass->name()->utf8_length() + 1024;
 172   char* message_buffer = NULL;
 173   char* exception_message = NULL;
 174 



 175   log_info(class, init)("Start class verification for: %s", klass->external_name());
 176   if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
 177     ClassVerifier split_verifier(klass, THREAD);
 178     split_verifier.verify_class(THREAD);
 179     exception_name = split_verifier.result();
 180 
 181     // If DumpSharedSpaces is set then don't fall back to the old verifier on
 182     // verification failure. If a class fails verification with the split verifier,
 183     // it might fail the CDS runtime verifier constraint check. In that case, we
 184     // don't want to share the class. We only archive classes that pass the split
 185     // verifier.
 186     bool can_failover = !DumpSharedSpaces &&
 187       klass->major_version() < NOFAILOVER_MAJOR_VERSION;
 188 
 189     if (can_failover && !HAS_PENDING_EXCEPTION &&  // Split verifier doesn't set PENDING_EXCEPTION for failure
 190         (exception_name == vmSymbols::java_lang_VerifyError() ||
 191          exception_name == vmSymbols::java_lang_ClassFormatError())) {
 192       log_info(verification)("Fail over class verification to old verifier for: %s", klass->external_name());
 193       log_info(class, init)("Fail over class verification to old verifier for: %s", klass->external_name());
 194       message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
 195       exception_message = message_buffer;
 196       exception_name = inference_verify(
 197         klass, message_buffer, message_buffer_len, THREAD);
 198     }
 199     if (exception_name != NULL) {
 200       exception_message = split_verifier.exception_message();
 201     }
 202   } else {
 203     message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
 204     exception_message = message_buffer;
 205     exception_name = inference_verify(
 206         klass, message_buffer, message_buffer_len, THREAD);
 207   }
 208 
 209   LogTarget(Info, class, init) lt1;




 148   // is IMPORTANT:
 149   if (klass->java_mirror() != NULL) {
 150     klass->java_mirror()->identity_hash();
 151   }
 152 
 153   if (!is_eligible_for_verification(klass, should_verify_class)) {
 154     return true;
 155   }
 156 
 157   // Timer includes any side effects of class verification (resolution,
 158   // etc), but not recursive calls to Verifier::verify().
 159   JavaThread* jt = (JavaThread*)THREAD;
 160   PerfClassTraceTime timer(ClassLoader::perf_class_verify_time(),
 161                            ClassLoader::perf_class_verify_selftime(),
 162                            ClassLoader::perf_classes_verified(),
 163                            jt->get_thread_stat()->perf_recursion_counts_addr(),
 164                            jt->get_thread_stat()->perf_timers_addr(),
 165                            PerfClassTraceTime::CLASS_VERIFY);
 166 
 167   // If the class should be verified, first see if we can use the split
 168   // verifier.  If not, or if verification fails and FailOverToOldVerifier
 169   // is set, then call the inference verifier.
 170   Symbol* exception_name = NULL;
 171   const size_t message_buffer_len = klass->name()->utf8_length() + 1024;
 172   char* message_buffer = NULL;
 173   char* exception_message = NULL;
 174 
 175   bool can_failover = FailOverToOldVerifier &&
 176      klass->major_version() < NOFAILOVER_MAJOR_VERSION;
 177 
 178   log_info(class, init)("Start class verification for: %s", klass->external_name());
 179   if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
 180     ClassVerifier split_verifier(klass, THREAD);
 181     split_verifier.verify_class(THREAD);
 182     exception_name = split_verifier.result();
 183     if (can_failover && !HAS_PENDING_EXCEPTION &&









 184         (exception_name == vmSymbols::java_lang_VerifyError() ||
 185          exception_name == vmSymbols::java_lang_ClassFormatError())) {
 186       log_info(verification)("Fail over class verification to old verifier for: %s", klass->external_name());
 187       log_info(class, init)("Fail over class verification to old verifier for: %s", klass->external_name());
 188       message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
 189       exception_message = message_buffer;
 190       exception_name = inference_verify(
 191         klass, message_buffer, message_buffer_len, THREAD);
 192     }
 193     if (exception_name != NULL) {
 194       exception_message = split_verifier.exception_message();
 195     }
 196   } else {
 197     message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
 198     exception_message = message_buffer;
 199     exception_name = inference_verify(
 200         klass, message_buffer, message_buffer_len, THREAD);
 201   }
 202 
 203   LogTarget(Info, class, init) lt1;


< prev index next >