class_linker.cc
mirror::Class* ClassLinker::DefineClass(const char* descriptor,
mirror::ClassLoader* class_loader,
const DexFile& dex_file,
const DexFile::ClassDef& dex_class_def) {
Thread* self = Thread::Current();
SirtRef<mirror::Class> klass(self, NULL);
// Load the class from the dex file.
if (UNLIKELY(!init_done_)) {
// finish up init of hand crafted class_roots_
if (strcmp(descriptor, "Ljava/lang/Object;") == 0) {
klass.reset(GetClassRoot(kJavaLangObject));
...
}
...
}
...
}
...
//刚开始不懂这个mirror是啥意思
//Class是声明在mirror namespace里的一个新类型
//刚开始发现class_linker.h头文件中mirror命名空间没有找到这种定义新类型
//后来发现在class_linker.cc的另外一个包含的头文件class.h里也有mirror的声明,里面有class的新类型声明
//DefineClass是ClassLinker类定义的一个方法
mirror/class.h
namespace mirror {
class ArtField;
class ClassLoader;
class DexCache;
class IfTable;
// Type for the InitializedStaticStorage table. Currently the Class
// provides the static storage. However, this might change to an Array
// to improve image sharing, so we use this type to avoid assumptions
// on the current storage.
class MANAGED StaticStorageBase : public Object {
};
// C++ mirror of java.lang.Class
class MANAGED Class : public StaticStorageBase {
public:
...
}
}