author | lfoltan |
Mon, 16 Jul 2018 11:34:17 -0400 | |
changeset 51097 | bef02342d179 |
parent 50944 | 8cc36fac7f3d |
child 51444 | 3e5d28e6de32 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48826
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, 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" |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47684
diff
changeset
|
26 |
#include "jvm.h" |
14385 | 27 |
#include "classfile/defaultMethods.hpp" |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
28 |
#include "classfile/javaClasses.hpp" |
47684
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
29 |
#include "classfile/resolutionErrors.hpp" |
34666 | 30 |
#include "classfile/symbolTable.hpp" |
7397 | 31 |
#include "classfile/systemDictionary.hpp" |
32 |
#include "classfile/vmSymbols.hpp" |
|
33 |
#include "compiler/compileBroker.hpp" |
|
30764 | 34 |
#include "gc/shared/collectedHeap.inline.hpp" |
7397 | 35 |
#include "interpreter/bytecode.hpp" |
36 |
#include "interpreter/interpreterRuntime.hpp" |
|
37 |
#include "interpreter/linkResolver.hpp" |
|
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
38 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
39 |
#include "logging/logStream.hpp" |
7397 | 40 |
#include "memory/resourceArea.hpp" |
49359
59f6547e151f
8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents:
49340
diff
changeset
|
41 |
#include "memory/universe.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48826
diff
changeset
|
42 |
#include "oops/cpCache.inline.hpp" |
7397 | 43 |
#include "oops/instanceKlass.hpp" |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
44 |
#include "oops/method.hpp" |
48826 | 45 |
#include "oops/objArrayKlass.hpp" |
7397 | 46 |
#include "oops/objArrayOop.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28738
diff
changeset
|
47 |
#include "oops/oop.inline.hpp" |
7397 | 48 |
#include "prims/methodHandles.hpp" |
49 |
#include "prims/nativeLookup.hpp" |
|
50 |
#include "runtime/compilationPolicy.hpp" |
|
51 |
#include "runtime/fieldDescriptor.hpp" |
|
52 |
#include "runtime/frame.inline.hpp" |
|
53 |
#include "runtime/handles.inline.hpp" |
|
54 |
#include "runtime/reflection.hpp" |
|
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
55 |
#include "runtime/safepointVerifiers.hpp" |
7397 | 56 |
#include "runtime/signature.hpp" |
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14488
diff
changeset
|
57 |
#include "runtime/thread.inline.hpp" |
7397 | 58 |
#include "runtime/vmThread.hpp" |
1 | 59 |
|
60 |
//------------------------------------------------------------------------------------------------------------------------ |
|
61 |
// Implementation of CallInfo |
|
62 |
||
63 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
64 |
void CallInfo::set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
65 |
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
|
66 |
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
1 | 67 |
} |
68 |
||
69 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
70 |
void CallInfo::set_interface(Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
71 |
Klass* selected_klass, |
31019 | 72 |
const methodHandle& resolved_method, |
73 |
const methodHandle& selected_method, |
|
74 |
int itable_index, TRAPS) { |
|
1 | 75 |
// This is only called for interface methods. If the resolved_method |
76 |
// comes from java/lang/Object, it can be the subject of a virtual call, so |
|
77 |
// 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
|
78 |
// 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
|
79 |
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
|
80 |
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
|
81 |
set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); |
1 | 82 |
} |
83 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
84 |
void CallInfo::set_virtual(Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
85 |
Klass* selected_klass, |
31019 | 86 |
const methodHandle& resolved_method, |
87 |
const methodHandle& selected_method, |
|
88 |
int vtable_index, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
1 | 94 |
} |
95 |
||
31019 | 96 |
void CallInfo::set_handle(const methodHandle& resolved_method, |
97 |
Handle resolved_appendix, |
|
98 |
Handle resolved_method_type, TRAPS) { |
|
36819 | 99 |
set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); |
100 |
} |
|
101 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
102 |
void CallInfo::set_handle(Klass* resolved_klass, |
36819 | 103 |
const methodHandle& resolved_method, |
104 |
Handle resolved_appendix, |
|
105 |
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
|
106 |
if (resolved_method.is_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
107 |
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
|
108 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
"linkMethod must return one of these"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
_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
|
116 |
_resolved_method_type = resolved_method_type; |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
117 |
} |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
118 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
119 |
void CallInfo::set_common(Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
120 |
Klass* selected_klass, |
31019 | 121 |
const methodHandle& resolved_method, |
122 |
const methodHandle& selected_method, |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
123 |
CallKind kind, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
124 |
int index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
125 |
TRAPS) { |
1 | 126 |
assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); |
127 |
_resolved_klass = resolved_klass; |
|
128 |
_selected_klass = selected_klass; |
|
129 |
_resolved_method = resolved_method; |
|
130 |
_selected_method = selected_method; |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
131 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
132 |
_call_index = index; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
133 |
_resolved_appendix = Handle(); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
134 |
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
|
135 |
|
38139
cf6f5c1b7205
8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents:
38034
diff
changeset
|
136 |
CompilationPolicy::compile_if_required(selected_method, THREAD); |
1 | 137 |
} |
138 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
139 |
// utility query for unreflecting a method |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
140 |
CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS) { |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
141 |
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
|
142 |
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
|
143 |
resolved_klass = resolved_method_holder; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
144 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
145 |
_resolved_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
146 |
_selected_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
147 |
_resolved_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
148 |
_selected_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
149 |
// classify: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
150 |
CallKind kind = CallInfo::unknown_kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
151 |
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
|
152 |
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
|
153 |
kind = CallInfo::direct_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
154 |
} 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
|
155 |
// 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
|
156 |
kind = CallInfo::vtable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
157 |
} else if (!resolved_klass->is_interface()) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
158 |
// A default or miranda method. Compute the vtable index. |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
159 |
index = LinkResolver::vtable_index_of_interface_method(resolved_klass, |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
160 |
resolved_method); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
161 |
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
|
162 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
163 |
kind = CallInfo::vtable_call; |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
164 |
} else if (resolved_method->has_vtable_index()) { |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
165 |
// 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
|
166 |
|
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
167 |
#ifdef ASSERT |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
168 |
// Ensure that this is really the case. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
169 |
Klass* object_klass = SystemDictionary::Object_klass(); |
46408
70aab0c2ea8b
8178350: klassVtable and klassItable should be ValueObj
iklam
parents:
46329
diff
changeset
|
170 |
Method * object_resolved_method = object_klass->vtable().method_at(index); |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
171 |
assert(object_resolved_method->name() == resolved_method->name(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
172 |
"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
|
173 |
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
|
174 |
assert(object_resolved_method->signature() == resolved_method->signature(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
175 |
"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
|
176 |
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
|
177 |
#endif // ASSERT |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
178 |
|
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
179 |
kind = CallInfo::vtable_call; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
180 |
} else { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
181 |
// A regular interface call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
182 |
kind = CallInfo::itable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
183 |
index = resolved_method->itable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
184 |
} |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
185 |
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
|
186 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
187 |
_call_index = index; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
188 |
_resolved_appendix = Handle(); |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
189 |
// Find or create a ResolvedMethod instance for this Method* |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
190 |
set_resolved_method_name(CHECK); |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
191 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
192 |
DEBUG_ONLY(verify()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
193 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
194 |
|
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
195 |
void CallInfo::set_resolved_method_name(TRAPS) { |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
196 |
Method* m = _resolved_method(); |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
197 |
assert(m != NULL, "Should already have a Method*"); |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
198 |
oop rmethod_name = java_lang_invoke_ResolvedMethodName::find_resolved_method(m, CHECK); |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
199 |
_resolved_method_name = Handle(THREAD, rmethod_name); |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
200 |
} |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
201 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
202 |
#ifdef ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
203 |
void CallInfo::verify() { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
204 |
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
|
205 |
case CallInfo::direct_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
206 |
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
|
207 |
// 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
|
208 |
case CallInfo::vtable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
209 |
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
|
210 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
211 |
case CallInfo::itable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
212 |
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
|
213 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
214 |
case CallInfo::unknown_kind: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
215 |
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
|
216 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
217 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
218 |
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
|
219 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
220 |
} |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
221 |
#endif // ASSERT |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
222 |
|
31019 | 223 |
#ifndef PRODUCT |
224 |
void CallInfo::print() { |
|
225 |
ResourceMark rm; |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
226 |
const char* kindstr; |
31019 | 227 |
switch (_call_kind) { |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
228 |
case direct_call: kindstr = "direct"; break; |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
229 |
case vtable_call: kindstr = "vtable"; break; |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
230 |
case itable_call: kindstr = "itable"; break; |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
231 |
default : kindstr = "unknown"; break; |
31019 | 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 |
|
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
241 |
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS) { |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
242 |
// resolve klass |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
243 |
_resolved_klass = pool->klass_ref_at(index, CHECK); |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
244 |
|
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
245 |
// Get name, signature, and static klass |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
246 |
_name = pool->name_ref_at(index); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
247 |
_signature = pool->signature_ref_at(index); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
248 |
_tag = pool->tag_ref_at(index); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
249 |
_current_klass = pool->pool_holder(); |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
250 |
_current_method = current_method; |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
251 |
|
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
252 |
// Coming from the constant pool always checks access |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
253 |
_check_access = true; |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
254 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
255 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
256 |
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 257 |
// resolve klass |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
258 |
_resolved_klass = pool->klass_ref_at(index, CHECK); |
31019 | 259 |
|
260 |
// Get name, signature, and static klass |
|
261 |
_name = pool->name_ref_at(index); |
|
262 |
_signature = pool->signature_ref_at(index); |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
263 |
_tag = pool->tag_ref_at(index); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
264 |
_current_klass = pool->pool_holder(); |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
265 |
_current_method = methodHandle(); |
31019 | 266 |
|
267 |
// Coming from the constant pool always checks access |
|
268 |
_check_access = true; |
|
269 |
} |
|
270 |
||
271 |
char* LinkInfo::method_string() const { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
272 |
return Method::name_and_sig_as_C_string(_resolved_klass, _name, _signature); |
31019 | 273 |
} |
274 |
||
275 |
#ifndef PRODUCT |
|
276 |
void LinkInfo::print() { |
|
277 |
ResourceMark rm; |
|
278 |
tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s", |
|
279 |
_resolved_klass->name()->as_C_string(), |
|
280 |
_name->as_C_string(), |
|
281 |
_signature->as_C_string(), |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
282 |
_current_klass == NULL ? "(none)" : _current_klass->name()->as_C_string(), |
31019 | 283 |
_check_access ? "true" : "false"); |
284 |
} |
|
285 |
#endif // PRODUCT |
|
1 | 286 |
//------------------------------------------------------------------------------------------------------------------------ |
287 |
// Klass resolution |
|
288 |
||
48826 | 289 |
void LinkResolver::check_klass_accessability(Klass* ref_klass, Klass* sel_klass, |
290 |
bool fold_type_to_class, TRAPS) { |
|
291 |
Klass* base_klass = sel_klass; |
|
292 |
if (fold_type_to_class) { |
|
293 |
if (sel_klass->is_objArray_klass()) { |
|
294 |
base_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass(); |
|
295 |
} |
|
296 |
// The element type could be a typeArray - we only need the access |
|
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
297 |
// check if it is a reference to another class. |
48826 | 298 |
if (!base_klass->is_instance_klass()) { |
299 |
return; // no relevant check to do |
|
300 |
} |
|
301 |
} |
|
36508 | 302 |
Reflection::VerifyClassAccessResults vca_result = |
48826 | 303 |
Reflection::verify_class_access(ref_klass, InstanceKlass::cast(base_klass), true); |
36508 | 304 |
if (vca_result != Reflection::ACCESS_OK) { |
1 | 305 |
ResourceMark rm(THREAD); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
306 |
char* msg = Reflection::verify_class_access_msg(ref_klass, |
48826 | 307 |
InstanceKlass::cast(base_klass), |
46262
83280d968b96
8174092: Remove array-related access checks from Reflection::verify_class_access()
hseigel
parents:
42074
diff
changeset
|
308 |
vca_result); |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
309 |
bool same_module = (base_klass->module() == ref_klass->module()); |
36508 | 310 |
if (msg == NULL) { |
311 |
Exceptions::fthrow( |
|
312 |
THREAD_AND_LOCATION, |
|
313 |
vmSymbols::java_lang_IllegalAccessError(), |
|
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
314 |
"failed to access class %s from class %s (%s%s%s)", |
48826 | 315 |
base_klass->external_name(), |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
316 |
ref_klass->external_name(), |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
317 |
(same_module) ? base_klass->joint_in_module_of_loader(ref_klass) : base_klass->class_in_module_of_loader(), |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
318 |
(same_module) ? "" : "; ", |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
319 |
(same_module) ? "" : ref_klass->class_in_module_of_loader()); |
36508 | 320 |
} else { |
321 |
// Use module specific message returned by verify_class_access_msg(). |
|
322 |
Exceptions::fthrow( |
|
323 |
THREAD_AND_LOCATION, |
|
324 |
vmSymbols::java_lang_IllegalAccessError(), |
|
325 |
"%s", msg); |
|
326 |
} |
|
1 | 327 |
} |
328 |
} |
|
329 |
||
330 |
//------------------------------------------------------------------------------------------------------------------------ |
|
331 |
// Method resolution |
|
332 |
// |
|
333 |
// According to JVM spec. $5.4.3c & $5.4.3d |
|
334 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
335 |
// Look up method in klasses, including static methods |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
336 |
// Then look up local default methods |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
337 |
Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
338 |
bool checkpolymorphism, |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
339 |
bool in_imethod_resolve) { |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
340 |
NoSafepointVerifier nsv; // Method* returned may not be reclaimed |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
341 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
342 |
Klass* klass = link_info.resolved_klass(); |
31019 | 343 |
Symbol* name = link_info.name(); |
344 |
Symbol* signature = link_info.signature(); |
|
345 |
||
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
346 |
// Ignore overpasses so statics can be found during resolution |
31019 | 347 |
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
|
348 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
349 |
if (klass->is_array_klass()) { |
27020 | 350 |
// Only consider klass and super klass for arrays |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
351 |
return result; |
27020 | 352 |
} |
353 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
354 |
InstanceKlass* ik = InstanceKlass::cast(klass); |
33602 | 355 |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
356 |
// 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
|
357 |
// 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
|
358 |
// 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
|
359 |
if (in_imethod_resolve && |
31019 | 360 |
result != NULL && |
33602 | 361 |
ik->is_interface() && |
31019 | 362 |
(result->is_static() || !result->is_public()) && |
363 |
result->method_holder() == SystemDictionary::Object_klass()) { |
|
364 |
result = NULL; |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
365 |
} |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
366 |
|
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
367 |
// 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
|
368 |
// current class if a method has not been found. |
31019 | 369 |
if (result == NULL) { |
33602 | 370 |
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
|
371 |
} |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
372 |
|
31019 | 373 |
if (result == NULL) { |
33602 | 374 |
Array<Method*>* default_methods = ik->default_methods(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
375 |
if (default_methods != NULL) { |
31019 | 376 |
result = InstanceKlass::find_method(default_methods, name, signature); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
377 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
378 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
379 |
|
31019 | 380 |
if (checkpolymorphism && result != NULL) { |
381 |
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
|
382 |
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
|
383 |
// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. |
31019 | 384 |
return NULL; |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
385 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
386 |
} |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
387 |
return result; |
1 | 388 |
} |
389 |
||
390 |
// returns first instance method |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
391 |
// Looks up method in classes, then looks up local default methods |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
392 |
methodHandle LinkResolver::lookup_instance_method_in_klasses(Klass* klass, |
31019 | 393 |
Symbol* name, |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
394 |
Symbol* signature, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
395 |
Klass::PrivateLookupMode private_mode, TRAPS) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
396 |
Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass, private_mode); |
31019 | 397 |
|
398 |
while (result != NULL && result->is_static() && result->method_holder()->super() != NULL) { |
|
399 |
Klass* super_klass = result->method_holder()->super(); |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
400 |
result = super_klass->uncached_lookup_method(name, signature, Klass::find_overpass, private_mode); |
1 | 401 |
} |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
402 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
403 |
if (klass->is_array_klass()) { |
27020 | 404 |
// Only consider klass and super klass for arrays |
31019 | 405 |
return methodHandle(THREAD, result); |
27020 | 406 |
} |
407 |
||
31019 | 408 |
if (result == NULL) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
409 |
Array<Method*>* default_methods = InstanceKlass::cast(klass)->default_methods(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
410 |
if (default_methods != NULL) { |
31019 | 411 |
result = InstanceKlass::find_method(default_methods, name, signature); |
412 |
assert(result == NULL || !result->is_static(), "static defaults not allowed"); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
413 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
414 |
} |
31019 | 415 |
return methodHandle(THREAD, result); |
1 | 416 |
} |
417 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
418 |
int LinkResolver::vtable_index_of_interface_method(Klass* klass, |
31019 | 419 |
const methodHandle& resolved_method) { |
1 | 420 |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
421 |
int vtable_index = Method::invalid_vtable_index; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
422 |
Symbol* name = resolved_method->name(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
423 |
Symbol* signature = resolved_method->signature(); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
424 |
InstanceKlass* ik = InstanceKlass::cast(klass); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
425 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
426 |
// First check in default method array |
33602 | 427 |
if (!resolved_method->is_abstract() && ik->default_methods() != NULL) { |
428 |
int index = InstanceKlass::find_method_index(ik->default_methods(), |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
429 |
name, signature, Klass::find_overpass, |
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
430 |
Klass::find_static, Klass::find_private); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
431 |
if (index >= 0 ) { |
33602 | 432 |
vtable_index = ik->default_vtable_indices()->at(index); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
433 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
434 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
435 |
if (vtable_index == Method::invalid_vtable_index) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
436 |
// get vtable_index for miranda methods |
46408
70aab0c2ea8b
8178350: klassVtable and klassItable should be ValueObj
iklam
parents:
46329
diff
changeset
|
437 |
klassVtable vt = ik->vtable(); |
70aab0c2ea8b
8178350: klassVtable and klassItable should be ValueObj
iklam
parents:
46329
diff
changeset
|
438 |
vtable_index = vt.index_of_miranda(name, signature); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
439 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
440 |
return vtable_index; |
1 | 441 |
} |
442 |
||
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
443 |
Method* LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
444 |
InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass()); |
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
445 |
|
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
446 |
// Specify 'true' in order to skip default methods when searching the |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
447 |
// interfaces. Function lookup_method_in_klasses() already looked for |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
448 |
// the method in the default methods table. |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
449 |
return ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), Klass::skip_defaults); |
1 | 450 |
} |
451 |
||
31019 | 452 |
methodHandle LinkResolver::lookup_polymorphic_method( |
453 |
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
|
454 |
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
|
455 |
Handle *method_type_result, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
456 |
TRAPS) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
457 |
Klass* klass = link_info.resolved_klass(); |
31019 | 458 |
Symbol* name = link_info.name(); |
459 |
Symbol* full_signature = link_info.signature(); |
|
460 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
461 |
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
|
462 |
if (TraceMethodHandles) { |
16691 | 463 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
464 |
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
|
465 |
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
|
466 |
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
|
467 |
} |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
468 |
if ((klass == SystemDictionary::MethodHandle_klass() || |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
469 |
klass == SystemDictionary::VarHandle_klass()) && |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
470 |
iid != vmIntrinsics::_none) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
471 |
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
|
472 |
// 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
|
473 |
// 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
|
474 |
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
|
475 |
TempNewSymbol basic_signature = |
31019 | 476 |
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
|
477 |
if (TraceMethodHandles) { |
16691 | 478 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
479 |
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
|
480 |
name->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
481 |
full_signature->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
482 |
basic_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
483 |
} |
31019 | 484 |
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
|
485 |
basic_signature, |
31019 | 486 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
487 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
488 |
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
|
489 |
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
|
490 |
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
|
491 |
if (TraceMethodHandles) { |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
492 |
ttyLocker ttyl; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
493 |
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
|
494 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
495 |
} |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
496 |
} |
31019 | 497 |
return result; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
498 |
} else if (iid == vmIntrinsics::_invokeGeneric |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32189
diff
changeset
|
499 |
&& THREAD->can_call_java() |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
500 |
&& appendix_result_or_null != NULL) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
501 |
// 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
|
502 |
// 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
|
503 |
if (!MethodHandles::enabled()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
504 |
// 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
|
505 |
Klass* natives = SystemDictionary::MethodHandleNatives_klass(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
509 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
510 |
true, |
31019 | 511 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
512 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
513 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
514 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
515 |
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
|
516 |
Handle method_type; |
31019 | 517 |
methodHandle result = SystemDictionary::find_method_handle_invoker( |
36819 | 518 |
klass, |
31019 | 519 |
name, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
520 |
full_signature, |
31019 | 521 |
link_info.current_klass(), |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
522 |
&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
|
523 |
&method_type, |
31019 | 524 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
525 |
if (TraceMethodHandles) { |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
526 |
ttyLocker ttyl; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
527 |
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
|
528 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
529 |
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
|
530 |
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
|
531 |
else appendix->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
532 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
533 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
534 |
#ifdef ASSERT |
16691 | 535 |
ResourceMark rm(THREAD); |
536 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
537 |
TempNewSymbol basic_signature = |
31019 | 538 |
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
|
539 |
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
|
540 |
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
|
541 |
// +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
|
542 |
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
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
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
|
547 |
result->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
548 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
549 |
assert(actual_size_of_params == expected_size_of_params, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
550 |
"%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
|
551 |
#endif //ASSERT |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
552 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
553 |
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
|
554 |
(*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
|
555 |
(*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
|
556 |
} |
31019 | 557 |
return result; |
2534 | 558 |
} |
559 |
} |
|
31019 | 560 |
return NULL; |
2534 | 561 |
} |
562 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
563 |
void LinkResolver::check_method_accessability(Klass* ref_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
564 |
Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
565 |
Klass* sel_klass, |
31019 | 566 |
const methodHandle& sel_method, |
1 | 567 |
TRAPS) { |
568 |
||
569 |
AccessFlags flags = sel_method->access_flags(); |
|
570 |
||
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
571 |
// Special case: arrays always override "clone". JVMS 2.15. |
1 | 572 |
// If the resolved klass is an array class, and the declaring class |
573 |
// is java.lang.Object and the method is "clone", set the flags |
|
574 |
// to public. |
|
575 |
// |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
576 |
// 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
|
577 |
// 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
|
578 |
if (sel_method->name() == vmSymbols::clone_name() && |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
579 |
sel_klass == SystemDictionary::Object_klass() && |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
580 |
resolved_klass->is_array_klass()) { |
1 | 581 |
// 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
|
582 |
assert(flags.is_protected(), "clone not protected?"); |
1 | 583 |
jint new_flags = flags.as_int(); |
584 |
new_flags = new_flags & (~JVM_ACC_PROTECTED); |
|
585 |
new_flags = new_flags | JVM_ACC_PUBLIC; |
|
586 |
flags.set_flags(new_flags); |
|
587 |
} |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
588 |
// assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); |
1 | 589 |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
590 |
bool can_access = Reflection::verify_member_access(ref_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
591 |
resolved_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
592 |
sel_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
593 |
flags, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
594 |
true, false, CHECK); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
595 |
// Any existing exceptions that may have been thrown, for example LinkageErrors |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
596 |
// from nest-host resolution, have been allowed to propagate. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
597 |
if (!can_access) { |
1 | 598 |
ResourceMark rm(THREAD); |
50761
cb07f4b539fc
8169559: Add class loader names to relevant VM messages
lfoltan
parents:
50735
diff
changeset
|
599 |
bool same_module = (sel_klass->module() == ref_klass->module()); |
1 | 600 |
Exceptions::fthrow( |
601 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
602 |
vmSymbols::java_lang_IllegalAccessError(), |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
603 |
"class %s tried to access %s%s%smethod %s.%s%s (%s%s%s)", |
50761
cb07f4b539fc
8169559: Add class loader names to relevant VM messages
lfoltan
parents:
50735
diff
changeset
|
604 |
ref_klass->external_name(), |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
605 |
sel_method->is_abstract() ? "abstract " : "", |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
606 |
sel_method->is_protected() ? "protected " : "", |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
607 |
sel_method->is_private() ? "private " : "", |
1 | 608 |
sel_klass->external_name(), |
609 |
sel_method->name()->as_C_string(), |
|
610 |
sel_method->signature()->as_C_string(), |
|
50761
cb07f4b539fc
8169559: Add class loader names to relevant VM messages
lfoltan
parents:
50735
diff
changeset
|
611 |
(same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(), |
cb07f4b539fc
8169559: Add class loader names to relevant VM messages
lfoltan
parents:
50735
diff
changeset
|
612 |
(same_module) ? "" : "; ", |
cb07f4b539fc
8169559: Add class loader names to relevant VM messages
lfoltan
parents:
50735
diff
changeset
|
613 |
(same_module) ? "" : sel_klass->class_in_module_of_loader() |
1 | 614 |
); |
615 |
return; |
|
616 |
} |
|
617 |
} |
|
618 |
||
31019 | 619 |
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
|
620 |
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
|
621 |
// This method is used only |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
622 |
// (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
|
623 |
// and |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
624 |
// (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
|
625 |
// 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
|
626 |
// FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. |
1 | 627 |
// resolve klass |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
628 |
if (code == Bytecodes::_invokedynamic) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
629 |
Klass* 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
|
630 |
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
|
631 |
Symbol* method_signature = pool->signature_ref_at(index); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
632 |
Klass* current_klass = pool->pool_holder(); |
31019 | 633 |
LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass); |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
634 |
return resolve_method(link_info, code, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
635 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
636 |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
637 |
LinkInfo link_info(pool, index, methodHandle(), CHECK_NULL); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
638 |
Klass* resolved_klass = link_info.resolved_klass(); |
1 | 639 |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
640 |
if (pool->has_preresolution() |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
641 |
|| (resolved_klass == SystemDictionary::MethodHandle_klass() && |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
642 |
MethodHandles::is_signature_polymorphic_name(resolved_klass, link_info.name()))) { |
31019 | 643 |
Method* result = ConstantPool::method_at_if_loaded(pool, index); |
644 |
if (result != NULL) { |
|
645 |
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
|
646 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
647 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
648 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
649 |
if (code == Bytecodes::_invokeinterface) { |
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
650 |
return resolve_interface_method(link_info, code, THREAD); |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
651 |
} else if (code == Bytecodes::_invokevirtual) { |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
652 |
return resolve_method(link_info, code, THREAD); |
21912 | 653 |
} else if (!resolved_klass->is_interface()) { |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
654 |
return resolve_method(link_info, code, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
655 |
} else { |
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
656 |
return resolve_interface_method(link_info, code, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
657 |
} |
1 | 658 |
} |
659 |
||
31019 | 660 |
// Check and print a loader constraint violation message for method or interface method |
661 |
void LinkResolver::check_method_loader_constraints(const LinkInfo& link_info, |
|
662 |
const methodHandle& resolved_method, |
|
663 |
const char* method_type, TRAPS) { |
|
664 |
Handle current_loader(THREAD, link_info.current_klass()->class_loader()); |
|
665 |
Handle resolved_loader(THREAD, resolved_method->method_holder()->class_loader()); |
|
666 |
||
667 |
ResourceMark rm(THREAD); |
|
668 |
Symbol* failed_type_symbol = |
|
669 |
SystemDictionary::check_signature_loaders(link_info.signature(), current_loader, |
|
670 |
resolved_loader, true, CHECK); |
|
671 |
if (failed_type_symbol != NULL) { |
|
51097
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
672 |
Klass* current_class = link_info.current_klass(); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
673 |
ClassLoaderData* current_loader_data = current_class->class_loader_data(); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
674 |
assert(current_loader_data != NULL, "current class has no class loader data"); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
675 |
Klass* resolved_method_class = resolved_method->method_holder(); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
676 |
ClassLoaderData* target_loader_data = resolved_method_class->class_loader_data(); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
677 |
assert(target_loader_data != NULL, "resolved method's class has no class loader data"); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
678 |
|
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
679 |
stringStream ss; |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
680 |
ss.print("loader constraint violation: when resolving %s" |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
681 |
" \"%s\" the class loader %s of the current class, %s," |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
682 |
" and the class loader %s for the method's defining class, %s, have" |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
683 |
" different Class objects for the type %s used in the signature (%s; %s)", |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
684 |
method_type, |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
685 |
link_info.method_string(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
686 |
current_loader_data->loader_name_and_id(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
687 |
current_class->name()->as_C_string(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
688 |
target_loader_data->loader_name_and_id(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
689 |
resolved_method_class->name()->as_C_string(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
690 |
failed_type_symbol->as_C_string(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
691 |
current_class->class_in_module_of_loader(false, true), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
692 |
resolved_method_class->class_in_module_of_loader(false, true)); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
693 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string()); |
31019 | 694 |
} |
695 |
} |
|
696 |
||
697 |
void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
698 |
Klass* current_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
699 |
Klass* sel_klass, TRAPS) { |
31019 | 700 |
Handle ref_loader(THREAD, current_klass->class_loader()); |
701 |
Handle sel_loader(THREAD, sel_klass->class_loader()); |
|
702 |
||
703 |
ResourceMark rm(THREAD); // needed for check_signature_loaders |
|
704 |
Symbol* failed_type_symbol = |
|
705 |
SystemDictionary::check_signature_loaders(sig, |
|
706 |
ref_loader, sel_loader, |
|
707 |
false, |
|
708 |
CHECK); |
|
709 |
if (failed_type_symbol != NULL) { |
|
51097
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
710 |
stringStream ss; |
50325
462453f3c7f6
8202913: loader constraint message for fields specifies incorrect referring class
hseigel
parents:
50036
diff
changeset
|
711 |
const char* failed_type_name = failed_type_symbol->as_klass_external_name(); |
51097
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
712 |
|
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
713 |
ss.print("loader constraint violation: when resolving field" |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
714 |
" \"%s\" of type %s, the class loader %s of the current class, " |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
715 |
"%s, and the class loader %s for the field's defining " |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
716 |
"type, %s, have different Class objects for type %s (%s; %s)", |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
717 |
field->as_C_string(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
718 |
failed_type_name, |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
719 |
current_klass->class_loader_data()->loader_name_and_id(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
720 |
current_klass->external_name(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
721 |
sel_klass->class_loader_data()->loader_name_and_id(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
722 |
sel_klass->external_name(), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
723 |
failed_type_name, |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
724 |
current_klass->class_in_module_of_loader(false, true), |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
725 |
sel_klass->class_in_module_of_loader(false, true)); |
bef02342d179
8205611: Improve the wording of LinkageErrors to include module and class loader information
lfoltan
parents:
50944
diff
changeset
|
726 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string()); |
31019 | 727 |
} |
728 |
} |
|
729 |
||
730 |
methodHandle LinkResolver::resolve_method(const LinkInfo& link_info, |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
731 |
Bytecodes::Code code, TRAPS) { |
1 | 732 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
733 |
Handle nested_exception; |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
734 |
Klass* 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
|
735 |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
736 |
// 1. For invokevirtual, cannot call an interface method |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
737 |
if (code == Bytecodes::_invokevirtual && resolved_klass->is_interface()) { |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
738 |
ResourceMark rm(THREAD); |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
739 |
char buf[200]; |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
740 |
jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
741 |
resolved_klass->external_name()); |
31019 | 742 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
743 |
} |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
744 |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
745 |
// 2. check constant pool tag for called method - must be JVM_CONSTANT_Methodref |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
746 |
if (!link_info.tag().is_invalid() && !link_info.tag().is_method()) { |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
747 |
ResourceMark rm(THREAD); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
748 |
char buf[200]; |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
749 |
jio_snprintf(buf, sizeof(buf), "Method %s must be Methodref constant", link_info.method_string()); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
750 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
751 |
} |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
752 |
|
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
753 |
// 3. lookup method in resolved klass and its super klasses |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
754 |
methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, true, false)); |
1 | 755 |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
756 |
// 4. lookup method in all the interfaces implemented by the resolved klass |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
757 |
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
758 |
resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info)); |
1 | 759 |
|
760 |
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
|
761 |
// JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
31019 | 762 |
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
|
763 |
if (HAS_PENDING_EXCEPTION) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
764 |
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
|
765 |
CLEAR_PENDING_EXCEPTION; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
766 |
} |
2534 | 767 |
} |
27020 | 768 |
} |
2534 | 769 |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
770 |
// 5. method lookup failed |
27020 | 771 |
if (resolved_method.is_null()) { |
772 |
ResourceMark rm(THREAD); |
|
31019 | 773 |
THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(), |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
774 |
Method::name_and_sig_as_C_string(resolved_klass, |
31019 | 775 |
link_info.name(), |
776 |
link_info.signature()), |
|
777 |
nested_exception, NULL); |
|
1 | 778 |
} |
779 |
||
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
780 |
// 6. access checks, access checking may be turned off when calling from within the VM. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
781 |
Klass* current_klass = link_info.current_klass(); |
31019 | 782 |
if (link_info.check_access()) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
783 |
assert(current_klass != NULL , "current_klass should not be null"); |
1 | 784 |
|
785 |
// check if method can be accessed by the referring class |
|
786 |
check_method_accessability(current_klass, |
|
787 |
resolved_klass, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
788 |
resolved_method->method_holder(), |
1 | 789 |
resolved_method, |
31019 | 790 |
CHECK_NULL); |
1 | 791 |
|
792 |
// check loader constraints |
|
31019 | 793 |
check_method_loader_constraints(link_info, resolved_method, "method", CHECK_NULL); |
1 | 794 |
} |
31019 | 795 |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
796 |
// For private method invocation we should only find the method in the resolved class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
797 |
// If that is not the case then we have a found a supertype method that we have nestmate |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
798 |
// access to. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
799 |
if (resolved_method->is_private() && resolved_method->method_holder() != resolved_klass) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
800 |
ResourceMark rm(THREAD); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
801 |
DEBUG_ONLY(bool is_nestmate = InstanceKlass::cast(link_info.current_klass())->has_nestmate_access_to(InstanceKlass::cast(resolved_klass), THREAD);) |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
802 |
assert(is_nestmate, "was only expecting nestmates to get here!"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
803 |
Exceptions::fthrow( |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
804 |
THREAD_AND_LOCATION, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
805 |
vmSymbols::java_lang_NoSuchMethodError(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
806 |
"%s: method %s%s not found", |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
807 |
resolved_klass->external_name(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
808 |
resolved_method->name()->as_C_string(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
809 |
resolved_method->signature()->as_C_string() |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
810 |
); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
811 |
return NULL; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
812 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
813 |
|
31019 | 814 |
return resolved_method; |
1 | 815 |
} |
816 |
||
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
817 |
static void trace_method_resolution(const char* prefix, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
818 |
Klass* klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
819 |
Klass* resolved_klass, |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
820 |
const methodHandle& method, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
821 |
bool logitables, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
822 |
int index = -1) { |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
823 |
#ifndef PRODUCT |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
824 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
825 |
Log(itables) logi; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
826 |
LogStream lsi(logi.trace()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
827 |
Log(vtables) logv; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
828 |
LogStream lsv(logv.trace()); |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
829 |
outputStream* st; |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
830 |
if (logitables) { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
831 |
st = &lsi; |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
832 |
} else { |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
833 |
st = &lsv; |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
834 |
} |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
835 |
st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
836 |
prefix, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
837 |
(klass == NULL ? "<NULL>" : klass->internal_name()), |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
838 |
(resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()), |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
839 |
Method::name_and_sig_as_C_string(resolved_klass, |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
840 |
method->name(), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
841 |
method->signature()), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
842 |
method->method_holder()->internal_name()); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
843 |
method->print_linkage_flags(st); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
844 |
if (index != -1) { |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
845 |
st->print("vtable_index:%d", index); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
846 |
} |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
847 |
st->cr(); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
848 |
#endif // PRODUCT |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
849 |
} |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
850 |
|
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
851 |
// Do linktime resolution of a method in the interface within the context of the specied bytecode. |
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
852 |
methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) { |
31019 | 853 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
854 |
Klass* resolved_klass = link_info.resolved_klass(); |
1 | 855 |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
856 |
// check if klass is interface |
1 | 857 |
if (!resolved_klass->is_interface()) { |
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
858 |
ResourceMark rm(THREAD); |
1 | 859 |
char buf[200]; |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
860 |
jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass->external_name()); |
31019 | 861 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 862 |
} |
863 |
||
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
864 |
// check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
865 |
if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) { |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
866 |
ResourceMark rm(THREAD); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
867 |
char buf[200]; |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
868 |
jio_snprintf(buf, sizeof(buf), "Method %s must be InterfaceMethodref constant", link_info.method_string()); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
869 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
870 |
} |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
871 |
|
1 | 872 |
// lookup method in this interface or its super, java.lang.Object |
21912 | 873 |
// JDK8: also look for static methods |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
874 |
methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true)); |
1 | 875 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
876 |
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { |
1 | 877 |
// lookup method in all the super-interfaces |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46701
diff
changeset
|
878 |
resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info)); |
27020 | 879 |
} |
880 |
||
881 |
if (resolved_method.is_null()) { |
|
882 |
// no method found |
|
883 |
ResourceMark rm(THREAD); |
|
31019 | 884 |
THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
885 |
Method::name_and_sig_as_C_string(resolved_klass, |
31019 | 886 |
link_info.name(), |
887 |
link_info.signature())); |
|
1 | 888 |
} |
889 |
||
31019 | 890 |
if (link_info.check_access()) { |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
891 |
// JDK8 adds non-public interface methods, and accessability check requirement |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
892 |
Klass* current_klass = link_info.current_klass(); |
31019 | 893 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
894 |
assert(current_klass != NULL , "current_klass should not be null"); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
895 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
896 |
// 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
|
897 |
check_method_accessability(current_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
898 |
resolved_klass, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
899 |
resolved_method->method_holder(), |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
900 |
resolved_method, |
31019 | 901 |
CHECK_NULL); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
902 |
|
31019 | 903 |
check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL); |
1 | 904 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
905 |
|
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
906 |
if (code != Bytecodes::_invokestatic && resolved_method->is_static()) { |
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
907 |
ResourceMark rm(THREAD); |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
908 |
char buf[200]; |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
909 |
jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
910 |
Method::name_and_sig_as_C_string(resolved_klass, |
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
911 |
resolved_method->name(), resolved_method->signature())); |
31019 | 912 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
913 |
} |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
914 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
915 |
if (log_develop_is_enabled(Trace, itables)) { |
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
39699
diff
changeset
|
916 |
char buf[200]; |
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
39699
diff
changeset
|
917 |
jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:", |
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
39699
diff
changeset
|
918 |
Bytecodes::name(code)); |
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
39699
diff
changeset
|
919 |
trace_method_resolution(buf, link_info.current_klass(), resolved_klass, |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
920 |
resolved_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
921 |
} |
31019 | 922 |
|
923 |
return resolved_method; |
|
1 | 924 |
} |
925 |
||
926 |
//------------------------------------------------------------------------------------------------------------------------ |
|
927 |
// Field resolution |
|
928 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
929 |
void LinkResolver::check_field_accessability(Klass* ref_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
930 |
Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
931 |
Klass* sel_klass, |
31019 | 932 |
const fieldDescriptor& fd, |
1 | 933 |
TRAPS) { |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
934 |
bool can_access = Reflection::verify_member_access(ref_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
935 |
resolved_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
936 |
sel_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
937 |
fd.access_flags(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
938 |
true, false, CHECK); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
939 |
// Any existing exceptions that may have been thrown, for example LinkageErrors |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
940 |
// from nest-host resolution, have been allowed to propagate. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
941 |
if (!can_access) { |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
942 |
bool same_module = (sel_klass->module() == ref_klass->module()); |
1 | 943 |
ResourceMark rm(THREAD); |
944 |
Exceptions::fthrow( |
|
945 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
946 |
vmSymbols::java_lang_IllegalAccessError(), |
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
947 |
"class %s tried to access %s%sfield %s.%s (%s%s%s)", |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
948 |
ref_klass->external_name(), |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
949 |
fd.is_protected() ? "protected " : "", |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
950 |
fd.is_private() ? "private " : "", |
1 | 951 |
sel_klass->external_name(), |
952 |
fd.name()->as_C_string(), |
|
50816
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
953 |
(same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(), |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
954 |
(same_module) ? "" : "; ", |
a73848f8d0ad
8199940: Print more information about class loaders in IllegalAccessErrors.
goetz
parents:
50761
diff
changeset
|
955 |
(same_module) ? "" : sel_klass->class_in_module_of_loader() |
1 | 956 |
); |
957 |
return; |
|
958 |
} |
|
959 |
} |
|
960 |
||
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
961 |
void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
962 |
LinkInfo link_info(pool, index, method, CHECK); |
31019 | 963 |
resolve_field(fd, link_info, byte, true, CHECK); |
1 | 964 |
} |
965 |
||
31019 | 966 |
void LinkResolver::resolve_field(fieldDescriptor& fd, |
967 |
const LinkInfo& link_info, |
|
968 |
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
|
969 |
TRAPS) { |
1 | 970 |
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
|
971 |
byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || |
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
29081
diff
changeset
|
972 |
byte == Bytecodes::_nofast_getfield || byte == Bytecodes::_nofast_putfield || |
31019 | 973 |
(byte == Bytecodes::_nop && !link_info.check_access()), "bad field access bytecode"); |
1 | 974 |
|
975 |
bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); |
|
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
29081
diff
changeset
|
976 |
bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); |
1 | 977 |
// Check if there's a resolved klass containing the field |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
978 |
Klass* resolved_klass = link_info.resolved_klass(); |
31019 | 979 |
Symbol* field = link_info.name(); |
980 |
Symbol* sig = link_info.signature(); |
|
981 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
982 |
if (resolved_klass == NULL) { |
1 | 983 |
ResourceMark rm(THREAD); |
984 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
985 |
} |
|
986 |
||
987 |
// Resolve instance field |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
988 |
Klass* sel_klass = resolved_klass->find_field(field, sig, &fd); |
1 | 989 |
// check if field exists; i.e., if a klass containing the field def has been selected |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
990 |
if (sel_klass == NULL) { |
1 | 991 |
ResourceMark rm(THREAD); |
992 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
993 |
} |
|
994 |
||
31019 | 995 |
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
|
996 |
// 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
|
997 |
return; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
998 |
|
1 | 999 |
// check access |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1000 |
Klass* 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
|
1001 |
check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); |
1 | 1002 |
|
1003 |
// check for errors |
|
1004 |
if (is_static != fd.is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1005 |
ResourceMark rm(THREAD); |
1 | 1006 |
char msg[200]; |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1007 |
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 | 1008 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); |
1009 |
} |
|
1010 |
||
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1011 |
// A final field can be modified only |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1012 |
// (1) by methods declared in the class declaring the field and |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1013 |
// (2) by the <clinit> method (in case of a static field) |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1014 |
// or by the <init> method (in case of an instance field). |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1015 |
if (is_put && fd.access_flags().is_final()) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1016 |
ResourceMark rm(THREAD); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1017 |
stringStream ss; |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1018 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1019 |
if (sel_klass != current_klass) { |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1020 |
ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class", |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1021 |
is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(), |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1022 |
current_klass->external_name()); |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1023 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1024 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1025 |
|
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1026 |
if (fd.constants()->pool_holder()->major_version() >= 53) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1027 |
methodHandle m = link_info.current_method(); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1028 |
assert(!m.is_null(), "information about the current method must be available for 'put' bytecodes"); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1029 |
bool is_initialized_static_final_update = (byte == Bytecodes::_putstatic && |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1030 |
fd.is_static() && |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1031 |
!m()->is_static_initializer()); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1032 |
bool is_initialized_instance_final_update = ((byte == Bytecodes::_putfield || byte == Bytecodes::_nofast_putfield) && |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1033 |
!fd.is_static() && |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1034 |
!m->is_object_initializer()); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1035 |
|
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1036 |
if (is_initialized_static_final_update || is_initialized_instance_final_update) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1037 |
ss.print("Update to %s final field %s.%s attempted from a different method (%s) than the initializer method %s ", |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1038 |
is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(), |
39699
7a2a49fd5ee0
8160527: Check for final instance field updates can be omitted
zmajo
parents:
39421
diff
changeset
|
1039 |
m()->name()->as_C_string(), |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1040 |
is_static ? "<clinit>" : "<init>"); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1041 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string()); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1042 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38939
diff
changeset
|
1043 |
} |
1 | 1044 |
} |
1045 |
||
1046 |
// initialize resolved_klass if necessary |
|
1047 |
// note 1: the klass which declared the field must be initialized (i.e, sel_klass) |
|
1048 |
// according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99) |
|
1049 |
// |
|
1050 |
// note 2: we don't want to force initialization if we are just checking |
|
1051 |
// 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
|
1052 |
if (is_static && initialize_class) { |
1 | 1053 |
sel_klass->initialize(CHECK); |
1054 |
} |
|
1055 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1056 |
if (sel_klass != current_klass) { |
31019 | 1057 |
check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK); |
1 | 1058 |
} |
1059 |
||
1060 |
// return information. note that the klass is set to the actual klass containing the |
|
1061 |
// field, otherwise access of static fields in superclasses will not work. |
|
1062 |
} |
|
1063 |
||
1064 |
||
1065 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1066 |
// Invoke resolution |
|
1067 |
// |
|
1068 |
// Naming conventions: |
|
1069 |
// |
|
1070 |
// resolved_method the specified method (i.e., static receiver specified via constant pool index) |
|
1071 |
// sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class) |
|
1072 |
// resolved_klass the specified klass (i.e., specified via constant pool index) |
|
1073 |
// recv_klass the receiver klass |
|
1074 |
||
1075 |
||
31019 | 1076 |
void LinkResolver::resolve_static_call(CallInfo& result, |
1077 |
const LinkInfo& link_info, |
|
1078 |
bool initialize_class, TRAPS) { |
|
1079 |
methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK); |
|
1 | 1080 |
|
31019 | 1081 |
// The resolved class can change as a result of this resolution. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1082 |
Klass* resolved_klass = resolved_method->method_holder(); |
31019 | 1083 |
|
1 | 1084 |
// Initialize klass (this should only happen if everything is ok) |
1085 |
if (initialize_class && resolved_klass->should_be_initialized()) { |
|
1086 |
resolved_klass->initialize(CHECK); |
|
38939
c1b1d1d0e89b
8158397: Crash: assert(save_resolved_method == resolved_method()) failed: does this change?
coleenp
parents:
38719
diff
changeset
|
1087 |
// Use updated LinkInfo to reresolve with resolved method holder |
31019 | 1088 |
LinkInfo new_info(resolved_klass, link_info.name(), link_info.signature(), |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1089 |
link_info.current_klass(), |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1090 |
link_info.check_access() ? LinkInfo::needs_access_check : LinkInfo::skip_access_check); |
31019 | 1091 |
resolved_method = linktime_resolve_static_method(new_info, CHECK); |
1 | 1092 |
} |
1093 |
||
1094 |
// setup result |
|
1095 |
result.set_static(resolved_klass, resolved_method, CHECK); |
|
1096 |
} |
|
1097 |
||
1098 |
// throws linktime exceptions |
|
31019 | 1099 |
methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) { |
1 | 1100 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1101 |
Klass* resolved_klass = link_info.resolved_klass(); |
31019 | 1102 |
methodHandle resolved_method; |
21912 | 1103 |
if (!resolved_klass->is_interface()) { |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1104 |
resolved_method = resolve_method(link_info, Bytecodes::_invokestatic, CHECK_NULL); |
21912 | 1105 |
} else { |
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
1106 |
resolved_method = resolve_interface_method(link_info, Bytecodes::_invokestatic, CHECK_NULL); |
21912 | 1107 |
} |
1 | 1108 |
assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); |
1109 |
||
1110 |
// check if static |
|
1111 |
if (!resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1112 |
ResourceMark rm(THREAD); |
1 | 1113 |
char buf[200]; |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1114 |
jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass, |
1 | 1115 |
resolved_method->name(), |
1116 |
resolved_method->signature())); |
|
31019 | 1117 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 1118 |
} |
31019 | 1119 |
return resolved_method; |
1 | 1120 |
} |
1121 |
||
1122 |
||
31019 | 1123 |
void LinkResolver::resolve_special_call(CallInfo& result, |
44738 | 1124 |
Handle recv, |
31019 | 1125 |
const LinkInfo& link_info, |
1126 |
TRAPS) { |
|
1127 |
methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK); |
|
47401 | 1128 |
runtime_resolve_special_method(result, link_info, resolved_method, recv, CHECK); |
1 | 1129 |
} |
1130 |
||
1131 |
// throws linktime exceptions |
|
31019 | 1132 |
methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, |
1133 |
TRAPS) { |
|
1 | 1134 |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1135 |
// Invokespecial is called for multiple special reasons: |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1136 |
// <init> |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1137 |
// 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
|
1138 |
// 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
|
1139 |
// 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
|
1140 |
// superinterface.method, which explicitly does not check shadowing |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1141 |
Klass* resolved_klass = link_info.resolved_klass(); |
31019 | 1142 |
methodHandle resolved_method; |
14385 | 1143 |
|
21912 | 1144 |
if (!resolved_klass->is_interface()) { |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1145 |
resolved_method = resolve_method(link_info, Bytecodes::_invokespecial, CHECK_NULL); |
21912 | 1146 |
} else { |
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
1147 |
resolved_method = resolve_interface_method(link_info, Bytecodes::_invokespecial, CHECK_NULL); |
21912 | 1148 |
} |
1 | 1149 |
|
1150 |
// check if method name is <init>, that it is found in same klass as static type |
|
1151 |
if (resolved_method->name() == vmSymbols::object_initializer_name() && |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1152 |
resolved_method->method_holder() != resolved_klass) { |
1 | 1153 |
ResourceMark rm(THREAD); |
1154 |
Exceptions::fthrow( |
|
1155 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1156 |
vmSymbols::java_lang_NoSuchMethodError(), |
1 | 1157 |
"%s: method %s%s not found", |
1158 |
resolved_klass->external_name(), |
|
1159 |
resolved_method->name()->as_C_string(), |
|
1160 |
resolved_method->signature()->as_C_string() |
|
1161 |
); |
|
31019 | 1162 |
return NULL; |
1 | 1163 |
} |
1164 |
||
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1165 |
// ensure that invokespecial's interface method reference is in |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1166 |
// a direct superinterface, not an indirect superinterface |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1167 |
Klass* current_klass = link_info.current_klass(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1168 |
if (current_klass != NULL && resolved_klass->is_interface()) { |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1169 |
InstanceKlass* ck = InstanceKlass::cast(current_klass); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1170 |
InstanceKlass *klass_to_check = !ck->is_anonymous() ? |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1171 |
ck : |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1172 |
InstanceKlass::cast(ck->host_klass()); |
25057 | 1173 |
// Disable verification for the dynamically-generated reflection bytecodes. |
1174 |
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
|
1175 |
SystemDictionary::reflect_MagicAccessorImpl_klass()); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1176 |
|
22218
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1177 |
if (!is_reflect && |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1178 |
!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
|
1179 |
ResourceMark rm(THREAD); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1180 |
char buf[200]; |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1181 |
jio_snprintf(buf, sizeof(buf), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1182 |
"Interface method reference: %s, is in an indirect superinterface of %s", |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1183 |
Method::name_and_sig_as_C_string(resolved_klass, |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1184 |
resolved_method->name(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1185 |
resolved_method->signature()), |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1186 |
current_klass->external_name()); |
31019 | 1187 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1188 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1189 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1190 |
|
1 | 1191 |
// check if not static |
1192 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1193 |
ResourceMark rm(THREAD); |
1 | 1194 |
char buf[200]; |
1195 |
jio_snprintf(buf, sizeof(buf), |
|
1196 |
"Expecting non-static method %s", |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1197 |
Method::name_and_sig_as_C_string(resolved_klass, |
31019 | 1198 |
resolved_method->name(), |
1199 |
resolved_method->signature())); |
|
1200 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
1 | 1201 |
} |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1202 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1203 |
if (log_develop_is_enabled(Trace, itables)) { |
31019 | 1204 |
trace_method_resolution("invokespecial resolved method: caller-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1205 |
current_klass, resolved_klass, resolved_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1206 |
} |
31019 | 1207 |
|
1208 |
return resolved_method; |
|
1 | 1209 |
} |
1210 |
||
1211 |
// throws runtime exceptions |
|
31019 | 1212 |
void LinkResolver::runtime_resolve_special_method(CallInfo& result, |
47401 | 1213 |
const LinkInfo& link_info, |
31019 | 1214 |
const methodHandle& resolved_method, |
47401 | 1215 |
Handle recv, TRAPS) { |
1216 |
||
1217 |
Klass* resolved_klass = link_info.resolved_klass(); |
|
1 | 1218 |
|
1219 |
// 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
|
1220 |
// for a superclass method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1221 |
// 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
|
1222 |
// no checks for shadowing |
1 | 1223 |
methodHandle sel_method(THREAD, resolved_method()); |
1224 |
||
47401 | 1225 |
if (link_info.check_access() && |
44738 | 1226 |
// check if the method is not <init> |
1227 |
resolved_method->name() != vmSymbols::object_initializer_name()) { |
|
1 | 1228 |
|
47401 | 1229 |
Klass* current_klass = link_info.current_klass(); |
50944 | 1230 |
|
1231 |
// Check if the class of the resolved_klass is a superclass |
|
1232 |
// (not supertype in order to exclude interface classes) of the current class. |
|
1233 |
// This check is not performed for super.invoke for interface methods |
|
1234 |
// in super interfaces. |
|
1235 |
if (current_klass->is_subclass_of(resolved_klass) && |
|
1236 |
current_klass != resolved_klass) { |
|
1 | 1237 |
// Lookup super method |
46458 | 1238 |
Klass* super_klass = current_klass->super(); |
31019 | 1239 |
sel_method = lookup_instance_method_in_klasses(super_klass, |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1240 |
resolved_method->name(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1241 |
resolved_method->signature(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1242 |
Klass::find_private, CHECK); |
1 | 1243 |
// check if found |
1244 |
if (sel_method.is_null()) { |
|
1245 |
ResourceMark rm(THREAD); |
|
1246 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
46458 | 1247 |
Method::name_and_sig_as_C_string(resolved_klass, |
1 | 1248 |
resolved_method->name(), |
1249 |
resolved_method->signature())); |
|
47401 | 1250 |
// check loader constraints if found a different method |
1251 |
} else if (sel_method() != resolved_method()) { |
|
1252 |
check_method_loader_constraints(link_info, sel_method, "method", CHECK); |
|
1 | 1253 |
} |
1254 |
} |
|
44738 | 1255 |
|
1256 |
// Check that the class of objectref (the receiver) is the current class or interface, |
|
1257 |
// or a subtype of the current class or interface (the sender), otherwise invokespecial |
|
1258 |
// throws IllegalAccessError. |
|
1259 |
// The verifier checks that the sender is a subtype of the class in the I/MR operand. |
|
1260 |
// The verifier also checks that the receiver is a subtype of the sender, if the sender is |
|
1261 |
// a class. If the sender is an interface, the check has to be performed at runtime. |
|
46458 | 1262 |
InstanceKlass* sender = InstanceKlass::cast(current_klass); |
44738 | 1263 |
sender = sender->is_anonymous() ? sender->host_klass() : sender; |
1264 |
if (sender->is_interface() && recv.not_null()) { |
|
1265 |
Klass* receiver_klass = recv->klass(); |
|
1266 |
if (!receiver_klass->is_subtype_of(sender)) { |
|
1267 |
ResourceMark rm(THREAD); |
|
1268 |
char buf[500]; |
|
1269 |
jio_snprintf(buf, sizeof(buf), |
|
1270 |
"Receiver class %s must be the current class or a subtype of interface %s", |
|
1271 |
receiver_klass->name()->as_C_string(), |
|
1272 |
sender->name()->as_C_string()); |
|
1273 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf); |
|
1274 |
} |
|
1275 |
} |
|
1 | 1276 |
} |
1277 |
||
1278 |
// check if not static |
|
1279 |
if (sel_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1280 |
ResourceMark rm(THREAD); |
1 | 1281 |
char buf[200]; |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1282 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1283 |
resolved_method->name(), |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1284 |
resolved_method->signature())); |
1 | 1285 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1286 |
} |
|
1287 |
||
1288 |
// check if abstract |
|
1289 |
if (sel_method->is_abstract()) { |
|
1290 |
ResourceMark rm(THREAD); |
|
1291 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1292 |
Method::name_and_sig_as_C_string(resolved_klass, |
31019 | 1293 |
sel_method->name(), |
1294 |
sel_method->signature())); |
|
1 | 1295 |
} |
1296 |
||
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1297 |
if (log_develop_is_enabled(Trace, itables)) { |
31019 | 1298 |
trace_method_resolution("invokespecial selected method: resolved-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1299 |
resolved_klass, resolved_klass, sel_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1300 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1301 |
|
1 | 1302 |
// setup result |
1303 |
result.set_static(resolved_klass, sel_method, CHECK); |
|
1304 |
} |
|
1305 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1306 |
void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, Klass* receiver_klass, |
31019 | 1307 |
const LinkInfo& link_info, |
1308 |
bool check_null_and_abstract, TRAPS) { |
|
1309 |
methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK); |
|
1310 |
runtime_resolve_virtual_method(result, resolved_method, |
|
1311 |
link_info.resolved_klass(), |
|
1312 |
recv, receiver_klass, |
|
1313 |
check_null_and_abstract, CHECK); |
|
1 | 1314 |
} |
1315 |
||
1316 |
// throws linktime exceptions |
|
31019 | 1317 |
methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_info, |
1318 |
TRAPS) { |
|
1 | 1319 |
// normal method resolution |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1320 |
methodHandle resolved_method = resolve_method(link_info, Bytecodes::_invokevirtual, CHECK_NULL); |
1 | 1321 |
|
1322 |
assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); |
|
1323 |
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); |
|
1324 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1325 |
// check if private interface method |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1326 |
Klass* resolved_klass = link_info.resolved_klass(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1327 |
Klass* current_klass = link_info.current_klass(); |
31019 | 1328 |
|
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1329 |
// This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1330 |
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
|
1331 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1332 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1333 |
jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1334 |
Method::name_and_sig_as_C_string(resolved_klass, |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1335 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1336 |
resolved_method->signature()), |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1337 |
(current_klass == NULL ? "<NULL>" : current_klass->internal_name())); |
31019 | 1338 |
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
|
1339 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1340 |
|
1 | 1341 |
// check if not static |
1342 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1343 |
ResourceMark rm(THREAD); |
1 | 1344 |
char buf[200]; |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1345 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1346 |
resolved_method->name(), |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1347 |
resolved_method->signature())); |
31019 | 1348 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 1349 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1350 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1351 |
if (log_develop_is_enabled(Trace, vtables)) { |
31019 | 1352 |
trace_method_resolution("invokevirtual resolved method: caller-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1353 |
current_klass, resolved_klass, resolved_method, false); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1354 |
} |
31019 | 1355 |
|
1356 |
return resolved_method; |
|
1 | 1357 |
} |
1358 |
||
1359 |
// throws runtime exceptions |
|
1360 |
void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, |
|
31019 | 1361 |
const methodHandle& resolved_method, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1362 |
Klass* resolved_klass, |
1 | 1363 |
Handle recv, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1364 |
Klass* recv_klass, |
1 | 1365 |
bool check_null_and_abstract, |
1366 |
TRAPS) { |
|
1367 |
||
1368 |
// setup default return values |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1369 |
int vtable_index = Method::invalid_vtable_index; |
1 | 1370 |
methodHandle selected_method; |
1371 |
||
1372 |
// runtime method resolution |
|
1373 |
if (check_null_and_abstract && recv.is_null()) { // check if receiver exists |
|
1374 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
1375 |
} |
|
1376 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1377 |
// Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s |
1 | 1378 |
// has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since |
1379 |
// 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
|
1380 |
assert(resolved_method->method_holder()->is_linked(), "must be linked"); |
1 | 1381 |
|
1382 |
// 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
|
1383 |
if (resolved_method->method_holder()->is_interface()) { // default or miranda method |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1384 |
vtable_index = vtable_index_of_interface_method(resolved_klass, resolved_method); |
1 | 1385 |
assert(vtable_index >= 0 , "we should have valid vtable index at this point"); |
1386 |
||
35900 | 1387 |
selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index)); |
1 | 1388 |
} else { |
1389 |
// 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
|
1390 |
// 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
|
1391 |
assert(!resolved_method->has_itable_index(), ""); |
1 | 1392 |
vtable_index = resolved_method->vtable_index(); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1393 |
// We could get a negative vtable_index of nonvirtual_vtable_index for private |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1394 |
// methods, or for final methods. Private methods never appear in the vtable |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1395 |
// and never override other methods. As an optimization, final methods are |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1396 |
// never put in the vtable, unless they override an existing method. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1397 |
// So if we do get nonvirtual_vtable_index, it means the selected method is the |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1398 |
// resolved 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
|
1399 |
if (vtable_index == Method::nonvirtual_vtable_index) { |
1 | 1400 |
assert(resolved_method->can_be_statically_bound(), "cannot override this method"); |
1401 |
selected_method = resolved_method; |
|
1402 |
} else { |
|
35900 | 1403 |
selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index)); |
1 | 1404 |
} |
1405 |
} |
|
1406 |
||
1407 |
// check if method exists |
|
1408 |
if (selected_method.is_null()) { |
|
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1409 |
throw_abstract_method_error(resolved_method, recv_klass, CHECK); |
1 | 1410 |
} |
1411 |
||
1412 |
// check if abstract |
|
1413 |
if (check_null_and_abstract && selected_method->is_abstract()) { |
|
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1414 |
// Pass arguments for generating a verbose error message. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1415 |
throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK); |
1 | 1416 |
} |
1417 |
||
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1418 |
if (log_develop_is_enabled(Trace, vtables)) { |
31019 | 1419 |
trace_method_resolution("invokevirtual selected method: receiver-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1420 |
recv_klass, resolved_klass, selected_method, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1421 |
false, vtable_index); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1422 |
} |
1 | 1423 |
// setup result |
1424 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); |
|
1425 |
} |
|
1426 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1427 |
void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass, |
31019 | 1428 |
const LinkInfo& link_info, |
1429 |
bool check_null_and_abstract, TRAPS) { |
|
1430 |
// throws linktime exceptions |
|
1431 |
methodHandle resolved_method = linktime_resolve_interface_method(link_info, CHECK); |
|
1432 |
runtime_resolve_interface_method(result, resolved_method,link_info.resolved_klass(), |
|
1433 |
recv, recv_klass, check_null_and_abstract, CHECK); |
|
1 | 1434 |
} |
1435 |
||
31019 | 1436 |
methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info, |
1437 |
TRAPS) { |
|
1 | 1438 |
// normal interface method resolution |
38034
f22f68545fd5
8153115: Move private interface check to linktime
iveresov
parents:
37267
diff
changeset
|
1439 |
methodHandle resolved_method = resolve_interface_method(link_info, Bytecodes::_invokeinterface, CHECK_NULL); |
1 | 1440 |
assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); |
1441 |
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); |
|
31019 | 1442 |
|
1443 |
return resolved_method; |
|
1 | 1444 |
} |
1445 |
||
1446 |
// throws runtime exceptions |
|
31019 | 1447 |
void LinkResolver::runtime_resolve_interface_method(CallInfo& result, |
1448 |
const methodHandle& resolved_method, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1449 |
Klass* resolved_klass, |
31019 | 1450 |
Handle recv, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1451 |
Klass* recv_klass, |
31019 | 1452 |
bool check_null_and_abstract, TRAPS) { |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1453 |
|
1 | 1454 |
// check if receiver exists |
1455 |
if (check_null_and_abstract && recv.is_null()) { |
|
1456 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
1457 |
} |
|
1458 |
||
1459 |
// check if receiver klass implements the resolved interface |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1460 |
if (!recv_klass->is_subtype_of(resolved_klass)) { |
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1461 |
ResourceMark rm(THREAD); |
1 | 1462 |
char buf[200]; |
1463 |
jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1464 |
recv_klass->external_name(), |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1465 |
resolved_klass->external_name()); |
1 | 1466 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1467 |
} |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1468 |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1469 |
methodHandle selected_method = resolved_method; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1470 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1471 |
// resolve the method in the receiver class, unless it is private |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1472 |
if (!resolved_method()->is_private()) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1473 |
// do lookup based on receiver klass |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1474 |
// This search must match the linktime preparation search for itable initialization |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1475 |
// to correctly enforce loader constraints for interface method inheritance. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1476 |
// Private methods are skipped as the resolved method was not private. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1477 |
selected_method = lookup_instance_method_in_klasses(recv_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1478 |
resolved_method->name(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1479 |
resolved_method->signature(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1480 |
Klass::skip_private, CHECK); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1481 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1482 |
if (selected_method.is_null() && !check_null_and_abstract) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1483 |
// In theory this is a harmless placeholder value, but |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1484 |
// in practice leaving in null affects the nsk default method tests. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1485 |
// This needs further study. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1486 |
selected_method = resolved_method; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1487 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1488 |
// check if method exists |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1489 |
if (selected_method.is_null()) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1490 |
// Pass arguments for generating a verbose error message. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1491 |
throw_abstract_method_error(resolved_method, recv_klass, CHECK); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1492 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1493 |
// check access |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1494 |
// Throw Illegal Access Error if selected_method is not public. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1495 |
if (!selected_method->is_public()) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1496 |
ResourceMark rm(THREAD); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1497 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1498 |
Method::name_and_sig_as_C_string(recv_klass, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1499 |
selected_method->name(), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1500 |
selected_method->signature())); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1501 |
} |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1502 |
// check if abstract |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1503 |
if (check_null_and_abstract && selected_method->is_abstract()) { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1504 |
throw_abstract_method_error(resolved_method, selected_method, recv_klass, CHECK); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1505 |
} |
1 | 1506 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1507 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1508 |
if (log_develop_is_enabled(Trace, itables)) { |
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
39699
diff
changeset
|
1509 |
trace_method_resolution("invokeinterface selected method: receiver-class:", |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1510 |
recv_klass, resolved_klass, selected_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1511 |
} |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1512 |
// setup result |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1513 |
if (resolved_method->has_vtable_index()) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1514 |
int vtable_index = resolved_method->vtable_index(); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1515 |
log_develop_trace(itables)(" -- vtable index: %d", vtable_index); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1516 |
assert(vtable_index == selected_method->vtable_index(), "sanity check"); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1517 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1518 |
} else if (resolved_method->has_itable_index()) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1519 |
int itable_index = resolved_method()->itable_index(); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1520 |
log_develop_trace(itables)(" -- itable index: %d", itable_index); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1521 |
result.set_interface(resolved_klass, recv_klass, resolved_method, selected_method, itable_index, CHECK); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1522 |
} else { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1523 |
int index = resolved_method->vtable_index(); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1524 |
log_develop_trace(itables)(" -- non itable/vtable index: %d", index); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1525 |
assert(index == Method::nonvirtual_vtable_index, "Oops hit another case!"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1526 |
assert(resolved_method()->is_private() || |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1527 |
(resolved_method()->is_final() && resolved_method->method_holder() == SystemDictionary::Object_klass()), |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1528 |
"Should only have non-virtual invokeinterface for private or final-Object methods!"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1529 |
assert(resolved_method()->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!"); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1530 |
// This sets up the nonvirtual form of "virtual" call (as needed for final and private methods) |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50325
diff
changeset
|
1531 |
result.set_virtual(resolved_klass, resolved_klass, resolved_method, resolved_method, index, CHECK); |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1532 |
} |
1 | 1533 |
} |
1534 |
||
1535 |
||
1536 |
methodHandle LinkResolver::linktime_resolve_interface_method_or_null( |
|
31019 | 1537 |
const LinkInfo& link_info) { |
1 | 1538 |
EXCEPTION_MARK; |
31019 | 1539 |
methodHandle method_result = linktime_resolve_interface_method(link_info, THREAD); |
1 | 1540 |
if (HAS_PENDING_EXCEPTION) { |
1541 |
CLEAR_PENDING_EXCEPTION; |
|
1542 |
return methodHandle(); |
|
1543 |
} else { |
|
1544 |
return method_result; |
|
1545 |
} |
|
1546 |
} |
|
1547 |
||
1548 |
methodHandle LinkResolver::linktime_resolve_virtual_method_or_null( |
|
31019 | 1549 |
const LinkInfo& link_info) { |
1 | 1550 |
EXCEPTION_MARK; |
31019 | 1551 |
methodHandle method_result = linktime_resolve_virtual_method(link_info, THREAD); |
1 | 1552 |
if (HAS_PENDING_EXCEPTION) { |
1553 |
CLEAR_PENDING_EXCEPTION; |
|
1554 |
return methodHandle(); |
|
1555 |
} else { |
|
1556 |
return method_result; |
|
1557 |
} |
|
1558 |
} |
|
1559 |
||
1560 |
methodHandle LinkResolver::resolve_virtual_call_or_null( |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1561 |
Klass* receiver_klass, |
31019 | 1562 |
const LinkInfo& link_info) { |
1 | 1563 |
EXCEPTION_MARK; |
1564 |
CallInfo info; |
|
31019 | 1565 |
resolve_virtual_call(info, Handle(), receiver_klass, link_info, false, THREAD); |
1 | 1566 |
if (HAS_PENDING_EXCEPTION) { |
1567 |
CLEAR_PENDING_EXCEPTION; |
|
1568 |
return methodHandle(); |
|
1569 |
} |
|
1570 |
return info.selected_method(); |
|
1571 |
} |
|
1572 |
||
1573 |
methodHandle LinkResolver::resolve_interface_call_or_null( |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1574 |
Klass* receiver_klass, |
31019 | 1575 |
const LinkInfo& link_info) { |
1 | 1576 |
EXCEPTION_MARK; |
1577 |
CallInfo info; |
|
31019 | 1578 |
resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD); |
1 | 1579 |
if (HAS_PENDING_EXCEPTION) { |
1580 |
CLEAR_PENDING_EXCEPTION; |
|
1581 |
return methodHandle(); |
|
1582 |
} |
|
1583 |
return info.selected_method(); |
|
1584 |
} |
|
1585 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1586 |
int LinkResolver::resolve_virtual_vtable_index(Klass* receiver_klass, |
31019 | 1587 |
const LinkInfo& link_info) { |
1 | 1588 |
EXCEPTION_MARK; |
1589 |
CallInfo info; |
|
31019 | 1590 |
resolve_virtual_call(info, Handle(), receiver_klass, link_info, |
1591 |
/*check_null_or_abstract*/false, THREAD); |
|
1 | 1592 |
if (HAS_PENDING_EXCEPTION) { |
1593 |
CLEAR_PENDING_EXCEPTION; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1594 |
return Method::invalid_vtable_index; |
1 | 1595 |
} |
1596 |
return info.vtable_index(); |
|
1597 |
} |
|
1598 |
||
31019 | 1599 |
methodHandle LinkResolver::resolve_static_call_or_null(const LinkInfo& link_info) { |
1 | 1600 |
EXCEPTION_MARK; |
1601 |
CallInfo info; |
|
31019 | 1602 |
resolve_static_call(info, link_info, /*initialize_class*/false, THREAD); |
1 | 1603 |
if (HAS_PENDING_EXCEPTION) { |
1604 |
CLEAR_PENDING_EXCEPTION; |
|
1605 |
return methodHandle(); |
|
1606 |
} |
|
1607 |
return info.selected_method(); |
|
1608 |
} |
|
1609 |
||
31019 | 1610 |
methodHandle LinkResolver::resolve_special_call_or_null(const LinkInfo& link_info) { |
1 | 1611 |
EXCEPTION_MARK; |
1612 |
CallInfo info; |
|
44738 | 1613 |
resolve_special_call(info, Handle(), link_info, THREAD); |
1 | 1614 |
if (HAS_PENDING_EXCEPTION) { |
1615 |
CLEAR_PENDING_EXCEPTION; |
|
1616 |
return methodHandle(); |
|
1617 |
} |
|
1618 |
return info.selected_method(); |
|
1619 |
} |
|
1620 |
||
1621 |
||
1622 |
||
1623 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1624 |
// ConstantPool entries |
|
1625 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1626 |
void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { |
1 | 1627 |
switch (byte) { |
1628 |
case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break; |
|
44738 | 1629 |
case Bytecodes::_invokespecial : resolve_invokespecial (result, recv, pool, index, CHECK); break; |
1 | 1630 |
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
|
1631 |
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
|
1632 |
case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; |
1 | 1633 |
case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
1634 |
default : break; |
1 | 1635 |
} |
1636 |
return; |
|
1637 |
} |
|
1638 |
||
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1639 |
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
|
1640 |
const methodHandle& attached_method, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1641 |
Bytecodes::Code byte, TRAPS) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1642 |
Klass* defc = attached_method->method_holder(); |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1643 |
Symbol* name = attached_method->name(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1644 |
Symbol* type = attached_method->signature(); |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38139
diff
changeset
|
1645 |
LinkInfo link_info(defc, name, type); |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1646 |
switch(byte) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1647 |
case Bytecodes::_invokevirtual: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1648 |
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
|
1649 |
/*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
|
1650 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1651 |
case Bytecodes::_invokeinterface: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1652 |
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
|
1653 |
/*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
|
1654 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1655 |
case Bytecodes::_invokestatic: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1656 |
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
|
1657 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1658 |
case Bytecodes::_invokespecial: |
44738 | 1659 |
resolve_special_call(result, recv, link_info, CHECK); |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1660 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1661 |
default: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1662 |
fatal("bad call: %s", Bytecodes::name(byte)); |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
1663 |
break; |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1664 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1665 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1666 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1667 |
void LinkResolver::resolve_invokestatic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1668 |
LinkInfo link_info(pool, index, CHECK); |
1669 |
resolve_static_call(result, link_info, /*initialize_class*/true, CHECK); |
|
1 | 1670 |
} |
1671 |
||
1672 |
||
44738 | 1673 |
void LinkResolver::resolve_invokespecial(CallInfo& result, Handle recv, |
1674 |
const constantPoolHandle& pool, int index, TRAPS) { |
|
31019 | 1675 |
LinkInfo link_info(pool, index, CHECK); |
44738 | 1676 |
resolve_special_call(result, recv, link_info, CHECK); |
1 | 1677 |
} |
1678 |
||
1679 |
||
1680 |
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
|
1681 |
const constantPoolHandle& pool, int index, |
1 | 1682 |
TRAPS) { |
1683 |
||
31019 | 1684 |
LinkInfo link_info(pool, index, CHECK); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1685 |
Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass(); |
31019 | 1686 |
resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK); |
1 | 1687 |
} |
1688 |
||
1689 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1690 |
void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1691 |
LinkInfo link_info(pool, index, CHECK); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1692 |
Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass(); |
31019 | 1693 |
resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK); |
1 | 1694 |
} |
1695 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1696 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1697 |
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
|
1698 |
// This guy is reached from InterpreterRuntime::resolve_invokehandle. |
31019 | 1699 |
LinkInfo link_info(pool, index, CHECK); |
16691 | 1700 |
if (TraceMethodHandles) { |
1701 |
ResourceMark rm(THREAD); |
|
31019 | 1702 |
tty->print_cr("resolve_invokehandle %s %s", link_info.name()->as_C_string(), |
1703 |
link_info.signature()->as_C_string()); |
|
16691 | 1704 |
} |
31019 | 1705 |
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
|
1706 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1707 |
|
31019 | 1708 |
void LinkResolver::resolve_handle_call(CallInfo& result, |
1709 |
const LinkInfo& link_info, |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1710 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1711 |
// JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1712 |
Klass* resolved_klass = link_info.resolved_klass(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1713 |
assert(resolved_klass == SystemDictionary::MethodHandle_klass() || |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1714 |
resolved_klass == SystemDictionary::VarHandle_klass(), ""); |
31019 | 1715 |
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
|
1716 |
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
|
1717 |
Handle resolved_method_type; |
31019 | 1718 |
methodHandle resolved_method = lookup_polymorphic_method(link_info, |
1719 |
&resolved_appendix, &resolved_method_type, CHECK); |
|
36819 | 1720 |
result.set_handle(resolved_klass, 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
|
1721 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1722 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1723 |
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
|
1724 |
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
|
1725 |
Symbol* method_signature = pool->signature_ref_at(index); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1726 |
Klass* current_klass = pool->pool_holder(); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1727 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1728 |
// 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
|
1729 |
Handle bootstrap_specifier; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1730 |
// Check if CallSite has been bound already: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1731 |
ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); |
47684
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1732 |
int pool_index = cpce->constant_pool_index(); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1733 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1734 |
if (cpce->is_f1_null()) { |
47684
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1735 |
if (cpce->indy_resolution_failed()) { |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1736 |
ConstantPool::throw_resolution_error(pool, |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1737 |
ResolutionErrorTable::encode_cpcache_index(index), |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1738 |
CHECK); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1739 |
} |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1740 |
|
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1741 |
// The initial step in Call Site Specifier Resolution is to resolve the symbolic |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1742 |
// reference to a method handle which will be the bootstrap method for a dynamic |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1743 |
// call site. If resolution for the java.lang.invoke.MethodHandle for the bootstrap |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1744 |
// method fails, then a MethodHandleInError is stored at the corresponding bootstrap |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1745 |
// method's CP index for the CONSTANT_MethodHandle_info. So, there is no need to |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1746 |
// set the indy_rf flag since any subsequent invokedynamic instruction which shares |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1747 |
// this bootstrap method will encounter the resolution of MethodHandleInError. |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1748 |
oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); |
48826 | 1749 |
Exceptions::wrap_dynamic_exception(CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1750 |
assert(bsm_info != NULL, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1751 |
// 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
|
1752 |
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
|
1753 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1754 |
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
|
1755 |
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
|
1756 |
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
|
1757 |
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
|
1758 |
result.set_handle(method, appendix, method_type, THREAD); |
48826 | 1759 |
Exceptions::wrap_dynamic_exception(CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1760 |
return; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1761 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1762 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1763 |
if (TraceMethodHandles) { |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1764 |
ResourceMark rm(THREAD); |
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1765 |
tty->print_cr("resolve_invokedynamic #%d %s %s in %s", |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1766 |
ConstantPool::decode_invokedynamic_index(index), |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1767 |
method_name->as_C_string(), method_signature->as_C_string(), |
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1768 |
current_klass->name()->as_C_string()); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1769 |
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
|
1770 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1771 |
|
48826 | 1772 |
resolve_dynamic_call(result, pool_index, bootstrap_specifier, method_name, |
47684
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1773 |
method_signature, current_klass, THREAD); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1774 |
if (HAS_PENDING_EXCEPTION && PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1775 |
int encoded_index = ResolutionErrorTable::encode_cpcache_index(index); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1776 |
bool recorded_res_status = cpce->save_and_throw_indy_exc(pool, pool_index, |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1777 |
encoded_index, |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1778 |
pool()->tag_at(pool_index), |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1779 |
CHECK); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1780 |
if (!recorded_res_status) { |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1781 |
// Another thread got here just before we did. So, either use the method |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1782 |
// that it resolved or throw the LinkageError exception that it threw. |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1783 |
if (!cpce->is_f1_null()) { |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1784 |
methodHandle method( THREAD, cpce->f1_as_method()); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1785 |
Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1786 |
Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1787 |
result.set_handle(method, appendix, method_type, THREAD); |
48826 | 1788 |
Exceptions::wrap_dynamic_exception(CHECK); |
47684
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1789 |
} else { |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1790 |
assert(cpce->indy_resolution_failed(), "Resolution failure flag not set"); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1791 |
ConstantPool::throw_resolution_error(pool, encoded_index, CHECK); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1792 |
} |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1793 |
return; |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1794 |
} |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1795 |
assert(cpce->indy_resolution_failed(), "Resolution failure flag wasn't set"); |
c3c04b6e14f8
8174954: Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
hseigel
parents:
47216
diff
changeset
|
1796 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1797 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1798 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1799 |
void LinkResolver::resolve_dynamic_call(CallInfo& result, |
48826 | 1800 |
int pool_index, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1801 |
Handle bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1802 |
Symbol* method_name, Symbol* method_signature, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46262
diff
changeset
|
1803 |
Klass* current_klass, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1804 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1805 |
// 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
|
1806 |
// 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
|
1807 |
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
|
1808 |
Handle resolved_method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1809 |
methodHandle resolved_method = |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1810 |
SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
48826 | 1811 |
pool_index, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1812 |
bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1813 |
method_name, method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1814 |
&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
|
1815 |
&resolved_method_type, |
13732
a9865f5514fc
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
13728
diff
changeset
|
1816 |
THREAD); |
48826 | 1817 |
Exceptions::wrap_dynamic_exception(CHECK); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1818 |
result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); |
48826 | 1819 |
Exceptions::wrap_dynamic_exception(CHECK); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1820 |
} |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1821 |
|
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1822 |
// Selected method is abstract. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1823 |
void LinkResolver::throw_abstract_method_error(const methodHandle& resolved_method, |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1824 |
const methodHandle& selected_method, |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1825 |
Klass *recv_klass, TRAPS) { |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1826 |
Klass *resolved_klass = resolved_method->method_holder(); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1827 |
ResourceMark rm(THREAD); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1828 |
stringStream ss; |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1829 |
|
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1830 |
if (recv_klass != NULL) { |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1831 |
ss.print("Receiver class %s does not define or inherit an " |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1832 |
"implementation of the", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1833 |
recv_klass->external_name()); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1834 |
} else { |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1835 |
ss.print("Missing implementation of"); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1836 |
} |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1837 |
|
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1838 |
assert(resolved_method.not_null(), "Sanity"); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1839 |
ss.print(" resolved method %s%s%s%s of %s %s.", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1840 |
resolved_method->is_abstract() ? "abstract " : "", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1841 |
resolved_method->is_private() ? "private " : "", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1842 |
resolved_method->name()->as_C_string(), |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1843 |
resolved_method->signature()->as_C_string(), |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1844 |
resolved_klass->external_kind(), |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1845 |
resolved_klass->external_name()); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1846 |
|
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1847 |
if (selected_method.not_null() && !(resolved_method == selected_method)) { |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1848 |
ss.print(" Selected method is %s%s%s.", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1849 |
selected_method->is_abstract() ? "abstract " : "", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1850 |
selected_method->is_private() ? "private " : "", |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1851 |
selected_method->name_and_sig_as_C_string()); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1852 |
} |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1853 |
|
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1854 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string()); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
49359
diff
changeset
|
1855 |
} |