< prev index next >

src/hotspot/share/classfile/verifier.cpp

Print this page




 279 
 280     // Can not verify the bytecodes for shared classes because they have
 281     // already been rewritten to contain constant pool cache indices,
 282     // which the verifier can't understand.
 283     // Shared classes shouldn't have stackmaps either.
 284     !klass->is_shared() &&
 285 
 286     // As of the fix for 4486457 we disable verification for all of the
 287     // dynamically-generated bytecodes associated with the 1.4
 288     // reflection implementation, not just those associated with
 289     // jdk/internal/reflect/SerializationConstructorAccessor.
 290     // NOTE: this is called too early in the bootstrapping process to be
 291     // guarded by Universe::is_gte_jdk14x_version().
 292     // Also for lambda generated code, gte jdk8
 293     (!is_reflect));
 294 }
 295 
 296 Symbol* Verifier::inference_verify(
 297     InstanceKlass* klass, char* message, size_t message_len, TRAPS) {
 298   JavaThread* thread = (JavaThread*)THREAD;
 299   JNIEnv *env = thread->jni_environment();
 300 
 301   verify_byte_codes_fn_t verify_func = verify_byte_codes_fn();
 302 
 303   if (verify_func == NULL) {
 304     jio_snprintf(message, message_len, "Could not link verifier");
 305     return vmSymbols::java_lang_VerifyError();
 306   }
 307 
 308   ResourceMark rm(THREAD);
 309   log_info(verification)("Verifying class %s with old format", klass->external_name());
 310 
 311   jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror());
 312   jint result;
 313 
 314   {
 315     HandleMark hm(thread);
 316     ThreadToNativeFromVM ttn(thread);
 317     // ThreadToNativeFromVM takes care of changing thread_state, so safepoint
 318     // code knows that we have left the VM
 319 
 320     result = (*verify_func)(env, cls, message, (int)message_len, klass->major_version());
 321   }
 322 
 323   JNIHandles::destroy_local(cls);
 324 
 325   // These numbers are chosen so that VerifyClassCodes interface doesn't need
 326   // to be changed (still return jboolean (unsigned char)), and result is
 327   // 1 when verification is passed.
 328   if (result == 0) {
 329     return vmSymbols::java_lang_VerifyError();
 330   } else if (result == 1) {
 331     return NULL; // verified.
 332   } else if (result == 2) {
 333     THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, NULL);
 334   } else if (result == 3) {
 335     return vmSymbols::java_lang_ClassFormatError();
 336   } else {
 337     ShouldNotReachHere();
 338     return NULL;
 339   }




 279 
 280     // Can not verify the bytecodes for shared classes because they have
 281     // already been rewritten to contain constant pool cache indices,
 282     // which the verifier can't understand.
 283     // Shared classes shouldn't have stackmaps either.
 284     !klass->is_shared() &&
 285 
 286     // As of the fix for 4486457 we disable verification for all of the
 287     // dynamically-generated bytecodes associated with the 1.4
 288     // reflection implementation, not just those associated with
 289     // jdk/internal/reflect/SerializationConstructorAccessor.
 290     // NOTE: this is called too early in the bootstrapping process to be
 291     // guarded by Universe::is_gte_jdk14x_version().
 292     // Also for lambda generated code, gte jdk8
 293     (!is_reflect));
 294 }
 295 
 296 Symbol* Verifier::inference_verify(
 297     InstanceKlass* klass, char* message, size_t message_len, TRAPS) {
 298   JavaThread* thread = (JavaThread*)THREAD;

 299 
 300   verify_byte_codes_fn_t verify_func = verify_byte_codes_fn();
 301 
 302   if (verify_func == NULL) {
 303     jio_snprintf(message, message_len, "Could not link verifier");
 304     return vmSymbols::java_lang_VerifyError();
 305   }
 306 
 307   ResourceMark rm(THREAD);
 308   log_info(verification)("Verifying class %s with old format", klass->external_name());
 309 
 310   jclass cls = (jclass) JNIHandles::make_local(thread, klass->java_mirror());
 311   jint result;
 312 
 313   {
 314     HandleMark hm(thread);
 315     ThreadToNativeFromVM ttn(thread);
 316     // ThreadToNativeFromVM takes care of changing thread_state, so safepoint
 317     // code knows that we have left the VM
 318     JNIEnv *env = thread->jni_environment();
 319     result = (*verify_func)(env, cls, message, (int)message_len, klass->major_version());
 320   }
 321 
 322   JNIHandles::destroy_local(cls);
 323 
 324   // These numbers are chosen so that VerifyClassCodes interface doesn't need
 325   // to be changed (still return jboolean (unsigned char)), and result is
 326   // 1 when verification is passed.
 327   if (result == 0) {
 328     return vmSymbols::java_lang_VerifyError();
 329   } else if (result == 1) {
 330     return NULL; // verified.
 331   } else if (result == 2) {
 332     THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, NULL);
 333   } else if (result == 3) {
 334     return vmSymbols::java_lang_ClassFormatError();
 335   } else {
 336     ShouldNotReachHere();
 337     return NULL;
 338   }


< prev index next >