6363#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52
6464#define MAX_ARRAY_DIMENSIONS 255
6565
66- // Access to external entry for VerifyClassCodes - old byte code verifier
66+ // Access to external entry for VerifyClassForMajorVersion - old byte code verifier
6767
6868extern " C" {
69- typedef jboolean (*verify_byte_codes_fn_t )(JNIEnv *, jclass, char *, jint);
70- typedef jboolean (*verify_byte_codes_fn_new_t )(JNIEnv *, jclass, char *, jint, jint);
69+ typedef jboolean (*verify_byte_codes_fn_t )(JNIEnv *, jclass, char *, jint, jint);
7170}
7271
73- static void * volatile _verify_byte_codes_fn = NULL ;
72+ static verify_byte_codes_fn_t volatile _verify_byte_codes_fn = NULL ;
7473
75- static volatile jint _is_new_verify_byte_codes_fn = (jint) true ;
74+ static verify_byte_codes_fn_t verify_byte_codes_fn () {
7675
77- static void * verify_byte_codes_fn () {
78- if (OrderAccess::load_acquire (&_verify_byte_codes_fn) == NULL ) {
79- void *lib_handle = os::native_java_library ();
80- void *func = os::dll_lookup (lib_handle, " VerifyClassCodesForMajorVersion" );
81- OrderAccess::release_store (&_verify_byte_codes_fn, func);
82- if (func == NULL ) {
83- _is_new_verify_byte_codes_fn = false ;
84- func = os::dll_lookup (lib_handle, " VerifyClassCodes" );
85- OrderAccess::release_store (&_verify_byte_codes_fn, func);
86- }
87- }
88- return (void *)_verify_byte_codes_fn;
76+ if (_verify_byte_codes_fn != NULL )
77+ return _verify_byte_codes_fn;
78+
79+ MutexLocker locker (Verify_lock);
80+
81+ if (_verify_byte_codes_fn != NULL )
82+ return _verify_byte_codes_fn;
83+
84+ // Load verify dll
85+ char buffer[JVM_MAXPATHLEN ];
86+ char ebuf[1024 ];
87+ if (!os::dll_locate_lib (buffer, sizeof (buffer), Arguments::get_dll_dir (), " verify" ))
88+ return NULL ; // Caller will throw VerifyError
89+
90+ void *lib_handle = os::dll_load (buffer, ebuf, sizeof (ebuf));
91+ if (lib_handle == NULL )
92+ return NULL ; // Caller will throw VerifyError
93+
94+ void *fn = os::dll_lookup (lib_handle, " VerifyClassForMajorVersion" );
95+ if (fn == NULL )
96+ return NULL ; // Caller will throw VerifyError
97+
98+ return _verify_byte_codes_fn = CAST_TO_FN_PTR (verify_byte_codes_fn_t , fn);
8999}
90100
91101
@@ -282,7 +292,7 @@ Symbol* Verifier::inference_verify(
282292 JavaThread* thread = (JavaThread*)THREAD ;
283293 JNIEnv *env = thread->jni_environment ();
284294
285- void * verify_func = verify_byte_codes_fn ();
295+ verify_byte_codes_fn_t verify_func = verify_byte_codes_fn ();
286296
287297 if (verify_func == NULL ) {
288298 jio_snprintf (message, message_len, " Could not link verifier" );
@@ -301,16 +311,7 @@ Symbol* Verifier::inference_verify(
301311 // ThreadToNativeFromVM takes care of changing thread_state, so safepoint
302312 // code knows that we have left the VM
303313
304- if (_is_new_verify_byte_codes_fn) {
305- verify_byte_codes_fn_new_t func =
306- CAST_TO_FN_PTR (verify_byte_codes_fn_new_t , verify_func);
307- result = (*func)(env, cls, message, (int )message_len,
308- klass->major_version ());
309- } else {
310- verify_byte_codes_fn_t func =
311- CAST_TO_FN_PTR (verify_byte_codes_fn_t , verify_func);
312- result = (*func)(env, cls, message, (int )message_len);
313- }
314+ result = (*verify_func)(env, cls, message, (int )message_len, klass->major_version ());
314315 }
315316
316317 JNIHandles::destroy_local (cls);
0 commit comments