ClassLinker can now FindClass all libcore classes
Summary:
- added ClassLinkerTest/LibCore test of finding all libcore classes
- fixed bug in LinkInterfaceMethods appending mirant methods to vtable_
- fixed bug in LinkVirtualMethods allocating subclass vtable_
- fixed mmap bug in MarkStack::Init
- bumped default (and max) heap sizes to handle ClassLinkerTest/LibCore
- made ObjectArray a templated class
- heap allocate Class::vtable_
- "mm test-art" and "mm test-art-target" added
- new is_host_ for use by tests
Details:
Added support for "mm test-art" and "mm test-art-target" in addition to test-art-host
Android.mk
Made ObjectArray a template class for clearer declarations and to
remove need the need for down_cast.
src/object.h
src/object_test.cc
src/class_linker.cc
src/class_linker.h
src/dex_cache.cc
src/dex_cache.h
src/dex_cache_test.cc
src/mark_sweep.cc
Made Class::vtable_ a heap allocated ObjectArray<Method>
src/class_linker.cc
Fix bug in ClassLinker::LinkInterfaceMethods where we were not
extending the vtable_ before appending miranda methods.
src/class_linker.cc
Changed all uses of DexFile* in ClassLinker to be const
src/class_linker.cc
src/class_linker.h
Fix bug in ClassLinker::LinkVirtualMethods where we were using
NumVirtualMethods vs vtable->GetLength when determining new max
vtable_ length.
src/class_linker.cc
New ClassLinkerTest/LibCore that enumerates the libcore dex file
and tries to FindClass every descriptor found.
src/class_linker_test.cc
Added if_host_ check for host only tests. In the future will use
for picking proper location of files, etc. on host vs target.
src/common_test.h
Fixed test to use ClassLinker::AllocDexCache
src/dex_cache_test.cc
Fixed fooIds comments to foo_ids_
src/dex_file.h
Bumped default heap size (and max as well) to make ClassLinkerTest/LibCore run
src/heap.h
Fixed bug where we were not using MAP_ANONYMOUS for MarkStack
allocation found running ClassLinkerTest/LibCore.
src/mark_stack.cc
Change-Id: I204e2ec7205210e2b60f5b81d126ab6e1da5a71c
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index 41fa5b1..4f921c4 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -4,6 +4,7 @@
#include "class_linker.h"
#include "dex_file.h"
#include "heap.h"
+#include "stringprintf.h"
#include "gtest/gtest.h"
namespace art {
@@ -72,6 +73,23 @@
EXPECT_EQ(0U, array->NumStaticFields());
EXPECT_EQ(2U, array->NumInterfaces());
}
+
+ void AssertDexFileClass(const DexFile* dex, const char* descriptor) {
+ CHECK(descriptor != NULL);
+ Class* klass = class_linker_->FindClass(descriptor, NULL, dex);
+ CHECK(klass != NULL);
+ }
+
+ void AssertDexFile(const DexFile* dex) {
+ CHECK(dex != NULL);
+ class_linker_->RegisterDexFile(dex);
+ for (size_t i = 0; i < dex->NumClassDefs(); i++) {
+ const DexFile::ClassDef class_def = dex->GetClassDef(i);
+ const char* descriptor = dex->GetClassDescriptor(class_def);
+ AssertDexFileClass(dex, descriptor);
+ }
+ }
+
};
TEST_F(ClassLinkerTest, FindClassNonexistent) {
@@ -273,4 +291,17 @@
EXPECT_TRUE(linker->HasSameNameAndPrototype(m4_2, m4_1));
}
+TEST_F(ClassLinkerTest, LibCore) {
+ // TODO add host support when we have DexFile::OpenJar
+ if (!is_host_) {
+ return;
+ }
+
+ // TODO switch to jar when we have DexFile::OpenJar
+ std::string libcore_dex_file_name = StringPrintf("%s/out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes.dex",
+ getenv("ANDROID_BUILD_TOP"));
+ scoped_ptr<DexFile> libcore_dex_file(DexFile::OpenFile(libcore_dex_file_name.c_str()));
+ AssertDexFile(libcore_dex_file.get());
+}
+
} // namespace art