1073 void LinkResolver::resolve_special_call(CallInfo& result, |
1073 void LinkResolver::resolve_special_call(CallInfo& result, |
1074 Handle recv, |
1074 Handle recv, |
1075 const LinkInfo& link_info, |
1075 const LinkInfo& link_info, |
1076 TRAPS) { |
1076 TRAPS) { |
1077 methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK); |
1077 methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK); |
1078 runtime_resolve_special_method(result, resolved_method, |
1078 runtime_resolve_special_method(result, link_info, resolved_method, recv, CHECK); |
1079 link_info.resolved_klass(), |
|
1080 link_info.current_klass(), |
|
1081 recv, |
|
1082 link_info.check_access(), CHECK); |
|
1083 } |
1079 } |
1084 |
1080 |
1085 // throws linktime exceptions |
1081 // throws linktime exceptions |
1086 methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, |
1082 methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, |
1087 TRAPS) { |
1083 TRAPS) { |
1161 return resolved_method; |
1157 return resolved_method; |
1162 } |
1158 } |
1163 |
1159 |
1164 // throws runtime exceptions |
1160 // throws runtime exceptions |
1165 void LinkResolver::runtime_resolve_special_method(CallInfo& result, |
1161 void LinkResolver::runtime_resolve_special_method(CallInfo& result, |
|
1162 const LinkInfo& link_info, |
1166 const methodHandle& resolved_method, |
1163 const methodHandle& resolved_method, |
1167 Klass* resolved_klass, |
1164 Handle recv, TRAPS) { |
1168 Klass* current_klass, |
1165 |
1169 Handle recv, |
1166 Klass* resolved_klass = link_info.resolved_klass(); |
1170 bool check_access, TRAPS) { |
|
1171 |
1167 |
1172 // resolved method is selected method unless we have an old-style lookup |
1168 // resolved method is selected method unless we have an old-style lookup |
1173 // for a superclass method |
1169 // for a superclass method |
1174 // Invokespecial for a superinterface, resolved method is selected method, |
1170 // Invokespecial for a superinterface, resolved method is selected method, |
1175 // no checks for shadowing |
1171 // no checks for shadowing |
1176 methodHandle sel_method(THREAD, resolved_method()); |
1172 methodHandle sel_method(THREAD, resolved_method()); |
1177 |
1173 |
1178 if (check_access && |
1174 if (link_info.check_access() && |
1179 // check if the method is not <init> |
1175 // check if the method is not <init> |
1180 resolved_method->name() != vmSymbols::object_initializer_name()) { |
1176 resolved_method->name() != vmSymbols::object_initializer_name()) { |
1181 |
1177 |
1182 // check if this is an old-style super call and do a new lookup if so |
1178 // check if this is an old-style super call and do a new lookup if so |
1183 // a) check if ACC_SUPER flag is set for the current class |
1179 // a) check if ACC_SUPER flag is set for the current class |
|
1180 Klass* current_klass = link_info.current_klass(); |
1184 if ((current_klass->is_super() || !AllowNonVirtualCalls) && |
1181 if ((current_klass->is_super() || !AllowNonVirtualCalls) && |
1185 // b) check if the class of the resolved_klass is a superclass |
1182 // b) check if the class of the resolved_klass is a superclass |
1186 // (not supertype in order to exclude interface classes) of the current class. |
1183 // (not supertype in order to exclude interface classes) of the current class. |
1187 // This check is not performed for super.invoke for interface methods |
1184 // This check is not performed for super.invoke for interface methods |
1188 // in super interfaces. |
1185 // in super interfaces. |
1198 ResourceMark rm(THREAD); |
1195 ResourceMark rm(THREAD); |
1199 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
1196 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
1200 Method::name_and_sig_as_C_string(resolved_klass, |
1197 Method::name_and_sig_as_C_string(resolved_klass, |
1201 resolved_method->name(), |
1198 resolved_method->name(), |
1202 resolved_method->signature())); |
1199 resolved_method->signature())); |
|
1200 // check loader constraints if found a different method |
|
1201 } else if (sel_method() != resolved_method()) { |
|
1202 check_method_loader_constraints(link_info, sel_method, "method", CHECK); |
1203 } |
1203 } |
1204 } |
1204 } |
1205 |
1205 |
1206 // Check that the class of objectref (the receiver) is the current class or interface, |
1206 // Check that the class of objectref (the receiver) is the current class or interface, |
1207 // or a subtype of the current class or interface (the sender), otherwise invokespecial |
1207 // or a subtype of the current class or interface (the sender), otherwise invokespecial |