1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
194
195 // The LinkResolver is used to resolve constant-pool references at run-time.
196 // It does all necessary link-time checks & throws exceptions if necessary.
197
198 class LinkResolver: AllStatic {
199 friend class klassVtable;
200 friend class klassItable;
201
202 private:
203
204 static Method* lookup_method_in_klasses(const LinkInfo& link_info,
205 bool checkpolymorphism,
206 bool in_imethod_resolve);
207 static Method* lookup_method_in_interfaces(const LinkInfo& link_info);
208
209 static methodHandle lookup_polymorphic_method(const LinkInfo& link_info,
210 Handle *appendix_result_or_null,
211 Handle *method_type_result, TRAPS);
212 JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod()
213 // Not Linktime so doesn't take LinkInfo
214 static methodHandle lookup_instance_method_in_klasses (
215 Klass* klass, Symbol* name, Symbol* signature, TRAPS);
216 JVMCI_ONLY(private:)
217
218 // Similar loader constraint checking functions that throw
219 // LinkageError with descriptive message.
220 static void check_method_loader_constraints(const LinkInfo& link_info,
221 const methodHandle& resolved_method,
222 const char* method_type, TRAPS);
223 static void check_field_loader_constraints(Symbol* field, Symbol* sig,
224 Klass* current_klass,
225 Klass* sel_klass, TRAPS);
226
227 static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS);
228 static methodHandle resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS);
229
230 static methodHandle linktime_resolve_static_method (const LinkInfo& link_info, TRAPS);
231 static methodHandle linktime_resolve_special_method (const LinkInfo& link_info, TRAPS);
232 static methodHandle linktime_resolve_virtual_method (const LinkInfo& link_info, TRAPS);
233 static methodHandle linktime_resolve_interface_method (const LinkInfo& link_info, TRAPS);
234
235 static void runtime_resolve_special_method (CallInfo& result,
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
194
195 // The LinkResolver is used to resolve constant-pool references at run-time.
196 // It does all necessary link-time checks & throws exceptions if necessary.
197
198 class LinkResolver: AllStatic {
199 friend class klassVtable;
200 friend class klassItable;
201
202 private:
203
204 static Method* lookup_method_in_klasses(const LinkInfo& link_info,
205 bool checkpolymorphism,
206 bool in_imethod_resolve);
207 static Method* lookup_method_in_interfaces(const LinkInfo& link_info);
208
209 static methodHandle lookup_polymorphic_method(const LinkInfo& link_info,
210 Handle *appendix_result_or_null,
211 Handle *method_type_result, TRAPS);
212 JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod()
213 // Not Linktime so doesn't take LinkInfo
214 static methodHandle lookup_instance_method_in_klasses (Klass* klass, Symbol* name, Symbol* signature,
215 Klass::PrivateLookupMode private_mode, TRAPS);
216 JVMCI_ONLY(private:)
217
218 // Similar loader constraint checking functions that throw
219 // LinkageError with descriptive message.
220 static void check_method_loader_constraints(const LinkInfo& link_info,
221 const methodHandle& resolved_method,
222 const char* method_type, TRAPS);
223 static void check_field_loader_constraints(Symbol* field, Symbol* sig,
224 Klass* current_klass,
225 Klass* sel_klass, TRAPS);
226
227 static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS);
228 static methodHandle resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS);
229
230 static methodHandle linktime_resolve_static_method (const LinkInfo& link_info, TRAPS);
231 static methodHandle linktime_resolve_special_method (const LinkInfo& link_info, TRAPS);
232 static methodHandle linktime_resolve_virtual_method (const LinkInfo& link_info, TRAPS);
233 static methodHandle linktime_resolve_interface_method (const LinkInfo& link_info, TRAPS);
234
235 static void runtime_resolve_special_method (CallInfo& result,
|