src/share/vm/prims/methodHandles.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/prims

src/share/vm/prims/methodHandles.cpp

Print this page




1180       if (!Reflection::verify_class_access(caller,
1181                                            reference_klass,
1182                                            true)) {
1183         THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), reference_klass->external_name());
1184       }
1185     }
1186   }
1187 
1188   KlassHandle caller(THREAD,
1189                      caller_jh == NULL ? (Klass*) NULL :
1190                      java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)));
1191   Handle resolved = MethodHandles::resolve_MemberName(mname, caller, CHECK_NULL);
1192 
1193   if (resolved.is_null()) {
1194     int flags = java_lang_invoke_MemberName::flags(mname());
1195     int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK;
1196     if (!MethodHandles::ref_kind_is_valid(ref_kind)) {
1197       THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "obsolete MemberName format");
1198     }
1199     if ((flags & ALL_KINDS) == IS_FIELD) {
1200       THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), "field resolution failed");
1201     } else if ((flags & ALL_KINDS) == IS_METHOD ||
1202                (flags & ALL_KINDS) == IS_CONSTRUCTOR) {
1203       THROW_MSG_NULL(vmSymbols::java_lang_NoSuchFieldError(), "method resolution failed");
1204     } else {
1205       THROW_MSG_NULL(vmSymbols::java_lang_LinkageError(), "resolution failed");
1206     }
1207   }
1208 
1209   return JNIHandles::make_local(THREAD, resolved());
1210 }
1211 JVM_END
1212 
1213 static jlong find_member_field_offset(oop mname, bool must_be_static, TRAPS) {
1214   if (mname == NULL ||
1215       java_lang_invoke_MemberName::vmtarget(mname) == NULL) {
1216     THROW_MSG_0(vmSymbols::java_lang_InternalError(), "mname not resolved");
1217   } else {
1218     int flags = java_lang_invoke_MemberName::flags(mname);
1219     if ((flags & IS_FIELD) != 0 &&
1220         (must_be_static
1221          ? (flags & JVM_ACC_STATIC) != 0
1222          : (flags & JVM_ACC_STATIC) == 0)) {
1223       int vmindex = java_lang_invoke_MemberName::vmindex(mname);




1180       if (!Reflection::verify_class_access(caller,
1181                                            reference_klass,
1182                                            true)) {
1183         THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), reference_klass->external_name());
1184       }
1185     }
1186   }
1187 
1188   KlassHandle caller(THREAD,
1189                      caller_jh == NULL ? (Klass*) NULL :
1190                      java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)));
1191   Handle resolved = MethodHandles::resolve_MemberName(mname, caller, CHECK_NULL);
1192 
1193   if (resolved.is_null()) {
1194     int flags = java_lang_invoke_MemberName::flags(mname());
1195     int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK;
1196     if (!MethodHandles::ref_kind_is_valid(ref_kind)) {
1197       THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "obsolete MemberName format");
1198     }
1199     if ((flags & ALL_KINDS) == IS_FIELD) {
1200       THROW_MSG_NULL(vmSymbols::java_lang_NoSuchFieldError(), "field resolution failed");
1201     } else if ((flags & ALL_KINDS) == IS_METHOD ||
1202                (flags & ALL_KINDS) == IS_CONSTRUCTOR) {
1203       THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), "method resolution failed");
1204     } else {
1205       THROW_MSG_NULL(vmSymbols::java_lang_LinkageError(), "resolution failed");
1206     }
1207   }
1208 
1209   return JNIHandles::make_local(THREAD, resolved());
1210 }
1211 JVM_END
1212 
1213 static jlong find_member_field_offset(oop mname, bool must_be_static, TRAPS) {
1214   if (mname == NULL ||
1215       java_lang_invoke_MemberName::vmtarget(mname) == NULL) {
1216     THROW_MSG_0(vmSymbols::java_lang_InternalError(), "mname not resolved");
1217   } else {
1218     int flags = java_lang_invoke_MemberName::flags(mname);
1219     if ((flags & IS_FIELD) != 0 &&
1220         (must_be_static
1221          ? (flags & JVM_ACC_STATIC) != 0
1222          : (flags & JVM_ACC_STATIC) == 0)) {
1223       int vmindex = java_lang_invoke_MemberName::vmindex(mname);


src/share/vm/prims/methodHandles.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File