1 /* |
1 /* |
2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
94 static const char * fatal_bad_ref_to_jni = "Bad global or local ref passed to JNI"; |
94 static const char * fatal_bad_ref_to_jni = "Bad global or local ref passed to JNI"; |
95 static const char * fatal_received_null_class = "JNI received a null class"; |
95 static const char * fatal_received_null_class = "JNI received a null class"; |
96 static const char * fatal_class_not_a_class = "JNI received a class argument that is not a class"; |
96 static const char * fatal_class_not_a_class = "JNI received a class argument that is not a class"; |
97 static const char * fatal_class_not_a_throwable_class = "JNI Throw or ThrowNew received a class argument that is not a Throwable or Throwable subclass"; |
97 static const char * fatal_class_not_a_throwable_class = "JNI Throw or ThrowNew received a class argument that is not a Throwable or Throwable subclass"; |
98 static const char * fatal_wrong_class_or_method = "Wrong object class or methodID passed to JNI call"; |
98 static const char * fatal_wrong_class_or_method = "Wrong object class or methodID passed to JNI call"; |
|
99 static const char * fatal_non_weak_method = "non-weak methodID passed to JNI call"; |
99 static const char * fatal_unknown_array_object = "Unknown array object passed to JNI array operations"; |
100 static const char * fatal_unknown_array_object = "Unknown array object passed to JNI array operations"; |
100 static const char * fatal_object_array_expected = "Object array expected but not received for JNI array operation"; |
101 static const char * fatal_object_array_expected = "Object array expected but not received for JNI array operation"; |
101 static const char * fatal_non_array = "Non-array passed to JNI array operations"; |
102 static const char * fatal_non_array = "Non-array passed to JNI array operations"; |
102 static const char * fatal_element_type_mismatch = "Array element type mismatch in JNI"; |
103 static const char * fatal_element_type_mismatch = "Array element type mismatch in JNI"; |
103 static const char * fatal_should_be_static = "Non-static field ID passed to JNI"; |
104 static const char * fatal_should_be_static = "Non-static field ID passed to JNI"; |
289 } |
290 } |
290 |
291 |
291 |
292 |
292 methodOop jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) { |
293 methodOop jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) { |
293 ASSERT_OOPS_ALLOWED; |
294 ASSERT_OOPS_ALLOWED; |
|
295 // do the fast jmethodID check first |
294 methodOop moop = JNIHandles::checked_resolve_jmethod_id(method_id); |
296 methodOop moop = JNIHandles::checked_resolve_jmethod_id(method_id); |
295 if (moop == NULL) { |
297 if (moop == NULL) { |
296 ReportJNIFatalError(thr, fatal_wrong_class_or_method); |
298 ReportJNIFatalError(thr, fatal_wrong_class_or_method); |
|
299 } |
|
300 // jmethodIDs are supposed to be weak global handles, but that |
|
301 // can be expensive so check it last |
|
302 else if (!JNIHandles::is_weak_global_handle((jobject) method_id)) { |
|
303 ReportJNIFatalError(thr, fatal_non_weak_method); |
297 } |
304 } |
298 return moop; |
305 return moop; |
299 } |
306 } |
300 |
307 |
301 |
308 |