blob: 7a99d3dc5ecf974d8cf15f8bf939d093089bdb2a [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_CLASS_LINKER_INL_H_
18#define ART_RUNTIME_CLASS_LINKER_INL_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
Mathieu Chartierc7853442015-03-27 14:35:38 -070020#include "art_field.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080021#include "class_linker.h"
Mathieu Chartier52e4b432014-06-10 11:22:31 -070022#include "gc/heap-inl.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070023#include "gc_root-inl.h"
24#include "handle_scope-inl.h"
Mathieu Chartier590fee92013-09-13 13:46:47 -070025#include "mirror/class_loader.h"
Mathieu Chartierbc56fc32014-06-03 15:37:03 -070026#include "mirror/dex_cache-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080027#include "mirror/iftable.h"
Andreas Gampec15a2f42017-04-21 12:09:39 -070028#include "mirror/object_array-inl.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070029#include "obj_ptr-inl.h"
Mathieu Chartierc4f39252016-10-05 18:32:08 -070030#include "scoped_thread_state_change-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031
Christina Wadsworthbf44e0e2016-08-18 10:37:42 -070032#include <atomic>
33
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080034namespace art {
35
Mathieu Chartierbc5a7952016-10-17 15:46:31 -070036inline mirror::Class* ClassLinker::FindArrayClass(Thread* self,
37 ObjPtr<mirror::Class>* element_class) {
Ian Rogers98379392014-02-24 16:53:16 -080038 for (size_t i = 0; i < kFindArrayCacheSize; ++i) {
Ian Rogersa55cf412014-02-27 00:31:26 -080039 // Read the cached array class once to avoid races with other threads setting it.
Mathieu Chartier28357fa2016-10-18 16:27:40 -070040 ObjPtr<mirror::Class> array_class = find_array_class_cache_[i].Read();
Mathieu Chartierb74cd292014-05-29 14:31:33 -070041 if (array_class != nullptr && array_class->GetComponentType() == *element_class) {
Mathieu Chartier28357fa2016-10-18 16:27:40 -070042 return array_class.Ptr();
Ian Rogers98379392014-02-24 16:53:16 -080043 }
44 }
Ian Rogers1ff3c982014-08-12 02:30:58 -070045 std::string descriptor = "[";
46 std::string temp;
47 descriptor += (*element_class)->GetDescriptor(&temp);
Mathieu Chartierb74cd292014-05-29 14:31:33 -070048 StackHandleScope<2> hs(Thread::Current());
49 Handle<mirror::ClassLoader> class_loader(hs.NewHandle((*element_class)->GetClassLoader()));
Mathieu Chartierbc5a7952016-10-17 15:46:31 -070050 HandleWrapperObjPtr<mirror::Class> h_element_class(hs.NewHandleWrapper(element_class));
Mathieu Chartier28357fa2016-10-18 16:27:40 -070051 ObjPtr<mirror::Class> array_class = FindClass(self, descriptor.c_str(), class_loader);
Nicolas Geoffray9638b642015-06-23 18:16:46 +010052 if (array_class != nullptr) {
53 // Benign races in storing array class and incrementing index.
54 size_t victim_index = find_array_class_cache_next_victim_;
55 find_array_class_cache_[victim_index] = GcRoot<mirror::Class>(array_class);
56 find_array_class_cache_next_victim_ = (victim_index + 1) % kFindArrayCacheSize;
57 } else {
58 // We should have a NoClassDefFoundError.
59 self->AssertPendingException();
60 }
Mathieu Chartier28357fa2016-10-18 16:27:40 -070061 return array_class.Ptr();
Ian Rogers98379392014-02-24 16:53:16 -080062}
63
Vladimir Marko666ee3d2017-12-11 18:37:36 +000064inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
65 ObjPtr<mirror::Class> referrer) {
66 if (kObjPtrPoisoning) {
67 StackHandleScope<1> hs(Thread::Current());
68 HandleWrapperObjPtr<mirror::Class> referrer_wrapper = hs.NewHandleWrapper(&referrer);
69 Thread::Current()->PoisonObjectPointers();
Vladimir Marko8d6768d2017-03-14 10:13:21 +000070 }
Vladimir Marko666ee3d2017-12-11 18:37:36 +000071 if (kIsDebugBuild) {
72 Thread::Current()->AssertNoPendingException();
73 }
74 // We do not need the read barrier for getting the DexCache for the initial resolved type
75 // lookup as both from-space and to-space copies point to the same native resolved types array.
76 ObjPtr<mirror::Class> resolved_type =
77 referrer->GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetResolvedType(type_idx);
78 if (resolved_type == nullptr) {
79 StackHandleScope<2> hs(Thread::Current());
80 Handle<mirror::DexCache> h_dex_cache(hs.NewHandle(referrer->GetDexCache()));
81 Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader()));
82 resolved_type = DoResolveType(type_idx, h_dex_cache, class_loader);
83 }
84 return resolved_type;
Vladimir Marko8d6768d2017-03-14 10:13:21 +000085}
86
Vladimir Marko28e012a2017-12-07 11:22:59 +000087inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
88 ArtMethod* referrer) {
Mathieu Chartiera59d9b22016-09-26 18:13:17 -070089 Thread::PoisonObjectPointersIfDebug();
Mathieu Chartierfb568d32016-12-06 13:21:38 -080090 if (kIsDebugBuild) {
91 Thread::Current()->AssertNoPendingException();
92 }
Vladimir Marko666ee3d2017-12-11 18:37:36 +000093 // We do not need the read barrier for getting the DexCache for the initial resolved type
94 // lookup as both from-space and to-space copies point to the same native resolved types array.
95 ObjPtr<mirror::Class> resolved_type =
96 referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedType(type_idx);
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070097 if (UNLIKELY(resolved_type == nullptr)) {
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070098 StackHandleScope<2> hs(Thread::Current());
Vladimir Marko666ee3d2017-12-11 18:37:36 +000099 ObjPtr<mirror::Class> referring_class = referrer->GetDeclaringClass();
Alex Light4ba388a2017-01-27 10:26:49 -0800100 Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache()));
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000101 Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referring_class->GetClassLoader()));
102 resolved_type = DoResolveType(type_idx, dex_cache, class_loader);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800103 }
Vladimir Marko28e012a2017-12-07 11:22:59 +0000104 return resolved_type;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800105}
106
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000107inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
108 Handle<mirror::DexCache> dex_cache,
109 Handle<mirror::ClassLoader> class_loader) {
110 DCHECK(dex_cache != nullptr);
111 Thread::PoisonObjectPointersIfDebug();
112 ObjPtr<mirror::Class> resolved = dex_cache->GetResolvedType(type_idx);
113 if (resolved == nullptr) {
114 resolved = DoResolveType(type_idx, dex_cache, class_loader);
115 }
116 return resolved;
117}
118
119inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type_idx,
120 ObjPtr<mirror::Class> referrer) {
121 // We do not need the read barrier for getting the DexCache for the initial resolved type
122 // lookup as both from-space and to-space copies point to the same native resolved types array.
123 ObjPtr<mirror::Class> type =
124 referrer->GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetResolvedType(type_idx);
125 if (type == nullptr) {
126 type = DoLookupResolvedType(type_idx, referrer->GetDexCache(), referrer->GetClassLoader());
127 }
128 return type;
129}
130
131inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type_idx,
132 ArtMethod* referrer) {
133 // We do not need the read barrier for getting the DexCache for the initial resolved type
134 // lookup as both from-space and to-space copies point to the same native resolved types array.
135 ObjPtr<mirror::Class> type =
136 referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedType(type_idx);
137 if (type == nullptr) {
138 type = DoLookupResolvedType(type_idx, referrer->GetDexCache(), referrer->GetClassLoader());
139 }
140 return type;
141}
142
143inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(
144 dex::TypeIndex type_idx,
145 ObjPtr<mirror::DexCache> dex_cache,
146 ObjPtr<mirror::ClassLoader> class_loader) {
147 ObjPtr<mirror::Class> type = dex_cache->GetResolvedType(type_idx);
148 if (type == nullptr) {
149 type = DoLookupResolvedType(type_idx, dex_cache, class_loader);
150 }
151 return type;
152}
153
Vladimir Markoba118822017-06-12 15:41:56 +0100154template <bool kThrowOnError, typename ClassGetter>
155inline bool ClassLinker::CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_cache,
156 InvokeType type,
157 ClassGetter class_getter) {
158 switch (type) {
159 case kStatic:
160 case kSuper:
161 break;
162 case kInterface: {
163 // We have to check whether the method id really belongs to an interface (dex static bytecode
164 // constraints A15, A16). Otherwise you must not invoke-interface on it.
165 ObjPtr<mirror::Class> klass = class_getter();
166 if (UNLIKELY(!klass->IsInterface())) {
167 if (kThrowOnError) {
168 ThrowIncompatibleClassChangeError(klass,
169 "Found class %s, but interface was expected",
170 klass->PrettyDescriptor().c_str());
171 }
172 return true;
173 }
174 break;
175 }
176 case kDirect:
Mathieu Chartierf6e31472017-12-28 13:32:08 -0800177 if (dex_cache->GetDexFile()->SupportsDefaultMethods()) {
Vladimir Markoba118822017-06-12 15:41:56 +0100178 break;
179 }
180 FALLTHROUGH_INTENDED;
181 case kVirtual: {
182 // Similarly, invoke-virtual (and invoke-direct without default methods) must reference
183 // a non-interface class (dex static bytecode constraint A24, A25).
184 ObjPtr<mirror::Class> klass = class_getter();
185 if (UNLIKELY(klass->IsInterface())) {
186 if (kThrowOnError) {
187 ThrowIncompatibleClassChangeError(klass,
188 "Found interface %s, but class was expected",
189 klass->PrettyDescriptor().c_str());
190 }
191 return true;
192 }
193 break;
194 }
195 default:
196 LOG(FATAL) << "Unreachable - invocation type: " << type;
197 UNREACHABLE();
198 }
199 return false;
200}
201
202template <bool kThrow>
203inline bool ClassLinker::CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_cache,
204 InvokeType type,
205 uint32_t method_idx,
206 ObjPtr<mirror::ClassLoader> class_loader) {
207 return CheckInvokeClassMismatch<kThrow>(
208 dex_cache,
209 type,
210 [this, dex_cache, method_idx, class_loader]() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000211 const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx);
Vladimir Markoba118822017-06-12 15:41:56 +0100212 ObjPtr<mirror::Class> klass =
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000213 LookupResolvedType(method_id.class_idx_, dex_cache, class_loader);
Vladimir Markoba118822017-06-12 15:41:56 +0100214 DCHECK(klass != nullptr);
215 return klass;
216 });
217}
218
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100219inline ArtMethod* ClassLinker::LookupResolvedMethod(uint32_t method_idx,
220 ObjPtr<mirror::DexCache> dex_cache,
221 ObjPtr<mirror::ClassLoader> class_loader) {
222 PointerSize pointer_size = image_pointer_size_;
223 ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx, pointer_size);
224 if (resolved == nullptr) {
225 const DexFile& dex_file = *dex_cache->GetDexFile();
226 const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
227 ObjPtr<mirror::Class> klass = LookupResolvedType(method_id.class_idx_, dex_cache, class_loader);
228 if (klass != nullptr) {
Nicolas Geoffrayea179f42018-02-08 22:30:18 +0000229 resolved = FindResolvedMethod(klass, dex_cache, class_loader, method_idx);
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100230 }
231 }
232 return resolved;
233}
234
Vladimir Markoba118822017-06-12 15:41:56 +0100235template <InvokeType type, ClassLinker::ResolveMode kResolveMode>
Mathieu Chartiere401d142015-04-22 13:56:20 -0700236inline ArtMethod* ClassLinker::GetResolvedMethod(uint32_t method_idx, ArtMethod* referrer) {
Vladimir Markoba118822017-06-12 15:41:56 +0100237 DCHECK(referrer != nullptr);
238 // Note: The referrer can be a Proxy constructor. In that case, we need to do the
239 // lookup in the context of the original method from where it steals the code.
240 // However, we delay the GetInterfaceMethodIfProxy() until needed.
241 DCHECK(!referrer->IsProxyMethod() || referrer->IsConstructor());
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000242 // We do not need the read barrier for getting the DexCache for the initial resolved method
243 // lookup as both from-space and to-space copies point to the same native resolved methods array.
Vladimir Marko5122e6b2017-08-17 16:10:09 +0100244 ArtMethod* resolved_method = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedMethod(
245 method_idx, image_pointer_size_);
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100246 if (resolved_method == nullptr) {
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700247 return nullptr;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800248 }
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100249 DCHECK(!resolved_method->IsRuntimeMethod());
Vladimir Markoba118822017-06-12 15:41:56 +0100250 if (kResolveMode == ResolveMode::kCheckICCEAndIAE) {
251 referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_);
252 // Check if the invoke type matches the class type.
253 ObjPtr<mirror::DexCache> dex_cache = referrer->GetDexCache();
254 ObjPtr<mirror::ClassLoader> class_loader = referrer->GetClassLoader();
255 if (CheckInvokeClassMismatch</* kThrow */ false>(dex_cache, type, method_idx, class_loader)) {
256 return nullptr;
257 }
258 // Check access.
259 ObjPtr<mirror::Class> referring_class = referrer->GetDeclaringClass();
260 if (!referring_class->CanAccessResolvedMethod(resolved_method->GetDeclaringClass(),
261 resolved_method,
262 dex_cache,
263 method_idx)) {
264 return nullptr;
265 }
266 // Check if the invoke type matches the method type.
267 if (UNLIKELY(resolved_method->CheckIncompatibleClassChange(type))) {
268 return nullptr;
269 }
Alex Lightfedd91d2016-01-07 14:49:16 -0800270 }
Vladimir Markoba118822017-06-12 15:41:56 +0100271 return resolved_method;
Alex Lightfedd91d2016-01-07 14:49:16 -0800272}
273
Andreas Gampe42ef8ab2015-12-03 17:27:32 -0800274template <ClassLinker::ResolveMode kResolveMode>
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700275inline ArtMethod* ClassLinker::ResolveMethod(Thread* self,
276 uint32_t method_idx,
277 ArtMethod* referrer,
278 InvokeType type) {
Vladimir Markoba118822017-06-12 15:41:56 +0100279 DCHECK(referrer != nullptr);
280 // Note: The referrer can be a Proxy constructor. In that case, we need to do the
281 // lookup in the context of the original method from where it steals the code.
282 // However, we delay the GetInterfaceMethodIfProxy() until needed.
283 DCHECK(!referrer->IsProxyMethod() || referrer->IsConstructor());
Mathieu Chartiera59d9b22016-09-26 18:13:17 -0700284 Thread::PoisonObjectPointersIfDebug();
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000285 // We do not need the read barrier for getting the DexCache for the initial resolved method
286 // lookup as both from-space and to-space copies point to the same native resolved methods array.
Vladimir Marko5122e6b2017-08-17 16:10:09 +0100287 ArtMethod* resolved_method = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedMethod(
288 method_idx, image_pointer_size_);
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100289 DCHECK(resolved_method == nullptr || !resolved_method->IsRuntimeMethod());
290 if (UNLIKELY(resolved_method == nullptr)) {
Vladimir Markoba118822017-06-12 15:41:56 +0100291 referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_);
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700292 ObjPtr<mirror::Class> declaring_class = referrer->GetDeclaringClass();
Mathieu Chartiere401d142015-04-22 13:56:20 -0700293 StackHandleScope<2> hs(self);
Alex Light4ba388a2017-01-27 10:26:49 -0800294 Handle<mirror::DexCache> h_dex_cache(hs.NewHandle(referrer->GetDexCache()));
Mathieu Chartiere401d142015-04-22 13:56:20 -0700295 Handle<mirror::ClassLoader> h_class_loader(hs.NewHandle(declaring_class->GetClassLoader()));
Vladimir Marko89011192017-12-11 13:45:05 +0000296 resolved_method = ResolveMethod<kResolveMode>(method_idx,
Andreas Gampe42ef8ab2015-12-03 17:27:32 -0800297 h_dex_cache,
298 h_class_loader,
299 referrer,
300 type);
Vladimir Markoba118822017-06-12 15:41:56 +0100301 } else if (kResolveMode == ResolveMode::kCheckICCEAndIAE) {
302 referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_);
303 // Check if the invoke type matches the class type.
304 ObjPtr<mirror::DexCache> dex_cache = referrer->GetDexCache();
305 ObjPtr<mirror::ClassLoader> class_loader = referrer->GetClassLoader();
306 if (CheckInvokeClassMismatch</* kThrow */ true>(dex_cache, type, method_idx, class_loader)) {
307 DCHECK(Thread::Current()->IsExceptionPending());
308 return nullptr;
309 }
310 // Check access.
311 ObjPtr<mirror::Class> referring_class = referrer->GetDeclaringClass();
312 if (!referring_class->CheckResolvedMethodAccess(resolved_method->GetDeclaringClass(),
313 resolved_method,
314 dex_cache,
315 method_idx,
316 type)) {
317 DCHECK(Thread::Current()->IsExceptionPending());
318 return nullptr;
319 }
320 // Check if the invoke type matches the method type.
321 if (UNLIKELY(resolved_method->CheckIncompatibleClassChange(type))) {
322 ThrowIncompatibleClassChangeError(type,
323 resolved_method->GetInvokeType(),
324 resolved_method,
325 referrer);
326 return nullptr;
327 }
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700328 }
Andreas Gampe58a5af82014-07-31 16:23:49 -0700329 // Note: We cannot check here to see whether we added the method to the cache. It
330 // might be an erroneous class, which results in it being hidden from us.
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700331 return resolved_method;
332}
333
Vladimir Markof44d36c2017-03-14 14:18:46 +0000334inline ArtField* ClassLinker::LookupResolvedField(uint32_t field_idx,
335 ArtMethod* referrer,
336 bool is_static) {
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000337 // We do not need the read barrier for getting the DexCache for the initial resolved field
338 // lookup as both from-space and to-space copies point to the same native resolved fields array.
339 ArtField* field = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedField(
340 field_idx, image_pointer_size_);
Vladimir Markof44d36c2017-03-14 14:18:46 +0000341 if (field == nullptr) {
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000342 ObjPtr<mirror::ClassLoader> class_loader = referrer->GetDeclaringClass()->GetClassLoader();
343 field = LookupResolvedField(field_idx, referrer->GetDexCache(), class_loader, is_static);
Vladimir Markof44d36c2017-03-14 14:18:46 +0000344 }
345 return field;
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700346}
347
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700348inline ArtField* ClassLinker::ResolveField(uint32_t field_idx,
349 ArtMethod* referrer,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700350 bool is_static) {
Mathieu Chartiera59d9b22016-09-26 18:13:17 -0700351 Thread::PoisonObjectPointersIfDebug();
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000352 // We do not need the read barrier for getting the DexCache for the initial resolved field
353 // lookup as both from-space and to-space copies point to the same native resolved fields array.
354 ArtField* resolved_field = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedField(
355 field_idx, image_pointer_size_);
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700356 if (UNLIKELY(resolved_field == nullptr)) {
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700357 StackHandleScope<2> hs(Thread::Current());
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000358 ObjPtr<mirror::Class> referring_class = referrer->GetDeclaringClass();
Alex Lightdba61482016-12-21 08:20:29 -0800359 Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache()));
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000360 Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referring_class->GetClassLoader()));
Vladimir Markoe11dd502017-12-08 14:09:45 +0000361 resolved_field = ResolveField(field_idx, dex_cache, class_loader, is_static);
Andreas Gampe58a5af82014-07-31 16:23:49 -0700362 // Note: We cannot check here to see whether we added the field to the cache. The type
363 // might be an erroneous class, which results in it being hidden from us.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800364 }
365 return resolved_field;
366}
367
Mathieu Chartier72041a02017-07-14 18:23:25 -0700368template <class Visitor>
369inline void ClassLinker::VisitClassTables(const Visitor& visitor) {
370 Thread* const self = Thread::Current();
371 WriterMutexLock mu(self, *Locks::classlinker_classes_lock_);
372 for (const ClassLoaderData& data : class_loaders_) {
373 if (data.class_table != nullptr) {
374 visitor(data.class_table);
375 }
376 }
377}
378
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800379} // namespace art
380
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700381#endif // ART_RUNTIME_CLASS_LINKER_INL_H_