blob: 83f35c0e50845b2711f4c708d361376be687f4f9 [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
Elliott Hughese5448b52012-01-18 16:44:06 -08006#include <map>
Brian Carlstrom1f870082011-08-23 16:02:11 -07007#include <vector>
8
9#include "dex_file.h"
10#include "object.h"
11
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
Elliott Hughese5448b52012-01-18 16:44:06 -080029 typedef std::map<const ClassLoader*, std::vector<const DexFile*> > Table;
Brian Carlstromaded5f72011-10-07 17:15:04 -070030 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 Carlstrom40381fb2011-10-19 14:13:40 -070054 static 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_