< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page

 954   result->set_type(args->return_type());
 955 
 956   // Invoke the method. Result is returned as oop.
 957   JavaCalls::call(result, method, &java_args, CHECK);
 958 
 959   // Convert result
 960   if (is_reference_type(result->get_type())) {
 961     result->set_jobject(JNIHandles::make_local(THREAD, result->get_oop()));
 962   }
 963 }
 964 
 965 DT_RETURN_MARK_DECL(AllocObject, jobject
 966                     , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref));
 967 
 968 JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz))
 969   HOTSPOT_JNI_ALLOCOBJECT_ENTRY(env, clazz);
 970 
 971   jobject ret = nullptr;
 972   DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret);
 973 
 974   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
 975   ret = JNIHandles::make_local(THREAD, i);
 976   return ret;
 977 JNI_END
 978 
 979 DT_RETURN_MARK_DECL(NewObjectA, jobject
 980                     , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref));
 981 
 982 JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args))
 983   HOTSPOT_JNI_NEWOBJECTA_ENTRY(env, clazz, (uintptr_t) methodID);
 984 
 985   jobject obj = nullptr;
 986   DT_RETURN_MARK(NewObjectA, jobject, (const jobject&)obj);
 987 
 988   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
 989   obj = JNIHandles::make_local(THREAD, i);
 990   JavaValue jvalue(T_VOID);
 991   JNI_ArgumentPusherArray ap(methodID, args);
 992   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
 993   return obj;
 994 JNI_END
 995 
 996 
 997 DT_RETURN_MARK_DECL(NewObjectV, jobject
 998                     , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref));
 999 
1000 JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args))
1001   HOTSPOT_JNI_NEWOBJECTV_ENTRY(env, clazz, (uintptr_t) methodID);
1002 
1003   jobject obj = nullptr;
1004   DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj);
1005 
1006   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
1007   obj = JNIHandles::make_local(THREAD, i);
1008   JavaValue jvalue(T_VOID);
1009   JNI_ArgumentPusherVaArg ap(methodID, args);
1010   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
1011   return obj;
1012 JNI_END
1013 
1014 
1015 DT_RETURN_MARK_DECL(NewObject, jobject
1016                     , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref));
1017 
1018 JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...))
1019   HOTSPOT_JNI_NEWOBJECT_ENTRY(env, clazz, (uintptr_t) methodID);
1020 
1021   jobject obj = nullptr;
1022   DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj);
1023 
1024   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL);
1025   obj = JNIHandles::make_local(THREAD, i);
1026   va_list args;
1027   va_start(args, methodID);
1028   JavaValue jvalue(T_VOID);
1029   JNI_ArgumentPusherVaArg ap(methodID, args);
1030   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
1031   va_end(args);
1032   return obj;
1033 JNI_END
1034 
1035 
1036 JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj))
1037   HOTSPOT_JNI_GETOBJECTCLASS_ENTRY(env, obj);
1038 
1039   Klass* k = JNIHandles::resolve_non_null(obj)->klass();
1040   jclass ret =
1041     (jclass) JNIHandles::make_local(THREAD, k->java_mirror());
1042 
1043   HOTSPOT_JNI_GETOBJECTCLASS_RETURN(ret);
1044   return ret;

 954   result->set_type(args->return_type());
 955 
 956   // Invoke the method. Result is returned as oop.
 957   JavaCalls::call(result, method, &java_args, CHECK);
 958 
 959   // Convert result
 960   if (is_reference_type(result->get_type())) {
 961     result->set_jobject(JNIHandles::make_local(THREAD, result->get_oop()));
 962   }
 963 }
 964 
 965 DT_RETURN_MARK_DECL(AllocObject, jobject
 966                     , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref));
 967 
 968 JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz))
 969   HOTSPOT_JNI_ALLOCOBJECT_ENTRY(env, clazz);
 970 
 971   jobject ret = nullptr;
 972   DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret);
 973 
 974   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), "jni", CHECK_NULL);
 975   ret = JNIHandles::make_local(THREAD, i);
 976   return ret;
 977 JNI_END
 978 
 979 DT_RETURN_MARK_DECL(NewObjectA, jobject
 980                     , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref));
 981 
 982 JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args))
 983   HOTSPOT_JNI_NEWOBJECTA_ENTRY(env, clazz, (uintptr_t) methodID);
 984 
 985   jobject obj = nullptr;
 986   DT_RETURN_MARK(NewObjectA, jobject, (const jobject&)obj);
 987 
 988   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), "jni", CHECK_NULL);
 989   obj = JNIHandles::make_local(THREAD, i);
 990   JavaValue jvalue(T_VOID);
 991   JNI_ArgumentPusherArray ap(methodID, args);
 992   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
 993   return obj;
 994 JNI_END
 995 
 996 
 997 DT_RETURN_MARK_DECL(NewObjectV, jobject
 998                     , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref));
 999 
1000 JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args))
1001   HOTSPOT_JNI_NEWOBJECTV_ENTRY(env, clazz, (uintptr_t) methodID);
1002 
1003   jobject obj = nullptr;
1004   DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj);
1005 
1006   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), "jni", CHECK_NULL);
1007   obj = JNIHandles::make_local(THREAD, i);
1008   JavaValue jvalue(T_VOID);
1009   JNI_ArgumentPusherVaArg ap(methodID, args);
1010   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
1011   return obj;
1012 JNI_END
1013 
1014 
1015 DT_RETURN_MARK_DECL(NewObject, jobject
1016                     , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref));
1017 
1018 JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...))
1019   HOTSPOT_JNI_NEWOBJECT_ENTRY(env, clazz, (uintptr_t) methodID);
1020 
1021   jobject obj = nullptr;
1022   DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj);
1023 
1024   instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), "jni", CHECK_NULL);
1025   obj = JNIHandles::make_local(THREAD, i);
1026   va_list args;
1027   va_start(args, methodID);
1028   JavaValue jvalue(T_VOID);
1029   JNI_ArgumentPusherVaArg ap(methodID, args);
1030   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
1031   va_end(args);
1032   return obj;
1033 JNI_END
1034 
1035 
1036 JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj))
1037   HOTSPOT_JNI_GETOBJECTCLASS_ENTRY(env, obj);
1038 
1039   Klass* k = JNIHandles::resolve_non_null(obj)->klass();
1040   jclass ret =
1041     (jclass) JNIHandles::make_local(THREAD, k->java_mirror());
1042 
1043   HOTSPOT_JNI_GETOBJECTCLASS_RETURN(ret);
1044   return ret;
< prev index next >