summaryrefslogtreecommitdiff
path: root/src/class_loader.cc
blob: 8f8e8297613c7d8ecc2241ab3e39a073c6512d86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2011 Google Inc. All Rights Reserved.

#include "class_loader.h"

#include "class_linker.h"
#include "runtime.h"

namespace art {

const std::vector<const DexFile*>& ClassLoader::GetClassPath(const ClassLoader* class_loader) {
  if (class_loader == NULL) {
    return Runtime::Current()->GetClassLinker()->GetBootClassPath();
  }
  return class_loader->class_path_;
}

// TODO: get global references for these
Class* PathClassLoader::dalvik_system_PathClassLoader_ = NULL;

const PathClassLoader* PathClassLoader::Alloc(std::vector<const DexFile*> dex_files) {
  DCHECK(dalvik_system_PathClassLoader_ != NULL);
  PathClassLoader* p = down_cast<PathClassLoader*>(dalvik_system_PathClassLoader_->AllocObject());
  p->SetClassPath(dex_files);
  return p;
}

void PathClassLoader::SetClass(Class* dalvik_system_PathClassLoader) {
  CHECK(dalvik_system_PathClassLoader_ == NULL);
  CHECK(dalvik_system_PathClassLoader != NULL);
  dalvik_system_PathClassLoader_ = dalvik_system_PathClassLoader;
}

void PathClassLoader::ResetClass() {
  CHECK(dalvik_system_PathClassLoader_ != NULL);
  dalvik_system_PathClassLoader_ = NULL;
}

}  // namespace art