blob: ba3556ef84083ef73f326b494f50ff73b01afbe8 [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
17#include "class.h"
18
19#include "abstract_method-inl.h"
20#include "class-inl.h"
21#include "class_linker.h"
22#include "class_loader.h"
23#include "dex_cache.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070024#include "dex_file-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080025#include "field-inl.h"
26#include "gc/card_table-inl.h"
27#include "object-inl.h"
28#include "object_array-inl.h"
29#include "object_utils.h"
30#include "runtime.h"
31#include "sirt_ref.h"
32#include "thread.h"
33#include "throwable.h"
34#include "utils.h"
35#include "well_known_classes.h"
36
37namespace art {
38namespace mirror {
39
40Class* Class::java_lang_Class_ = NULL;
41
42void Class::SetClassClass(Class* java_lang_Class) {
43 CHECK(java_lang_Class_ == NULL) << java_lang_Class_ << " " << java_lang_Class;
44 CHECK(java_lang_Class != NULL);
45 java_lang_Class_ = java_lang_Class;
46}
47
48void Class::ResetClass() {
49 CHECK(java_lang_Class_ != NULL);
50 java_lang_Class_ = NULL;
51}
52
53void Class::SetStatus(Status new_status) {
54 CHECK(new_status > GetStatus() || new_status == kStatusError || !Runtime::Current()->IsStarted())
55 << PrettyClass(this) << " " << GetStatus() << " -> " << new_status;
56 CHECK(sizeof(Status) == sizeof(uint32_t)) << PrettyClass(this);
57 if (new_status > kStatusResolved) {
58 CHECK_EQ(GetThinLockId(), Thread::Current()->GetThinLockId()) << PrettyClass(this);
59 }
60 if (new_status == kStatusError) {
61 CHECK_NE(GetStatus(), kStatusError) << PrettyClass(this);
62
63 // stash current exception
64 Thread* self = Thread::Current();
65 SirtRef<Throwable> exception(self, self->GetException());
66 CHECK(exception.get() != NULL);
67
68 // clear exception to call FindSystemClass
69 self->ClearException();
70 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
71 Class* eiie_class = class_linker->FindSystemClass("Ljava/lang/ExceptionInInitializerError;");
72 CHECK(!self->IsExceptionPending());
73
74 // only verification errors, not initialization problems, should set a verify error.
75 // this is to ensure that ThrowEarlierClassFailure will throw NoClassDefFoundError in that case.
76 Class* exception_class = exception->GetClass();
77 if (!eiie_class->IsAssignableFrom(exception_class)) {
78 SetVerifyErrorClass(exception_class);
79 }
80
81 // restore exception
82 self->SetException(exception.get());
83 }
84 return SetField32(OFFSET_OF_OBJECT_MEMBER(Class, status_), new_status, false);
85}
86
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080087void Class::SetDexCache(DexCache* new_dex_cache) {
88 SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), new_dex_cache, false);
89}
90
91Object* Class::AllocObject(Thread* self) {
92 DCHECK(!IsArrayClass()) << PrettyClass(this);
93 DCHECK(IsInstantiable()) << PrettyClass(this);
94 // TODO: decide whether we want this check. It currently fails during bootstrap.
95 // DCHECK(!Runtime::Current()->IsStarted() || IsInitializing()) << PrettyClass(this);
96 DCHECK_GE(this->object_size_, sizeof(Object));
97 return Runtime::Current()->GetHeap()->AllocObject(self, this, this->object_size_);
98}
99
100void Class::SetClassSize(size_t new_class_size) {
101 DCHECK_GE(new_class_size, GetClassSize()) << " class=" << PrettyTypeOf(this);
102 SetField32(OFFSET_OF_OBJECT_MEMBER(Class, class_size_), new_class_size, false);
103}
104
105// Return the class' name. The exact format is bizarre, but it's the specified behavior for
106// Class.getName: keywords for primitive types, regular "[I" form for primitive arrays (so "int"
107// but "[I"), and arrays of reference types written between "L" and ";" but with dots rather than
108// slashes (so "java.lang.String" but "[Ljava.lang.String;"). Madness.
109String* Class::ComputeName() {
110 String* name = GetName();
111 if (name != NULL) {
112 return name;
113 }
114 std::string descriptor(ClassHelper(this).GetDescriptor());
115 if ((descriptor[0] != 'L') && (descriptor[0] != '[')) {
116 // The descriptor indicates that this is the class for
117 // a primitive type; special-case the return value.
118 const char* c_name = NULL;
119 switch (descriptor[0]) {
120 case 'Z': c_name = "boolean"; break;
121 case 'B': c_name = "byte"; break;
122 case 'C': c_name = "char"; break;
123 case 'S': c_name = "short"; break;
124 case 'I': c_name = "int"; break;
125 case 'J': c_name = "long"; break;
126 case 'F': c_name = "float"; break;
127 case 'D': c_name = "double"; break;
128 case 'V': c_name = "void"; break;
129 default:
130 LOG(FATAL) << "Unknown primitive type: " << PrintableChar(descriptor[0]);
131 }
132 name = String::AllocFromModifiedUtf8(Thread::Current(), c_name);
133 } else {
134 // Convert the UTF-8 name to a java.lang.String. The name must use '.' to separate package
135 // components.
136 if (descriptor.size() > 2 && descriptor[0] == 'L' && descriptor[descriptor.size() - 1] == ';') {
137 descriptor.erase(0, 1);
138 descriptor.erase(descriptor.size() - 1);
139 }
140 std::replace(descriptor.begin(), descriptor.end(), '/', '.');
141 name = String::AllocFromModifiedUtf8(Thread::Current(), descriptor.c_str());
142 }
143 SetName(name);
144 return name;
145}
146
147void Class::DumpClass(std::ostream& os, int flags) const {
148 if ((flags & kDumpClassFullDetail) == 0) {
149 os << PrettyClass(this);
150 if ((flags & kDumpClassClassLoader) != 0) {
151 os << ' ' << GetClassLoader();
152 }
153 if ((flags & kDumpClassInitialized) != 0) {
154 os << ' ' << GetStatus();
155 }
156 os << "\n";
157 return;
158 }
159
160 Class* super = GetSuperClass();
161 ClassHelper kh(this);
162 os << "----- " << (IsInterface() ? "interface" : "class") << " "
163 << "'" << kh.GetDescriptor() << "' cl=" << GetClassLoader() << " -----\n",
164 os << " objectSize=" << SizeOf() << " "
165 << "(" << (super != NULL ? super->SizeOf() : -1) << " from super)\n",
166 os << StringPrintf(" access=0x%04x.%04x\n",
167 GetAccessFlags() >> 16, GetAccessFlags() & kAccJavaFlagsMask);
168 if (super != NULL) {
169 os << " super='" << PrettyClass(super) << "' (cl=" << super->GetClassLoader() << ")\n";
170 }
171 if (IsArrayClass()) {
172 os << " componentType=" << PrettyClass(GetComponentType()) << "\n";
173 }
174 if (kh.NumDirectInterfaces() > 0) {
175 os << " interfaces (" << kh.NumDirectInterfaces() << "):\n";
176 for (size_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
177 Class* interface = kh.GetDirectInterface(i);
178 const ClassLoader* cl = interface->GetClassLoader();
179 os << StringPrintf(" %2zd: %s (cl=%p)\n", i, PrettyClass(interface).c_str(), cl);
180 }
181 }
182 os << " vtable (" << NumVirtualMethods() << " entries, "
183 << (super != NULL ? super->NumVirtualMethods() : 0) << " in super):\n";
184 for (size_t i = 0; i < NumVirtualMethods(); ++i) {
185 os << StringPrintf(" %2zd: %s\n", i, PrettyMethod(GetVirtualMethodDuringLinking(i)).c_str());
186 }
187 os << " direct methods (" << NumDirectMethods() << " entries):\n";
188 for (size_t i = 0; i < NumDirectMethods(); ++i) {
189 os << StringPrintf(" %2zd: %s\n", i, PrettyMethod(GetDirectMethod(i)).c_str());
190 }
191 if (NumStaticFields() > 0) {
192 os << " static fields (" << NumStaticFields() << " entries):\n";
193 if (IsResolved() || IsErroneous()) {
194 for (size_t i = 0; i < NumStaticFields(); ++i) {
195 os << StringPrintf(" %2zd: %s\n", i, PrettyField(GetStaticField(i)).c_str());
196 }
197 } else {
198 os << " <not yet available>";
199 }
200 }
201 if (NumInstanceFields() > 0) {
202 os << " instance fields (" << NumInstanceFields() << " entries):\n";
203 if (IsResolved() || IsErroneous()) {
204 for (size_t i = 0; i < NumInstanceFields(); ++i) {
205 os << StringPrintf(" %2zd: %s\n", i, PrettyField(GetInstanceField(i)).c_str());
206 }
207 } else {
208 os << " <not yet available>";
209 }
210 }
211}
212
213void Class::SetReferenceInstanceOffsets(uint32_t new_reference_offsets) {
214 if (new_reference_offsets != CLASS_WALK_SUPER) {
215 // Sanity check that the number of bits set in the reference offset bitmap
216 // agrees with the number of references
217 size_t count = 0;
218 for (Class* c = this; c != NULL; c = c->GetSuperClass()) {
219 count += c->NumReferenceInstanceFieldsDuringLinking();
220 }
221 CHECK_EQ((size_t)__builtin_popcount(new_reference_offsets), count);
222 }
223 SetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_instance_offsets_),
224 new_reference_offsets, false);
225}
226
227void Class::SetReferenceStaticOffsets(uint32_t new_reference_offsets) {
228 if (new_reference_offsets != CLASS_WALK_SUPER) {
229 // Sanity check that the number of bits set in the reference offset bitmap
230 // agrees with the number of references
231 CHECK_EQ((size_t)__builtin_popcount(new_reference_offsets),
232 NumReferenceStaticFieldsDuringLinking());
233 }
234 SetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_static_offsets_),
235 new_reference_offsets, false);
236}
237
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800238bool Class::IsInSamePackage(const StringPiece& descriptor1, const StringPiece& descriptor2) {
239 size_t i = 0;
240 while (descriptor1[i] != '\0' && descriptor1[i] == descriptor2[i]) {
241 ++i;
242 }
243 if (descriptor1.find('/', i) != StringPiece::npos ||
244 descriptor2.find('/', i) != StringPiece::npos) {
245 return false;
246 } else {
247 return true;
248 }
249}
250
251bool Class::IsInSamePackage(const Class* that) const {
252 const Class* klass1 = this;
253 const Class* klass2 = that;
254 if (klass1 == klass2) {
255 return true;
256 }
257 // Class loaders must match.
258 if (klass1->GetClassLoader() != klass2->GetClassLoader()) {
259 return false;
260 }
261 // Arrays are in the same package when their element classes are.
262 while (klass1->IsArrayClass()) {
263 klass1 = klass1->GetComponentType();
264 }
265 while (klass2->IsArrayClass()) {
266 klass2 = klass2->GetComponentType();
267 }
Anwar Ghuloum9fa3f202013-03-26 14:32:54 -0700268 // trivial check again for array types
269 if (klass1 == klass2) {
270 return true;
271 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800272 // Compare the package part of the descriptor string.
Anwar Ghuloum9fa3f202013-03-26 14:32:54 -0700273 if (LIKELY(!klass1->IsProxyClass() && !klass2->IsProxyClass())) {
274 ClassHelper kh(klass1);
Brian Carlstrom857fe962013-03-26 22:46:15 -0700275 const DexFile* dex_file1 = &kh.GetDexFile();
276 const DexFile::TypeId* type_id1 = &dex_file1->GetTypeId(klass1->GetDexTypeIndex());
277 const char* descriptor1 = dex_file1->GetTypeDescriptor(*type_id1);
Anwar Ghuloum9fa3f202013-03-26 14:32:54 -0700278 kh.ChangeClass(klass2);
Brian Carlstrom857fe962013-03-26 22:46:15 -0700279 const DexFile* dex_file2 = &kh.GetDexFile();
280 const DexFile::TypeId* type_id2 = &dex_file2->GetTypeId(klass2->GetDexTypeIndex());
281 const char* descriptor2 = dex_file2->GetTypeDescriptor(*type_id2);
Anwar Ghuloum9fa3f202013-03-26 14:32:54 -0700282 return IsInSamePackage(descriptor1, descriptor2);
283 }
Brian Carlstrom857fe962013-03-26 22:46:15 -0700284 ClassHelper kh(klass1);
285 std::string descriptor1(kh.GetDescriptor());
286 kh.ChangeClass(klass2);
287 std::string descriptor2(kh.GetDescriptor());
288 return IsInSamePackage(descriptor1, descriptor2);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800289}
290
291bool Class::IsClassClass() const {
292 Class* java_lang_Class = GetClass()->GetClass();
293 return this == java_lang_Class;
294}
295
296bool Class::IsStringClass() const {
297 return this == String::GetJavaLangString();
298}
299
300bool Class::IsThrowableClass() const {
301 return WellKnownClasses::ToClass(WellKnownClasses::java_lang_Throwable)->IsAssignableFrom(this);
302}
303
304bool Class::IsFieldClass() const {
305 Class* java_lang_Class = GetClass();
306 Class* java_lang_reflect_Field = java_lang_Class->GetInstanceField(0)->GetClass();
307 return this == java_lang_reflect_Field;
308
309}
310
311bool Class::IsMethodClass() const {
312 return (this == AbstractMethod::GetMethodClass()) ||
313 (this == AbstractMethod::GetConstructorClass());
314
315}
316
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800317void Class::SetClassLoader(ClassLoader* new_class_loader) {
318 SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), new_class_loader, false);
319}
320
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800321AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const {
322 // Check the current class before checking the interfaces.
323 AbstractMethod* method = FindDeclaredVirtualMethod(name, signature);
324 if (method != NULL) {
325 return method;
326 }
327
328 int32_t iftable_count = GetIfTableCount();
329 IfTable* iftable = GetIfTable();
330 for (int32_t i = 0; i < iftable_count; i++) {
331 method = iftable->GetInterface(i)->FindDeclaredVirtualMethod(name, signature);
332 if (method != NULL) {
333 return method;
334 }
335 }
336 return NULL;
337}
338
339AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const {
340 // Check the current class before checking the interfaces.
341 AbstractMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx);
342 if (method != NULL) {
343 return method;
344 }
345
346 int32_t iftable_count = GetIfTableCount();
347 IfTable* iftable = GetIfTable();
348 for (int32_t i = 0; i < iftable_count; i++) {
349 method = iftable->GetInterface(i)->FindDeclaredVirtualMethod(dex_cache, dex_method_idx);
350 if (method != NULL) {
351 return method;
352 }
353 }
354 return NULL;
355}
356
357
358AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const {
359 MethodHelper mh;
360 for (size_t i = 0; i < NumDirectMethods(); ++i) {
361 AbstractMethod* method = GetDirectMethod(i);
362 mh.ChangeMethod(method);
363 if (name == mh.GetName() && signature == mh.GetSignature()) {
364 return method;
365 }
366 }
367 return NULL;
368}
369
370AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const {
371 if (GetDexCache() == dex_cache) {
372 for (size_t i = 0; i < NumDirectMethods(); ++i) {
373 AbstractMethod* method = GetDirectMethod(i);
374 if (method->GetDexMethodIndex() == dex_method_idx) {
375 return method;
376 }
377 }
378 }
379 return NULL;
380}
381
382AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const {
383 for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) {
384 AbstractMethod* method = klass->FindDeclaredDirectMethod(name, signature);
385 if (method != NULL) {
386 return method;
387 }
388 }
389 return NULL;
390}
391
392AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const {
393 for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) {
394 AbstractMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx);
395 if (method != NULL) {
396 return method;
397 }
398 }
399 return NULL;
400}
401
402AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name,
403 const StringPiece& signature) const {
404 MethodHelper mh;
405 for (size_t i = 0; i < NumVirtualMethods(); ++i) {
406 AbstractMethod* method = GetVirtualMethod(i);
407 mh.ChangeMethod(method);
408 if (name == mh.GetName() && signature == mh.GetSignature()) {
409 return method;
410 }
411 }
412 return NULL;
413}
414
415AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const {
416 if (GetDexCache() == dex_cache) {
417 for (size_t i = 0; i < NumVirtualMethods(); ++i) {
418 AbstractMethod* method = GetVirtualMethod(i);
419 if (method->GetDexMethodIndex() == dex_method_idx) {
420 return method;
421 }
422 }
423 }
424 return NULL;
425}
426
427AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const {
428 for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) {
429 AbstractMethod* method = klass->FindDeclaredVirtualMethod(name, signature);
430 if (method != NULL) {
431 return method;
432 }
433 }
434 return NULL;
435}
436
437AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const {
438 for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) {
439 AbstractMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx);
440 if (method != NULL) {
441 return method;
442 }
443 }
444 return NULL;
445}
446
447Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) {
448 // Is the field in this class?
449 // Interfaces are not relevant because they can't contain instance fields.
450 FieldHelper fh;
451 for (size_t i = 0; i < NumInstanceFields(); ++i) {
452 Field* f = GetInstanceField(i);
453 fh.ChangeField(f);
454 if (name == fh.GetName() && type == fh.GetTypeDescriptor()) {
455 return f;
456 }
457 }
458 return NULL;
459}
460
461Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) {
462 if (GetDexCache() == dex_cache) {
463 for (size_t i = 0; i < NumInstanceFields(); ++i) {
464 Field* f = GetInstanceField(i);
465 if (f->GetDexFieldIndex() == dex_field_idx) {
466 return f;
467 }
468 }
469 }
470 return NULL;
471}
472
473Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) {
474 // Is the field in this class, or any of its superclasses?
475 // Interfaces are not relevant because they can't contain instance fields.
476 for (Class* c = this; c != NULL; c = c->GetSuperClass()) {
477 Field* f = c->FindDeclaredInstanceField(name, type);
478 if (f != NULL) {
479 return f;
480 }
481 }
482 return NULL;
483}
484
485Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) {
486 // Is the field in this class, or any of its superclasses?
487 // Interfaces are not relevant because they can't contain instance fields.
488 for (Class* c = this; c != NULL; c = c->GetSuperClass()) {
489 Field* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx);
490 if (f != NULL) {
491 return f;
492 }
493 }
494 return NULL;
495}
496
497Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) {
498 DCHECK(type != NULL);
499 FieldHelper fh;
500 for (size_t i = 0; i < NumStaticFields(); ++i) {
501 Field* f = GetStaticField(i);
502 fh.ChangeField(f);
503 if (name == fh.GetName() && type == fh.GetTypeDescriptor()) {
504 return f;
505 }
506 }
507 return NULL;
508}
509
510Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) {
511 if (dex_cache == GetDexCache()) {
512 for (size_t i = 0; i < NumStaticFields(); ++i) {
513 Field* f = GetStaticField(i);
514 if (f->GetDexFieldIndex() == dex_field_idx) {
515 return f;
516 }
517 }
518 }
519 return NULL;
520}
521
522Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) {
523 // Is the field in this class (or its interfaces), or any of its
524 // superclasses (or their interfaces)?
525 ClassHelper kh;
526 for (Class* k = this; k != NULL; k = k->GetSuperClass()) {
527 // Is the field in this class?
528 Field* f = k->FindDeclaredStaticField(name, type);
529 if (f != NULL) {
530 return f;
531 }
532 // Is this field in any of this class' interfaces?
533 kh.ChangeClass(k);
534 for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
535 Class* interface = kh.GetDirectInterface(i);
536 f = interface->FindStaticField(name, type);
537 if (f != NULL) {
538 return f;
539 }
540 }
541 }
542 return NULL;
543}
544
545Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) {
546 ClassHelper kh;
547 for (Class* k = this; k != NULL; k = k->GetSuperClass()) {
548 // Is the field in this class?
549 Field* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx);
550 if (f != NULL) {
551 return f;
552 }
553 // Is this field in any of this class' interfaces?
554 kh.ChangeClass(k);
555 for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
556 Class* interface = kh.GetDirectInterface(i);
557 f = interface->FindStaticField(dex_cache, dex_field_idx);
558 if (f != NULL) {
559 return f;
560 }
561 }
562 }
563 return NULL;
564}
565
566Field* Class::FindField(const StringPiece& name, const StringPiece& type) {
567 // Find a field using the JLS field resolution order
568 ClassHelper kh;
569 for (Class* k = this; k != NULL; k = k->GetSuperClass()) {
570 // Is the field in this class?
571 Field* f = k->FindDeclaredInstanceField(name, type);
572 if (f != NULL) {
573 return f;
574 }
575 f = k->FindDeclaredStaticField(name, type);
576 if (f != NULL) {
577 return f;
578 }
579 // Is this field in any of this class' interfaces?
580 kh.ChangeClass(k);
581 for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) {
582 Class* interface = kh.GetDirectInterface(i);
583 f = interface->FindStaticField(name, type);
584 if (f != NULL) {
585 return f;
586 }
587 }
588 }
589 return NULL;
590}
591
592} // namespace mirror
593} // namespace art