art::ObjPtr<art::mirror::LongArray> ClassLoaderHelper::GetDexFileCookie(
art::Handle<art::mirror::Object> java_dex_file_obj) { // mCookie is nulled out if the DexFile has been closed but mInternalCookie sticks around until // the object is finalized. Since they always point to the same array if mCookie is not null we // just use the mInternalCookie field. We will update one or both of these fields later.
art::ArtField* internal_cookie_field = java_dex_file_obj->GetClass()->FindDeclaredInstanceField( "mInternalCookie", "Ljava/lang/Object;"); // TODO Add check that mCookie is either null or same as mInternalCookie
CHECK(internal_cookie_field != nullptr); return internal_cookie_field->GetObject(java_dex_file_obj.Get())->AsLongArray();
}
art::ObjPtr<art::mirror::LongArray> ClassLoaderHelper::AllocateNewDexFileCookie(
art::Thread* self,
art::Handle<art::mirror::LongArray> cookie, const art::DexFile* dex_file) {
art::StackHandleScope<1> hs(self);
CHECK(cookie != nullptr);
CHECK_GE(cookie->GetLength(), 1);
art::Handle<art::mirror::LongArray> new_cookie(
hs.NewHandle(art::mirror::LongArray::Alloc(self, cookie->GetLength() + 1))); if (new_cookie == nullptr) {
self->AssertPendingOOMException(); return nullptr;
} // Copy the oat-dex field at the start.
new_cookie->SetWithoutChecks<false>(0, cookie->GetWithoutChecks(0)); // This must match the casts in runtime/native/dalvik_system_DexFile.cc:ConvertDexFilesToJavaArray
new_cookie->SetWithoutChecks<false>( 1, static_cast<int64_t>(reinterpret_cast<uintptr_t>(dex_file)));
new_cookie->Memcpy(2, cookie.Get(), 1, cookie->GetLength() - 1); return new_cookie.Get();
}
// Get all the ArtFields so we can look in the BaseDexClassLoader
art::ArtField* path_list_field =
art::WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList;
art::ArtField* dex_path_list_element_field =
art::WellKnownClasses::dalvik_system_DexPathList_dexElements;
// Check if loader is a BaseDexClassLoader
art::Handle<art::mirror::Class> loader_class(hs.NewHandle(loader->GetClass())); // Currently only base_dex_loader is allowed to actually define classes but if this changes in the // future we should make sure to support all class loader types. if (!loader_class->IsSubClass(base_dex_loader_class.Get())) {
LOG(ERROR) << "The classloader " << loader_class->PrettyClass() << " is not a "
<< base_dex_loader_class->PrettyClass() << " which is currently the only "
<< "supported class loader type!"; return nullptr;
} // Start navigating the fields of the loader (now known to be a BaseDexClassLoader derivative)
art::Handle<art::mirror::Object> path_list(
hs.NewHandle(path_list_field->GetObject(loader.Get())));
CHECK(path_list != nullptr);
art::ObjPtr<art::mirror::ObjectArray<art::mirror::Object>> dex_elements_list =
dex_path_list_element_field->GetObject(path_list.Get())->AsObjectArray<art::mirror::Object>(); return dex_elements_list;
}
// TODO This should return the actual source java.lang.DexFile object for the klass being loaded.
art::ObjPtr<art::mirror::Object> ClassLoaderHelper::FindSourceDexFileObject(
art::Thread* self, art::Handle<art::mirror::ClassLoader> loader) {
art::ObjPtr<art::mirror::Object> res = nullptr;
VisitDexFileObjects(self,
loader,
[&] (art::ObjPtr<art::mirror::Object> dex_file) {
res = dex_file; // Just stop at the first one. // TODO It would be cleaner to put the art::DexFile into the // dalvik.system.DexFile the class comes from but it is more annoying // because we would need to find this class. It is not necessary for proper // function since we just need to be in front of the classes old dex file in // the path. returnfalse;
}); return res;
}
} // namespace openjdkjvmti
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.