blob: 8f8e8297613c7d8ecc2241ab3e39a073c6512d86 [file] [log] [blame]
Brian Carlstrom1f870082011-08-23 16:02:11 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#include "class_loader.h"
4
5#include "class_linker.h"
6#include "runtime.h"
7
8namespace art {
9
10const std::vector<const DexFile*>& ClassLoader::GetClassPath(const ClassLoader* class_loader) {
11 if (class_loader == NULL) {
12 return Runtime::Current()->GetClassLinker()->GetBootClassPath();
13 }
14 return class_loader->class_path_;
15}
16
17// TODO: get global references for these
18Class* PathClassLoader::dalvik_system_PathClassLoader_ = NULL;
19
20const PathClassLoader* PathClassLoader::Alloc(std::vector<const DexFile*> dex_files) {
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070021 DCHECK(dalvik_system_PathClassLoader_ != NULL);
Brian Carlstrom1f870082011-08-23 16:02:11 -070022 PathClassLoader* p = down_cast<PathClassLoader*>(dalvik_system_PathClassLoader_->AllocObject());
23 p->SetClassPath(dex_files);
24 return p;
25}
26
27void PathClassLoader::SetClass(Class* dalvik_system_PathClassLoader) {
28 CHECK(dalvik_system_PathClassLoader_ == NULL);
29 CHECK(dalvik_system_PathClassLoader != NULL);
30 dalvik_system_PathClassLoader_ = dalvik_system_PathClassLoader;
31}
32
33void PathClassLoader::ResetClass() {
34 CHECK(dalvik_system_PathClassLoader_ != NULL);
35 dalvik_system_PathClassLoader_ = NULL;
36}
37
38} // namespace art