blob: 8fe6a092822f12f5fa61c1132fd8688c2c9afd8d [file] [log] [blame]
Brian Carlstrom1f870082011-08-23 16:02:11 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_CLASS_LOADER_H_
4#define ART_SRC_CLASS_LOADER_H_
5
6#include <vector>
7
8#include "dex_file.h"
9#include "object.h"
Brian Carlstromaded5f72011-10-07 17:15:04 -070010#include "unordered_map.h"
Brian Carlstrom1f870082011-08-23 16:02:11 -070011
12namespace art {
13
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070014// C++ mirror of java.lang.ClassLoader
Brian Carlstromaded5f72011-10-07 17:15:04 -070015class MANAGED ClassLoader : public Object {
Brian Carlstrom1f870082011-08-23 16:02:11 -070016 public:
Brian Carlstromaded5f72011-10-07 17:15:04 -070017 static const std::vector<const DexFile*>& GetCompileTimeClassPath(const ClassLoader* class_loader);
18 static void SetCompileTimeClassPath(const ClassLoader* class_loader, std::vector<const DexFile*>& class_path);
19 static bool UseCompileTimeClassPath() {
20 return use_compile_time_class_path;
Brian Carlstrom1f870082011-08-23 16:02:11 -070021 }
22
23 private:
24 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
25 Object* packages_;
26 ClassLoader* parent_;
27
Brian Carlstromaded5f72011-10-07 17:15:04 -070028 typedef std::tr1::unordered_map<const ClassLoader*, std::vector<const DexFile*>, ObjectIdentityHash> Table;
29 static Table compile_time_class_paths_;
30
31 static bool use_compile_time_class_path;
Brian Carlstrom1f870082011-08-23 16:02:11 -070032
Brian Carlstrom693267a2011-09-06 09:25:34 -070033 friend struct ClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070034 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader);
35};
36
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070037// C++ mirror of dalvik.system.BaseDexClassLoader
Brian Carlstrome4f7e1d2011-09-11 13:21:12 -070038// TODO: add MANAGED when class_path_ removed
Brian Carlstrom1f870082011-08-23 16:02:11 -070039class BaseDexClassLoader : public ClassLoader {
40 private:
41 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
42 String* original_path_;
43 Object* path_list_;
Brian Carlstrom693267a2011-09-06 09:25:34 -070044
45 friend struct BaseDexClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070046 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader);
47};
48
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070049// C++ mirror of dalvik.system.PathClassLoader
Brian Carlstrome4f7e1d2011-09-11 13:21:12 -070050// TODO: add MANAGED when class_path_ removed
Brian Carlstrom1f870082011-08-23 16:02:11 -070051class PathClassLoader : public BaseDexClassLoader {
52 public:
Brian Carlstromaded5f72011-10-07 17:15:04 -070053 static const PathClassLoader* AllocCompileTime(std::vector<const DexFile*>& dex_files);
Brian Carlstrom1f870082011-08-23 16:02:11 -070054 static void SetClass(Class* dalvik_system_PathClassLoader);
55 static void ResetClass();
56 private:
57 static Class* dalvik_system_PathClassLoader_;
Brian Carlstrom693267a2011-09-06 09:25:34 -070058 friend struct PathClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070059 DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader);
60};
61
62} // namespace art
63
64#endif // ART_SRC_OBJECT_H_