< prev index next >

src/hotspot/share/interpreter/linkResolver.cpp

Print this page




1237         current_klass != resolved_klass &&
1238         // c) check the method is not private - we don't re-resolve private methods
1239         !resolved_method->is_private()
1240         ) {
1241       // Lookup super method
1242       Klass* super_klass = current_klass->super();
1243       sel_method = lookup_instance_method_in_klasses(super_klass,
1244                            resolved_method->name(),
1245                            resolved_method->signature(), CHECK);
1246       // check if found
1247       if (sel_method.is_null()) {
1248         ResourceMark rm(THREAD);
1249         THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
1250                   Method::name_and_sig_as_C_string(resolved_klass,
1251                                             resolved_method->name(),
1252                                             resolved_method->signature()));
1253       }
1254     }
1255 
1256     // Check that the class of objectref (the receiver) is the current class or interface,
1257     // or a subtype of the current class or interface (the sender), or else they are
1258     // nestmates, otherwise invokespecial throws IllegalAccessError.
1259     // The verifier checks that the sender is a subtype of the class in the I/MR operand.
1260     // The verifier also checks that the receiver is a subtype of the sender, if the sender is
1261     // a class.  If the sender is an interface, the check has to be performed at runtime.
1262     InstanceKlass* cur_ik = InstanceKlass::cast(current_klass);
1263     InstanceKlass* sender = cur_ik->is_anonymous() ? cur_ik->host_klass() : cur_ik;
1264     if (sender->is_interface() && recv.not_null()) {
1265       Klass* receiver_klass = recv->klass();
1266       if (!receiver_klass->is_subtype_of(sender) &&
1267           (cur_ik == sender && // don't check nestmate access for anonymous classes
1268            // Note: we check the resolved class here, not the receiver class - the latter
1269            // may be a subtype of the resolved class defined outside the nest.
1270            !sender->has_nestmate_access_to(InstanceKlass::cast(resolved_klass), THREAD))) {
1271         ResourceMark rm(THREAD);
1272         char buf[500];
1273         jio_snprintf(buf, sizeof(buf),
1274                      "Receiver class %s must be the current class or a subtype of interface %s",
1275                      receiver_klass->name()->as_C_string(),
1276                      sender->name()->as_C_string());
1277         THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);
1278       }
1279     }
1280   }
1281 
1282   // check if not static
1283   if (sel_method->is_static()) {
1284     ResourceMark rm(THREAD);
1285     char buf[200];
1286     jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
1287                                                                                       resolved_method->name(),
1288                                                                                       resolved_method->signature()));
1289     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
1290   }




1237         current_klass != resolved_klass &&
1238         // c) check the method is not private - we don't re-resolve private methods
1239         !resolved_method->is_private()
1240         ) {
1241       // Lookup super method
1242       Klass* super_klass = current_klass->super();
1243       sel_method = lookup_instance_method_in_klasses(super_klass,
1244                            resolved_method->name(),
1245                            resolved_method->signature(), CHECK);
1246       // check if found
1247       if (sel_method.is_null()) {
1248         ResourceMark rm(THREAD);
1249         THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
1250                   Method::name_and_sig_as_C_string(resolved_klass,
1251                                             resolved_method->name(),
1252                                             resolved_method->signature()));
1253       }
1254     }
1255 
1256     // Check that the class of objectref (the receiver) is the current class or interface,
1257     // or a subtype of the current class or interface (the sender), otherwise invokespecial
1258     // throws IllegalAccessError.
1259     // The verifier checks that the sender is a subtype of the class in the I/MR operand.
1260     // The verifier also checks that the receiver is a subtype of the sender, if the sender is
1261     // a class.  If the sender is an interface, the check has to be performed at runtime.
1262     InstanceKlass* cur_ik = InstanceKlass::cast(current_klass);
1263     InstanceKlass* sender = cur_ik->is_anonymous() ? cur_ik->host_klass() : cur_ik;
1264     if (sender->is_interface() && recv.not_null()) {
1265       Klass* receiver_klass = recv->klass();
1266       if (!receiver_klass->is_subtype_of(sender)) {




1267         ResourceMark rm(THREAD);
1268         char buf[500];
1269         jio_snprintf(buf, sizeof(buf),
1270                      "Receiver class %s must be the current class or a subtype of interface %s",
1271                      receiver_klass->name()->as_C_string(),
1272                      sender->name()->as_C_string());
1273         THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);
1274       }
1275     }
1276   }
1277 
1278   // check if not static
1279   if (sel_method->is_static()) {
1280     ResourceMark rm(THREAD);
1281     char buf[200];
1282     jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
1283                                                                                       resolved_method->name(),
1284                                                                                       resolved_method->signature()));
1285     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
1286   }


< prev index next >