Home | History | Annotate | Download | only in runtime

Lines Matching full:mirror

46 #include "mirror/art_field-inl.h"
47 #include "mirror/art_method-inl.h"
48 #include "mirror/class.h"
49 #include "mirror/class-inl.h"
50 #include "mirror/class_loader.h"
51 #include "mirror/dex_cache-inl.h"
52 #include "mirror/iftable-inl.h"
53 #include "mirror/object-inl.h"
54 #include "mirror/object_array-inl.h"
55 #include "mirror/proxy.h"
56 #include "mirror/stack_trace_element.h"
85 static void ThrowEarlierClassFailure(mirror::Class* c)
212 SirtRef<mirror::Class>
214 down_cast<mirror::Class*>(heap->AllocObject(self, NULL,
215 sizeof(mirror::ClassClass))));
217 mirror::Class::SetClassClass(java_lang_Class.get());
219 java_lang_Class->SetClassSize(sizeof(mirror::ClassClass));
220 // AllocClass(mirror::Class*) can now be used
223 SirtRef<mirror::Class> class_array_class(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class)));
227 SirtRef<mirror::Class> java_lang_Object(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class)));
231 java_lang_Object->SetStatus(mirror::Class::kStatusLoaded, self);
234 SirtRef<mirror::Class> object_array_class(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class)));
238 SirtRef<mirror::Class> char_class(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class)));
241 SirtRef<mirror::Class> char_array_class(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class)));
243 mirror::CharArray::SetArrayClass(char_array_class.get());
246 SirtRef<mirror::Class> java_lang_String(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::StringClass)));
247 mirror::String::SetClass(java_lang_String.get());
248 java_lang_String->SetObjectSize(sizeof(mirror::String));
249 java_lang_String->SetStatus(mirror::Class::kStatusResolved, self);
252 class_roots_ = mirror::ObjectArray<mirror::Class>::Alloc(self, object_array_class.get(), kClassRootsMax);
275 SirtRef<mirror::Class> int_array_class(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class)));
277 mirror::IntArray::SetArrayClass(int_array_class.get());
283 SirtRef<mirror::Class>
284 java_lang_DexCache(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::DexCacheClass)));
286 java_lang_DexCache->SetObjectSize(sizeof(mirror::DexCacheClass));
287 java_lang_DexCache->SetStatus(mirror::Class::kStatusResolved, self);
290 SirtRef<mirror::Class> java_lang_reflect_ArtField(self, AllocClass(self, java_lang_Class.get(),
291 sizeof(mirror::ArtFieldClass)));
293 java_lang_reflect_ArtField->SetObjectSize(sizeof(mirror::ArtField));
295 java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusResolved, self);
296 mirror::ArtField::SetClass(java_lang_reflect_ArtField.get());
298 SirtRef<mirror::Class> java_lang_reflect_ArtMethod(self, AllocClass(self, java_lang_Class.get(),
299 sizeof(mirror::ArtMethodClass)));
301 java_lang_reflect_ArtMethod->SetObjectSize(sizeof(mirror::ArtMethod));
303 java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusResolved, self);
305 mirror::ArtMethod::SetClass(java_lang_reflect_ArtMethod.get());
308 SirtRef<mirror::Class> object_array_string(self, AllocClass(self, java_lang_Class.get(),
309 sizeof(mirror::Class)));
313 SirtRef<mirror::Class> object_array_art_method(self, AllocClass(self, java_lang_Class.get(),
314 sizeof(mirror::Class)));
318 SirtRef<mirror::Class> object_array_art_field(self, AllocClass(self, java_lang_Class.get(),
319 sizeof(mirror::Class)));
340 java_lang_Object->SetStatus(mirror::Class::kStatusNotReady, self);
341 mirror::Class* Object_class = FindSystemClass("Ljava/lang/Object;");
343 CHECK_EQ(java_lang_Object->GetObjectSize(), sizeof(mirror::Object));
344 java_lang_String->SetStatus(mirror::Class::kStatusNotReady, self);
345 mirror::Class* String_class = FindSystemClass("Ljava/lang/String;");
347 CHECK_EQ(java_lang_String->GetObjectSize(), sizeof(mirror::String));
348 java_lang_DexCache->SetStatus(mirror::Class::kStatusNotReady, self);
349 mirror::Class* DexCache_class = FindSystemClass("Ljava/lang/DexCache;");
352 CHECK_EQ(java_lang_DexCache->GetObjectSize(), sizeof(mirror::DexCache));
356 mirror::BooleanArray::SetArrayClass(GetClassRoot(kBooleanArrayClass));
359 mirror::ByteArray::SetArrayClass(GetClassRoot(kByteArrayClass));
361 mirror::Class* found_char_array_class = FindSystemClass("[C");
365 mirror::ShortArray::SetArrayClass(GetClassRoot(kShortArrayClass));
367 mirror::Class* found_int_array_class = FindSystemClass("[I");
371 mirror::LongArray::SetArrayClass(GetClassRoot(kLongArrayClass));
374 mirror::FloatArray::SetArrayClass(GetClassRoot(kFloatArrayClass));
377 mirror::DoubleArray::SetArrayClass(GetClassRoot(kDoubleArrayClass));
379 mirror::Class* found_class_array_class = FindSystemClass("[Ljava/lang/Class;");
382 mirror::Class* found_object_array_class = FindSystemClass("[Ljava/lang/Object;");
386 mirror::Class* java_lang_Cloneable = FindSystemClass("Ljava/lang/Cloneable;");
388 mirror::Class* java_io_Serializable = FindSystemClass("Ljava/io/Serializable;");
404 mirror::Class* Class_class = FindSystemClass("Ljava/lang/Class;");
407 java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusNotReady, self);
408 mirror::Class* Art_method_class = FindSystemClass("Ljava/lang/reflect/ArtMethod;");
411 java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusNotReady, self);
412 mirror::Class* Art_field_class = FindSystemClass("Ljava/lang/reflect/ArtField;");
415 mirror::Class* String_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangStringArrayClass]);
418 mirror::Class* Art_method_array_class =
422 mirror::Class* Art_field_array_class =
429 mirror::Class* java_lang_reflect_Proxy = FindSystemClass("Ljava/lang/reflect/Proxy;");
433 mirror::Class* java_lang_ref_Reference = FindSystemClass("Ljava/lang/ref/Reference;");
435 mirror::Class* java_lang_ref_FinalizerReference = FindSystemClass("Ljava/lang/ref/FinalizerReference;");
439 mirror::Class* java_lang_ref_PhantomReference = FindSystemClass("Ljava/lang/ref/PhantomReference;");
443 mirror::Class* java_lang_ref_SoftReference = FindSystemClass("Ljava/lang/ref/SoftReference;");
446 mirror::Class* java_lang_ref_WeakReference = FindSystemClass("Ljava/lang/ref/WeakReference;");
452 mirror::Class* java_lang_ClassLoader = FindSystemClass("Ljava/lang/ClassLoader;");
453 CHECK_EQ(java_lang_ClassLoader->GetObjectSize(), sizeof(mirror::ClassLoader));
459 mirror::Throwable::SetClass(GetClassRoot(kJavaLangThrowable));
463 mirror::StackTraceElement::SetClass(GetClassRoot(kJavaLangStackTraceElement));
477 mirror::Class* java_lang_ref_Reference = GetClassRoot(kJavaLangRefReference);
478 mirror::Class* java_lang_ref_FinalizerReference =
481 mirror::ArtField* pendingNext = java_lang_ref_Reference->GetInstanceField(0);
486 mirror::ArtField* queue = java_lang_ref_Reference->GetInstanceField(1);
491 mirror::ArtField* queueNext = java_lang_ref_Reference->GetInstanceField(2);
496 mirror::ArtField* referent = java_lang_ref_Reference->GetInstanceField(3);
501 mirror::ArtField* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2);
516 mirror::Class* klass = GetClassRoot(class_root);
535 mirror::Class* c = GetClassRoot(ClassRoot(i));
994 static void InitFromImageInterpretOnlyCallback(mirror::Object* obj, void* arg)
1002 mirror::ArtMethod* method = obj->AsArtMethod();
1026 mirror::Object* dex_caches_object = space->GetImageHeader().GetImageRoot(ImageHeader::kDexCaches);
1027 mirror::ObjectArray<mirror::DexCache>* dex_caches =
1028 dex_caches_object->AsObjectArray<mirror::DexCache>();
1030 mirror::ObjectArray<mirror::Class>* class_roots =
1031 space->GetImageHeader().GetImageRoot(ImageHeader::kClassRoots)->AsObjectArray<mirror::Class>();
1036 mirror::String::SetClass(GetClassRoot(kJavaLangString));
1042 SirtRef<mirror::DexCache> dex_cache(self, dex_caches->Get(i));
1059 mirror::ArtMethod::SetClass(GetClassRoot(kJavaLangReflectArtMethod));
1069 mirror::Class::SetClassClass(class_roots->Get(kJavaLangClass));
1076 mirror::ArtField::SetClass(GetClassRoot(kJavaLangReflectArtField));
1077 mirror::BooleanArray::SetArrayClass(GetClassRoot(kBooleanArrayClass));
1078 mirror::ByteArray::SetArrayClass(GetClassRoot(kByteArrayClass));
1079 mirror::CharArray::SetArrayClass(GetClassRoot(kCharArrayClass));
1080 mirror::DoubleArray::SetArrayClass(GetClassRoot(kDoubleArrayClass));
1081 mirror::FloatArray::SetArrayClass(GetClassRoot(kFloatArrayClass));
1082 mirror::IntArray::SetArrayClass(GetClassRoot(kIntArrayClass));
1083 mirror::LongArray::SetArrayClass(GetClassRoot(kLongArrayClass));
1084 mirror::ShortArray::SetArrayClass(GetClassRoot(kShortArrayClass));
1085 mirror::Throwable::SetClass(GetClassRoot(kJavaLangThrowable));
1086 mirror::StackTraceElement::SetClass(GetClassRoot(kJavaLangStackTraceElement));
1102 for (mirror::DexCache* dex_cache : dex_caches_) {
1114 for (const std::pair<size_t, mirror::Class*>& it : class_table_) {
1134 for (const std::pair<size_t, mirror::Class*>& it : class_table_) {
1141 static bool GetClassesVisitor(mirror::Class* c, void* arg) {
1142 std::set<mirror::Class*>* classes = reinterpret_cast<std::set<mirror::Class*>*>(arg);
1148 std::set<mirror::Class*> classes;
1150 for (mirror::Class* klass : classes) {
1159 mirror::Class::ResetClass();
1160 mirror::String::ResetClass();
1161 mirror::ArtField::ResetClass();
1162 mirror::ArtMethod::ResetClass();
1163 mirror::BooleanArray::ResetArrayClass();
1164 mirror::ByteArray::ResetArrayClass();
1165 mirror::CharArray::ResetArrayClass();
1166 mirror::DoubleArray::ResetArrayClass();
1167 mirror::FloatArray::ResetArrayClass();
1168 mirror::IntArray::ResetArrayClass();
1169 mirror::LongArray::ResetArrayClass();
1170 mirror::ShortArray::ResetArrayClass();
1171 mirror::Throwable::ResetClass();
1172 mirror::StackTraceElement::ResetClass();
1177 mirror::DexCache* ClassLinker::AllocDexCache(Thread* self, const DexFile& dex_file) {
1179 mirror::Class* dex_cache_class = GetClassRoot(kJavaLangDexCache);
1180 SirtRef<mirror::DexCache> dex_cache(self,
1181 down_cast<mirror::DexCache*>(heap->AllocObject(self, dex_cache_class,
1186 SirtRef<mirror::String>
1191 SirtRef<mirror::ObjectArray<mirror::String> >
1196 SirtRef<mirror::ObjectArray<mirror::Class> >
1201 SirtRef<mirror::ObjectArray<mirror::ArtMethod> >
1206 SirtRef<mirror::ObjectArray<mirror::ArtField> >
1211 SirtRef<mirror::ObjectArray<mirror::StaticStorageBase> >
1213 AllocObjectArray<mirror::StaticStorageBase>(self, dex_file.NumTypeIds()));
1228 mirror::Class* ClassLinker::AllocClass(Thread* self, mirror::Class* java_lang_Class,
1230 DCHECK_GE(class_size, sizeof(mirror::Class));
1232 mirror::Object* k = heap->AllocObject(self, java_lang_Class, class_size);
1237 mirror::Class* klass = k->AsClass();
1245 mirror::Class* ClassLinker::AllocClass(Thread* self, size_t class_size) {
1249 mirror::ArtField* ClassLinker::AllocArtField(Thread* self) {
1250 return down_cast<mirror::ArtField*>(GetClassRoot(kJavaLangReflectArtField)->AllocObject(self));
1253 mirror::ArtMethod* ClassLinker::AllocArtMethod(Thread* self) {
1254 return down_cast<mirror::ArtMethod*>(GetClassRoot(kJavaLangReflectArtMethod)->AllocObject(self));
1257 mirror::ObjectArray<mirror::StackTraceElement>* ClassLinker::AllocStackTraceElementArray(Thread* self,
1259 return mirror::ObjectArray<mirror::StackTraceElement>::Alloc(self,
1264 static mirror::Class* EnsureResolved(Thread* self, mirror::Class* klass)
1273 klass->SetStatus(mirror::Class::kStatusError, self);
1296 mirror::Class* ClassLinker::FindSystemClass(const char* descriptor) {
1300 mirror::Class* ClassLinker::FindClass(const char* descriptor, mirror::ClassLoader* class_loader) {
1311 mirror::Class* klass = LookupClass(descriptor, class_loader);
1329 mirror::Class* system_class = FindSystemClass(descriptor);
1373 // success, return mirror::Class*
1374 return soa.Decode<mirror::Class*>(result.get());
1382 mirror::Class* ClassLinker::DefineClass(const char* descriptor,
1383 mirror::ClassLoader* class_loader,
1387 SirtRef<mirror::Class> klass(self, NULL);
1417 klass->SetStatus(mirror::Class::kStatusError, self);
1424 mirror::Class* existing = InsertClass(descriptor, klass.get(), Hash(descriptor));
1435 klass->SetStatus(mirror::Class::kStatusError, self);
1443 klass->SetStatus(mirror::Class::kStatusError, self);
1486 size_t size = sizeof(mirror::Class);
1552 const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::ArtMethod* method) {
1555 mirror::Class* declaring_class = method->GetDeclaringClass();
1588 const void* ClassLinker::GetOatCodeFor(const mirror::ArtMethod* method) {
1614 static bool NeedsInterpreter(const mirror::ArtMethod* method, const void* code) {
1632 void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) {
1658 mirror::ArtMethod* method = klass->GetDirectMethod(method_index);
1674 static void LinkCode(SirtRef<mirror::ArtMethod>& method, const OatFile::OatClass* oat_class,
1720 SirtRef<mirror::Class>& klass,
1721 mirror::ClassLoader* class_loader) {
1724 CHECK_EQ(mirror::Class::kStatusNotReady, klass->GetStatus());
1735 klass->SetStatus(mirror::Class::kStatusIdx, NULL);
1748 mirror::ObjectArray<mirror::ArtField>* statics = AllocArtFieldArray(self, it.NumStaticFields());
1756 mirror::ObjectArray<mirror::ArtField>* fields =
1765 SirtRef<mirror::ArtField> sfield(self, AllocArtField(self));
1774 SirtRef<mirror::ArtField> ifield(self, AllocArtField(self));
1791 mirror::ObjectArray<mirror::ArtMethod>* directs =
1801 mirror::ObjectArray<mirror::ArtMethod>* virtuals =
1811 SirtRef<mirror::ArtMethod> method(self, LoadMethod(self, dex_file, it, klass));
1824 SirtRef<mirror::ArtMethod> method(self, LoadMethod(self, dex_file, it, klass));
1840 SirtRef<mirror::Class>& klass, SirtRef<mirror::ArtField>& dst) {
1847 mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file,
1849 SirtRef<mirror::Class>& klass) {
1854 mirror::ArtMethod* dst = AllocArtMethod(self);
1912 SirtRef<mirror::DexCache> dex_cache(self, AllocDexCache(self, dex_file));
1917 void ClassLinker::AppendToBootClassPath(const DexFile& dex_file, SirtRef<mirror::DexCache>& dex_cache) {
1938 void ClassLinker::RegisterDexFileLocked(const DexFile& dex_file, SirtRef<mirror::DexCache>& dex_cache) {
1959 SirtRef<mirror::DexCache> dex_cache(self, AllocDexCache(self, dex_file));
1970 void ClassLinker::RegisterDexFile(const DexFile& dex_file, SirtRef<mirror::DexCache>& dex_cache) {
1975 mirror::DexCache* ClassLinker::FindDexCache(const DexFile& dex_file) const {
1979 mirror::DexCache* dex_cache = dex_caches_[i];
1987 mirror::DexCache* dex_cache = dex_caches_[i];
1994 mirror::DexCache* dex_cache = dex_caches_[i];
2001 void ClassLinker::FixupDexCaches(mirror::ArtMethod* resolution_method) const {
2008 mirror::Class* ClassLinker::CreatePrimitiveClass(Thread* self, Primitive::Type type) {
2009 mirror::Class* klass = AllocClass(self, sizeof(mirror::Class));
2016 mirror::Class* ClassLinker::InitializePrimitiveClass(mirror::Class* primitive_class, Primitive::Type type) {
2023 primitive_class->SetStatus(mirror::Class::kStatusInitialized, self);
2025 mirror::Class* existing = InsertClass(descriptor, primitive_class, Hash(descriptor));
2043 mirror::Class* ClassLinker::CreateArrayClass(const char* descriptor,
2044 mirror::ClassLoader* class_loader) {
2047 mirror::Class* component_type = FindClass(descriptor + 1, class_loader);
2071 mirror::Class* new_class = LookupClass(descriptor, component_type->GetClassLoader());
2086 SirtRef<mirror::Class> new_class(self, NULL);
2108 new_class.reset(AllocClass(self, sizeof(mirror::Class)));
2116 mirror::Class* java_lang_Object = GetClassRoot(kJavaLangObject);
2121 new_class->SetStatus(mirror::Class::kStatusInitialized, self);
2152 mirror::Class* existing = InsertClass(descriptor, new_class.get(), Hash(descriptor));
2165 mirror::Class* ClassLinker::FindPrimitiveClass(char type) {
2193 mirror::Class* ClassLinker::InsertClass(const char* descriptor, mirror::Class* klass,
2196 mirror::DexCache* dex_cache = klass->GetDexCache();
2205 mirror::Class* existing =
2224 bool ClassLinker::RemoveClass(const char* descriptor, const mirror::ClassLoader* class_loader) {
2230 mirror::Class* klass = it->second;
2240 mirror::Class* ClassLinker::LookupClass(const char* descriptor,
2241 const mirror::ClassLoader* class_loader) {
2245 mirror::Class* result = LookupClassFromTableLocked(descriptor, class_loader, hash);
2254 mirror::Class* result = LookupClassFromImage(descriptor);
2270 mirror::Class* ClassLinker::LookupClassFromTableLocked(const char* descriptor,
2271 const mirror::ClassLoader* class_loader,
2276 mirror::Class* klass = it->second;
2282 mirror::Class* klass2 = it->second;
2295 static mirror::ObjectArray<mirror::DexCache>* GetImageDexCaches()
2299 mirror::Object* root = image->GetImageHeader().GetImageRoot(ImageHeader::kDexCaches);
2300 return root->AsObjectArray<mirror::DexCache>();
2311 mirror::ObjectArray<mirror::DexCache>* dex_caches = GetImageDexCaches();
2314 mirror::DexCache* dex_cache = dex_caches->Get(i);
2315 mirror::ObjectArray<mirror::Class>* types = dex_cache->GetResolvedTypes();
2317 mirror::Class* klass = types->Get(j);
2323 mirror::Class* existing = LookupClassFromTableLocked(descriptor, NULL, hash);
2338 mirror::Class* ClassLinker::LookupClassFromImage(const char* descriptor) {
2342 mirror::ObjectArray<mirror::DexCache>* dex_caches = GetImageDexCaches();
2344 mirror::DexCache* dex_cache = dex_caches->Get(i);
2353 mirror::Class* klass = dex_cache->GetResolvedType(dex_file->GetIndexForTypeId(*type_id));
2368 mirror::Class* klass = dex_cache->GetResolvedType(type_idx);
2380 void ClassLinker::LookupClasses(const char* descriptor, std::vector<mirror::Class*>& result) {
2390 mirror::Class* klass = it->second;
2398 void ClassLinker::VerifyClass(mirror::Class* klass) {
2416 if (klass->GetStatus() == mirror::Class::kStatusResolved) {
2417 klass->SetStatus(mirror::Class::kStatusVerifying, self);
2419 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime)
2422 klass->SetStatus(mirror::Class::kStatusVerifyingAtRuntime, self);
2426 SirtRef<mirror::Class> super(self, klass->GetSuperClass());
2439 SirtRef<mirror::Throwable> cause(self, self->GetException(NULL));
2447 klass->SetStatus(mirror::Class::kStatusError, self);
2454 mirror::Class::Status oat_file_class_status(mirror::Class::kStatusNotReady);
2456 if (oat_file_class_status == mirror::Class::kStatusError) {
2462 klass->SetStatus(mirror::Class::kStatusError, self);
2485 klass->SetStatus(mirror::Class::kStatusVerified, self);
2487 CHECK_EQ(super->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime);
2488 klass->SetStatus(mirror::Class::kStatusRetryVerificationAtRuntime, self);
2498 klass->SetStatus(mirror::Class::kStatusRetryVerificationAtRuntime, self);
2500 klass->SetStatus(mirror::Class::kStatusVerified, self);
2509 klass->SetStatus(mirror::Class::kStatusError, self);
2522 bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass,
2523 mirror::Class::Status& oat_file_class_status) {
2559 if (oat_file_class_status == mirror::Class::kStatusVerified ||
2560 oat_file_class_status == mirror::Class::kStatusInitialized) {
2563 if (oat_file_class_status == mirror::Class::kStatusRetryVerificationAtRuntime) {
2583 if (oat_file_class_status == mirror::Class::kStatusError) {
2588 if (oat_file_class_status == mirror::Class::kStatusNotReady) {
2601 void ClassLinker::ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mirror::Class* klass) {
2611 mirror::ArtMethod* method) {
2629 mirror::Class* exception_type = linker->ResolveType(iterator.GetHandlerTypeIndex(), method);
2640 static void CheckProxyConstructor(mirror::ArtMethod* constructor);
2641 static void CheckProxyMethod(mirror::ArtMethod* method,
2642 SirtRef<mirror::ArtMethod>& prototype);
2644 mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name,
2645 mirror::ObjectArray<mirror::Class>* interfaces,
2646 mirror::ClassLoader* loader,
2647 mirror::ObjectArray<mirror::ArtMethod>* methods,
2648 mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws) {
2650 SirtRef<mirror::Class> klass(self, AllocClass(self, GetClassRoot(kJavaLangClass),
2651 sizeof(mirror::SynthesizedProxyClass)));
2657 klass->SetObjectSize(sizeof(mirror::Proxy));
2662 mirror::Class* proxy_class = GetClassRoot(kJavaLangReflectProxy);
2664 klass->SetStatus(mirror::Class::kStatusIdx, self);
2668 mirror::ObjectArray<mirror::ArtField>* sfields = AllocArtFieldArray(self, 2);
2677 SirtRef<mirror::ArtField> interfaces_sfield(self, AllocArtField(self));
2687 SirtRef<mirror::ArtField> throws_sfield(self, AllocArtField(self));
2699 mirror::ObjectArray<mirror::ArtMethod>* directs =
2706 mirror
2717 mirror::ObjectArray<mirror::ArtMethod>* virtuals =
2726 SirtRef<mirror::ArtMethod> prototype(self, methods->Get(i));
2727 mirror::ArtMethod* clone = CreateProxyMethod(self, klass, prototype);
2736 klass->SetStatus(mirror::Class::kStatusLoaded, self); // Class is now effectively in the loaded state
2743 klass->SetStatus(mirror::Class::kStatusError, self);
2749 klass->SetStatus(mirror::Class::kStatusInitialized, self);
2757 SirtRef<mirror::ArtMethod> prototype(self, methods->Get(i));
2769 mirror::SynthesizedProxyClass* synth_proxy_class =
2770 down_cast<mirror::SynthesizedProxyClass*>(klass.get());
2775 mirror::Class* existing = InsertClass(descriptor.c_str(), klass.get(), Hash(descriptor.c_str()));
2780 std::string ClassLinker::GetDescriptorForProxy(const mirror::Class* proxy_class) {
2782 mirror::String* name = proxy_class->GetName();
2787 mirror::ArtMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class,
2788 const mirror::ArtMethod* proxy_method) {
2792 mirror::DexCache* dex_cache = NULL;
2794 mirror::ObjectArray<mirror::Class>* resolved_types = proxy_method->GetDexCacheResolvedTypes();
2805 mirror::ArtMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx);
2811 mirror::ArtMethod* ClassLinker::CreateProxyConstructor(Thread* self,
2812 SirtRef<mirror::Class>& klass,
2813 mirror::Class* proxy_class) {
2815 mirror::ObjectArray<mirror::ArtMethod>* proxy_direct_methods =
2818 mirror::ArtMethod* proxy_constructor = proxy_direct_methods->Get(2);
2821 mirror::ArtMethod* constructor =
2822 down_cast<mirror::ArtMethod*>(proxy_constructor->Clone(self));
2833 static void CheckProxyConstructor(mirror::ArtMethod* constructor)
2842 mirror::ArtMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef<mirror::Class>& klass,
2843 SirtRef<mirror::ArtMethod>& prototype) {
2850 mirror::ArtMethod* method = down_cast<mirror::ArtMethod*>(prototype->Clone(self));
2863 mirror::ArtMethod* refs_and_args =
2874 static void CheckProxyMethod(mirror::ArtMethod* method,
2875 SirtRef<mirror::ArtMethod>& prototype)
2899 static bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics,
2907 mirror::ArtMethod* clinit = klass->FindDeclaredDirectMethod("<clinit>", "()V");
2922 mirror::Class* super_class = klass->GetSuperClass();
2934 bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_init_statics,
2977 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime);
2988 if (klass->GetStatus() == mirror::Class::kStatusInitializing) {
2999 klass->SetStatus(mirror::Class::kStatusError, self);
3003 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << PrettyClass(klass);
3008 klass->SetStatus(mirror::Class::kStatusInitializing, self);
3015 mirror::Class* super_class = klass->GetSuperClass();
3030 klass->SetStatus(mirror::Class::kStatusError, self);
3046 SafeMap<uint32_t, mirror::ArtField*> field_map;
3054 mirror::ArtMethod* clinit = klass->FindDeclaredDirectMethod("<clinit>", "()V");
3076 klass->SetStatus(mirror::Class::kStatusError, self);
3086 klass->SetStatus(mirror::Class::kStatusInitialized, self);
3096 bool ClassLinker::WaitForInitializeClass(mirror::Class* klass, Thread* self, ObjectLock& lock)
3108 klass->SetStatus(mirror::Class::kStatusError, self);
3112 mirror::Class::kStatusInitializing) {
3115 if (klass->GetStatus() == mirror::Class::kStatusVerified && Runtime::Current()->IsCompiler()) {
3134 bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) {
3141 const mirror::Class* super = klass->GetSuperClass();
3143 const mirror::ArtMethod* method = klass->GetVTable()->Get(i);
3153 mirror::IfTable* iftable = klass->GetIfTable();
3155 mirror::Class* interface = iftable->GetInterface(i);
3158 const mirror::ArtMethod* method = iftable->GetMethodArray(i)->Get(j);
3175 bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method,
3176 const mirror::Class* klass1,
3177 const mirror::Class* klass2) {
3208 const mirror::Class* klass1,
3209 const mirror::Class* klass2) {
3216 mirror::Class* found1 = FindClass(descriptor, klass1->GetClassLoader());
3220 mirror::Class* found2 = FindClass(descriptor, klass2->GetClassLoader());
3227 bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_init_fields, bool can_init_parents) {
3242 mirror::Class* c, SafeMap<uint32_t, mirror::ArtField*>& field_map) {
3243 mirror::ClassLoader* cl = c->GetClassLoader();
3251 bool ClassLinker::LinkClass(SirtRef<mirror::Class>& klass,
3252 mirror::ObjectArray<mirror::Class>* interfaces, Thread* self) {
3253 CHECK_EQ(mirror::Class::kStatusLoaded, klass->GetStatus());
3268 CHECK_EQ(mirror::Class::kStatusLoaded, klass->GetStatus());
3269 klass->SetStatus(mirror::Class::kStatusResolved, self);
3273 bool ClassLinker::LoadSuperAndInterfaces(SirtRef<mirror::Class>& klass, const DexFile& dex_file) {
3274 CHECK_EQ(mirror::Class::kStatusIdx, klass->GetStatus());
3278 mirror::Class* super_class = ResolveType(dex_file, super_class_idx, klass.get());
3296 mirror::Class* interface = ResolveType(dex_file, idx, klass.get());
3312 klass->SetStatus(mirror::Class::kStatusLoaded, NULL);
3316 bool ClassLinker::LinkSuperClass(SirtRef<mirror::Class>& klass) {
3318 mirror::Class* super = klass->GetSuperClass();
3375 bool ClassLinker::LinkMethods(SirtRef<mirror::Class>& klass,
3376 mirror::ObjectArray<mirror::Class>* interfaces) {
3396 bool ClassLinker::LinkVirtualMethods(SirtRef<mirror::Class>& klass) {
3403 SirtRef<mirror::ObjectArray<mirror::ArtMethod> >
3413 mirror::ArtMethod* local_method = klass->GetVirtualMethodDuringLinking(i);
3417 mirror::ArtMethod* super_method = vtable->Get(j);
3465 SirtRef<mirror::ObjectArray<mirror::ArtMethod> >
3472 mirror::ArtMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i);
3481 bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass,
3482 mirror::ObjectArray<mirror::Class>* interfaces) {
3494 mirror::Class* interface = interfaces == NULL ? kh.GetDirectInterface(i) : interfaces->Get(i);
3506 mirror::IfTable* super_iftable = klass->GetSuperClass()->GetIfTable();
3520 mirror::IfTable> iftable(self, AllocIfTable(self, ifcount));
3526 mirror::IfTable* super_iftable = klass->GetSuperClass()->GetIfTable();
3528 mirror::Class* super_interface = super_iftable->GetInterface(i);
3535 mirror::Class* interface = interfaces == NULL ? kh.GetDirectInterface(i) : interfaces->Get(i);
3547 mirror::Class* existing_interface = iftable->GetInterface(j);
3558 mirror::Class* super_interface = interface->GetIfTable()->GetInterface(j);
3561 mirror::Class* existing_interface = iftable->GetInterface(k);
3575 iftable.reset(down_cast<mirror::IfTable*>(iftable->CopyOf(self, idx * mirror::IfTable::kMax)));
3590 std::vector<mirror::ArtMethod*> miranda_list;
3594 mirror::Class* interface = iftable->GetInterface(i);
3597 mirror::ObjectArray<mirror::ArtMethod>* method_array =
3604 mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking();
3606 mirror::ArtMethod* interface_method = interface->GetVirtualMethod(j);
3618 mirror::ArtMethod* vtable_method = vtable->Get(k);
3633 SirtRef<mirror::ArtMethod> miranda_method(self, NULL);
3635 mirror::ArtMethod* mir_method = miranda_list[mir];
3644 miranda_method.reset(down_cast<mirror::ArtMethod*>(interface_method->Clone(self)));
3663 mirror::ObjectArray<mirror::ArtMethod>* virtuals;
3675 SirtRef<mirror::ObjectArray<mirror::ArtMethod> >
3686 mirror::ArtMethod* method = miranda_list[i];
3697 mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking();
3707 bool ClassLinker::LinkInstanceFields(SirtRef<mirror::Class>& klass) {
3712 bool ClassLinker::LinkStaticFields(SirtRef<mirror::Class>& klass) {
3725 bool operator()(const mirror::ArtField* field1, const mirror::ArtField* field2)
3753 bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) {
3757 mirror::ObjectArray<mirror::ArtField>* fields =
3765 field_offset = mirror::Class::FieldsOffset();
3767 mirror::Class* super_class = klass->GetSuperClass();
3779 std::deque<mirror::ArtField*> grouped_and_sorted_fields;
3792 mirror::ArtField* field = grouped_and_sorted_fields.front();
3811 mirror::ArtField* field = grouped_and_sorted_fields[i];
3832 mirror::ArtField* field = grouped_and_sorted_fields.front();
3862 mirror::ArtField* field = fields->Get(i);
3867 << " offset=" << field->GetField32(MemberOffset(mirror::ArtField::OffsetOffset()),
3898 DCHECK_GE(size, sizeof(mirror::Object)) << ClassHelper(klass.get(), this).GetDescriptor();
3907 void ClassLinker::CreateReferenceInstanceOffsets(SirtRef<mirror::Class>& klass) {
3909 mirror::Class* super_class = klass->GetSuperClass();
3921 void ClassLinker::CreateReferenceStaticOffsets(SirtRef<mirror::Class>& klass) {
3925 mirror::Class>& klass, bool is_static,
3930 const mirror::ObjectArray<mirror::ArtField>* fields =
3937 const mirror::ArtField* field = fields->Get(i);
3957 mirror::String* ClassLinker::ResolveString(const DexFile& dex_file,
3958 uint32_t string_idx, mirror::DexCache* dex_cache) {
3960 mirror::String* resolved = dex_cache->GetResolvedString(string_idx);
3967 mirror::String* string = intern_table_->InternStrong(utf16_length, utf8_data);
3972 mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file,
3974 mirror::DexCache* dex_cache,
3975 mirror::ClassLoader* class_loader) {
3977 mirror::Class* resolved = dex_cache->GetResolvedType(type_idx);
3991 SirtRef<mirror::Throwable> cause(self, self->GetException(NULL));
4004 mirror::ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file,
4006 mirror::DexCache* dex_cache,
4007 mirror::ClassLoader* class_loader,
4008 const mirror::ArtMethod* referrer,
4012 mirror::ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx);
4018 mirror::Class* klass = ResolveType(dex_file, method_id.class_idx_, dex_cache, class_loader);
4089 mirror::Class* methods_class = resolved->GetDeclaringClass();
4090 mirror::Class* referring_class = referrer->GetDeclaringClass();
4151 mirror::ArtField* ClassLinker::ResolveField(const DexFile& dex_file,
4153 mirror::DexCache* dex_cache,
4154 mirror::ClassLoader* class_loader,
4157 mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx);
4162 mirror::Class* klass = ResolveType(dex_file, field_id.class_idx_, dex_cache, class_loader);
4191 mirror::ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file,
4193 mirror::DexCache* dex_cache,
4194 mirror::ClassLoader* class_loader) {
4196 mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx);
4201 mirror::Class* klass = ResolveType(dex_file, field_id.class_idx_, dex_cache, class_loader);
4218 const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer,
4220 mirror::Class* declaring_class = referrer->GetDeclaringClass();
4221 mirror::DexCache* dex_cache = declaring_class->GetDexCache();
4233 std::vector<mirror::Class*> all_classes;
4236 for (const std::pair<size_t, mirror::Class*>& it : class_table_) {
4270 void ClassLinker::SetClassRoot(ClassRoot class_root, mirror::Class* klass) {