blob: 2904e3ee457550ad7b7466d840604a31a59479e8 [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_;
Jesse Wilson1b5f4972011-10-11 21:41:08 -040027 Object* proxyCache_;
Brian Carlstrom1f870082011-08-23 16:02:11 -070028
Brian Carlstromaded5f72011-10-07 17:15:04 -070029 typedef std::tr1::unordered_map<const ClassLoader*, std::vector<const DexFile*>, ObjectIdentityHash> Table;
30 static Table compile_time_class_paths_;
31
32 static bool use_compile_time_class_path;
Brian Carlstrom1f870082011-08-23 16:02:11 -070033
Brian Carlstrom693267a2011-09-06 09:25:34 -070034 friend struct ClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070035 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader);
36};
37
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070038// C++ mirror of dalvik.system.BaseDexClassLoader
Brian Carlstrome4f7e1d2011-09-11 13:21:12 -070039// TODO: add MANAGED when class_path_ removed
Brian Carlstrom1f870082011-08-23 16:02:11 -070040class BaseDexClassLoader : public ClassLoader {
41 private:
42 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
43 String* original_path_;
44 Object* path_list_;
Brian Carlstrom693267a2011-09-06 09:25:34 -070045
46 friend struct BaseDexClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070047 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader);
48};
49
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070050// C++ mirror of dalvik.system.PathClassLoader
Brian Carlstrome4f7e1d2011-09-11 13:21:12 -070051// TODO: add MANAGED when class_path_ removed
Brian Carlstrom1f870082011-08-23 16:02:11 -070052class PathClassLoader : public BaseDexClassLoader {
53 public:
Brian Carlstromaded5f72011-10-07 17:15:04 -070054 static const PathClassLoader* AllocCompileTime(std::vector<const DexFile*>& dex_files);
Brian Carlstrom1f870082011-08-23 16:02:11 -070055 static void SetClass(Class* dalvik_system_PathClassLoader);
56 static void ResetClass();
57 private:
58 static Class* dalvik_system_PathClassLoader_;
Brian Carlstrom693267a2011-09-06 09:25:34 -070059 friend struct PathClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070060 DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader);
61};
62
63} // namespace art
64
65#endif // ART_SRC_OBJECT_H_