Lines Matching refs:klass
567 mirror::Class* klass = GetClassRoot(class_root); in FinishInit() local
568 CHECK(klass != nullptr); in FinishInit()
569 DCHECK(klass->IsArrayClass() || klass->IsPrimitive() || klass->GetDexCache() != nullptr); in FinishInit()
1793 for (mirror::Class* klass : classes) { in VisitClassesWithoutClassesLock()
1794 if (!visitor(klass, arg)) { in VisitClassesWithoutClassesLock()
1827 mirror::Class* klass = classes->Get(i); in VisitClassesWithoutClassesLock() local
1828 if (klass != nullptr && !visitor(klass, arg)) { in VisitClassesWithoutClassesLock()
1932 mirror::Class* klass) { in EnsureResolved() argument
1933 DCHECK(klass != nullptr); in EnsureResolved()
1936 if (init_done_ && klass->IsTemp()) { in EnsureResolved()
1937 CHECK(!klass->IsResolved()); in EnsureResolved()
1938 if (klass->IsErroneous()) { in EnsureResolved()
1939 ThrowEarlierClassFailure(klass); in EnsureResolved()
1943 Handle<mirror::Class> h_class(hs.NewHandle(klass)); in EnsureResolved()
1955 klass = LookupClass(descriptor, h_class.Get()->GetClassLoader()); in EnsureResolved()
1959 if (!klass->IsResolved() && !klass->IsErroneous()) { in EnsureResolved()
1961 HandleWrapper<mirror::Class> h_class(hs.NewHandleWrapper(&klass)); in EnsureResolved()
1975 if (klass->IsErroneous()) { in EnsureResolved()
1976 ThrowEarlierClassFailure(klass); in EnsureResolved()
1980 CHECK(klass->IsResolved()) << PrettyClass(klass); in EnsureResolved()
1982 return klass; in EnsureResolved()
2014 mirror::Class* klass = LookupClass(descriptor, nullptr); in FindClassInPathClassLoader() local
2015 if (klass != nullptr) { in FindClassInPathClassLoader()
2016 return EnsureResolved(self, descriptor, klass); in FindClassInPathClassLoader()
2018 klass = DefineClass(descriptor, NullHandle<mirror::ClassLoader>(), *pair.first, in FindClassInPathClassLoader()
2020 if (klass != nullptr) { in FindClassInPathClassLoader()
2021 return klass; in FindClassInPathClassLoader()
2069 mirror::Class* klass = in FindClassInPathClassLoader() local
2071 if (klass == nullptr) { in FindClassInPathClassLoader()
2076 return klass; in FindClassInPathClassLoader()
2098 mirror::Class* klass = LookupClass(descriptor, class_loader.Get()); in FindClass() local
2099 if (klass != nullptr) { in FindClass()
2100 return EnsureResolved(self, descriptor, klass); in FindClass()
2121 klass = LookupClass(descriptor, nullptr); in FindClass()
2122 if (klass != nullptr) { in FindClass()
2123 return EnsureResolved(self, descriptor, klass); in FindClass()
2146 mirror::Class* klass = FindClassInPathClassLoader(soa, self, descriptor, class_loader); in FindClass() local
2147 if (klass != nullptr) { in FindClass()
2148 return klass; in FindClass()
2191 auto klass = hs.NewHandle<mirror::Class>(nullptr); in DefineClass() local
2198 klass.Assign(GetClassRoot(kJavaLangObject)); in DefineClass()
2200 klass.Assign(GetClassRoot(kJavaLangClass)); in DefineClass()
2202 klass.Assign(GetClassRoot(kJavaLangString)); in DefineClass()
2204 klass.Assign(GetClassRoot(kJavaLangRefReference)); in DefineClass()
2206 klass.Assign(GetClassRoot(kJavaLangDexCache)); in DefineClass()
2208 klass.Assign(GetClassRoot(kJavaLangReflectArtField)); in DefineClass()
2210 klass.Assign(GetClassRoot(kJavaLangReflectArtMethod)); in DefineClass()
2223 klass.Assign(AllocClass(self, SizeOfClassWithoutEmbeddedTables(dex_file, dex_class_def))); in DefineClass()
2225 if (UNLIKELY(klass.Get() == nullptr)) { in DefineClass()
2229 klass->SetDexCache(FindDexCache(dex_file)); in DefineClass()
2230 LoadClass(dex_file, dex_class_def, klass, class_loader.Get()); in DefineClass()
2231 ObjectLock<mirror::Class> lock(self, klass); in DefineClass()
2235 if (!klass->IsErroneous()) { in DefineClass()
2236 klass->SetStatus(mirror::Class::kStatusError, self); in DefineClass()
2240 klass->SetClinitThreadId(self->GetTid()); in DefineClass()
2243 mirror::Class* existing = InsertClass(descriptor, klass.Get(), Hash(descriptor)); in DefineClass()
2251 CHECK(!klass->IsLoaded()); in DefineClass()
2252 if (!LoadSuperAndInterfaces(klass, dex_file)) { in DefineClass()
2254 if (!klass->IsErroneous()) { in DefineClass()
2255 klass->SetStatus(mirror::Class::kStatusError, self); in DefineClass()
2259 CHECK(klass->IsLoaded()); in DefineClass()
2261 CHECK(!klass->IsResolved()); in DefineClass()
2266 if (!LinkClass(self, descriptor, klass, interfaces, &new_class)) { in DefineClass()
2268 if (!klass->IsErroneous()) { in DefineClass()
2269 klass->SetStatus(mirror::Class::kStatusError, self); in DefineClass()
2511 void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { in FixupStaticTrampolines() argument
2512 DCHECK(klass->IsInitialized()) << PrettyDescriptor(klass); in FixupStaticTrampolines()
2513 if (klass->NumDirectMethods() == 0) { in FixupStaticTrampolines()
2523 const DexFile& dex_file = klass->GetDexFile(); in FixupStaticTrampolines()
2524 const DexFile::ClassDef* dex_class_def = klass->GetClassDef(); in FixupStaticTrampolines()
2528 CHECK(class_data != nullptr) << PrettyDescriptor(klass); in FixupStaticTrampolines()
2538 bool has_oat_class = FindOatClass(dex_file, klass->GetDexClassDefIndex(), &oat_class); in FixupStaticTrampolines()
2541 mirror::ArtMethod* method = klass->GetDirectMethod(method_index); in FixupStaticTrampolines()
2693 Handle<mirror::Class> klass, in LoadClass() argument
2695 CHECK(klass.Get() != nullptr); in LoadClass()
2696 CHECK(klass->GetDexCache() != nullptr); in LoadClass()
2697 CHECK_EQ(mirror::Class::kStatusNotReady, klass->GetStatus()); in LoadClass()
2701 klass->SetClass(GetClassRoot(kJavaLangClass)); in LoadClass()
2703 klass->AssertReadBarrierPointer(); in LoadClass()
2707 klass->SetAccessFlags(access_flags); in LoadClass()
2708 klass->SetClassLoader(class_loader); in LoadClass()
2709 DCHECK_EQ(klass->GetPrimitiveType(), Primitive::kPrimNot); in LoadClass()
2710 klass->SetStatus(mirror::Class::kStatusIdx, nullptr); in LoadClass()
2712 klass->SetDexClassDefIndex(dex_file.GetIndexForClassDef(dex_class_def)); in LoadClass()
2713 klass->SetDexTypeIndex(dex_class_def.class_idx_); in LoadClass()
2723 && FindOatClass(dex_file, klass->GetDexClassDefIndex(), &oat_class)) { in LoadClass()
2724 LoadClassMembers(dex_file, class_data, klass, class_loader, &oat_class); in LoadClass()
2726 LoadClassMembers(dex_file, class_data, klass, class_loader, nullptr); in LoadClass()
2732 Handle<mirror::Class> klass, in LoadClassMembers() argument
2744 klass->SetSFields(statics); in LoadClassMembers()
2753 klass->SetIFields(fields); in LoadClassMembers()
2762 klass->SetStaticField(i, sfield.Get()); in LoadClassMembers()
2763 LoadField(dex_file, it, klass, sfield); in LoadClassMembers()
2772 klass->SetInstanceField(i, ifield.Get()); in LoadClassMembers()
2773 LoadField(dex_file, it, klass, ifield); in LoadClassMembers()
2785 klass->SetDirectMethods(directs); in LoadClassMembers()
2795 klass->SetVirtualMethods(virtuals); in LoadClassMembers()
2802 Handle<mirror::ArtMethod> method(hs.NewHandle(LoadMethod(self, dex_file, it, klass))); in LoadClassMembers()
2807 klass->SetDirectMethod(i, method.Get()); in LoadClassMembers()
2822 Handle<mirror::ArtMethod> method(hs.NewHandle(LoadMethod(self, dex_file, it, klass))); in LoadClassMembers()
2827 klass->SetVirtualMethod(i, method.Get()); in LoadClassMembers()
2836 Handle<mirror::Class> klass, Handle<mirror::ArtField> dst) { in LoadField() argument
2839 dst->SetDeclaringClass(klass.Get()); in LoadField()
2845 Handle<mirror::Class> klass) { in LoadMethod() argument
2859 dst->SetDeclaringClass(klass.Get()); in LoadMethod()
2862 dst->SetDexCacheStrings(klass->GetDexCache()->GetStrings()); in LoadMethod()
2863 dst->SetDexCacheResolvedMethods(klass->GetDexCache()->GetResolvedMethods()); in LoadMethod()
2864 dst->SetDexCacheResolvedTypes(klass->GetDexCache()->GetResolvedTypes()); in LoadMethod()
2872 if (klass->GetClassLoader() != nullptr) { // All non-boot finalizer methods are flagged. in LoadMethod()
2873 klass->SetFinalizable(); in LoadMethod()
2876 const char* klass_descriptor = klass->GetDescriptor(&temp); in LoadMethod()
2884 klass->SetFinalizable(); in LoadMethod()
2897 << PrettyDescriptor(klass.Get()) << " in dex file " << dex_file.GetLocation(); in LoadMethod()
3019 mirror::Class* klass = AllocClass(self, mirror::Class::PrimitiveClassSize()); in CreatePrimitiveClass() local
3020 if (UNLIKELY(klass == nullptr)) { in CreatePrimitiveClass()
3023 return InitializePrimitiveClass(klass, type); in CreatePrimitiveClass()
3221 mirror::Class* ClassLinker::InsertClass(const char* descriptor, mirror::Class* klass, in InsertClass() argument
3224 mirror::DexCache* dex_cache = klass->GetDexCache(); in InsertClass()
3234 LookupClassFromTableLocked(descriptor, klass->GetClassLoader(), hash); in InsertClass()
3238 if (kIsDebugBuild && !klass->IsTemp() && klass->GetClassLoader() == nullptr && in InsertClass()
3244 CHECK(klass == existing); in InsertClass()
3247 VerifyObject(klass); in InsertClass()
3248 class_table_.insert(std::make_pair(hash, GcRoot<mirror::Class>(klass))); in InsertClass()
3250 new_class_roots_.push_back(std::make_pair(hash, GcRoot<mirror::Class>(klass))); in InsertClass()
3255 mirror::Class* ClassLinker::UpdateClass(const char* descriptor, mirror::Class* klass, in UpdateClass() argument
3259 LookupClassFromTableLocked(descriptor, klass->GetClassLoader(), hash); in UpdateClass()
3262 CHECK(klass->IsProxyClass()); in UpdateClass()
3266 CHECK_NE(existing, klass) << descriptor; in UpdateClass()
3268 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusResolving) << descriptor; in UpdateClass()
3272 mirror::Class* klass = it->second.Read(); in UpdateClass() local
3273 if (klass == existing) { in UpdateClass()
3279 CHECK(!klass->IsTemp()) << descriptor; in UpdateClass()
3280 if (kIsDebugBuild && klass->GetClassLoader() == nullptr && in UpdateClass()
3286 CHECK(klass == existing) << descriptor; in UpdateClass()
3289 VerifyObject(klass); in UpdateClass()
3291 class_table_.insert(std::make_pair(hash, GcRoot<mirror::Class>(klass))); in UpdateClass()
3293 new_class_roots_.push_back(std::make_pair(hash, GcRoot<mirror::Class>(klass))); in UpdateClass()
3305 mirror::Class* klass = it->second.Read(); in RemoveClass() local
3306 if (klass->GetClassLoader() == class_loader && klass->DescriptorEquals(descriptor)) { in RemoveClass()
3349 mirror::Class* klass = it->second.Read(); in LookupClassFromTableLocked() local
3350 if (klass->GetClassLoader() == class_loader && klass->DescriptorEquals(descriptor)) { in LookupClassFromTableLocked()
3357 << PrettyClass(klass) << " " << klass << " " << klass->GetClassLoader() << " " in LookupClassFromTableLocked()
3361 return klass; in LookupClassFromTableLocked()
3389 mirror::Class* klass = types->Get(j); in MoveImageClassesToClassTable() local
3390 if (klass != nullptr) { in MoveImageClassesToClassTable()
3391 DCHECK(klass->GetClassLoader() == nullptr); in MoveImageClassesToClassTable()
3392 const char* descriptor = klass->GetDescriptor(&temp); in MoveImageClassesToClassTable()
3396 CHECK(existing == klass) << PrettyClassAndClassLoader(existing) << " != " in MoveImageClassesToClassTable()
3397 << PrettyClassAndClassLoader(klass); in MoveImageClassesToClassTable()
3399 class_table_.insert(std::make_pair(hash, GcRoot<mirror::Class>(klass))); in MoveImageClassesToClassTable()
3401 new_class_roots_.push_back(std::make_pair(hash, GcRoot<mirror::Class>(klass))); in MoveImageClassesToClassTable()
3426 mirror::Class* klass = dex_cache->GetResolvedType(type_idx); in LookupClassFromImage() local
3427 if (klass != nullptr) { in LookupClassFromImage()
3429 return klass; in LookupClassFromImage()
3447 mirror::Class* klass = it->second.Read(); in LookupClasses() local
3448 if (klass->DescriptorEquals(descriptor)) { in LookupClasses()
3449 result.push_back(klass); in LookupClasses()
3454 void ClassLinker::VerifyClass(Handle<mirror::Class> klass) { in VerifyClass() argument
3457 ObjectLock<mirror::Class> lock(self, klass); in VerifyClass()
3460 if (klass->IsVerified()) { in VerifyClass()
3461 EnsurePreverifiedMethods(klass); in VerifyClass()
3464 if (klass->IsCompileTimeVerified() && Runtime::Current()->IsCompiler()) { in VerifyClass()
3470 if (klass->IsErroneous()) { in VerifyClass()
3471 ThrowEarlierClassFailure(klass.Get()); in VerifyClass()
3475 if (klass->GetStatus() == mirror::Class::kStatusResolved) { in VerifyClass()
3476 klass->SetStatus(mirror::Class::kStatusVerifying, self); in VerifyClass()
3478 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime) in VerifyClass()
3479 << PrettyClass(klass.Get()); in VerifyClass()
3481 klass->SetStatus(mirror::Class::kStatusVerifyingAtRuntime, self); in VerifyClass()
3486 klass->SetStatus(mirror::Class::kStatusVerified, self); in VerifyClass()
3487 EnsurePreverifiedMethods(klass); in VerifyClass()
3493 Handle<mirror::Class> super(hs.NewHandle(klass->GetSuperClass())); in VerifyClass()
3504 PrettyDescriptor(klass.Get()).c_str(), in VerifyClass()
3506 LOG(ERROR) << error_msg << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8(); in VerifyClass()
3511 ThrowVerifyError(klass.Get(), "%s", error_msg.c_str()); in VerifyClass()
3515 ClassReference ref(klass->GetDexCache()->GetDexFile(), klass->GetDexClassDefIndex()); in VerifyClass()
3519 klass->SetStatus(mirror::Class::kStatusError, self); in VerifyClass()
3525 const DexFile& dex_file = *klass->GetDexCache()->GetDexFile(); in VerifyClass()
3527 bool preverified = VerifyClassUsingOatFile(dex_file, klass.Get(), oat_file_class_status); in VerifyClass()
3530 << PrettyDescriptor(klass.Get()) << " in " in VerifyClass()
3531 << klass->GetDexCache()->GetLocation()->ToModifiedUtf8(); in VerifyClass()
3532 ThrowVerifyError(klass.Get(), "Rejecting class %s because it failed compile-time verification", in VerifyClass()
3533 PrettyDescriptor(klass.Get()).c_str()); in VerifyClass()
3534 klass->SetStatus(mirror::Class::kStatusError, self); in VerifyClass()
3540 verifier_failure = verifier::MethodVerifier::VerifyClass(klass.Get(), in VerifyClass()
3546 VLOG(class_linker) << "Soft verification failure in class " << PrettyDescriptor(klass.Get()) in VerifyClass()
3547 << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8() in VerifyClass()
3552 ResolveClassExceptionHandlerTypes(dex_file, klass); in VerifyClass()
3557 klass->SetStatus(mirror::Class::kStatusVerified, self); in VerifyClass()
3560 klass->SetStatus(mirror::Class::kStatusRetryVerificationAtRuntime, self); in VerifyClass()
3570 klass->SetStatus(mirror::Class::kStatusRetryVerificationAtRuntime, self); in VerifyClass()
3572 klass->SetStatus(mirror::Class::kStatusVerified, self); in VerifyClass()
3575 klass->SetAccessFlags(klass->GetAccessFlags() | kAccPreverified); in VerifyClass()
3579 LOG(ERROR) << "Verification failed on class " << PrettyDescriptor(klass.Get()) in VerifyClass()
3580 << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8() in VerifyClass()
3583 ThrowVerifyError(klass.Get(), "%s", error_msg.c_str()); in VerifyClass()
3584 klass->SetStatus(mirror::Class::kStatusError, self); in VerifyClass()
3593 EnsurePreverifiedMethods(klass); in VerifyClass()
3597 void ClassLinker::EnsurePreverifiedMethods(Handle<mirror::Class> klass) { in EnsurePreverifiedMethods() argument
3598 if ((klass->GetAccessFlags() & kAccPreverified) == 0) { in EnsurePreverifiedMethods()
3599 klass->SetPreverifiedFlagOnAllMethods(); in EnsurePreverifiedMethods()
3600 klass->SetAccessFlags(klass->GetAccessFlags() | kAccPreverified); in EnsurePreverifiedMethods()
3604 bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass, in VerifyClassUsingOatFile() argument
3618 if (klass->GetClassLoader() != nullptr) { in VerifyClassUsingOatFile()
3629 uint16_t class_def_index = klass->GetDexClassDefIndex(); in VerifyClassUsingOatFile()
3669 << " " << dex_file.GetLocation() << " " << PrettyClass(klass) << " " in VerifyClassUsingOatFile()
3670 << klass->GetDescriptor(&temp); in VerifyClassUsingOatFile()
3676 Handle<mirror::Class> klass) { in ResolveClassExceptionHandlerTypes() argument
3677 for (size_t i = 0; i < klass->NumDirectMethods(); i++) { in ResolveClassExceptionHandlerTypes()
3678 ResolveMethodExceptionHandlerTypes(dex_file, klass->GetDirectMethod(i)); in ResolveClassExceptionHandlerTypes()
3680 for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { in ResolveClassExceptionHandlerTypes()
3681 ResolveMethodExceptionHandlerTypes(dex_file, klass->GetVirtualMethod(i)); in ResolveClassExceptionHandlerTypes()
3724 Handle<mirror::Class> klass(hs.NewHandle( in CreateProxyClass() local
3726 if (klass.Get() == nullptr) { in CreateProxyClass()
3730 DCHECK(klass->GetClass() != nullptr); in CreateProxyClass()
3731 klass->SetObjectSize(sizeof(mirror::Proxy)); in CreateProxyClass()
3733 klass->SetAccessFlags(kAccClassIsProxy | kAccPublic | kAccFinal | kAccPreverified); in CreateProxyClass()
3734 klass->SetClassLoader(soa.Decode<mirror::ClassLoader*>(loader)); in CreateProxyClass()
3735 DCHECK_EQ(klass->GetPrimitiveType(), Primitive::kPrimNot); in CreateProxyClass()
3736 klass->SetName(soa.Decode<mirror::String*>(name)); in CreateProxyClass()
3738 klass->SetDexCache(proxy_class->GetDexCache()); in CreateProxyClass()
3739 klass->SetStatus(mirror::Class::kStatusIdx, self); in CreateProxyClass()
3748 klass->SetSFields(sfields); in CreateProxyClass()
3757 klass->SetStaticField(0, interfaces_sfield.Get()); in CreateProxyClass()
3759 interfaces_sfield->SetDeclaringClass(klass.Get()); in CreateProxyClass()
3767 klass->SetStaticField(1, throws_sfield.Get()); in CreateProxyClass()
3769 throws_sfield->SetDeclaringClass(klass.Get()); in CreateProxyClass()
3779 klass->SetDirectMethods(directs); in CreateProxyClass()
3780 mirror::ArtMethod* constructor = CreateProxyConstructor(self, klass, proxy_class); in CreateProxyClass()
3785 klass->SetDirectMethod(0, constructor); in CreateProxyClass()
3798 klass->SetVirtualMethods(virtuals); in CreateProxyClass()
3805 mirror::ArtMethod* clone = CreateProxyMethod(self, klass, prototype); in CreateProxyClass()
3810 klass->SetVirtualMethod(i, clone); in CreateProxyClass()
3813 klass->SetSuperClass(proxy_class); // The super class is java.lang.reflect.Proxy in CreateProxyClass()
3814 klass->SetStatus(mirror::Class::kStatusLoaded, self); // Now effectively in the loaded state. in CreateProxyClass()
3817 std::string descriptor(GetDescriptorForProxy(klass.Get())); in CreateProxyClass()
3821 ObjectLock<mirror::Class> resolution_lock(self, klass); in CreateProxyClass()
3825 if (!LinkClass(self, descriptor.c_str(), klass, h_interfaces, &new_class)) { in CreateProxyClass()
3826 klass->SetStatus(mirror::Class::kStatusError, self); in CreateProxyClass()
3831 CHECK(klass->IsRetired()); in CreateProxyClass()
3832 CHECK_NE(klass.Get(), new_class); in CreateProxyClass()
3833 klass.Assign(new_class); in CreateProxyClass()
3836 interfaces_sfield->SetObject<false>(klass.Get(), in CreateProxyClass()
3839 throws_sfield->SetObject<false>(klass.Get(), in CreateProxyClass()
3844 ObjectLock<mirror::Class> initialization_lock(self, klass); in CreateProxyClass()
3845 klass->SetStatus(mirror::Class::kStatusInitialized, self); in CreateProxyClass()
3850 CHECK(klass->GetIFields() == nullptr); in CreateProxyClass()
3851 CheckProxyConstructor(klass->GetDirectMethod(0)); in CreateProxyClass()
3857 Handle<mirror::ArtMethod> virtual_method(hs.NewHandle(klass->GetVirtualMethod(i))); in CreateProxyClass()
3864 CHECK_EQ(PrettyField(klass->GetStaticField(0)), interfaces_field_name); in CreateProxyClass()
3868 CHECK_EQ(PrettyField(klass->GetStaticField(1)), throws_field_name); in CreateProxyClass()
3870 CHECK_EQ(klass.Get()->GetInterfaces(), in CreateProxyClass()
3872 CHECK_EQ(klass.Get()->GetThrows(), in CreateProxyClass()
3875 mirror::Class* existing = InsertClass(descriptor.c_str(), klass.Get(), Hash(descriptor.c_str())); in CreateProxyClass()
3877 return klass.Get(); in CreateProxyClass()
3912 Handle<mirror::Class> klass, in CreateProxyConstructor() argument
3932 constructor->SetDeclaringClass(klass.Get()); in CreateProxyConstructor()
3946 Handle<mirror::Class> klass, in CreateProxyMethod() argument
3962 method->SetDeclaringClass(klass.Get()); in CreateProxyMethod()
3998 static bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics, in CanWeInitializeClass() argument
4006 mirror::ArtMethod* clinit = klass->FindClassInitializer(); in CanWeInitializeClass()
4011 if (klass->NumStaticFields() != 0) { in CanWeInitializeClass()
4012 const DexFile::ClassDef* dex_class_def = klass->GetClassDef(); in CanWeInitializeClass()
4019 if (!klass->IsInterface() && klass->HasSuperClass()) { in CanWeInitializeClass()
4020 mirror::Class* super_class = klass->GetSuperClass(); in CanWeInitializeClass()
4036 bool ClassLinker::InitializeClass(Handle<mirror::Class> klass, bool can_init_statics, in InitializeClass() argument
4043 if (klass->IsInitialized()) { in InitializeClass()
4048 if (!CanWeInitializeClass(klass.Get(), can_init_statics, can_init_parents)) { in InitializeClass()
4055 ObjectLock<mirror::Class> lock(self, klass); in InitializeClass()
4058 if (klass->IsInitialized()) { in InitializeClass()
4063 if (klass->IsErroneous()) { in InitializeClass()
4064 ThrowEarlierClassFailure(klass.Get()); in InitializeClass()
4068 CHECK(klass->IsResolved()) << PrettyClass(klass.Get()) << ": state=" << klass->GetStatus(); in InitializeClass()
4070 if (!klass->IsVerified()) { in InitializeClass()
4071 VerifyClass(klass); in InitializeClass()
4072 if (!klass->IsVerified()) { in InitializeClass()
4075 if (klass->IsErroneous()) { in InitializeClass()
4079 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime); in InitializeClass()
4092 if (klass->GetStatus() == mirror::Class::kStatusInitializing) { in InitializeClass()
4098 if (klass->GetClinitThreadId() == self->GetTid()) { in InitializeClass()
4103 return WaitForInitializeClass(klass, self, lock); in InitializeClass()
4106 if (!ValidateSuperClassDescriptors(klass)) { in InitializeClass()
4107 klass->SetStatus(mirror::Class::kStatusError, self); in InitializeClass()
4111 CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << PrettyClass(klass.Get()); in InitializeClass()
4115 klass->SetClinitThreadId(self->GetTid()); in InitializeClass()
4116 klass->SetStatus(mirror::Class::kStatusInitializing, self); in InitializeClass()
4122 if (!klass->IsInterface() && klass->HasSuperClass()) { in InitializeClass()
4123 mirror::Class* super_class = klass->GetSuperClass(); in InitializeClass()
4139 ObjectLock<mirror::Class> lock(self, klass); in InitializeClass()
4141 klass->SetStatus(mirror::Class::kStatusError, self); in InitializeClass()
4147 if (klass->NumStaticFields() > 0) { in InitializeClass()
4148 const DexFile::ClassDef* dex_class_def = klass->GetClassDef(); in InitializeClass()
4150 const DexFile& dex_file = klass->GetDexFile(); in InitializeClass()
4152 Handle<mirror::ClassLoader> class_loader(hs.NewHandle(klass->GetClassLoader())); in InitializeClass()
4153 Handle<mirror::DexCache> dex_cache(hs.NewHandle(klass->GetDexCache())); in InitializeClass()
4161 ConstructFieldMap(dex_file, *dex_class_def, klass.Get(), field_map); in InitializeClass()
4172 mirror::ArtMethod* clinit = klass->FindClassInitializer(); in InitializeClass()
4183 ObjectLock<mirror::Class> lock(self, klass); in InitializeClass()
4187 klass->SetStatus(mirror::Class::kStatusError, self); in InitializeClass()
4197 klass->SetStatus(mirror::Class::kStatusInitialized, self); in InitializeClass()
4200 LOG(INFO) << "Initialized class " << klass->GetDescriptor(&temp) << " from " << in InitializeClass()
4201 klass->GetLocation(); in InitializeClass()
4204 FixupStaticTrampolines(klass.Get()); in InitializeClass()
4210 bool ClassLinker::WaitForInitializeClass(Handle<mirror::Class> klass, Thread* self, in WaitForInitializeClass() argument
4215 CHECK(!klass->IsInitialized()); in WaitForInitializeClass()
4223 klass->SetStatus(mirror::Class::kStatusError, self); in WaitForInitializeClass()
4227 if (klass->GetStatus() == mirror::Class::kStatusInitializing) { in WaitForInitializeClass()
4230 if (klass->GetStatus() == mirror::Class::kStatusVerified && Runtime::Current()->IsCompiler()) { in WaitForInitializeClass()
4234 if (klass->IsErroneous()) { in WaitForInitializeClass()
4238 PrettyDescriptor(klass.Get()).c_str()); in WaitForInitializeClass()
4241 if (klass->IsInitialized()) { in WaitForInitializeClass()
4244 LOG(FATAL) << "Unexpected class status. " << PrettyClass(klass.Get()) << " is " in WaitForInitializeClass()
4245 << klass->GetStatus(); in WaitForInitializeClass()
4247 LOG(FATAL) << "Not Reached" << PrettyClass(klass.Get()); in WaitForInitializeClass()
4250 bool ClassLinker::ValidateSuperClassDescriptors(Handle<mirror::Class> klass) { in ValidateSuperClassDescriptors() argument
4251 if (klass->IsInterface()) { in ValidateSuperClassDescriptors()
4258 if (klass->HasSuperClass() && in ValidateSuperClassDescriptors()
4259 klass->GetClassLoader() != klass->GetSuperClass()->GetClassLoader()) { in ValidateSuperClassDescriptors()
4260 for (int i = klass->GetSuperClass()->GetVTableLength() - 1; i >= 0; --i) { in ValidateSuperClassDescriptors()
4261 mh.ChangeMethod(klass->GetVTableEntry(i)); in ValidateSuperClassDescriptors()
4262 super_mh.ChangeMethod(klass->GetSuperClass()->GetVTableEntry(i)); in ValidateSuperClassDescriptors()
4265 ThrowLinkageError(klass.Get(), in ValidateSuperClassDescriptors()
4267 PrettyDescriptor(klass.Get()).c_str(), in ValidateSuperClassDescriptors()
4269 PrettyDescriptor(klass->GetSuperClass()).c_str()); in ValidateSuperClassDescriptors()
4274 for (int32_t i = 0; i < klass->GetIfTableCount(); ++i) { in ValidateSuperClassDescriptors()
4275 if (klass->GetClassLoader() != klass->GetIfTable()->GetInterface(i)->GetClassLoader()) { in ValidateSuperClassDescriptors()
4276 uint32_t num_methods = klass->GetIfTable()->GetInterface(i)->NumVirtualMethods(); in ValidateSuperClassDescriptors()
4278 mh.ChangeMethod(klass->GetIfTable()->GetMethodArray(i)->GetWithoutChecks(j)); in ValidateSuperClassDescriptors()
4279 super_mh.ChangeMethod(klass->GetIfTable()->GetInterface(i)->GetVirtualMethod(j)); in ValidateSuperClassDescriptors()
4282 ThrowLinkageError(klass.Get(), in ValidateSuperClassDescriptors()
4284 PrettyDescriptor(klass.Get()).c_str(), in ValidateSuperClassDescriptors()
4286 PrettyDescriptor(klass->GetIfTable()->GetInterface(i)).c_str()); in ValidateSuperClassDescriptors()
4366 bool ClassLinker::LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass, in LinkClass() argument
4369 CHECK_EQ(mirror::Class::kStatusLoaded, klass->GetStatus()); in LinkClass()
4371 if (!LinkSuperClass(klass)) { in LinkClass()
4374 if (!LinkMethods(self, klass, interfaces)) { in LinkClass()
4377 if (!LinkInstanceFields(klass)) { in LinkClass()
4381 if (!LinkStaticFields(klass, &class_size)) { in LinkClass()
4384 CreateReferenceInstanceOffsets(klass); in LinkClass()
4385 CreateReferenceStaticOffsets(klass); in LinkClass()
4386 CHECK_EQ(mirror::Class::kStatusLoaded, klass->GetStatus()); in LinkClass()
4388 if (!klass->IsTemp() || (!init_done_ && klass->GetClassSize() == class_size)) { in LinkClass()
4391 CHECK_EQ(klass->GetClassSize(), class_size) << PrettyDescriptor(klass.Get()); in LinkClass()
4393 if (klass->ShouldHaveEmbeddedImtAndVTable()) { in LinkClass()
4394 klass->PopulateEmbeddedImtAndVTable(); in LinkClass()
4399 klass->SetStatus(mirror::Class::kStatusResolved, self); in LinkClass()
4400 *new_class = klass.Get(); in LinkClass()
4402 CHECK(!klass->IsResolved()); in LinkClass()
4404 *new_class = klass->CopyOf(self, class_size); in LinkClass()
4407 klass->SetStatus(mirror::Class::kStatusError, self); in LinkClass()
4416 FixupTemporaryDeclaringClass(klass.Get(), new_class_h.Get()); in LinkClass()
4419 CHECK(existing == nullptr || existing == klass.Get()); in LinkClass()
4423 klass->SetStatus(mirror::Class::kStatusRetired, self); in LinkClass()
4433 bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file) { in LoadSuperAndInterfaces() argument
4434 CHECK_EQ(mirror::Class::kStatusIdx, klass->GetStatus()); in LoadSuperAndInterfaces()
4435 const DexFile::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex()); in LoadSuperAndInterfaces()
4438 mirror::Class* super_class = ResolveType(dex_file, super_class_idx, klass.Get()); in LoadSuperAndInterfaces()
4444 if (!klass->CanAccess(super_class)) { in LoadSuperAndInterfaces()
4445 ThrowIllegalAccessError(klass.Get(), "Class %s extended by class %s is inaccessible", in LoadSuperAndInterfaces()
4447 PrettyDescriptor(klass.Get()).c_str()); in LoadSuperAndInterfaces()
4451 klass->SetSuperClass(super_class); in LoadSuperAndInterfaces()
4457 mirror::Class* interface = ResolveType(dex_file, idx, klass.Get()); in LoadSuperAndInterfaces()
4463 if (!klass->CanAccess(interface)) { in LoadSuperAndInterfaces()
4465 ThrowIllegalAccessError(klass.Get(), "Interface %s implemented by class %s is inaccessible", in LoadSuperAndInterfaces()
4467 PrettyDescriptor(klass.Get()).c_str()); in LoadSuperAndInterfaces()
4473 klass->SetStatus(mirror::Class::kStatusLoaded, nullptr); in LoadSuperAndInterfaces()
4477 bool ClassLinker::LinkSuperClass(Handle<mirror::Class> klass) { in LinkSuperClass() argument
4478 CHECK(!klass->IsPrimitive()); in LinkSuperClass()
4479 mirror::Class* super = klass->GetSuperClass(); in LinkSuperClass()
4480 if (klass.Get() == GetClassRoot(kJavaLangObject)) { in LinkSuperClass()
4482 ThrowClassFormatError(klass.Get(), "java.lang.Object must not have a superclass"); in LinkSuperClass()
4488 ThrowLinkageError(klass.Get(), "No superclass defined for class %s", in LinkSuperClass()
4489 PrettyDescriptor(klass.Get()).c_str()); in LinkSuperClass()
4494 ThrowIncompatibleClassChangeError(klass.Get(), "Superclass %s of %s is %s", in LinkSuperClass()
4496 PrettyDescriptor(klass.Get()).c_str(), in LinkSuperClass()
4500 if (!klass->CanAccess(super)) { in LinkSuperClass()
4501 ThrowIllegalAccessError(klass.Get(), "Superclass %s is inaccessible to class %s", in LinkSuperClass()
4503 PrettyDescriptor(klass.Get()).c_str()); in LinkSuperClass()
4510 klass->SetFinalizable(); in LinkSuperClass()
4516 klass->SetAccessFlags(klass->GetAccessFlags() | reference_flags); in LinkSuperClass()
4520 ThrowLinkageError(klass.Get(), in LinkSuperClass()
4522 PrettyDescriptor(klass.Get()).c_str()); in LinkSuperClass()
4537 bool ClassLinker::LinkMethods(Thread* self, Handle<mirror::Class> klass, in LinkMethods() argument
4539 if (klass->IsInterface()) { in LinkMethods()
4541 size_t count = klass->NumVirtualMethods(); in LinkMethods()
4543 ThrowClassFormatError(klass.Get(), "Too many methods on interface: %zd", count); in LinkMethods()
4547 klass->GetVirtualMethodDuringLinking(i)->SetMethodIndex(i); in LinkMethods()
4550 return LinkInterfaceMethods(klass, interfaces); in LinkMethods()
4553 return LinkVirtualMethods(self, klass) && LinkInterfaceMethods(klass, interfaces); in LinkMethods()
4558 bool ClassLinker::LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass) { in LinkVirtualMethods() argument
4559 if (klass->HasSuperClass()) { in LinkVirtualMethods()
4560 uint32_t max_count = klass->NumVirtualMethods() + in LinkVirtualMethods()
4561 klass->GetSuperClass()->GetVTableLength(); in LinkVirtualMethods()
4562 size_t actual_count = klass->GetSuperClass()->GetVTableLength(); in LinkVirtualMethods()
4565 Handle<mirror::Class> super_class(hs.NewHandle(klass->GetSuperClass())); in LinkVirtualMethods()
4589 for (size_t i = 0; i < klass->NumVirtualMethods(); ++i) { in LinkVirtualMethods()
4590 mirror::ArtMethod* local_method = klass->GetVirtualMethodDuringLinking(i); in LinkVirtualMethods()
4597 if (klass->CanAccessMember(super_method->GetDeclaringClass(), in LinkVirtualMethods()
4600 ThrowLinkageError(klass.Get(), "Method %s overrides final method in class %s", in LinkVirtualMethods()
4623 ThrowClassFormatError(klass.Get(), "Too many methods defined on class: %zd", actual_count); in LinkVirtualMethods()
4635 klass->SetVTable(vtable.Get()); in LinkVirtualMethods()
4637 CHECK_EQ(klass.Get(), GetClassRoot(kJavaLangObject)); in LinkVirtualMethods()
4638 uint32_t num_virtual_methods = klass->NumVirtualMethods(); in LinkVirtualMethods()
4640 ThrowClassFormatError(klass.Get(), "Too many methods: %d", num_virtual_methods); in LinkVirtualMethods()
4651 mirror::ArtMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); in LinkVirtualMethods()
4655 klass->SetVTable(vtable.Get()); in LinkVirtualMethods()
4660 bool ClassLinker::LinkInterfaceMethods(Handle<mirror::Class> klass, in LinkInterfaceMethods() argument
4665 klass->SetImTable(runtime->GetDefaultImt()); in LinkInterfaceMethods()
4667 if (klass->HasSuperClass()) { in LinkInterfaceMethods()
4668 super_ifcount = klass->GetSuperClass()->GetIfTableCount(); in LinkInterfaceMethods()
4673 interfaces.Get() == nullptr ? klass->NumDirectInterfaces() : interfaces->GetLength(); in LinkInterfaceMethods()
4677 interfaces.Get() == nullptr ? mirror::Class::GetDirectInterface(self, klass, i) : in LinkInterfaceMethods()
4683 DCHECK_EQ(klass->GetIfTableCount(), 0); in LinkInterfaceMethods()
4684 DCHECK(klass->GetIfTable() == nullptr); in LinkInterfaceMethods()
4690 mirror::IfTable* super_iftable = klass->GetSuperClass()->GetIfTable(); in LinkInterfaceMethods()
4699 klass->SetIfTable(super_iftable); in LinkInterfaceMethods()
4710 mirror::IfTable* super_iftable = klass->GetSuperClass()->GetIfTable(); in LinkInterfaceMethods()
4720 interfaces.Get() == nullptr ? mirror::Class::GetDirectInterface(self, klass, i) : in LinkInterfaceMethods()
4725 ThrowIncompatibleClassChangeError(klass.Get(), "Class %s implements non-interface class %s", in LinkInterfaceMethods()
4726 PrettyDescriptor(klass.Get()).c_str(), in LinkInterfaceMethods()
4770 klass->SetIfTable(iftable.Get()); in LinkInterfaceMethods()
4773 if (klass->IsInterface()) { in LinkInterfaceMethods()
4799 hs.NewHandle(klass->GetVTableDuringLinking())); in LinkInterfaceMethods()
4818 klass.Get(), in LinkInterfaceMethods()
4869 klass->SetImTable(imtable.Get()); in LinkInterfaceMethods()
4872 int old_method_count = klass->NumVirtualMethods(); in LinkInterfaceMethods()
4878 virtuals = klass->GetVirtualMethods()->CopyOf(self, new_method_count); in LinkInterfaceMethods()
4884 klass->SetVirtualMethods(virtuals); in LinkInterfaceMethods()
4888 hs.NewHandle(klass->GetVTableDuringLinking())); in LinkInterfaceMethods()
4902 klass->SetVirtualMethod(old_method_count + i, method); in LinkInterfaceMethods()
4906 klass->SetVTable(vtable.Get()); in LinkInterfaceMethods()
4909 mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking(); in LinkInterfaceMethods()
4919 bool ClassLinker::LinkInstanceFields(Handle<mirror::Class> klass) { in LinkInstanceFields() argument
4920 CHECK(klass.Get() != nullptr); in LinkInstanceFields()
4921 return LinkFields(klass, false, nullptr); in LinkInstanceFields()
4924 bool ClassLinker::LinkStaticFields(Handle<mirror::Class> klass, size_t* class_size) { in LinkStaticFields() argument
4925 CHECK(klass.Get() != nullptr); in LinkStaticFields()
4926 return LinkFields(klass, true, class_size); in LinkStaticFields()
4956 bool ClassLinker::LinkFields(Handle<mirror::Class> klass, bool is_static, size_t* class_size) { in LinkFields() argument
4958 is_static ? klass->NumStaticFields() : klass->NumInstanceFields(); in LinkFields()
4961 is_static ? klass->GetSFields() : klass->GetIFields(); in LinkFields()
4967 if (klass->ShouldHaveEmbeddedImtAndVTable()) { in LinkFields()
4969 base = mirror::Class::ComputeClassSize(true, klass->GetVTableDuringLinking()->GetLength(), in LinkFields()
4974 mirror::Class* super_class = klass->GetSuperClass(); in LinkFields()
4977 << PrettyClass(klass.Get()) << " " << PrettyClass(super_class); in LinkFields()
4982 CHECK_EQ(num_fields == 0, fields == nullptr) << PrettyClass(klass.Get()); in LinkFields()
4989 CHECK(f != nullptr) << PrettyClass(klass.Get()); in LinkFields()
5036 << PrettyClass(klass.Get()); in LinkFields()
5052 if (!is_static && klass->DescriptorEquals("Ljava/lang/ref/Reference;")) { in LinkFields()
5055 CHECK_EQ(num_reference_fields, num_fields) << PrettyClass(klass.Get()); in LinkFields()
5056 CHECK_STREQ(fields->Get(num_fields - 1)->GetName(), "referent") << PrettyClass(klass.Get()); in LinkFields()
5068 << " class=" << PrettyClass(klass.Get()) in LinkFields()
5075 if (klass->DescriptorEquals("Ljava/lang/ref/Reference;") && in LinkFields()
5089 DCHECK_EQ(num_fields, num_reference_fields) << PrettyClass(klass.Get()); in LinkFields()
5096 klass->SetNumReferenceStaticFields(num_reference_fields); in LinkFields()
5099 klass->SetNumReferenceInstanceFields(num_reference_fields); in LinkFields()
5100 if (!klass->IsVariableSize()) { in LinkFields()
5102 DCHECK_GE(size, sizeof(mirror::Object)) << klass->GetDescriptor(&temp); in LinkFields()
5103 size_t previous_size = klass->GetObjectSize(); in LinkFields()
5106 CHECK_EQ(previous_size, size) << klass->GetDescriptor(&temp); in LinkFields()
5108 klass->SetObjectSize(size); in LinkFields()
5116 void ClassLinker::CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) { in CreateReferenceInstanceOffsets() argument
5118 mirror::Class* super_class = klass->GetSuperClass(); in CreateReferenceInstanceOffsets()
5123 klass->SetReferenceInstanceOffsets(reference_offsets); in CreateReferenceInstanceOffsets()
5127 CreateReferenceOffsets(klass, false, reference_offsets); in CreateReferenceInstanceOffsets()
5130 void ClassLinker::CreateReferenceStaticOffsets(Handle<mirror::Class> klass) { in CreateReferenceStaticOffsets() argument
5131 CreateReferenceOffsets(klass, true, 0); in CreateReferenceStaticOffsets()
5134 void ClassLinker::CreateReferenceOffsets(Handle<mirror::Class> klass, bool is_static, in CreateReferenceOffsets() argument
5137 is_static ? klass->NumReferenceStaticFieldsDuringLinking() in CreateReferenceOffsets()
5138 : klass->NumReferenceInstanceFieldsDuringLinking(); in CreateReferenceOffsets()
5140 is_static ? klass->GetSFields() : klass->GetIFields(); in CreateReferenceOffsets()
5160 klass->SetReferenceStaticOffsets(reference_offsets); in CreateReferenceOffsets()
5162 klass->SetReferenceInstanceOffsets(reference_offsets); in CreateReferenceOffsets()
5234 mirror::Class* klass = ResolveType(dex_file, method_id.class_idx_, dex_cache, class_loader); in ResolveMethod() local
5235 if (klass == nullptr) { in ResolveMethod()
5244 resolved = klass->FindDirectMethod(dex_cache.Get(), method_idx); in ResolveMethod()
5247 resolved = klass->FindInterfaceMethod(dex_cache.Get(), method_idx); in ResolveMethod()
5252 resolved = klass->FindVirtualMethod(dex_cache.Get(), method_idx); in ResolveMethod()
5264 resolved = klass->FindDirectMethod(name, signature); in ResolveMethod()
5267 resolved = klass->FindInterfaceMethod(name, signature); in ResolveMethod()
5272 resolved = klass->FindVirtualMethod(name, signature); in ResolveMethod()
5293 resolved = klass->FindVirtualMethod(name, signature); in ResolveMethod()
5300 resolved = klass->FindDirectMethod(name, signature); in ResolveMethod()
5328 resolved = klass->FindInterfaceMethod(name, signature); in ResolveMethod()
5332 ThrowNoSuchMethodError(type, klass, name, signature); in ResolveMethod()
5340 resolved = klass->FindVirtualMethod(name, signature); in ResolveMethod()
5344 ThrowNoSuchMethodError(type, klass, name, signature); in ResolveMethod()
5352 ThrowNoSuchMethodError(type, klass, name, signature); in ResolveMethod()
5359 resolved = klass->FindInterfaceMethod(name, signature); in ResolveMethod()
5363 ThrowNoSuchMethodError(type, klass, name, signature); in ResolveMethod()
5386 Handle<mirror::Class> klass( in ResolveField() local
5388 if (klass.Get() == nullptr) { in ResolveField()
5394 resolved = mirror::Class::FindStaticField(self, klass, dex_cache.Get(), field_idx); in ResolveField()
5396 resolved = klass->FindInstanceField(dex_cache.Get(), field_idx); in ResolveField()
5403 resolved = mirror::Class::FindStaticField(self, klass, name, type); in ResolveField()
5405 resolved = klass->FindInstanceField(name, type); in ResolveField()
5408 ThrowNoSuchFieldError(is_static ? "static " : "instance ", klass.Get(), type, name); in ResolveField()
5428 Handle<mirror::Class> klass( in ResolveFieldJLS() local
5430 if (klass.Get() == nullptr) { in ResolveFieldJLS()
5438 resolved = mirror::Class::FindField(self, klass, name, type); in ResolveFieldJLS()
5442 ThrowNoSuchFieldError("", klass.Get(), type, name); in ResolveFieldJLS()
5466 mirror::Class* klass = it.second.Read(); in DumpAllClasses() local
5467 all_classes.push_back(klass); in DumpAllClasses()
5500 void ClassLinker::SetClassRoot(ClassRoot class_root, mirror::Class* klass) { in SetClassRoot() argument
5503 DCHECK(klass != nullptr); in SetClassRoot()
5504 DCHECK(klass->GetClassLoader() == nullptr); in SetClassRoot()
5509 class_roots->Set<false>(class_root, klass); in SetClassRoot()