< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page

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

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