cprover
java_class_loader_base.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_BASE_H
10 #define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_BASE_H
11 
12 #include <util/message.h>
13 
14 #include "jar_pool.h"
16 
19 {
20 public:
23  {
24  classpath_entries.clear();
25  }
26 
31  void add_classpath_entry(const std::string &);
32 
33  static std::string file_to_class_name(const std::string &);
34  static std::string class_name_to_os_file(const irep_idt &);
35  static std::string class_name_to_jar_file(const irep_idt &);
36 
39 
40 protected:
43  {
44  using kindt = enum { JAR, DIRECTORY };
46  std::string path;
47 
48  classpath_entryt(kindt _kind, const std::string &_path)
49  : kind(_kind), path(_path)
50  {
51  }
52  };
53 
55  std::list<classpath_entryt> classpath_entries;
56 
59  load_class(const irep_idt &class_name, const classpath_entryt &);
60 
63  get_class_from_jar(const irep_idt &class_name, const std::string &jar_file);
64 
67  get_class_from_directory(const irep_idt &class_name, const std::string &path);
68 };
69 
70 #endif // CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_BASE_H
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
java_class_loader_baset::jar_pool
jar_poolt jar_pool
a cache for jar_filet, by path name
Definition: java_class_loader_base.h:38
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
java_class_loader_baset::file_to_class_name
static std::string file_to_class_name(const std::string &)
Convert a file name to the class name.
Definition: java_class_loader_base.cpp:55
jar_pool.h
java_class_loader_baset::class_name_to_jar_file
static std::string class_name_to_jar_file(const irep_idt &)
Convert a class name to a file name, does the inverse of file_to_class_name.
Definition: java_class_loader_base.cpp:87
java_class_loader_baset::classpath_entryt
An entry in the classpath.
Definition: java_class_loader_base.h:43
java_class_loader_baset
Base class for maintaining classpath.
Definition: java_class_loader_base.h:19
java_class_loader_baset::get_class_from_jar
optionalt< java_bytecode_parse_treet > get_class_from_jar(const irep_idt &class_name, const std::string &jar_file)
attempt to load a class from a given jar file
Definition: java_class_loader_base.cpp:149
java_class_loader_baset::classpath_entries
std::list< classpath_entryt > classpath_entries
List of entries in the classpath.
Definition: java_class_loader_base.h:55
java_bytecode_parse_tree.h
java_class_loader_baset::add_classpath_entry
void add_classpath_entry(const std::string &)
Appends an entry to the class path, used for loading classes.
Definition: java_class_loader_base.cpp:20
java_class_loader_baset::load_class
optionalt< java_bytecode_parse_treet > load_class(const irep_idt &class_name, const classpath_entryt &)
attempt to load a class from a classpath_entry
Definition: java_class_loader_base.cpp:128
jar_poolt
A chache for jar_filet objects, by file name.
Definition: jar_pool.h:19
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
java_class_loader_baset::classpath_entryt::classpath_entryt
classpath_entryt(kindt _kind, const std::string &_path)
Definition: java_class_loader_base.h:48
java_class_loader_baset::classpath_entryt::path
std::string path
Definition: java_class_loader_base.h:46
java_class_loader_baset::class_name_to_os_file
static std::string class_name_to_os_file(const irep_idt &)
Convert a class name to a file name, with OS-dependent syntax.
Definition: java_class_loader_base.cpp:106
java_class_loader_baset::classpath_entryt::kind
kindt kind
Definition: java_class_loader_base.h:45
java_class_loader_baset::classpath_entryt::kindt
enum { JAR, DIRECTORY } kindt
Definition: java_class_loader_base.h:44
java_class_loader_baset::get_class_from_directory
optionalt< java_bytecode_parse_treet > get_class_from_directory(const irep_idt &class_name, const std::string &path)
attempt to load a class from a given directory
Definition: java_class_loader_base.cpp:179
java_class_loader_baset::clear_classpath
void clear_classpath()
Clear all classpath entries.
Definition: java_class_loader_base.h:22
message.h