src/share/vm/classfile/verifier.cpp

Print this page




 171     instanceKlassHandle kls =
 172       SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
 173     while (!kls.is_null()) {
 174       if (kls == klass) {
 175         // If the class being verified is the exception we're creating
 176         // or one of it's superclasses, we're in trouble and are going
 177         // to infinitely recurse when we try to initialize the exception.
 178         // So bail out here by throwing the preallocated VM error.
 179         THROW_OOP_(Universe::virtual_machine_error_instance(), false);
 180       }
 181       kls = kls->super();
 182     }
 183     message_buffer[message_buffer_len - 1] = '\0'; // just to be sure
 184     THROW_MSG_(exception_name, exception_message, false);
 185   }
 186 }
 187 
 188 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) {
 189   Symbol* name = klass->name();
 190   Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();
 191   Klass* lambda_magic_klass = SystemDictionary::lambda_MagicLambdaImpl_klass();
 192 
 193   bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass);
 194   bool is_lambda = lambda_magic_klass != NULL && klass->is_subtype_of(lambda_magic_klass);
 195 
 196   return (should_verify_for(klass->class_loader(), should_verify_class) &&
 197     // return if the class is a bootstrapping class
 198     // or defineClass specified not to verify by default (flags override passed arg)
 199     // We need to skip the following four for bootstraping
 200     name != vmSymbols::java_lang_Object() &&
 201     name != vmSymbols::java_lang_Class() &&
 202     name != vmSymbols::java_lang_String() &&
 203     name != vmSymbols::java_lang_Throwable() &&
 204 
 205     // Can not verify the bytecodes for shared classes because they have
 206     // already been rewritten to contain constant pool cache indices,
 207     // which the verifier can't understand.
 208     // Shared classes shouldn't have stackmaps either.
 209     !klass()->is_shared() &&
 210 
 211     // As of the fix for 4486457 we disable verification for all of the
 212     // dynamically-generated bytecodes associated with the 1.4
 213     // reflection implementation, not just those associated with
 214     // sun/reflect/SerializationConstructorAccessor.
 215     // NOTE: this is called too early in the bootstrapping process to be
 216     // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection.
 217     // Also for lambda generated code, gte jdk8
 218     (!is_reflect || VerifyReflectionBytecodes) &&
 219     (!is_lambda || VerifyLambdaBytecodes)
 220   );
 221 }
 222 
 223 Symbol* Verifier::inference_verify(
 224     instanceKlassHandle klass, char* message, size_t message_len, TRAPS) {
 225   JavaThread* thread = (JavaThread*)THREAD;
 226   JNIEnv *env = thread->jni_environment();
 227 
 228   void* verify_func = verify_byte_codes_fn();
 229 
 230   if (verify_func == NULL) {
 231     jio_snprintf(message, message_len, "Could not link verifier");
 232     return vmSymbols::java_lang_VerifyError();
 233   }
 234 
 235   ResourceMark rm(THREAD);
 236   if (VerboseVerification) {
 237     tty->print_cr("Verifying class %s with old format", klass->external_name());
 238   }
 239 
 240   jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror());




 171     instanceKlassHandle kls =
 172       SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
 173     while (!kls.is_null()) {
 174       if (kls == klass) {
 175         // If the class being verified is the exception we're creating
 176         // or one of it's superclasses, we're in trouble and are going
 177         // to infinitely recurse when we try to initialize the exception.
 178         // So bail out here by throwing the preallocated VM error.
 179         THROW_OOP_(Universe::virtual_machine_error_instance(), false);
 180       }
 181       kls = kls->super();
 182     }
 183     message_buffer[message_buffer_len - 1] = '\0'; // just to be sure
 184     THROW_MSG_(exception_name, exception_message, false);
 185   }
 186 }
 187 
 188 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) {
 189   Symbol* name = klass->name();
 190   Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();

 191 
 192   bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass);

 193 
 194   return (should_verify_for(klass->class_loader(), should_verify_class) &&
 195     // return if the class is a bootstrapping class
 196     // or defineClass specified not to verify by default (flags override passed arg)
 197     // We need to skip the following four for bootstraping
 198     name != vmSymbols::java_lang_Object() &&
 199     name != vmSymbols::java_lang_Class() &&
 200     name != vmSymbols::java_lang_String() &&
 201     name != vmSymbols::java_lang_Throwable() &&
 202 
 203     // Can not verify the bytecodes for shared classes because they have
 204     // already been rewritten to contain constant pool cache indices,
 205     // which the verifier can't understand.
 206     // Shared classes shouldn't have stackmaps either.
 207     !klass()->is_shared() &&
 208 
 209     // As of the fix for 4486457 we disable verification for all of the
 210     // dynamically-generated bytecodes associated with the 1.4
 211     // reflection implementation, not just those associated with
 212     // sun/reflect/SerializationConstructorAccessor.
 213     // NOTE: this is called too early in the bootstrapping process to be
 214     // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection.
 215     // Also for lambda generated code, gte jdk8
 216     (!is_reflect || VerifyReflectionBytecodes));


 217 }
 218 
 219 Symbol* Verifier::inference_verify(
 220     instanceKlassHandle klass, char* message, size_t message_len, TRAPS) {
 221   JavaThread* thread = (JavaThread*)THREAD;
 222   JNIEnv *env = thread->jni_environment();
 223 
 224   void* verify_func = verify_byte_codes_fn();
 225 
 226   if (verify_func == NULL) {
 227     jio_snprintf(message, message_len, "Could not link verifier");
 228     return vmSymbols::java_lang_VerifyError();
 229   }
 230 
 231   ResourceMark rm(THREAD);
 232   if (VerboseVerification) {
 233     tty->print_cr("Verifying class %s with old format", klass->external_name());
 234   }
 235 
 236   jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror());