Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 19 | #include "art_field-inl.h" |
| 20 | #include "art_method-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 21 | #include "class-inl.h" |
| 22 | #include "class_linker.h" |
| 23 | #include "class_loader.h" |
| 24 | #include "dex_cache.h" |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 25 | #include "dex_file-inl.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 26 | #include "gc/accounting/card_table-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 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 | |
| 37 | namespace art { |
| 38 | namespace mirror { |
| 39 | |
| 40 | Class* Class::java_lang_Class_ = NULL; |
| 41 | |
| 42 | void 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 | |
| 48 | void Class::ResetClass() { |
| 49 | CHECK(java_lang_Class_ != NULL); |
| 50 | java_lang_Class_ = NULL; |
| 51 | } |
| 52 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 53 | void Class::SetStatus(Status new_status, Thread* self) { |
| 54 | Status old_status = GetStatus(); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame^] | 55 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 56 | bool class_linker_initialized = class_linker != nullptr && class_linker->IsInitialized(); |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 57 | if (LIKELY(class_linker_initialized)) { |
| 58 | if (UNLIKELY(new_status <= old_status && new_status != kStatusError)) { |
Ian Rogers | 8f3c9ae | 2013-08-20 17:26:41 -0700 | [diff] [blame] | 59 | LOG(FATAL) << "Unexpected change back of class status for " << PrettyClass(this) << " " |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 60 | << old_status << " -> " << new_status; |
Ian Rogers | 8f3c9ae | 2013-08-20 17:26:41 -0700 | [diff] [blame] | 61 | } |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 62 | if (new_status >= kStatusResolved || old_status >= kStatusResolved) { |
| 63 | // When classes are being resolved the resolution code should hold the lock. |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 64 | CHECK_EQ(GetLockOwnerThreadId(), self->GetThreadId()) |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 65 | << "Attempt to change status of class while not holding its lock: " |
| 66 | << PrettyClass(this) << " " << old_status << " -> " << new_status; |
| 67 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 68 | } |
| 69 | if (new_status == kStatusError) { |
Ian Rogers | 8f3c9ae | 2013-08-20 17:26:41 -0700 | [diff] [blame] | 70 | CHECK_NE(GetStatus(), kStatusError) |
| 71 | << "Attempt to set as erroneous an already erroneous class " << PrettyClass(this); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 72 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 73 | // Stash current exception. |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 74 | SirtRef<mirror::Object> old_throw_this_object(self, NULL); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 75 | SirtRef<mirror::ArtMethod> old_throw_method(self, NULL); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 76 | SirtRef<mirror::Throwable> old_exception(self, NULL); |
| 77 | uint32_t old_throw_dex_pc; |
| 78 | { |
| 79 | ThrowLocation old_throw_location; |
| 80 | mirror::Throwable* old_exception_obj = self->GetException(&old_throw_location); |
| 81 | old_throw_this_object.reset(old_throw_location.GetThis()); |
| 82 | old_throw_method.reset(old_throw_location.GetMethod()); |
| 83 | old_exception.reset(old_exception_obj); |
| 84 | old_throw_dex_pc = old_throw_location.GetDexPc(); |
| 85 | self->ClearException(); |
| 86 | } |
| 87 | CHECK(old_exception.get() != NULL); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 88 | |
| 89 | // clear exception to call FindSystemClass |
| 90 | self->ClearException(); |
| 91 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 92 | Class* eiie_class = class_linker->FindSystemClass("Ljava/lang/ExceptionInInitializerError;"); |
| 93 | CHECK(!self->IsExceptionPending()); |
| 94 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 95 | // Only verification errors, not initialization problems, should set a verify error. |
| 96 | // This is to ensure that ThrowEarlierClassFailure will throw NoClassDefFoundError in that case. |
| 97 | Class* exception_class = old_exception->GetClass(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 98 | if (!eiie_class->IsAssignableFrom(exception_class)) { |
| 99 | SetVerifyErrorClass(exception_class); |
| 100 | } |
| 101 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 102 | // Restore exception. |
| 103 | ThrowLocation gc_safe_throw_location(old_throw_this_object.get(), old_throw_method.get(), |
| 104 | old_throw_dex_pc); |
| 105 | |
| 106 | self->SetException(gc_safe_throw_location, old_exception.get()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 107 | } |
Ian Rogers | 8f3c9ae | 2013-08-20 17:26:41 -0700 | [diff] [blame] | 108 | CHECK(sizeof(Status) == sizeof(uint32_t)) << PrettyClass(this); |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 109 | SetField32(OFFSET_OF_OBJECT_MEMBER(Class, status_), new_status, false); |
| 110 | // Classes that are being resolved or initialized need to notify waiters that the class status |
| 111 | // changed. See ClassLinker::EnsureResolved and ClassLinker::WaitForInitializeClass. |
| 112 | if ((old_status >= kStatusResolved || new_status >= kStatusResolved) && |
| 113 | class_linker_initialized) { |
| 114 | NotifyAll(self); |
| 115 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 116 | } |
| 117 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 118 | void Class::SetDexCache(DexCache* new_dex_cache) { |
| 119 | SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), new_dex_cache, false); |
| 120 | } |
| 121 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 122 | void Class::SetClassSize(size_t new_class_size) { |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 123 | if (kIsDebugBuild && (new_class_size < GetClassSize())) { |
| 124 | DumpClass(LOG(ERROR), kDumpClassFullDetail); |
| 125 | CHECK_GE(new_class_size, GetClassSize()) << " class=" << PrettyTypeOf(this); |
| 126 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 127 | SetField32(OFFSET_OF_OBJECT_MEMBER(Class, class_size_), new_class_size, false); |
| 128 | } |
| 129 | |
| 130 | // Return the class' name. The exact format is bizarre, but it's the specified behavior for |
| 131 | // Class.getName: keywords for primitive types, regular "[I" form for primitive arrays (so "int" |
| 132 | // but "[I"), and arrays of reference types written between "L" and ";" but with dots rather than |
| 133 | // slashes (so "java.lang.String" but "[Ljava.lang.String;"). Madness. |
| 134 | String* Class::ComputeName() { |
| 135 | String* name = GetName(); |
| 136 | if (name != NULL) { |
| 137 | return name; |
| 138 | } |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 139 | std::string descriptor(ClassHelper(this).GetDescriptor()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 140 | if ((descriptor[0] != 'L') && (descriptor[0] != '[')) { |
| 141 | // The descriptor indicates that this is the class for |
| 142 | // a primitive type; special-case the return value. |
| 143 | const char* c_name = NULL; |
| 144 | switch (descriptor[0]) { |
| 145 | case 'Z': c_name = "boolean"; break; |
| 146 | case 'B': c_name = "byte"; break; |
| 147 | case 'C': c_name = "char"; break; |
| 148 | case 'S': c_name = "short"; break; |
| 149 | case 'I': c_name = "int"; break; |
| 150 | case 'J': c_name = "long"; break; |
| 151 | case 'F': c_name = "float"; break; |
| 152 | case 'D': c_name = "double"; break; |
| 153 | case 'V': c_name = "void"; break; |
| 154 | default: |
| 155 | LOG(FATAL) << "Unknown primitive type: " << PrintableChar(descriptor[0]); |
| 156 | } |
| 157 | name = String::AllocFromModifiedUtf8(Thread::Current(), c_name); |
| 158 | } else { |
| 159 | // Convert the UTF-8 name to a java.lang.String. The name must use '.' to separate package |
| 160 | // components. |
| 161 | if (descriptor.size() > 2 && descriptor[0] == 'L' && descriptor[descriptor.size() - 1] == ';') { |
| 162 | descriptor.erase(0, 1); |
| 163 | descriptor.erase(descriptor.size() - 1); |
| 164 | } |
| 165 | std::replace(descriptor.begin(), descriptor.end(), '/', '.'); |
| 166 | name = String::AllocFromModifiedUtf8(Thread::Current(), descriptor.c_str()); |
| 167 | } |
| 168 | SetName(name); |
| 169 | return name; |
| 170 | } |
| 171 | |
| 172 | void Class::DumpClass(std::ostream& os, int flags) const { |
| 173 | if ((flags & kDumpClassFullDetail) == 0) { |
| 174 | os << PrettyClass(this); |
| 175 | if ((flags & kDumpClassClassLoader) != 0) { |
| 176 | os << ' ' << GetClassLoader(); |
| 177 | } |
| 178 | if ((flags & kDumpClassInitialized) != 0) { |
| 179 | os << ' ' << GetStatus(); |
| 180 | } |
| 181 | os << "\n"; |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | Class* super = GetSuperClass(); |
| 186 | ClassHelper kh(this); |
| 187 | os << "----- " << (IsInterface() ? "interface" : "class") << " " |
| 188 | << "'" << kh.GetDescriptor() << "' cl=" << GetClassLoader() << " -----\n", |
| 189 | os << " objectSize=" << SizeOf() << " " |
| 190 | << "(" << (super != NULL ? super->SizeOf() : -1) << " from super)\n", |
| 191 | os << StringPrintf(" access=0x%04x.%04x\n", |
| 192 | GetAccessFlags() >> 16, GetAccessFlags() & kAccJavaFlagsMask); |
| 193 | if (super != NULL) { |
| 194 | os << " super='" << PrettyClass(super) << "' (cl=" << super->GetClassLoader() << ")\n"; |
| 195 | } |
| 196 | if (IsArrayClass()) { |
| 197 | os << " componentType=" << PrettyClass(GetComponentType()) << "\n"; |
| 198 | } |
| 199 | if (kh.NumDirectInterfaces() > 0) { |
| 200 | os << " interfaces (" << kh.NumDirectInterfaces() << "):\n"; |
| 201 | for (size_t i = 0; i < kh.NumDirectInterfaces(); ++i) { |
| 202 | Class* interface = kh.GetDirectInterface(i); |
| 203 | const ClassLoader* cl = interface->GetClassLoader(); |
| 204 | os << StringPrintf(" %2zd: %s (cl=%p)\n", i, PrettyClass(interface).c_str(), cl); |
| 205 | } |
| 206 | } |
| 207 | os << " vtable (" << NumVirtualMethods() << " entries, " |
| 208 | << (super != NULL ? super->NumVirtualMethods() : 0) << " in super):\n"; |
| 209 | for (size_t i = 0; i < NumVirtualMethods(); ++i) { |
| 210 | os << StringPrintf(" %2zd: %s\n", i, PrettyMethod(GetVirtualMethodDuringLinking(i)).c_str()); |
| 211 | } |
| 212 | os << " direct methods (" << NumDirectMethods() << " entries):\n"; |
| 213 | for (size_t i = 0; i < NumDirectMethods(); ++i) { |
| 214 | os << StringPrintf(" %2zd: %s\n", i, PrettyMethod(GetDirectMethod(i)).c_str()); |
| 215 | } |
| 216 | if (NumStaticFields() > 0) { |
| 217 | os << " static fields (" << NumStaticFields() << " entries):\n"; |
| 218 | if (IsResolved() || IsErroneous()) { |
| 219 | for (size_t i = 0; i < NumStaticFields(); ++i) { |
| 220 | os << StringPrintf(" %2zd: %s\n", i, PrettyField(GetStaticField(i)).c_str()); |
| 221 | } |
| 222 | } else { |
| 223 | os << " <not yet available>"; |
| 224 | } |
| 225 | } |
| 226 | if (NumInstanceFields() > 0) { |
| 227 | os << " instance fields (" << NumInstanceFields() << " entries):\n"; |
| 228 | if (IsResolved() || IsErroneous()) { |
| 229 | for (size_t i = 0; i < NumInstanceFields(); ++i) { |
| 230 | os << StringPrintf(" %2zd: %s\n", i, PrettyField(GetInstanceField(i)).c_str()); |
| 231 | } |
| 232 | } else { |
| 233 | os << " <not yet available>"; |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | void Class::SetReferenceInstanceOffsets(uint32_t new_reference_offsets) { |
| 239 | if (new_reference_offsets != CLASS_WALK_SUPER) { |
| 240 | // Sanity check that the number of bits set in the reference offset bitmap |
| 241 | // agrees with the number of references |
| 242 | size_t count = 0; |
| 243 | for (Class* c = this; c != NULL; c = c->GetSuperClass()) { |
| 244 | count += c->NumReferenceInstanceFieldsDuringLinking(); |
| 245 | } |
| 246 | CHECK_EQ((size_t)__builtin_popcount(new_reference_offsets), count); |
| 247 | } |
| 248 | SetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_instance_offsets_), |
| 249 | new_reference_offsets, false); |
| 250 | } |
| 251 | |
| 252 | void Class::SetReferenceStaticOffsets(uint32_t new_reference_offsets) { |
| 253 | if (new_reference_offsets != CLASS_WALK_SUPER) { |
| 254 | // Sanity check that the number of bits set in the reference offset bitmap |
| 255 | // agrees with the number of references |
| 256 | CHECK_EQ((size_t)__builtin_popcount(new_reference_offsets), |
| 257 | NumReferenceStaticFieldsDuringLinking()); |
| 258 | } |
| 259 | SetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_static_offsets_), |
| 260 | new_reference_offsets, false); |
| 261 | } |
| 262 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 263 | bool Class::IsInSamePackage(const StringPiece& descriptor1, const StringPiece& descriptor2) { |
| 264 | size_t i = 0; |
| 265 | while (descriptor1[i] != '\0' && descriptor1[i] == descriptor2[i]) { |
| 266 | ++i; |
| 267 | } |
| 268 | if (descriptor1.find('/', i) != StringPiece::npos || |
| 269 | descriptor2.find('/', i) != StringPiece::npos) { |
| 270 | return false; |
| 271 | } else { |
| 272 | return true; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | bool Class::IsInSamePackage(const Class* that) const { |
| 277 | const Class* klass1 = this; |
| 278 | const Class* klass2 = that; |
| 279 | if (klass1 == klass2) { |
| 280 | return true; |
| 281 | } |
| 282 | // Class loaders must match. |
| 283 | if (klass1->GetClassLoader() != klass2->GetClassLoader()) { |
| 284 | return false; |
| 285 | } |
| 286 | // Arrays are in the same package when their element classes are. |
| 287 | while (klass1->IsArrayClass()) { |
| 288 | klass1 = klass1->GetComponentType(); |
| 289 | } |
| 290 | while (klass2->IsArrayClass()) { |
| 291 | klass2 = klass2->GetComponentType(); |
| 292 | } |
Anwar Ghuloum | 9fa3f20 | 2013-03-26 14:32:54 -0700 | [diff] [blame] | 293 | // trivial check again for array types |
| 294 | if (klass1 == klass2) { |
| 295 | return true; |
| 296 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 297 | // Compare the package part of the descriptor string. |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 298 | return IsInSamePackage(ClassHelper(klass1).GetDescriptor(), |
| 299 | ClassHelper(klass2).GetDescriptor()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | bool Class::IsClassClass() const { |
| 303 | Class* java_lang_Class = GetClass()->GetClass(); |
| 304 | return this == java_lang_Class; |
| 305 | } |
| 306 | |
| 307 | bool Class::IsStringClass() const { |
| 308 | return this == String::GetJavaLangString(); |
| 309 | } |
| 310 | |
| 311 | bool Class::IsThrowableClass() const { |
| 312 | return WellKnownClasses::ToClass(WellKnownClasses::java_lang_Throwable)->IsAssignableFrom(this); |
| 313 | } |
| 314 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 315 | bool Class::IsArtFieldClass() const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 316 | Class* java_lang_Class = GetClass(); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 317 | Class* java_lang_reflect_ArtField = java_lang_Class->GetInstanceField(0)->GetClass(); |
| 318 | return this == java_lang_reflect_ArtField; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 319 | } |
| 320 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 321 | bool Class::IsArtMethodClass() const { |
| 322 | return this == ArtMethod::GetJavaLangReflectArtMethod(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 325 | void Class::SetClassLoader(ClassLoader* new_class_loader) { |
| 326 | SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), new_class_loader, false); |
| 327 | } |
| 328 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 329 | ArtMethod* Class::FindInterfaceMethod(const StringPiece& name, const Signature& signature) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 330 | // Check the current class before checking the interfaces. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 331 | ArtMethod* method = FindDeclaredVirtualMethod(name, signature); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 332 | if (method != NULL) { |
| 333 | return method; |
| 334 | } |
| 335 | |
| 336 | int32_t iftable_count = GetIfTableCount(); |
| 337 | IfTable* iftable = GetIfTable(); |
| 338 | for (int32_t i = 0; i < iftable_count; i++) { |
| 339 | method = iftable->GetInterface(i)->FindDeclaredVirtualMethod(name, signature); |
| 340 | if (method != NULL) { |
| 341 | return method; |
| 342 | } |
| 343 | } |
| 344 | return NULL; |
| 345 | } |
| 346 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 347 | ArtMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 348 | // Check the current class before checking the interfaces. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 349 | ArtMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 350 | if (method != NULL) { |
| 351 | return method; |
| 352 | } |
| 353 | |
| 354 | int32_t iftable_count = GetIfTableCount(); |
| 355 | IfTable* iftable = GetIfTable(); |
| 356 | for (int32_t i = 0; i < iftable_count; i++) { |
| 357 | method = iftable->GetInterface(i)->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); |
| 358 | if (method != NULL) { |
| 359 | return method; |
| 360 | } |
| 361 | } |
| 362 | return NULL; |
| 363 | } |
| 364 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 365 | ArtMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 366 | MethodHelper mh; |
| 367 | for (size_t i = 0; i < NumDirectMethods(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 368 | ArtMethod* method = GetDirectMethod(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 369 | mh.ChangeMethod(method); |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 370 | if (name == mh.GetName() && mh.GetSignature() == signature) { |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 371 | return method; |
| 372 | } |
| 373 | } |
| 374 | return NULL; |
| 375 | } |
| 376 | |
| 377 | ArtMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const Signature& signature) const { |
| 378 | MethodHelper mh; |
| 379 | for (size_t i = 0; i < NumDirectMethods(); ++i) { |
| 380 | ArtMethod* method = GetDirectMethod(i); |
| 381 | mh.ChangeMethod(method); |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 382 | if (name == mh.GetName() && signature == mh.GetSignature()) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 383 | return method; |
| 384 | } |
| 385 | } |
| 386 | return NULL; |
| 387 | } |
| 388 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 389 | ArtMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 390 | if (GetDexCache() == dex_cache) { |
| 391 | for (size_t i = 0; i < NumDirectMethods(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 392 | ArtMethod* method = GetDirectMethod(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 393 | if (method->GetDexMethodIndex() == dex_method_idx) { |
| 394 | return method; |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | return NULL; |
| 399 | } |
| 400 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 401 | ArtMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 402 | for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 403 | ArtMethod* method = klass->FindDeclaredDirectMethod(name, signature); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 404 | if (method != NULL) { |
| 405 | return method; |
| 406 | } |
| 407 | } |
| 408 | return NULL; |
| 409 | } |
| 410 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 411 | ArtMethod* Class::FindDirectMethod(const StringPiece& name, const Signature& signature) const { |
| 412 | for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { |
| 413 | ArtMethod* method = klass->FindDeclaredDirectMethod(name, signature); |
| 414 | if (method != NULL) { |
| 415 | return method; |
| 416 | } |
| 417 | } |
| 418 | return NULL; |
| 419 | } |
| 420 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 421 | ArtMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 422 | for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 423 | ArtMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 424 | if (method != NULL) { |
| 425 | return method; |
| 426 | } |
| 427 | } |
| 428 | return NULL; |
| 429 | } |
| 430 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 431 | ArtMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const { |
| 432 | MethodHelper mh; |
| 433 | for (size_t i = 0; i < NumVirtualMethods(); ++i) { |
| 434 | ArtMethod* method = GetVirtualMethod(i); |
| 435 | mh.ChangeMethod(method); |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 436 | if (name == mh.GetName() && mh.GetSignature() == signature) { |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 437 | return method; |
| 438 | } |
| 439 | } |
| 440 | return NULL; |
| 441 | } |
| 442 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 443 | ArtMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 444 | const Signature& signature) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 445 | MethodHelper mh; |
| 446 | for (size_t i = 0; i < NumVirtualMethods(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 447 | ArtMethod* method = GetVirtualMethod(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 448 | mh.ChangeMethod(method); |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 449 | if (name == mh.GetName() && signature == mh.GetSignature()) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 450 | return method; |
| 451 | } |
| 452 | } |
| 453 | return NULL; |
| 454 | } |
| 455 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 456 | ArtMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 457 | if (GetDexCache() == dex_cache) { |
| 458 | for (size_t i = 0; i < NumVirtualMethods(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 459 | ArtMethod* method = GetVirtualMethod(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 460 | if (method->GetDexMethodIndex() == dex_method_idx) { |
| 461 | return method; |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | return NULL; |
| 466 | } |
| 467 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 468 | ArtMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 469 | for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 470 | ArtMethod* method = klass->FindDeclaredVirtualMethod(name, signature); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 471 | if (method != NULL) { |
| 472 | return method; |
| 473 | } |
| 474 | } |
| 475 | return NULL; |
| 476 | } |
| 477 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 478 | ArtMethod* Class::FindVirtualMethod(const StringPiece& name, const Signature& signature) const { |
| 479 | for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { |
| 480 | ArtMethod* method = klass->FindDeclaredVirtualMethod(name, signature); |
| 481 | if (method != NULL) { |
| 482 | return method; |
| 483 | } |
| 484 | } |
| 485 | return NULL; |
| 486 | } |
| 487 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 488 | ArtMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 489 | for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 490 | ArtMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 491 | if (method != NULL) { |
| 492 | return method; |
| 493 | } |
| 494 | } |
| 495 | return NULL; |
| 496 | } |
| 497 | |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 498 | ArtMethod* Class::FindClassInitializer() const { |
| 499 | for (size_t i = 0; i < NumDirectMethods(); ++i) { |
| 500 | ArtMethod* method = GetDirectMethod(i); |
| 501 | if (method->IsConstructor() && method->IsStatic()) { |
| 502 | if (kIsDebugBuild) { |
| 503 | MethodHelper mh(method); |
Ian Rogers | 241b5de | 2013-10-09 17:58:57 -0700 | [diff] [blame] | 504 | CHECK(mh.IsClassInitializer()); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 505 | CHECK_STREQ(mh.GetName(), "<clinit>"); |
| 506 | CHECK_STREQ(mh.GetSignature().ToString().c_str(), "()V"); |
| 507 | } |
| 508 | return method; |
| 509 | } |
| 510 | } |
| 511 | return NULL; |
| 512 | } |
| 513 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 514 | ArtField* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 515 | // Is the field in this class? |
| 516 | // Interfaces are not relevant because they can't contain instance fields. |
| 517 | FieldHelper fh; |
| 518 | for (size_t i = 0; i < NumInstanceFields(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 519 | ArtField* f = GetInstanceField(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 520 | fh.ChangeField(f); |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 521 | if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 522 | return f; |
| 523 | } |
| 524 | } |
| 525 | return NULL; |
| 526 | } |
| 527 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 528 | ArtField* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 529 | if (GetDexCache() == dex_cache) { |
| 530 | for (size_t i = 0; i < NumInstanceFields(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 531 | ArtField* f = GetInstanceField(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 532 | if (f->GetDexFieldIndex() == dex_field_idx) { |
| 533 | return f; |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | return NULL; |
| 538 | } |
| 539 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 540 | ArtField* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 541 | // Is the field in this class, or any of its superclasses? |
| 542 | // Interfaces are not relevant because they can't contain instance fields. |
| 543 | for (Class* c = this; c != NULL; c = c->GetSuperClass()) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 544 | ArtField* f = c->FindDeclaredInstanceField(name, type); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 545 | if (f != NULL) { |
| 546 | return f; |
| 547 | } |
| 548 | } |
| 549 | return NULL; |
| 550 | } |
| 551 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 552 | ArtField* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 553 | // Is the field in this class, or any of its superclasses? |
| 554 | // Interfaces are not relevant because they can't contain instance fields. |
| 555 | for (Class* c = this; c != NULL; c = c->GetSuperClass()) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 556 | ArtField* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 557 | if (f != NULL) { |
| 558 | return f; |
| 559 | } |
| 560 | } |
| 561 | return NULL; |
| 562 | } |
| 563 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 564 | ArtField* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 565 | DCHECK(type != NULL); |
| 566 | FieldHelper fh; |
| 567 | for (size_t i = 0; i < NumStaticFields(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 568 | ArtField* f = GetStaticField(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 569 | fh.ChangeField(f); |
Ian Rogers | dfb325e | 2013-10-30 01:00:44 -0700 | [diff] [blame] | 570 | if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 571 | return f; |
| 572 | } |
| 573 | } |
| 574 | return NULL; |
| 575 | } |
| 576 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 577 | ArtField* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 578 | if (dex_cache == GetDexCache()) { |
| 579 | for (size_t i = 0; i < NumStaticFields(); ++i) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 580 | ArtField* f = GetStaticField(i); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 581 | if (f->GetDexFieldIndex() == dex_field_idx) { |
| 582 | return f; |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | return NULL; |
| 587 | } |
| 588 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 589 | ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 590 | // Is the field in this class (or its interfaces), or any of its |
| 591 | // superclasses (or their interfaces)? |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 592 | for (Class* k = this; k != NULL; k = k->GetSuperClass()) { |
| 593 | // Is the field in this class? |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 594 | ArtField* f = k->FindDeclaredStaticField(name, type); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 595 | if (f != NULL) { |
| 596 | return f; |
| 597 | } |
| 598 | // Is this field in any of this class' interfaces? |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame^] | 599 | ClassHelper kh(k); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 600 | for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) { |
| 601 | Class* interface = kh.GetDirectInterface(i); |
| 602 | f = interface->FindStaticField(name, type); |
| 603 | if (f != NULL) { |
| 604 | return f; |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | return NULL; |
| 609 | } |
| 610 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 611 | ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 612 | for (Class* k = this; k != NULL; k = k->GetSuperClass()) { |
| 613 | // Is the field in this class? |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 614 | ArtField* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 615 | if (f != NULL) { |
| 616 | return f; |
| 617 | } |
| 618 | // Is this field in any of this class' interfaces? |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame^] | 619 | ClassHelper kh(k); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 620 | for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) { |
| 621 | Class* interface = kh.GetDirectInterface(i); |
| 622 | f = interface->FindStaticField(dex_cache, dex_field_idx); |
| 623 | if (f != NULL) { |
| 624 | return f; |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | return NULL; |
| 629 | } |
| 630 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 631 | ArtField* Class::FindField(const StringPiece& name, const StringPiece& type) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 632 | // Find a field using the JLS field resolution order |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 633 | for (Class* k = this; k != NULL; k = k->GetSuperClass()) { |
| 634 | // Is the field in this class? |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 635 | ArtField* f = k->FindDeclaredInstanceField(name, type); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 636 | if (f != NULL) { |
| 637 | return f; |
| 638 | } |
| 639 | f = k->FindDeclaredStaticField(name, type); |
| 640 | if (f != NULL) { |
| 641 | return f; |
| 642 | } |
| 643 | // Is this field in any of this class' interfaces? |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame^] | 644 | ClassHelper kh(k); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 645 | for (uint32_t i = 0; i < kh.NumDirectInterfaces(); ++i) { |
| 646 | Class* interface = kh.GetDirectInterface(i); |
| 647 | f = interface->FindStaticField(name, type); |
| 648 | if (f != NULL) { |
| 649 | return f; |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | return NULL; |
| 654 | } |
| 655 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 656 | static void SetPreverifiedFlagOnMethods(mirror::ObjectArray<mirror::ArtMethod>* methods) |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 657 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 658 | if (methods != NULL) { |
| 659 | for (int32_t index = 0, end = methods->GetLength(); index < end; ++index) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 660 | mirror::ArtMethod* method = methods->GetWithoutChecks(index); |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 661 | DCHECK(method != NULL); |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 662 | if (!method->IsNative() && !method->IsAbstract()) { |
| 663 | method->SetPreverified(); |
| 664 | } |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | void Class::SetPreverifiedFlagOnAllMethods() { |
| 670 | DCHECK(IsVerified()); |
| 671 | SetPreverifiedFlagOnMethods(GetDirectMethods()); |
| 672 | SetPreverifiedFlagOnMethods(GetVirtualMethods()); |
| 673 | } |
| 674 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 675 | } // namespace mirror |
| 676 | } // namespace art |