author | twisti |
Fri, 18 Dec 2015 12:39:02 -0800 | |
changeset 35135 | dd2ce9021031 |
parent 35086 | bbf32241d851 |
parent 34666 | 1c7168ea0034 |
child 35495 | e27da438fa13 |
child 35543 | 0961315f4016 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
28731
f7339cba0a6a
8067480: Crash in klassItable::initialize_itable_for_interface when running vm.runtime.defmeth.StaticMethodsTest.
lfoltan
parents:
27020
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14385 | 26 |
#include "classfile/defaultMethods.hpp" |
34666 | 27 |
#include "classfile/symbolTable.hpp" |
7397 | 28 |
#include "classfile/systemDictionary.hpp" |
29 |
#include "classfile/vmSymbols.hpp" |
|
30 |
#include "compiler/compileBroker.hpp" |
|
30764 | 31 |
#include "gc/shared/collectedHeap.inline.hpp" |
7397 | 32 |
#include "interpreter/bytecode.hpp" |
33 |
#include "interpreter/interpreterRuntime.hpp" |
|
34 |
#include "interpreter/linkResolver.hpp" |
|
35 |
#include "memory/resourceArea.hpp" |
|
36 |
#include "memory/universe.inline.hpp" |
|
37 |
#include "oops/instanceKlass.hpp" |
|
38 |
#include "oops/objArrayOop.hpp" |
|
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28738
diff
changeset
|
39 |
#include "oops/oop.inline.hpp" |
7397 | 40 |
#include "prims/methodHandles.hpp" |
41 |
#include "prims/nativeLookup.hpp" |
|
42 |
#include "runtime/compilationPolicy.hpp" |
|
43 |
#include "runtime/fieldDescriptor.hpp" |
|
44 |
#include "runtime/frame.inline.hpp" |
|
45 |
#include "runtime/handles.inline.hpp" |
|
46 |
#include "runtime/reflection.hpp" |
|
47 |
#include "runtime/signature.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14488
diff
changeset
|
48 |
#include "runtime/thread.inline.hpp" |
7397 | 49 |
#include "runtime/vmThread.hpp" |
1 | 50 |
|
51 |
||
52 |
//------------------------------------------------------------------------------------------------------------------------ |
|
53 |
// Implementation of CallInfo |
|
54 |
||
55 |
||
31019 | 56 |
void CallInfo::set_static(KlassHandle resolved_klass, const methodHandle& resolved_method, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
57 |
int vtable_index = Method::nonvirtual_vtable_index; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
58 |
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
1 | 59 |
} |
60 |
||
61 |
||
31019 | 62 |
void CallInfo::set_interface(KlassHandle resolved_klass, |
63 |
KlassHandle selected_klass, |
|
64 |
const methodHandle& resolved_method, |
|
65 |
const methodHandle& selected_method, |
|
66 |
int itable_index, TRAPS) { |
|
1 | 67 |
// This is only called for interface methods. If the resolved_method |
68 |
// comes from java/lang/Object, it can be the subject of a virtual call, so |
|
69 |
// we should pick the vtable index from the resolved method. |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
70 |
// In that case, the caller must call set_virtual instead of set_interface. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
71 |
assert(resolved_method->method_holder()->is_interface(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
72 |
assert(itable_index == resolved_method()->itable_index(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
73 |
set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); |
1 | 74 |
} |
75 |
||
31019 | 76 |
void CallInfo::set_virtual(KlassHandle resolved_klass, |
77 |
KlassHandle selected_klass, |
|
78 |
const methodHandle& resolved_method, |
|
79 |
const methodHandle& selected_method, |
|
80 |
int vtable_index, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
81 |
assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
82 |
assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
83 |
CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
84 |
set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
85 |
assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
1 | 86 |
} |
87 |
||
31019 | 88 |
void CallInfo::set_handle(const methodHandle& resolved_method, |
89 |
Handle resolved_appendix, |
|
90 |
Handle resolved_method_type, TRAPS) { |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
91 |
if (resolved_method.is_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
92 |
THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
93 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
94 |
KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
95 |
assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
96 |
resolved_method->is_compiled_lambda_form(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
97 |
"linkMethod must return one of these"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
98 |
int vtable_index = Method::nonvirtual_vtable_index; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
99 |
assert(!resolved_method->has_vtable_index(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
100 |
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
101 |
_resolved_appendix = resolved_appendix; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
102 |
_resolved_method_type = resolved_method_type; |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
103 |
} |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
104 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
105 |
void CallInfo::set_common(KlassHandle resolved_klass, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
106 |
KlassHandle selected_klass, |
31019 | 107 |
const methodHandle& resolved_method, |
108 |
const methodHandle& selected_method, |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
109 |
CallKind kind, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
110 |
int index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
111 |
TRAPS) { |
1 | 112 |
assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); |
113 |
_resolved_klass = resolved_klass; |
|
114 |
_selected_klass = selected_klass; |
|
115 |
_resolved_method = resolved_method; |
|
116 |
_selected_method = selected_method; |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
117 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
118 |
_call_index = index; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
119 |
_resolved_appendix = Handle(); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
120 |
DEBUG_ONLY(verify()); // verify before making side effects |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
121 |
|
6453 | 122 |
if (CompilationPolicy::must_be_compiled(selected_method)) { |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
123 |
// This path is unusual, mostly used by the '-Xcomp' stress test mode. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
124 |
|
6453 | 125 |
// Note: with several active threads, the must_be_compiled may be true |
126 |
// while can_be_compiled is false; remove assert |
|
127 |
// assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32189
diff
changeset
|
128 |
if (!THREAD->can_call_java()) { |
1 | 129 |
// don't force compilation, resolve was on behalf of compiler |
130 |
return; |
|
131 |
} |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
132 |
if (selected_method->method_holder()->is_not_initialized()) { |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
133 |
// 'is_not_initialized' means not only '!is_initialized', but also that |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
134 |
// initialization has not been started yet ('!being_initialized') |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
135 |
// Do not force compilation of methods in uninitialized classes. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
136 |
// Note that doing this would throw an assert later, |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
137 |
// in CompileBroker::compile_method. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
138 |
// We sometimes use the link resolver to do reflective lookups |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
139 |
// even before classes are initialized. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
140 |
return; |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
141 |
} |
1 | 142 |
CompileBroker::compile_method(selected_method, InvocationEntryBci, |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10008
diff
changeset
|
143 |
CompilationPolicy::policy()->initial_compile_level(), |
6453 | 144 |
methodHandle(), 0, "must_be_compiled", CHECK); |
1 | 145 |
} |
146 |
} |
|
147 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
148 |
// utility query for unreflecting a method |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
149 |
CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
150 |
Klass* resolved_method_holder = resolved_method->method_holder(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
151 |
if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
152 |
resolved_klass = resolved_method_holder; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
153 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
154 |
_resolved_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
155 |
_selected_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
156 |
_resolved_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
157 |
_selected_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
158 |
// classify: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
159 |
CallKind kind = CallInfo::unknown_kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
160 |
int index = resolved_method->vtable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
161 |
if (resolved_method->can_be_statically_bound()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
162 |
kind = CallInfo::direct_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
163 |
} else if (!resolved_method_holder->is_interface()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
164 |
// Could be an Object method inherited into an interface, but still a vtable call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
165 |
kind = CallInfo::vtable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
166 |
} else if (!resolved_klass->is_interface()) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
167 |
// A default or miranda method. Compute the vtable index. |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
168 |
ResourceMark rm; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
169 |
klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable(); |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
170 |
index = LinkResolver::vtable_index_of_interface_method(resolved_klass, |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
171 |
resolved_method); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
172 |
assert(index >= 0 , "we should have valid vtable index at this point"); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
173 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
174 |
kind = CallInfo::vtable_call; |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
175 |
} else if (resolved_method->has_vtable_index()) { |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
176 |
// Can occur if an interface redeclares a method of Object. |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
177 |
|
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
178 |
#ifdef ASSERT |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
179 |
// Ensure that this is really the case. |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
180 |
KlassHandle object_klass = SystemDictionary::Object_klass(); |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
181 |
Method * object_resolved_method = object_klass()->vtable()->method_at(index); |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
182 |
assert(object_resolved_method->name() == resolved_method->name(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
183 |
"Object and interface method names should match at vtable index %d, %s != %s", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
184 |
index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()); |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
185 |
assert(object_resolved_method->signature() == resolved_method->signature(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
186 |
"Object and interface method signatures should match at vtable index %d, %s != %s", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
187 |
index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string()); |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
188 |
#endif // ASSERT |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
189 |
|
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
190 |
kind = CallInfo::vtable_call; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
191 |
} else { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
192 |
// A regular interface call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
193 |
kind = CallInfo::itable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
194 |
index = resolved_method->itable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
195 |
} |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
196 |
assert(index == Method::nonvirtual_vtable_index || index >= 0, "bad index %d", index); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
197 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
198 |
_call_index = index; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
199 |
_resolved_appendix = Handle(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
200 |
DEBUG_ONLY(verify()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
201 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
202 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
203 |
#ifdef ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
204 |
void CallInfo::verify() { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
205 |
switch (call_kind()) { // the meaning and allowed value of index depends on kind |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
206 |
case CallInfo::direct_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
207 |
if (_call_index == Method::nonvirtual_vtable_index) break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
208 |
// else fall through to check vtable index: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
209 |
case CallInfo::vtable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
210 |
assert(resolved_klass()->verify_vtable_index(_call_index), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
211 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
212 |
case CallInfo::itable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
213 |
assert(resolved_method()->method_holder()->verify_itable_index(_call_index), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
214 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
215 |
case CallInfo::unknown_kind: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
216 |
assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set"); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
217 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
218 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
219 |
fatal("Unexpected call kind %d", call_kind()); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
220 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
221 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
222 |
#endif //ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
223 |
|
31019 | 224 |
#ifndef PRODUCT |
225 |
void CallInfo::print() { |
|
226 |
ResourceMark rm; |
|
227 |
const char* kindstr = "unknown"; |
|
228 |
switch (_call_kind) { |
|
229 |
case direct_call: kindstr = "direct"; break; |
|
230 |
case vtable_call: kindstr = "vtable"; break; |
|
231 |
case itable_call: kindstr = "itable"; break; |
|
232 |
} |
|
233 |
tty->print_cr("Call %s@%d %s", kindstr, _call_index, |
|
234 |
_resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string()); |
|
235 |
} |
|
236 |
#endif |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
237 |
|
31019 | 238 |
//------------------------------------------------------------------------------------------------------------------------ |
239 |
// Implementation of LinkInfo |
|
1 | 240 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
241 |
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 242 |
// resolve klass |
243 |
Klass* result = pool->klass_ref_at(index, CHECK); |
|
244 |
_resolved_klass = KlassHandle(THREAD, result); |
|
245 |
||
246 |
// Get name, signature, and static klass |
|
247 |
_name = pool->name_ref_at(index); |
|
248 |
_signature = pool->signature_ref_at(index); |
|
249 |
_current_klass = KlassHandle(THREAD, pool->pool_holder()); |
|
250 |
||
251 |
// Coming from the constant pool always checks access |
|
252 |
_check_access = true; |
|
253 |
} |
|
254 |
||
255 |
char* LinkInfo::method_string() const { |
|
256 |
return Method::name_and_sig_as_C_string(_resolved_klass(), _name, _signature); |
|
257 |
} |
|
258 |
||
259 |
#ifndef PRODUCT |
|
260 |
void LinkInfo::print() { |
|
261 |
ResourceMark rm; |
|
262 |
tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s", |
|
263 |
_resolved_klass->name()->as_C_string(), |
|
264 |
_name->as_C_string(), |
|
265 |
_signature->as_C_string(), |
|
266 |
_current_klass.is_null() ? "(none)" : _current_klass->name()->as_C_string(), |
|
267 |
_check_access ? "true" : "false"); |
|
268 |
} |
|
269 |
#endif // PRODUCT |
|
1 | 270 |
//------------------------------------------------------------------------------------------------------------------------ |
271 |
// Klass resolution |
|
272 |
||
273 |
void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
274 |
if (!Reflection::verify_class_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
275 |
sel_klass(), |
1 | 276 |
true)) { |
277 |
ResourceMark rm(THREAD); |
|
278 |
Exceptions::fthrow( |
|
279 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
280 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 281 |
"tried to access class %s from class %s", |
282 |
sel_klass->external_name(), |
|
283 |
ref_klass->external_name() |
|
284 |
); |
|
285 |
return; |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
//------------------------------------------------------------------------------------------------------------------------ |
|
290 |
// Method resolution |
|
291 |
// |
|
292 |
// According to JVM spec. $5.4.3c & $5.4.3d |
|
293 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
294 |
// Look up method in klasses, including static methods |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
295 |
// Then look up local default methods |
31019 | 296 |
methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, |
297 |
bool checkpolymorphism, |
|
298 |
bool in_imethod_resolve, TRAPS) { |
|
299 |
KlassHandle klass = link_info.resolved_klass(); |
|
300 |
Symbol* name = link_info.name(); |
|
301 |
Symbol* signature = link_info.signature(); |
|
302 |
||
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
303 |
// Ignore overpasses so statics can be found during resolution |
31019 | 304 |
Method* result = klass->uncached_lookup_method(name, signature, Klass::skip_overpass); |
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
305 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
306 |
if (klass->is_array_klass()) { |
27020 | 307 |
// Only consider klass and super klass for arrays |
31019 | 308 |
return methodHandle(THREAD, result); |
27020 | 309 |
} |
310 |
||
33602 | 311 |
InstanceKlass* ik = InstanceKlass::cast(klass()); |
312 |
||
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
313 |
// JDK 8, JVMS 5.4.3.4: Interface method resolution should |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
314 |
// ignore static and non-public methods of java.lang.Object, |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
315 |
// like clone, finalize, registerNatives. |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
316 |
if (in_imethod_resolve && |
31019 | 317 |
result != NULL && |
33602 | 318 |
ik->is_interface() && |
31019 | 319 |
(result->is_static() || !result->is_public()) && |
320 |
result->method_holder() == SystemDictionary::Object_klass()) { |
|
321 |
result = NULL; |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
322 |
} |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
323 |
|
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
324 |
// Before considering default methods, check for an overpass in the |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
325 |
// current class if a method has not been found. |
31019 | 326 |
if (result == NULL) { |
33602 | 327 |
result = ik->find_method(name, signature); |
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
328 |
} |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
329 |
|
31019 | 330 |
if (result == NULL) { |
33602 | 331 |
Array<Method*>* default_methods = ik->default_methods(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
332 |
if (default_methods != NULL) { |
31019 | 333 |
result = InstanceKlass::find_method(default_methods, name, signature); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
334 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
335 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
336 |
|
31019 | 337 |
if (checkpolymorphism && result != NULL) { |
338 |
vmIntrinsics::ID iid = result->intrinsic_id(); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
339 |
if (MethodHandles::is_signature_polymorphic(iid)) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
340 |
// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. |
31019 | 341 |
return NULL; |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
342 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
343 |
} |
31019 | 344 |
return methodHandle(THREAD, result); |
1 | 345 |
} |
346 |
||
347 |
// returns first instance method |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
348 |
// Looks up method in classes, then looks up local default methods |
31019 | 349 |
methodHandle LinkResolver::lookup_instance_method_in_klasses(KlassHandle klass, |
350 |
Symbol* name, |
|
351 |
Symbol* signature, TRAPS) { |
|
352 |
Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass); |
|
353 |
||
354 |
while (result != NULL && result->is_static() && result->method_holder()->super() != NULL) { |
|
355 |
Klass* super_klass = result->method_holder()->super(); |
|
356 |
result = super_klass->uncached_lookup_method(name, signature, Klass::find_overpass); |
|
1 | 357 |
} |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
358 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
359 |
if (klass->is_array_klass()) { |
27020 | 360 |
// Only consider klass and super klass for arrays |
31019 | 361 |
return methodHandle(THREAD, result); |
27020 | 362 |
} |
363 |
||
31019 | 364 |
if (result == NULL) { |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
365 |
Array<Method*>* default_methods = InstanceKlass::cast(klass())->default_methods(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
366 |
if (default_methods != NULL) { |
31019 | 367 |
result = InstanceKlass::find_method(default_methods, name, signature); |
368 |
assert(result == NULL || !result->is_static(), "static defaults not allowed"); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
369 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
370 |
} |
31019 | 371 |
return methodHandle(THREAD, result); |
1 | 372 |
} |
373 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
374 |
int LinkResolver::vtable_index_of_interface_method(KlassHandle klass, |
31019 | 375 |
const methodHandle& resolved_method) { |
1 | 376 |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
377 |
int vtable_index = Method::invalid_vtable_index; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
378 |
Symbol* name = resolved_method->name(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
379 |
Symbol* signature = resolved_method->signature(); |
33602 | 380 |
InstanceKlass* ik = InstanceKlass::cast(klass()); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
381 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
382 |
// First check in default method array |
33602 | 383 |
if (!resolved_method->is_abstract() && ik->default_methods() != NULL) { |
384 |
int index = InstanceKlass::find_method_index(ik->default_methods(), |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
385 |
name, signature, Klass::find_overpass, |
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
386 |
Klass::find_static, Klass::find_private); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
387 |
if (index >= 0 ) { |
33602 | 388 |
vtable_index = ik->default_vtable_indices()->at(index); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
389 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
390 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
391 |
if (vtable_index == Method::invalid_vtable_index) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
392 |
// get vtable_index for miranda methods |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
393 |
ResourceMark rm; |
33602 | 394 |
klassVtable *vt = ik->vtable(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
395 |
vtable_index = vt->index_of_miranda(name, signature); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
396 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
397 |
return vtable_index; |
1 | 398 |
} |
399 |
||
31019 | 400 |
methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) { |
401 |
InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass()()); |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
402 |
|
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
403 |
// Specify 'true' in order to skip default methods when searching the |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
404 |
// interfaces. Function lookup_method_in_klasses() already looked for |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
405 |
// the method in the default methods table. |
31019 | 406 |
return methodHandle(THREAD, |
407 |
ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), |
|
408 |
Klass::skip_defaults)); |
|
1 | 409 |
} |
410 |
||
31019 | 411 |
methodHandle LinkResolver::lookup_polymorphic_method( |
412 |
const LinkInfo& link_info, |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
413 |
Handle *appendix_result_or_null, |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
414 |
Handle *method_type_result, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
415 |
TRAPS) { |
31019 | 416 |
KlassHandle klass = link_info.resolved_klass(); |
417 |
Symbol* name = link_info.name(); |
|
418 |
Symbol* full_signature = link_info.signature(); |
|
419 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
420 |
vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
421 |
if (TraceMethodHandles) { |
16691 | 422 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
423 |
tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s", |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
424 |
vmIntrinsics::name_at(iid), klass->external_name(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
425 |
name->as_C_string(), full_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
426 |
} |
24322 | 427 |
if (klass() == SystemDictionary::MethodHandle_klass() && |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
428 |
iid != vmIntrinsics::_none) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
429 |
if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
430 |
// Most of these do not need an up-call to Java to resolve, so can be done anywhere. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
431 |
// Do not erase last argument type (MemberName) if it is a static linkTo method. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
432 |
bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
433 |
TempNewSymbol basic_signature = |
31019 | 434 |
MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
435 |
if (TraceMethodHandles) { |
16691 | 436 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
437 |
tty->print_cr("lookup_polymorphic_method %s %s => basic %s", |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
438 |
name->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
439 |
full_signature->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
440 |
basic_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
441 |
} |
31019 | 442 |
methodHandle result = SystemDictionary::find_method_handle_intrinsic(iid, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
443 |
basic_signature, |
31019 | 444 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
445 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
446 |
assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
447 |
assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
448 |
assert(basic_signature == result->signature(), "predict the result signature"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
449 |
if (TraceMethodHandles) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
450 |
tty->print("lookup_polymorphic_method => intrinsic "); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
451 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
452 |
} |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
453 |
} |
31019 | 454 |
return result; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
455 |
} else if (iid == vmIntrinsics::_invokeGeneric |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32189
diff
changeset
|
456 |
&& THREAD->can_call_java() |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
457 |
&& appendix_result_or_null != NULL) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
458 |
// This is a method with type-checking semantics. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
459 |
// We will ask Java code to spin an adapter method for it. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
460 |
if (!MethodHandles::enabled()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
461 |
// Make sure the Java part of the runtime has been booted up. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
462 |
Klass* natives = SystemDictionary::MethodHandleNatives_klass(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
463 |
if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
464 |
SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
465 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
466 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
467 |
true, |
31019 | 468 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
469 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
470 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
471 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
472 |
Handle appendix; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
473 |
Handle method_type; |
31019 | 474 |
methodHandle result = SystemDictionary::find_method_handle_invoker( |
475 |
name, |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
476 |
full_signature, |
31019 | 477 |
link_info.current_klass(), |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
478 |
&appendix, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
479 |
&method_type, |
31019 | 480 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
481 |
if (TraceMethodHandles) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
482 |
tty->print("lookup_polymorphic_method => (via Java) "); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
483 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
484 |
tty->print(" lookup_polymorphic_method => appendix = "); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
485 |
if (appendix.is_null()) tty->print_cr("(none)"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
486 |
else appendix->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
487 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
488 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
489 |
#ifdef ASSERT |
16691 | 490 |
ResourceMark rm(THREAD); |
491 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
492 |
TempNewSymbol basic_signature = |
31019 | 493 |
MethodHandles::lookup_basic_type_signature(full_signature, CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
494 |
int actual_size_of_params = result->size_of_parameters(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
495 |
int expected_size_of_params = ArgumentSizeComputer(basic_signature).size(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
496 |
// +1 for MethodHandle.this, +1 for trailing MethodType |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
497 |
if (!MethodHandles::is_signature_polymorphic_static(iid)) expected_size_of_params += 1; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
498 |
if (appendix.not_null()) expected_size_of_params += 1; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
499 |
if (actual_size_of_params != expected_size_of_params) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
500 |
tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
501 |
tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid)); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
502 |
result->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
503 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
504 |
assert(actual_size_of_params == expected_size_of_params, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
505 |
"%d != %d", actual_size_of_params, expected_size_of_params); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
506 |
#endif //ASSERT |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
507 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
508 |
assert(appendix_result_or_null != NULL, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
509 |
(*appendix_result_or_null) = appendix; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
510 |
(*method_type_result) = method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
511 |
} |
31019 | 512 |
return result; |
2534 | 513 |
} |
514 |
} |
|
31019 | 515 |
return NULL; |
2534 | 516 |
} |
517 |
||
1 | 518 |
void LinkResolver::check_method_accessability(KlassHandle ref_klass, |
519 |
KlassHandle resolved_klass, |
|
520 |
KlassHandle sel_klass, |
|
31019 | 521 |
const methodHandle& sel_method, |
1 | 522 |
TRAPS) { |
523 |
||
524 |
AccessFlags flags = sel_method->access_flags(); |
|
525 |
||
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
526 |
// Special case: arrays always override "clone". JVMS 2.15. |
1 | 527 |
// If the resolved klass is an array class, and the declaring class |
528 |
// is java.lang.Object and the method is "clone", set the flags |
|
529 |
// to public. |
|
530 |
// |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
531 |
// We'll check for the method name first, as that's most likely |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
532 |
// to be false (so we'll short-circuit out of these tests). |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
533 |
if (sel_method->name() == vmSymbols::clone_name() && |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
534 |
sel_klass() == SystemDictionary::Object_klass() && |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
535 |
resolved_klass->is_array_klass()) { |
1 | 536 |
// We need to change "protected" to "public". |
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
537 |
assert(flags.is_protected(), "clone not protected?"); |
1 | 538 |
jint new_flags = flags.as_int(); |
539 |
new_flags = new_flags & (~JVM_ACC_PROTECTED); |
|
540 |
new_flags = new_flags | JVM_ACC_PUBLIC; |
|
541 |
flags.set_flags(new_flags); |
|
542 |
} |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
543 |
// assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); |
1 | 544 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
545 |
if (!Reflection::verify_field_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
546 |
resolved_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
547 |
sel_klass(), |
1 | 548 |
flags, |
549 |
true)) { |
|
550 |
ResourceMark rm(THREAD); |
|
551 |
Exceptions::fthrow( |
|
552 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
553 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 554 |
"tried to access method %s.%s%s from class %s", |
555 |
sel_klass->external_name(), |
|
556 |
sel_method->name()->as_C_string(), |
|
557 |
sel_method->signature()->as_C_string(), |
|
558 |
ref_klass->external_name() |
|
559 |
); |
|
560 |
return; |
|
561 |
} |
|
562 |
} |
|
563 |
||
31019 | 564 |
methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
565 |
const constantPoolHandle& pool, int index, TRAPS) { |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
566 |
// This method is used only |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
567 |
// (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
568 |
// and |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
569 |
// (2) in Bytecode_invoke::static_target |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
570 |
// It appears to fail when applied to an invokeinterface call site. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
571 |
// FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. |
1 | 572 |
// resolve klass |
31019 | 573 |
KlassHandle resolved_klass; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
574 |
if (code == Bytecodes::_invokedynamic) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
575 |
resolved_klass = SystemDictionary::MethodHandle_klass(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
576 |
Symbol* method_name = vmSymbols::invoke_name(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
577 |
Symbol* method_signature = pool->signature_ref_at(index); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
578 |
KlassHandle current_klass(THREAD, pool->pool_holder()); |
31019 | 579 |
LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass); |
580 |
return resolve_method(link_info, /*require_methodref*/false, THREAD); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
581 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
582 |
|
31019 | 583 |
LinkInfo link_info(pool, index, CHECK_NULL); |
584 |
resolved_klass = link_info.resolved_klass(); |
|
1 | 585 |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
586 |
if (pool->has_preresolution() |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
587 |
|| (resolved_klass() == SystemDictionary::MethodHandle_klass() && |
31019 | 588 |
MethodHandles::is_signature_polymorphic_name(resolved_klass(), link_info.name()))) { |
589 |
Method* result = ConstantPool::method_at_if_loaded(pool, index); |
|
590 |
if (result != NULL) { |
|
591 |
return methodHandle(THREAD, result); |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
592 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
593 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
594 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
595 |
if (code == Bytecodes::_invokeinterface) { |
31019 | 596 |
return resolve_interface_method(link_info, true, THREAD); |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
597 |
} else if (code == Bytecodes::_invokevirtual) { |
31019 | 598 |
return resolve_method(link_info, /*require_methodref*/true, THREAD); |
21912 | 599 |
} else if (!resolved_klass->is_interface()) { |
31019 | 600 |
return resolve_method(link_info, /*require_methodref*/false, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
601 |
} else { |
21912 | 602 |
bool nostatics = (code == Bytecodes::_invokestatic) ? false : true; |
31019 | 603 |
return resolve_interface_method(link_info, nostatics, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
604 |
} |
1 | 605 |
} |
606 |
||
31019 | 607 |
// Check and print a loader constraint violation message for method or interface method |
608 |
void LinkResolver::check_method_loader_constraints(const LinkInfo& link_info, |
|
609 |
const methodHandle& resolved_method, |
|
610 |
const char* method_type, TRAPS) { |
|
611 |
Handle current_loader(THREAD, link_info.current_klass()->class_loader()); |
|
612 |
Handle resolved_loader(THREAD, resolved_method->method_holder()->class_loader()); |
|
613 |
||
614 |
ResourceMark rm(THREAD); |
|
615 |
Symbol* failed_type_symbol = |
|
616 |
SystemDictionary::check_signature_loaders(link_info.signature(), current_loader, |
|
617 |
resolved_loader, true, CHECK); |
|
618 |
if (failed_type_symbol != NULL) { |
|
619 |
const char* msg = "loader constraint violation: when resolving %s" |
|
620 |
" \"%s\" the class loader (instance of %s) of the current class, %s," |
|
621 |
" and the class loader (instance of %s) for the method's defining class, %s, have" |
|
622 |
" different Class objects for the type %s used in the signature"; |
|
623 |
char* sig = link_info.method_string(); |
|
624 |
const char* loader1_name = SystemDictionary::loader_name(current_loader()); |
|
625 |
char* current = link_info.current_klass()->name()->as_C_string(); |
|
626 |
const char* loader2_name = SystemDictionary::loader_name(resolved_loader()); |
|
627 |
char* target = resolved_method->method_holder()->name()->as_C_string(); |
|
628 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
|
629 |
size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1_name) + |
|
630 |
strlen(current) + strlen(loader2_name) + strlen(target) + |
|
631 |
strlen(failed_type_name) + strlen(method_type) + 1; |
|
632 |
char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
|
633 |
jio_snprintf(buf, buflen, msg, method_type, sig, loader1_name, current, loader2_name, |
|
634 |
target, failed_type_name); |
|
635 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
|
636 |
} |
|
637 |
} |
|
638 |
||
639 |
void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig, |
|
640 |
KlassHandle current_klass, |
|
641 |
KlassHandle sel_klass, TRAPS) { |
|
642 |
Handle ref_loader(THREAD, current_klass->class_loader()); |
|
643 |
Handle sel_loader(THREAD, sel_klass->class_loader()); |
|
644 |
||
645 |
ResourceMark rm(THREAD); // needed for check_signature_loaders |
|
646 |
Symbol* failed_type_symbol = |
|
647 |
SystemDictionary::check_signature_loaders(sig, |
|
648 |
ref_loader, sel_loader, |
|
649 |
false, |
|
650 |
CHECK); |
|
651 |
if (failed_type_symbol != NULL) { |
|
652 |
const char* msg = "loader constraint violation: when resolving field" |
|
653 |
" \"%s\" the class loader (instance of %s) of the referring class, " |
|
654 |
"%s, and the class loader (instance of %s) for the field's resolved " |
|
655 |
"type, %s, have different Class objects for that type"; |
|
656 |
char* field_name = field->as_C_string(); |
|
657 |
const char* loader1_name = SystemDictionary::loader_name(ref_loader()); |
|
658 |
char* sel = sel_klass->name()->as_C_string(); |
|
659 |
const char* loader2_name = SystemDictionary::loader_name(sel_loader()); |
|
660 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
|
661 |
size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1_name) + |
|
662 |
strlen(sel) + strlen(loader2_name) + strlen(failed_type_name) + 1; |
|
663 |
char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
|
664 |
jio_snprintf(buf, buflen, msg, field_name, loader1_name, sel, loader2_name, |
|
665 |
failed_type_name); |
|
666 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
|
667 |
} |
|
668 |
} |
|
669 |
||
670 |
methodHandle LinkResolver::resolve_method(const LinkInfo& link_info, |
|
671 |
bool require_methodref, TRAPS) { |
|
1 | 672 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
673 |
Handle nested_exception; |
31019 | 674 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
675 |
|
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
676 |
// 1. check if methodref required, that resolved_klass is not interfacemethodref |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
677 |
if (require_methodref && resolved_klass->is_interface()) { |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
678 |
ResourceMark rm(THREAD); |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
679 |
char buf[200]; |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
680 |
jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
681 |
resolved_klass()->external_name()); |
31019 | 682 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
683 |
} |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
684 |
|
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
685 |
// 2. lookup method in resolved klass and its super klasses |
31019 | 686 |
methodHandle resolved_method = lookup_method_in_klasses(link_info, true, false, CHECK_NULL); |
1 | 687 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
688 |
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
689 |
// 3. lookup method in all the interfaces implemented by the resolved klass |
31019 | 690 |
resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL); |
1 | 691 |
|
692 |
if (resolved_method.is_null()) { |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
693 |
// JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
31019 | 694 |
resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, (Handle*)NULL, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
695 |
if (HAS_PENDING_EXCEPTION) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
696 |
nested_exception = Handle(THREAD, PENDING_EXCEPTION); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
697 |
CLEAR_PENDING_EXCEPTION; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
698 |
} |
2534 | 699 |
} |
27020 | 700 |
} |
2534 | 701 |
|
27020 | 702 |
if (resolved_method.is_null()) { |
703 |
// 4. method lookup failed |
|
704 |
ResourceMark rm(THREAD); |
|
31019 | 705 |
THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(), |
27020 | 706 |
Method::name_and_sig_as_C_string(resolved_klass(), |
31019 | 707 |
link_info.name(), |
708 |
link_info.signature()), |
|
709 |
nested_exception, NULL); |
|
1 | 710 |
} |
711 |
||
22739
74105c330330
8032010: Attempt to resolve abstract method in concrete class fails with AbstractMethodError
ccheung
parents:
22521
diff
changeset
|
712 |
// 5. access checks, access checking may be turned off when calling from within the VM. |
31019 | 713 |
KlassHandle current_klass = link_info.current_klass(); |
714 |
if (link_info.check_access()) { |
|
1 | 715 |
assert(current_klass.not_null() , "current_klass should not be null"); |
716 |
||
717 |
// check if method can be accessed by the referring class |
|
718 |
check_method_accessability(current_klass, |
|
719 |
resolved_klass, |
|
720 |
KlassHandle(THREAD, resolved_method->method_holder()), |
|
721 |
resolved_method, |
|
31019 | 722 |
CHECK_NULL); |
1 | 723 |
|
724 |
// check loader constraints |
|
31019 | 725 |
check_method_loader_constraints(link_info, resolved_method, "method", CHECK_NULL); |
1 | 726 |
} |
31019 | 727 |
|
728 |
return resolved_method; |
|
1 | 729 |
} |
730 |
||
31019 | 731 |
methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, |
732 |
bool nostatics, TRAPS) { |
|
733 |
||
734 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
|
1 | 735 |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
736 |
// check if klass is interface |
1 | 737 |
if (!resolved_klass->is_interface()) { |
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
738 |
ResourceMark rm(THREAD); |
1 | 739 |
char buf[200]; |
14488 | 740 |
jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); |
31019 | 741 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 742 |
} |
743 |
||
744 |
// lookup method in this interface or its super, java.lang.Object |
|
21912 | 745 |
// JDK8: also look for static methods |
31019 | 746 |
methodHandle resolved_method = lookup_method_in_klasses(link_info, false, true, CHECK_NULL); |
1 | 747 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
748 |
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { |
1 | 749 |
// lookup method in all the super-interfaces |
31019 | 750 |
resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL); |
27020 | 751 |
} |
752 |
||
753 |
if (resolved_method.is_null()) { |
|
754 |
// no method found |
|
755 |
ResourceMark rm(THREAD); |
|
31019 | 756 |
THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), |
757 |
Method::name_and_sig_as_C_string(resolved_klass(), |
|
758 |
link_info.name(), |
|
759 |
link_info.signature())); |
|
1 | 760 |
} |
761 |
||
31019 | 762 |
if (link_info.check_access()) { |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
763 |
// JDK8 adds non-public interface methods, and accessability check requirement |
31019 | 764 |
KlassHandle current_klass = link_info.current_klass(); |
765 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
766 |
assert(current_klass.not_null() , "current_klass should not be null"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
767 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
768 |
// check if method can be accessed by the referring class |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
769 |
check_method_accessability(current_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
770 |
resolved_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
771 |
KlassHandle(THREAD, resolved_method->method_holder()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
772 |
resolved_method, |
31019 | 773 |
CHECK_NULL); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
774 |
|
31019 | 775 |
check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL); |
1 | 776 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
777 |
|
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
778 |
if (nostatics && resolved_method->is_static()) { |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
779 |
ResourceMark rm(THREAD); |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
780 |
char buf[200]; |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
781 |
jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
782 |
Method::name_and_sig_as_C_string(resolved_klass(), |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
783 |
resolved_method->name(), resolved_method->signature())); |
31019 | 784 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
785 |
} |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
786 |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
787 |
if (TraceItables && Verbose) { |
31019 | 788 |
trace_method_resolution("invokeinterface resolved method: caller-class", |
789 |
link_info.current_klass(), resolved_klass, resolved_method); |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
790 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
791 |
} |
31019 | 792 |
|
793 |
return resolved_method; |
|
1 | 794 |
} |
795 |
||
796 |
//------------------------------------------------------------------------------------------------------------------------ |
|
797 |
// Field resolution |
|
798 |
||
799 |
void LinkResolver::check_field_accessability(KlassHandle ref_klass, |
|
800 |
KlassHandle resolved_klass, |
|
801 |
KlassHandle sel_klass, |
|
31019 | 802 |
const fieldDescriptor& fd, |
1 | 803 |
TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
804 |
if (!Reflection::verify_field_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
805 |
resolved_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
806 |
sel_klass(), |
1 | 807 |
fd.access_flags(), |
808 |
true)) { |
|
809 |
ResourceMark rm(THREAD); |
|
810 |
Exceptions::fthrow( |
|
811 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
812 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 813 |
"tried to access field %s.%s from class %s", |
814 |
sel_klass->external_name(), |
|
815 |
fd.name()->as_C_string(), |
|
816 |
ref_klass->external_name() |
|
817 |
); |
|
818 |
return; |
|
819 |
} |
|
820 |
} |
|
821 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
822 |
void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { |
31019 | 823 |
LinkInfo link_info(pool, index, CHECK); |
824 |
resolve_field(fd, link_info, byte, true, CHECK); |
|
1 | 825 |
} |
826 |
||
31019 | 827 |
void LinkResolver::resolve_field(fieldDescriptor& fd, |
828 |
const LinkInfo& link_info, |
|
829 |
Bytecodes::Code byte, bool initialize_class, |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
830 |
TRAPS) { |
1 | 831 |
assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
832 |
byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || |
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
29081
diff
changeset
|
833 |
byte == Bytecodes::_nofast_getfield || byte == Bytecodes::_nofast_putfield || |
31019 | 834 |
(byte == Bytecodes::_nop && !link_info.check_access()), "bad field access bytecode"); |
1 | 835 |
|
836 |
bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); |
|
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
29081
diff
changeset
|
837 |
bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); |
1 | 838 |
// Check if there's a resolved klass containing the field |
31019 | 839 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
840 |
Symbol* field = link_info.name(); |
|
841 |
Symbol* sig = link_info.signature(); |
|
842 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
843 |
if (resolved_klass.is_null()) { |
1 | 844 |
ResourceMark rm(THREAD); |
845 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
846 |
} |
|
847 |
||
848 |
// Resolve instance field |
|
27020 | 849 |
KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); |
1 | 850 |
// check if field exists; i.e., if a klass containing the field def has been selected |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
851 |
if (sel_klass.is_null()) { |
1 | 852 |
ResourceMark rm(THREAD); |
853 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
854 |
} |
|
855 |
||
31019 | 856 |
if (!link_info.check_access()) |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
857 |
// Access checking may be turned off when calling from within the VM. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
858 |
return; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
859 |
|
1 | 860 |
// check access |
31019 | 861 |
KlassHandle current_klass = link_info.current_klass(); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
862 |
check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); |
1 | 863 |
|
864 |
// check for errors |
|
865 |
if (is_static != fd.is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
866 |
ResourceMark rm(THREAD); |
1 | 867 |
char msg[200]; |
14488 | 868 |
jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string()); |
1 | 869 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); |
870 |
} |
|
871 |
||
872 |
// Final fields can only be accessed from its own class. |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
873 |
if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) { |
1 | 874 |
THROW(vmSymbols::java_lang_IllegalAccessError()); |
875 |
} |
|
876 |
||
877 |
// initialize resolved_klass if necessary |
|
878 |
// note 1: the klass which declared the field must be initialized (i.e, sel_klass) |
|
879 |
// according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99) |
|
880 |
// |
|
881 |
// note 2: we don't want to force initialization if we are just checking |
|
882 |
// if the field access is legal; e.g., during compilation |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
883 |
if (is_static && initialize_class) { |
1 | 884 |
sel_klass->initialize(CHECK); |
885 |
} |
|
886 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
887 |
if (sel_klass() != current_klass()) { |
31019 | 888 |
check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK); |
1 | 889 |
} |
890 |
||
891 |
// return information. note that the klass is set to the actual klass containing the |
|
892 |
// field, otherwise access of static fields in superclasses will not work. |
|
893 |
} |
|
894 |
||
895 |
||
896 |
//------------------------------------------------------------------------------------------------------------------------ |
|
897 |
// Invoke resolution |
|
898 |
// |
|
899 |
// Naming conventions: |
|
900 |
// |
|
901 |
// resolved_method the specified method (i.e., static receiver specified via constant pool index) |
|
902 |
// sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class) |
|
903 |
// resolved_klass the specified klass (i.e., specified via constant pool index) |
|
904 |
// recv_klass the receiver klass |
|
905 |
||
906 |
||
31019 | 907 |
void LinkResolver::resolve_static_call(CallInfo& result, |
908 |
const LinkInfo& link_info, |
|
909 |
bool initialize_class, TRAPS) { |
|
910 |
methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK); |
|
1 | 911 |
|
31019 | 912 |
// The resolved class can change as a result of this resolution. |
913 |
KlassHandle resolved_klass = KlassHandle(THREAD, resolved_method->method_holder()); |
|
914 |
||
915 |
Method* save_resolved_method = resolved_method(); |
|
1 | 916 |
// Initialize klass (this should only happen if everything is ok) |
917 |
if (initialize_class && resolved_klass->should_be_initialized()) { |
|
918 |
resolved_klass->initialize(CHECK); |
|
31019 | 919 |
// Use updated LinkInfo (to reresolve with resolved_klass as method_holder?) |
920 |
LinkInfo new_info(resolved_klass, link_info.name(), link_info.signature(), |
|
34238 | 921 |
link_info.current_klass(), link_info.check_access()); |
31019 | 922 |
resolved_method = linktime_resolve_static_method(new_info, CHECK); |
1 | 923 |
} |
924 |
||
31019 | 925 |
assert(save_resolved_method == resolved_method(), "does this change?"); |
1 | 926 |
// setup result |
927 |
result.set_static(resolved_klass, resolved_method, CHECK); |
|
928 |
} |
|
929 |
||
930 |
// throws linktime exceptions |
|
31019 | 931 |
methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) { |
1 | 932 |
|
31019 | 933 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
934 |
methodHandle resolved_method; |
|
21912 | 935 |
if (!resolved_klass->is_interface()) { |
31019 | 936 |
resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); |
21912 | 937 |
} else { |
31019 | 938 |
resolved_method = resolve_interface_method(link_info, /*nostatics*/false, CHECK_NULL); |
21912 | 939 |
} |
1 | 940 |
assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); |
941 |
||
942 |
// check if static |
|
943 |
if (!resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
944 |
ResourceMark rm(THREAD); |
1 | 945 |
char buf[200]; |
14488 | 946 |
jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 947 |
resolved_method->name(), |
948 |
resolved_method->signature())); |
|
31019 | 949 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 950 |
} |
31019 | 951 |
return resolved_method; |
1 | 952 |
} |
953 |
||
954 |
||
31019 | 955 |
void LinkResolver::resolve_special_call(CallInfo& result, |
956 |
const LinkInfo& link_info, |
|
957 |
TRAPS) { |
|
958 |
methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK); |
|
959 |
runtime_resolve_special_method(result, resolved_method, |
|
960 |
link_info.resolved_klass(), |
|
961 |
link_info.current_klass(), |
|
962 |
link_info.check_access(), CHECK); |
|
1 | 963 |
} |
964 |
||
965 |
// throws linktime exceptions |
|
31019 | 966 |
methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, |
967 |
TRAPS) { |
|
1 | 968 |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
969 |
// Invokespecial is called for multiple special reasons: |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
970 |
// <init> |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
971 |
// local private method invocation, for classes and interfaces |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
972 |
// superclass.method, which can also resolve to a default method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
973 |
// and the selected method is recalculated relative to the direct superclass |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
974 |
// superinterface.method, which explicitly does not check shadowing |
31019 | 975 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
976 |
methodHandle resolved_method; |
|
14385 | 977 |
|
21912 | 978 |
if (!resolved_klass->is_interface()) { |
31019 | 979 |
resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); |
21912 | 980 |
} else { |
31019 | 981 |
resolved_method = resolve_interface_method(link_info, /*nostatics*/true, CHECK_NULL); |
21912 | 982 |
} |
1 | 983 |
|
984 |
// check if method name is <init>, that it is found in same klass as static type |
|
985 |
if (resolved_method->name() == vmSymbols::object_initializer_name() && |
|
986 |
resolved_method->method_holder() != resolved_klass()) { |
|
987 |
ResourceMark rm(THREAD); |
|
988 |
Exceptions::fthrow( |
|
989 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
990 |
vmSymbols::java_lang_NoSuchMethodError(), |
1 | 991 |
"%s: method %s%s not found", |
992 |
resolved_klass->external_name(), |
|
993 |
resolved_method->name()->as_C_string(), |
|
994 |
resolved_method->signature()->as_C_string() |
|
995 |
); |
|
31019 | 996 |
return NULL; |
1 | 997 |
} |
998 |
||
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
999 |
// check if invokespecial's interface method reference is in an indirect superinterface |
31019 | 1000 |
KlassHandle current_klass = link_info.current_klass(); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1001 |
if (!current_klass.is_null() && resolved_klass->is_interface()) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1002 |
Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ? |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1003 |
current_klass() : |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1004 |
InstanceKlass::cast(current_klass())->host_klass(); |
25057 | 1005 |
// Disable verification for the dynamically-generated reflection bytecodes. |
1006 |
bool is_reflect = klass_to_check->is_subclass_of( |
|
22218
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1007 |
SystemDictionary::reflect_MagicAccessorImpl_klass()); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1008 |
|
22218
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1009 |
if (!is_reflect && |
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1010 |
!InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) { |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1011 |
ResourceMark rm(THREAD); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1012 |
char buf[200]; |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1013 |
jio_snprintf(buf, sizeof(buf), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1014 |
"Interface method reference: %s, is in an indirect superinterface of %s", |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1015 |
Method::name_and_sig_as_C_string(resolved_klass(), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1016 |
resolved_method->name(), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1017 |
resolved_method->signature()), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1018 |
current_klass->external_name()); |
31019 | 1019 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1020 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1021 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1022 |
|
1 | 1023 |
// check if not static |
1024 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1025 |
ResourceMark rm(THREAD); |
1 | 1026 |
char buf[200]; |
1027 |
jio_snprintf(buf, sizeof(buf), |
|
1028 |
"Expecting non-static method %s", |
|
14488 | 1029 |
Method::name_and_sig_as_C_string(resolved_klass(), |
31019 | 1030 |
resolved_method->name(), |
1031 |
resolved_method->signature())); |
|
1032 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
1 | 1033 |
} |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1034 |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1035 |
if (TraceItables && Verbose) { |
31019 | 1036 |
trace_method_resolution("invokespecial resolved method: caller-class:", |
1037 |
current_klass, resolved_klass, resolved_method); |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1038 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1039 |
} |
31019 | 1040 |
|
1041 |
return resolved_method; |
|
1 | 1042 |
} |
1043 |
||
1044 |
// throws runtime exceptions |
|
31019 | 1045 |
void LinkResolver::runtime_resolve_special_method(CallInfo& result, |
1046 |
const methodHandle& resolved_method, |
|
1047 |
KlassHandle resolved_klass, |
|
1048 |
KlassHandle current_klass, |
|
1049 |
bool check_access, TRAPS) { |
|
1 | 1050 |
|
1051 |
// resolved method is selected method unless we have an old-style lookup |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1052 |
// for a superclass method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1053 |
// Invokespecial for a superinterface, resolved method is selected method, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1054 |
// no checks for shadowing |
1 | 1055 |
methodHandle sel_method(THREAD, resolved_method()); |
1056 |
||
1057 |
// check if this is an old-style super call and do a new lookup if so |
|
1058 |
{ KlassHandle method_klass = KlassHandle(THREAD, |
|
1059 |
resolved_method->method_holder()); |
|
1060 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1061 |
if (check_access && |
1 | 1062 |
// a) check if ACC_SUPER flag is set for the current class |
15918 | 1063 |
(current_klass->is_super() || !AllowNonVirtualCalls) && |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1064 |
// b) check if the class of the resolved_klass is a superclass |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1065 |
// (not supertype in order to exclude interface classes) of the current class. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1066 |
// This check is not performed for super.invoke for interface methods |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1067 |
// in super interfaces. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1068 |
current_klass->is_subclass_of(resolved_klass()) && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1069 |
current_klass() != resolved_klass() && |
1 | 1070 |
// c) check if the method is not <init> |
1071 |
resolved_method->name() != vmSymbols::object_initializer_name()) { |
|
1072 |
// Lookup super method |
|
1073 |
KlassHandle super_klass(THREAD, current_klass->super()); |
|
31019 | 1074 |
sel_method = lookup_instance_method_in_klasses(super_klass, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1075 |
resolved_method->name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1076 |
resolved_method->signature(), CHECK); |
1 | 1077 |
// check if found |
1078 |
if (sel_method.is_null()) { |
|
1079 |
ResourceMark rm(THREAD); |
|
1080 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1081 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1082 |
resolved_method->name(), |
1083 |
resolved_method->signature())); |
|
1084 |
} |
|
1085 |
} |
|
1086 |
} |
|
1087 |
||
1088 |
// check if not static |
|
1089 |
if (sel_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1090 |
ResourceMark rm(THREAD); |
1 | 1091 |
char buf[200]; |
14488 | 1092 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1093 |
resolved_method->name(), |
1094 |
resolved_method->signature())); |
|
1095 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
1096 |
} |
|
1097 |
||
1098 |
// check if abstract |
|
1099 |
if (sel_method->is_abstract()) { |
|
1100 |
ResourceMark rm(THREAD); |
|
1101 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1102 |
Method::name_and_sig_as_C_string(resolved_klass(), |
31019 | 1103 |
sel_method->name(), |
1104 |
sel_method->signature())); |
|
1 | 1105 |
} |
1106 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1107 |
if (TraceItables && Verbose) { |
31019 | 1108 |
trace_method_resolution("invokespecial selected method: resolved-class:", |
1109 |
resolved_klass, resolved_klass, sel_method); |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1110 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1111 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1112 |
|
1 | 1113 |
// setup result |
1114 |
result.set_static(resolved_klass, sel_method, CHECK); |
|
1115 |
} |
|
1116 |
||
31019 | 1117 |
void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, |
1118 |
const LinkInfo& link_info, |
|
1119 |
bool check_null_and_abstract, TRAPS) { |
|
1120 |
methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK); |
|
1121 |
runtime_resolve_virtual_method(result, resolved_method, |
|
1122 |
link_info.resolved_klass(), |
|
1123 |
recv, receiver_klass, |
|
1124 |
check_null_and_abstract, CHECK); |
|
1 | 1125 |
} |
1126 |
||
1127 |
// throws linktime exceptions |
|
31019 | 1128 |
methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_info, |
1129 |
TRAPS) { |
|
1 | 1130 |
// normal method resolution |
31019 | 1131 |
methodHandle resolved_method = resolve_method(link_info, /*require_methodref*/true, CHECK_NULL); |
1 | 1132 |
|
1133 |
assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); |
|
1134 |
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); |
|
1135 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1136 |
// check if private interface method |
31019 | 1137 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
1138 |
KlassHandle current_klass = link_info.current_klass(); |
|
1139 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1140 |
if (resolved_klass->is_interface() && resolved_method->is_private()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1141 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1142 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1143 |
jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1144 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1145 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1146 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1147 |
(current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); |
31019 | 1148 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1149 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1150 |
|
1 | 1151 |
// check if not static |
1152 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1153 |
ResourceMark rm(THREAD); |
1 | 1154 |
char buf[200]; |
14488 | 1155 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1156 |
resolved_method->name(), |
1157 |
resolved_method->signature())); |
|
31019 | 1158 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 1159 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1160 |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1161 |
if (PrintVtables && Verbose) { |
31019 | 1162 |
trace_method_resolution("invokevirtual resolved method: caller-class:", |
1163 |
current_klass, resolved_klass, resolved_method); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1164 |
tty->cr(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1165 |
} |
31019 | 1166 |
|
1167 |
return resolved_method; |
|
1 | 1168 |
} |
1169 |
||
1170 |
// throws runtime exceptions |
|
1171 |
void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, |
|
31019 | 1172 |
const methodHandle& resolved_method, |
1 | 1173 |
KlassHandle resolved_klass, |
1174 |
Handle recv, |
|
1175 |
KlassHandle recv_klass, |
|
1176 |
bool check_null_and_abstract, |
|
1177 |
TRAPS) { |
|
1178 |
||
1179 |
// setup default return values |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1180 |
int vtable_index = Method::invalid_vtable_index; |
1 | 1181 |
methodHandle selected_method; |
1182 |
||
1183 |
assert(recv.is_null() || recv->is_oop(), "receiver is not an oop"); |
|
1184 |
||
1185 |
// runtime method resolution |
|
1186 |
if (check_null_and_abstract && recv.is_null()) { // check if receiver exists |
|
1187 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
1188 |
} |
|
1189 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1190 |
// Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s |
1 | 1191 |
// has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since |
1192 |
// a missing receiver might result in a bogus lookup. |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
1193 |
assert(resolved_method->method_holder()->is_linked(), "must be linked"); |
1 | 1194 |
|
1195 |
// do lookup based on receiver klass using the vtable index |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
1196 |
if (resolved_method->method_holder()->is_interface()) { // default or miranda method |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1197 |
vtable_index = vtable_index_of_interface_method(resolved_klass, |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1198 |
resolved_method); |
1 | 1199 |
assert(vtable_index >= 0 , "we should have valid vtable index at this point"); |
1200 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1201 |
InstanceKlass* inst = InstanceKlass::cast(recv_klass()); |
1 | 1202 |
selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index)); |
1203 |
} else { |
|
1204 |
// at this point we are sure that resolved_method is virtual and not |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
1205 |
// a default or miranda method; therefore, it must have a valid vtable index. |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1206 |
assert(!resolved_method->has_itable_index(), ""); |
1 | 1207 |
vtable_index = resolved_method->vtable_index(); |
1208 |
// We could get a negative vtable_index for final methods, |
|
1209 |
// because as an optimization they are they are never put in the vtable, |
|
1210 |
// unless they override an existing method. |
|
1211 |
// If we do get a negative, it means the resolved method is the the selected |
|
1212 |
// method, and it can never be changed by an override. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1213 |
if (vtable_index == Method::nonvirtual_vtable_index) { |
1 | 1214 |
assert(resolved_method->can_be_statically_bound(), "cannot override this method"); |
1215 |
selected_method = resolved_method; |
|
1216 |
} else { |
|
1217 |
// recv_klass might be an arrayKlassOop but all vtables start at |
|
1218 |
// the same place. The cast is to avoid virtual call and assertion. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1219 |
InstanceKlass* inst = (InstanceKlass*)recv_klass(); |
1 | 1220 |
selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index)); |
1221 |
} |
|
1222 |
} |
|
1223 |
||
1224 |
// check if method exists |
|
1225 |
if (selected_method.is_null()) { |
|
1226 |
ResourceMark rm(THREAD); |
|
1227 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1228 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1229 |
resolved_method->name(), |
1230 |
resolved_method->signature())); |
|
1231 |
} |
|
1232 |
||
1233 |
// check if abstract |
|
1234 |
if (check_null_and_abstract && selected_method->is_abstract()) { |
|
1235 |
ResourceMark rm(THREAD); |
|
1236 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1237 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1238 |
selected_method->name(), |
1239 |
selected_method->signature())); |
|
1240 |
} |
|
1241 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1242 |
if (PrintVtables && Verbose) { |
31019 | 1243 |
trace_method_resolution("invokevirtual selected method: receiver-class:", |
1244 |
recv_klass, resolved_klass, selected_method); |
|
1245 |
tty->print_cr("vtable_index:%d", vtable_index); |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1246 |
} |
1 | 1247 |
// setup result |
1248 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); |
|
1249 |
} |
|
1250 |
||
31019 | 1251 |
void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, |
1252 |
const LinkInfo& link_info, |
|
1253 |
bool check_null_and_abstract, TRAPS) { |
|
1254 |
// throws linktime exceptions |
|
1255 |
methodHandle resolved_method = linktime_resolve_interface_method(link_info, CHECK); |
|
1256 |
runtime_resolve_interface_method(result, resolved_method,link_info.resolved_klass(), |
|
1257 |
recv, recv_klass, check_null_and_abstract, CHECK); |
|
1 | 1258 |
} |
1259 |
||
31019 | 1260 |
methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info, |
1261 |
TRAPS) { |
|
1 | 1262 |
// normal interface method resolution |
31019 | 1263 |
methodHandle resolved_method = resolve_interface_method(link_info, true, CHECK_NULL); |
1 | 1264 |
assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); |
1265 |
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); |
|
31019 | 1266 |
|
1267 |
return resolved_method; |
|
1 | 1268 |
} |
1269 |
||
1270 |
// throws runtime exceptions |
|
31019 | 1271 |
void LinkResolver::runtime_resolve_interface_method(CallInfo& result, |
1272 |
const methodHandle& resolved_method, |
|
1273 |
KlassHandle resolved_klass, |
|
1274 |
Handle recv, |
|
1275 |
KlassHandle recv_klass, |
|
1276 |
bool check_null_and_abstract, TRAPS) { |
|
1 | 1277 |
// check if receiver exists |
1278 |
if (check_null_and_abstract && recv.is_null()) { |
|
1279 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
1280 |
} |
|
1281 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1282 |
// check if private interface method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1283 |
if (resolved_klass->is_interface() && resolved_method->is_private()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1284 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1285 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1286 |
jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1287 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1288 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1289 |
resolved_method->signature())); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1290 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1291 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1292 |
|
1 | 1293 |
// check if receiver klass implements the resolved interface |
1294 |
if (!recv_klass->is_subtype_of(resolved_klass())) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1295 |
ResourceMark rm(THREAD); |
1 | 1296 |
char buf[200]; |
1297 |
jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", |
|
14488 | 1298 |
recv_klass()->external_name(), |
1299 |
resolved_klass()->external_name()); |
|
1 | 1300 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1301 |
} |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1302 |
|
1 | 1303 |
// do lookup based on receiver klass |
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1304 |
// This search must match the linktime preparation search for itable initialization |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1305 |
// to correctly enforce loader constraints for interface method inheritance |
31019 | 1306 |
methodHandle sel_method = lookup_instance_method_in_klasses(recv_klass, |
1307 |
resolved_method->name(), |
|
1308 |
resolved_method->signature(), CHECK); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1309 |
if (sel_method.is_null() && !check_null_and_abstract) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1310 |
// In theory this is a harmless placeholder value, but |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1311 |
// in practice leaving in null affects the nsk default method tests. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1312 |
// This needs further study. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1313 |
sel_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1314 |
} |
1 | 1315 |
// check if method exists |
1316 |
if (sel_method.is_null()) { |
|
1317 |
ResourceMark rm(THREAD); |
|
1318 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
31019 | 1319 |
Method::name_and_sig_as_C_string(recv_klass(), |
1320 |
resolved_method->name(), |
|
1321 |
resolved_method->signature())); |
|
1 | 1322 |
} |
17024
49cbeca23983
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
16691
diff
changeset
|
1323 |
// check access |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1324 |
// Throw Illegal Access Error if sel_method is not public. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1325 |
if (!sel_method->is_public()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1326 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1327 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1328 |
Method::name_and_sig_as_C_string(recv_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1329 |
sel_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1330 |
sel_method->signature())); |
17024
49cbeca23983
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
16691
diff
changeset
|
1331 |
} |
1 | 1332 |
// check if abstract |
1333 |
if (check_null_and_abstract && sel_method->is_abstract()) { |
|
1334 |
ResourceMark rm(THREAD); |
|
1335 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1336 |
Method::name_and_sig_as_C_string(recv_klass(), |
1 | 1337 |
sel_method->name(), |
1338 |
sel_method->signature())); |
|
1339 |
} |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1340 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1341 |
if (TraceItables && Verbose) { |
31019 | 1342 |
trace_method_resolution("invokeinterface selected method: receiver-class", |
1343 |
recv_klass, resolved_klass, sel_method); |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1344 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1345 |
} |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1346 |
// setup result |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1347 |
if (!resolved_method->has_itable_index()) { |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1348 |
int vtable_index = resolved_method->vtable_index(); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1349 |
assert(vtable_index == sel_method->vtable_index(), "sanity check"); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1350 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1351 |
} else { |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1352 |
int itable_index = resolved_method()->itable_index(); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1353 |
result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1354 |
} |
1 | 1355 |
} |
1356 |
||
1357 |
||
1358 |
methodHandle LinkResolver::linktime_resolve_interface_method_or_null( |
|
31019 | 1359 |
const LinkInfo& link_info) { |
1 | 1360 |
EXCEPTION_MARK; |
31019 | 1361 |
methodHandle method_result = linktime_resolve_interface_method(link_info, THREAD); |
1 | 1362 |
if (HAS_PENDING_EXCEPTION) { |
1363 |
CLEAR_PENDING_EXCEPTION; |
|
1364 |
return methodHandle(); |
|
1365 |
} else { |
|
1366 |
return method_result; |
|
1367 |
} |
|
1368 |
} |
|
1369 |
||
1370 |
methodHandle LinkResolver::linktime_resolve_virtual_method_or_null( |
|
31019 | 1371 |
const LinkInfo& link_info) { |
1 | 1372 |
EXCEPTION_MARK; |
31019 | 1373 |
methodHandle method_result = linktime_resolve_virtual_method(link_info, THREAD); |
1 | 1374 |
if (HAS_PENDING_EXCEPTION) { |
1375 |
CLEAR_PENDING_EXCEPTION; |
|
1376 |
return methodHandle(); |
|
1377 |
} else { |
|
1378 |
return method_result; |
|
1379 |
} |
|
1380 |
} |
|
1381 |
||
1382 |
methodHandle LinkResolver::resolve_virtual_call_or_null( |
|
1383 |
KlassHandle receiver_klass, |
|
31019 | 1384 |
const LinkInfo& link_info) { |
1 | 1385 |
EXCEPTION_MARK; |
1386 |
CallInfo info; |
|
31019 | 1387 |
resolve_virtual_call(info, Handle(), receiver_klass, link_info, false, THREAD); |
1 | 1388 |
if (HAS_PENDING_EXCEPTION) { |
1389 |
CLEAR_PENDING_EXCEPTION; |
|
1390 |
return methodHandle(); |
|
1391 |
} |
|
1392 |
return info.selected_method(); |
|
1393 |
} |
|
1394 |
||
1395 |
methodHandle LinkResolver::resolve_interface_call_or_null( |
|
1396 |
KlassHandle receiver_klass, |
|
31019 | 1397 |
const LinkInfo& link_info) { |
1 | 1398 |
EXCEPTION_MARK; |
1399 |
CallInfo info; |
|
31019 | 1400 |
resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD); |
1 | 1401 |
if (HAS_PENDING_EXCEPTION) { |
1402 |
CLEAR_PENDING_EXCEPTION; |
|
1403 |
return methodHandle(); |
|
1404 |
} |
|
1405 |
return info.selected_method(); |
|
1406 |
} |
|
1407 |
||
31019 | 1408 |
int LinkResolver::resolve_virtual_vtable_index(KlassHandle receiver_klass, |
1409 |
const LinkInfo& link_info) { |
|
1 | 1410 |
EXCEPTION_MARK; |
1411 |
CallInfo info; |
|
31019 | 1412 |
resolve_virtual_call(info, Handle(), receiver_klass, link_info, |
1413 |
/*check_null_or_abstract*/false, THREAD); |
|
1 | 1414 |
if (HAS_PENDING_EXCEPTION) { |
1415 |
CLEAR_PENDING_EXCEPTION; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1416 |
return Method::invalid_vtable_index; |
1 | 1417 |
} |
1418 |
return info.vtable_index(); |
|
1419 |
} |
|
1420 |
||
31019 | 1421 |
methodHandle LinkResolver::resolve_static_call_or_null(const LinkInfo& link_info) { |
1 | 1422 |
EXCEPTION_MARK; |
1423 |
CallInfo info; |
|
31019 | 1424 |
resolve_static_call(info, link_info, /*initialize_class*/false, THREAD); |
1 | 1425 |
if (HAS_PENDING_EXCEPTION) { |
1426 |
CLEAR_PENDING_EXCEPTION; |
|
1427 |
return methodHandle(); |
|
1428 |
} |
|
1429 |
return info.selected_method(); |
|
1430 |
} |
|
1431 |
||
31019 | 1432 |
methodHandle LinkResolver::resolve_special_call_or_null(const LinkInfo& link_info) { |
1 | 1433 |
EXCEPTION_MARK; |
1434 |
CallInfo info; |
|
31019 | 1435 |
resolve_special_call(info, link_info, THREAD); |
1 | 1436 |
if (HAS_PENDING_EXCEPTION) { |
1437 |
CLEAR_PENDING_EXCEPTION; |
|
1438 |
return methodHandle(); |
|
1439 |
} |
|
1440 |
return info.selected_method(); |
|
1441 |
} |
|
1442 |
||
1443 |
||
1444 |
||
1445 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1446 |
// ConstantPool entries |
|
1447 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1448 |
void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { |
1 | 1449 |
switch (byte) { |
1450 |
case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break; |
|
1451 |
case Bytecodes::_invokespecial : resolve_invokespecial (result, pool, index, CHECK); break; |
|
1452 |
case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break; |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1453 |
case Bytecodes::_invokehandle : resolve_invokehandle (result, pool, index, CHECK); break; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1454 |
case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; |
1 | 1455 |
case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; |
1456 |
} |
|
1457 |
return; |
|
1458 |
} |
|
1459 |
||
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1460 |
void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1461 |
const methodHandle& attached_method, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1462 |
Bytecodes::Code byte, TRAPS) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1463 |
KlassHandle defc = attached_method->method_holder(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1464 |
Symbol* name = attached_method->name(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1465 |
Symbol* type = attached_method->signature(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1466 |
LinkInfo link_info(defc, name, type, KlassHandle(), /*check_access=*/false); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1467 |
switch(byte) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1468 |
case Bytecodes::_invokevirtual: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1469 |
resolve_virtual_call(result, recv, recv->klass(), link_info, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1470 |
/*check_null_and_abstract=*/true, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1471 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1472 |
case Bytecodes::_invokeinterface: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1473 |
resolve_interface_call(result, recv, recv->klass(), link_info, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1474 |
/*check_null_and_abstract=*/true, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1475 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1476 |
case Bytecodes::_invokestatic: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1477 |
resolve_static_call(result, link_info, /*initialize_class=*/false, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1478 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1479 |
case Bytecodes::_invokespecial: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1480 |
resolve_special_call(result, link_info, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1481 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1482 |
default: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1483 |
fatal("bad call: %s", Bytecodes::name(byte)); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1484 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1485 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1486 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1487 |
void LinkResolver::resolve_invokestatic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1488 |
LinkInfo link_info(pool, index, CHECK); |
1489 |
resolve_static_call(result, link_info, /*initialize_class*/true, CHECK); |
|
1 | 1490 |
} |
1491 |
||
1492 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1493 |
void LinkResolver::resolve_invokespecial(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1494 |
LinkInfo link_info(pool, index, CHECK); |
1495 |
resolve_special_call(result, link_info, CHECK); |
|
1 | 1496 |
} |
1497 |
||
1498 |
||
1499 |
void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv, |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1500 |
const constantPoolHandle& pool, int index, |
1 | 1501 |
TRAPS) { |
1502 |
||
31019 | 1503 |
LinkInfo link_info(pool, index, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1504 |
KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
31019 | 1505 |
resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK); |
1 | 1506 |
} |
1507 |
||
1508 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1509 |
void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1510 |
LinkInfo link_info(pool, index, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1511 |
KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
31019 | 1512 |
resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK); |
1 | 1513 |
} |
1514 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1515 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1516 |
void LinkResolver::resolve_invokehandle(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1517 |
// This guy is reached from InterpreterRuntime::resolve_invokehandle. |
31019 | 1518 |
LinkInfo link_info(pool, index, CHECK); |
16691 | 1519 |
if (TraceMethodHandles) { |
1520 |
ResourceMark rm(THREAD); |
|
31019 | 1521 |
tty->print_cr("resolve_invokehandle %s %s", link_info.name()->as_C_string(), |
1522 |
link_info.signature()->as_C_string()); |
|
16691 | 1523 |
} |
31019 | 1524 |
resolve_handle_call(result, link_info, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1525 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1526 |
|
31019 | 1527 |
void LinkResolver::resolve_handle_call(CallInfo& result, |
1528 |
const LinkInfo& link_info, |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1529 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1530 |
// JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar |
31019 | 1531 |
assert(link_info.resolved_klass()() == SystemDictionary::MethodHandle_klass(), ""); |
1532 |
assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1533 |
Handle resolved_appendix; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1534 |
Handle resolved_method_type; |
31019 | 1535 |
methodHandle resolved_method = lookup_polymorphic_method(link_info, |
1536 |
&resolved_appendix, &resolved_method_type, CHECK); |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1537 |
result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1538 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1539 |
|
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1540 |
static void wrap_invokedynamic_exception(TRAPS) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1541 |
if (HAS_PENDING_EXCEPTION) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1542 |
if (TraceMethodHandles) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1543 |
tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1544 |
PENDING_EXCEPTION->print(); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1545 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1546 |
if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1547 |
// throw these guys, since they are already wrapped |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1548 |
return; |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1549 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1550 |
if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1551 |
// intercept only LinkageErrors which might have failed to wrap |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1552 |
return; |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1553 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1554 |
// See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1555 |
Handle nested_exception(THREAD, PENDING_EXCEPTION); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1556 |
CLEAR_PENDING_EXCEPTION; |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1557 |
THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1558 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1559 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1560 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1561 |
void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1562 |
Symbol* method_name = pool->name_ref_at(index); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1563 |
Symbol* method_signature = pool->signature_ref_at(index); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1564 |
KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1565 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1566 |
// Resolve the bootstrap specifier (BSM + optional arguments). |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1567 |
Handle bootstrap_specifier; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1568 |
// Check if CallSite has been bound already: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1569 |
ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1570 |
if (cpce->is_f1_null()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1571 |
int pool_index = cpce->constant_pool_index(); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1572 |
oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1573 |
wrap_invokedynamic_exception(CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1574 |
assert(bsm_info != NULL, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1575 |
// FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1576 |
bootstrap_specifier = Handle(THREAD, bsm_info); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1577 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1578 |
if (!cpce->is_f1_null()) { |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1579 |
methodHandle method( THREAD, cpce->f1_as_method()); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1580 |
Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1581 |
Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1582 |
result.set_handle(method, appendix, method_type, THREAD); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1583 |
wrap_invokedynamic_exception(CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1584 |
return; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1585 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1586 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1587 |
if (TraceMethodHandles) { |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1588 |
ResourceMark rm(THREAD); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1589 |
tty->print_cr("resolve_invokedynamic #%d %s %s", |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1590 |
ConstantPool::decode_invokedynamic_index(index), |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1591 |
method_name->as_C_string(), method_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1592 |
tty->print(" BSM info: "); bootstrap_specifier->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1593 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1594 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1595 |
resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1596 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1597 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1598 |
void LinkResolver::resolve_dynamic_call(CallInfo& result, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1599 |
Handle bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1600 |
Symbol* method_name, Symbol* method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1601 |
KlassHandle current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1602 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1603 |
// JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1604 |
// The appendix argument is likely to be a freshly-created CallSite. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1605 |
Handle resolved_appendix; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1606 |
Handle resolved_method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1607 |
methodHandle resolved_method = |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1608 |
SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1609 |
bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1610 |
method_name, method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1611 |
&resolved_appendix, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1612 |
&resolved_method_type, |
13732
a9865f5514fc
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
13728
diff
changeset
|
1613 |
THREAD); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1614 |
wrap_invokedynamic_exception(CHECK); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1615 |
result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1616 |
wrap_invokedynamic_exception(CHECK); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1617 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1618 |
|
1 | 1619 |
#ifndef PRODUCT |
31019 | 1620 |
void LinkResolver::trace_method_resolution(const char* prefix, |
1621 |
KlassHandle klass, |
|
1622 |
KlassHandle resolved_klass, |
|
1623 |
const methodHandle& method) { |
|
1 | 1624 |
ResourceMark rm; |
31019 | 1625 |
tty->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
1626 |
prefix, |
|
1627 |
(klass.is_null() ? "<NULL>" : klass->internal_name()), |
|
1628 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
|
1629 |
Method::name_and_sig_as_C_string(resolved_klass(), |
|
1630 |
method->name(), |
|
1631 |
method->signature()), |
|
1632 |
method->method_holder()->internal_name() |
|
1633 |
); |
|
1634 |
method->access_flags().print_on(tty); |
|
1635 |
if (method->is_default_method()) { |
|
1636 |
tty->print("default "); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1637 |
} |
31019 | 1638 |
if (method->is_overpass()) { |
1639 |
tty->print("overpass "); |
|
1640 |
} |
|
1 | 1641 |
} |
31019 | 1642 |
#endif // PRODUCT |