Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame^] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "class_loader.h" |
| 4 | |
| 5 | #include "class_linker.h" |
| 6 | #include "runtime.h" |
| 7 | |
| 8 | namespace art { |
| 9 | |
| 10 | const 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 |
| 18 | Class* PathClassLoader::dalvik_system_PathClassLoader_ = NULL; |
| 19 | |
| 20 | const PathClassLoader* PathClassLoader::Alloc(std::vector<const DexFile*> dex_files) { |
| 21 | PathClassLoader* p = down_cast<PathClassLoader*>(dalvik_system_PathClassLoader_->AllocObject()); |
| 22 | p->SetClassPath(dex_files); |
| 23 | return p; |
| 24 | } |
| 25 | |
| 26 | void PathClassLoader::SetClass(Class* dalvik_system_PathClassLoader) { |
| 27 | CHECK(dalvik_system_PathClassLoader_ == NULL); |
| 28 | CHECK(dalvik_system_PathClassLoader != NULL); |
| 29 | dalvik_system_PathClassLoader_ = dalvik_system_PathClassLoader; |
| 30 | } |
| 31 | |
| 32 | void PathClassLoader::ResetClass() { |
| 33 | CHECK(dalvik_system_PathClassLoader_ != NULL); |
| 34 | dalvik_system_PathClassLoader_ = NULL; |
| 35 | } |
| 36 | |
| 37 | } // namespace art |