< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page

        

@@ -86,10 +86,14 @@
 #include "utilities/dtrace.hpp"
 #include "utilities/events.hpp"
 #include "utilities/histogram.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/vmError.hpp"
+#if INCLUDE_JVMCI
+#include "jvmci/jvmciCompiler.hpp"
+#include "jvmci/jvmciRuntime.hpp"
+#endif
 
 static jint CurrentVersion = JNI_VERSION_10;
 
 #ifdef _WIN32
 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );

@@ -327,11 +331,11 @@
                          "Class name exceeds maximum length of %d: %s",
                          Symbol::max_length(),
                          name);
       return 0;
     }
-    class_name = SymbolTable::new_symbol(name);
+    class_name = SymbolTable::new_symbol(name, CHECK_NULL);
   }
   ResourceMark rm(THREAD);
   ClassFileStream st((u1*)buf, bufLen, NULL, ClassFileStream::verify);
   Handle class_loader (THREAD, JNIHandles::resolve(loaderRef));
 

@@ -414,11 +418,11 @@
     } else {
       loader = Handle(THREAD, k->class_loader());
     }
   }
 
-  TempNewSymbol sym = SymbolTable::new_symbol(name);
+  TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
   result = find_class_from_class_loader(env, sym, true, loader,
                                         protection_domain, true, thread);
 
   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));

@@ -1312,19 +1316,18 @@
 
   if (name == NULL || signature == NULL) {
     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
   }
 
-  Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
-
   // Throw a NoSuchMethodError exception if we have an instance of a
   // primitive java.lang.Class
   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) {
-    ResourceMark rm;
-    THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig));
+    THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
   }
 
+  Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
+
   // Make sure class is linked and initialized before handing id's out to
   // Method*s.
   klass->initialize(CHECK_NULL);
 
   Method* m;

@@ -1341,12 +1344,11 @@
     if (m == NULL &&  klass->is_instance_klass()) {
       m = InstanceKlass::cast(klass)->lookup_method_in_ordered_interfaces(name, signature);
     }
   }
   if (m == NULL || (m->is_static() != is_static)) {
-    ResourceMark rm;
-    THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig));
+    THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
   }
   return m->jmethod_id();
 }
 
 

@@ -2010,30 +2012,26 @@
   JNIWrapper("GetFieldID");
   HOTSPOT_JNI_GETFIELDID_ENTRY(env, clazz, (char *) name, (char *) sig);
   jfieldID ret = 0;
   DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret);
 
-  Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
-
   // The class should have been loaded (we have an instance of the class
   // passed in) so the field and signature should already be in the symbol
   // table.  If they're not there, the field doesn't exist.
   TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name));
   TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig));
   if (fieldname == NULL || signame == NULL) {
-    ResourceMark rm;
-    THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), err_msg("%s.%s %s", k->external_name(), name, sig));
+    THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
   }
-
+  Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
   // Make sure class is initialized before handing id's out to fields
   k->initialize(CHECK_NULL);
 
   fieldDescriptor fd;
   if (!k->is_instance_klass() ||
       !InstanceKlass::cast(k)->find_field(fieldname, signame, false, &fd)) {
-    ResourceMark rm;
-    THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), err_msg("%s.%s %s", k->external_name(), name, sig));
+    THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
   }
 
   // A jfieldID for a non-static field is simply the offset of the field within the instanceOop
   // It may also have hash bits for k, if VerifyJNIFields is turned on.
   ret = jfieldIDWorkaround::to_instance_jfieldID(k, fd.offset());

@@ -2955,24 +2953,22 @@
 static bool register_native(Klass* k, Symbol* name, Symbol* signature, address entry, TRAPS) {
   Method* method = k->lookup_method(name, signature);
   if (method == NULL) {
     ResourceMark rm;
     stringStream st;
-    st.print("Method '");
-    Method::print_external_name(&st, k, name, signature);
-    st.print("' name or signature does not match");
+    st.print("Method %s name or signature does not match",
+             Method::name_and_sig_as_C_string(k, name, signature));
     THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
   }
   if (!method->is_native()) {
     // trying to register to a non-native method, see if a JVM TI agent has added prefix(es)
     method = find_prefixed_native(k, name, signature, THREAD);
     if (method == NULL) {
       ResourceMark rm;
       stringStream st;
-      st.print("Method '");
-      Method::print_external_name(&st, k, name, signature);
-      st.print("' is not declared as native");
+      st.print("Method %s is not declared as native",
+               Method::name_and_sig_as_C_string(k, name, signature));
       THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
     }
   }
 
   if (entry != NULL) {

@@ -3286,11 +3282,11 @@
 
 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) {
   Handle loader;            // null (bootstrap) loader
   Handle protection_domain; // null protection domain
 
-  TempNewSymbol sym = SymbolTable::new_symbol(name);
+  TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
   jclass result =  find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
 
   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }

@@ -3971,11 +3967,11 @@
     // functions in order to properly handle error conditions.
     VMError::test_error_handler();
 #endif
 
     // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving.
-    ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_native);
+    ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native);
   } else {
     // If create_vm exits because of a pending exception, exit with that
     // exception.  In the future when we figure out how to reclaim memory,
     // we may be able to exit with JNI_ERR and allow the calling application
     // to continue.

@@ -4073,11 +4069,11 @@
     // Should not change thread state, VM is gone
     vm_created = 0;
     res = JNI_OK;
     return res;
   } else {
-    ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_native);
+    ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native);
     res = JNI_ERR;
     return res;
   }
 }
 

@@ -4195,11 +4191,11 @@
   // Now leaving the VM, so change thread_state. This is normally automatically taken care
   // of in the JVM_ENTRY. But in this situation we have to do it manually. Notice, that by
   // using ThreadStateTransition::transition, we do a callback to the safepoint code if
   // needed.
 
-  ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_native);
+  ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native);
 
   // Perform any platform dependent FPU setup
   os::setup_fpu();
 
   return JNI_OK;
< prev index next >