< prev index next >

src/hotspot/share/classfile/verifier.cpp

Print this page




  52 #include "utilities/align.hpp"
  53 #include "utilities/bytes.hpp"
  54 
  55 #define NOFAILOVER_MAJOR_VERSION                       51
  56 #define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION  51
  57 #define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION       52
  58 #define MAX_ARRAY_DIMENSIONS 255
  59 
  60 // Access to external entry for VerifyClassCodes - old byte code verifier
  61 
  62 extern "C" {
  63   typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint);
  64   typedef jboolean (*verify_byte_codes_fn_new_t)(JNIEnv *, jclass, char *, jint, jint);
  65 }
  66 
  67 static void* volatile _verify_byte_codes_fn = NULL;
  68 
  69 static volatile jint _is_new_verify_byte_codes_fn = (jint) true;
  70 
  71 static void* verify_byte_codes_fn() {
  72   if (OrderAccess::load_ptr_acquire(&_verify_byte_codes_fn) == NULL) {
  73     void *lib_handle = os::native_java_library();
  74     void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion");
  75     OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func);
  76     if (func == NULL) {
  77       _is_new_verify_byte_codes_fn = false;
  78       func = os::dll_lookup(lib_handle, "VerifyClassCodes");
  79       OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func);
  80     }
  81   }
  82   return (void*)_verify_byte_codes_fn;
  83 }
  84 
  85 
  86 // Methods in Verifier
  87 
  88 bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) {
  89   return (class_loader == NULL || !should_verify_class) ?
  90     BytecodeVerificationLocal : BytecodeVerificationRemote;
  91 }
  92 
  93 bool Verifier::relax_access_for(oop loader) {
  94   bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
  95   bool need_verify =
  96     // verifyAll
  97     (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
  98     // verifyRemote
  99     (!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted);




  52 #include "utilities/align.hpp"
  53 #include "utilities/bytes.hpp"
  54 
  55 #define NOFAILOVER_MAJOR_VERSION                       51
  56 #define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION  51
  57 #define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION       52
  58 #define MAX_ARRAY_DIMENSIONS 255
  59 
  60 // Access to external entry for VerifyClassCodes - old byte code verifier
  61 
  62 extern "C" {
  63   typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint);
  64   typedef jboolean (*verify_byte_codes_fn_new_t)(JNIEnv *, jclass, char *, jint, jint);
  65 }
  66 
  67 static void* volatile _verify_byte_codes_fn = NULL;
  68 
  69 static volatile jint _is_new_verify_byte_codes_fn = (jint) true;
  70 
  71 static void* verify_byte_codes_fn() {
  72   if (OrderAccess::load_acquire(&_verify_byte_codes_fn) == NULL) {
  73     void *lib_handle = os::native_java_library();
  74     void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion");
  75     OrderAccess::release_store(&_verify_byte_codes_fn, func);
  76     if (func == NULL) {
  77       _is_new_verify_byte_codes_fn = false;
  78       func = os::dll_lookup(lib_handle, "VerifyClassCodes");
  79       OrderAccess::release_store(&_verify_byte_codes_fn, func);
  80     }
  81   }
  82   return (void*)_verify_byte_codes_fn;
  83 }
  84 
  85 
  86 // Methods in Verifier
  87 
  88 bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) {
  89   return (class_loader == NULL || !should_verify_class) ?
  90     BytecodeVerificationLocal : BytecodeVerificationRemote;
  91 }
  92 
  93 bool Verifier::relax_access_for(oop loader) {
  94   bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
  95   bool need_verify =
  96     // verifyAll
  97     (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
  98     // verifyRemote
  99     (!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted);


< prev index next >