Mercurial > hg > graal-compiler
comparison src/share/vm/prims/methodHandles.cpp @ 3387:2848194272f4
7044892: JSR 292: API entry points sometimes throw the wrong exceptions or doesn't throw the expected one
Summary: Fix to 7042656: JSR292: invokeExact/Generic doesn't throw UnsupportedOperationException if invoked via Method.invoke
Reviewed-by: never
author | jrose |
---|---|
date | Tue, 17 May 2011 15:43:46 -0700 |
parents | fabcf26ee72f |
children | b79e8b4ecd76 |
comparison
equal
deleted
inserted
replaced
3386:231c2b41ea4d | 3387:2848194272f4 |
---|---|
2920 // TO DO: expand at least some of the MemberNames, to avoid massive callbacks | 2920 // TO DO: expand at least some of the MemberNames, to avoid massive callbacks |
2921 return res; | 2921 return res; |
2922 } | 2922 } |
2923 JVM_END | 2923 JVM_END |
2924 | 2924 |
2925 JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv *env, jobject igmh, jobjectArray igargs)) { | |
2926 TempNewSymbol UOE_name = SymbolTable::new_symbol("java/lang/UnsupportedOperationException", CHECK_NULL); | |
2927 THROW_MSG_NULL(UOE_name, "MethodHandle.invoke cannot be invoked reflectively"); | |
2928 return NULL; | |
2929 } | |
2930 JVM_END | |
2931 | |
2932 JVM_ENTRY(jobject, MH_invokeExact_UOE(JNIEnv *env, jobject igmh, jobjectArray igargs)) { | |
2933 TempNewSymbol UOE_name = SymbolTable::new_symbol("java/lang/UnsupportedOperationException", CHECK_NULL); | |
2934 THROW_MSG_NULL(UOE_name, "MethodHandle.invokeExact cannot be invoked reflectively"); | |
2935 return NULL; | |
2936 } | |
2937 JVM_END | |
2938 | |
2925 | 2939 |
2926 /// JVM_RegisterMethodHandleMethods | 2940 /// JVM_RegisterMethodHandleMethods |
2927 | 2941 |
2928 #define LANG "Ljava/lang/" | 2942 #define LANG "Ljava/lang/" |
2929 #define JLINV "Ljava/lang/invoke/" | 2943 #define JLINV "Ljava/lang/invoke/" |
2958 // static native int getMembers(Class<?> defc, String matchName, String matchSig, | 2972 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
2959 // int matchFlags, Class<?> caller, int skip, MemberName[] results); | 2973 // int matchFlags, Class<?> caller, int skip, MemberName[] results); |
2960 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} | 2974 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} |
2961 }; | 2975 }; |
2962 | 2976 |
2977 static JNINativeMethod invoke_methods[] = { | |
2978 // void init(MemberName self, AccessibleObject ref) | |
2979 {CC"invoke", CC"(["OBJ")"OBJ, FN_PTR(MH_invoke_UOE)}, | |
2980 {CC"invokeExact", CC"(["OBJ")"OBJ, FN_PTR(MH_invokeExact_UOE)} | |
2981 }; | |
2982 | |
2963 // This one function is exported, used by NativeLookup. | 2983 // This one function is exported, used by NativeLookup. |
2964 | 2984 |
2965 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { | 2985 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2966 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); | 2986 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); |
2967 | 2987 |
2974 | 2994 |
2975 { | 2995 { |
2976 ThreadToNativeFromVM ttnfv(thread); | 2996 ThreadToNativeFromVM ttnfv(thread); |
2977 | 2997 |
2978 int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod)); | 2998 int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod)); |
2999 if (!env->ExceptionOccurred()) { | |
3000 const char* L_MH_name = (JLINV "MethodHandle"); | |
3001 const char* MH_name = L_MH_name+1; | |
3002 jclass MH_class = env->FindClass(MH_name); | |
3003 status = env->RegisterNatives(MH_class, invoke_methods, sizeof(invoke_methods)/sizeof(JNINativeMethod)); | |
3004 } | |
2979 if (env->ExceptionOccurred()) { | 3005 if (env->ExceptionOccurred()) { |
2980 MethodHandles::set_enabled(false); | 3006 MethodHandles::set_enabled(false); |
2981 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); | 3007 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); |
2982 enable_MH = false; | 3008 enable_MH = false; |
2983 env->ExceptionClear(); | 3009 env->ExceptionClear(); |