cprover
java_class_loader.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H
11 #define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H
12 
13 #include <map>
14 #include <regex>
15 #include <set>
16 
18 
19 #include "jar_file.h"
21 #include "java_class_loader_base.h"
23 
27 {
28 public:
30  typedef std::list<java_bytecode_parse_treet> parse_tree_with_overlayst;
33  typedef std::map<irep_idt, parse_tree_with_overlayst>
35 
37  typedef std::function<std::vector<irep_idt>(const irep_idt &)>
39 
41  {
42  }
43 
44  parse_tree_with_overlayst &operator()(const irep_idt &class_name);
45 
47  java_class_loader_limitt &class_loader_limit,
48  const irep_idt &class_name);
49 
53  {
54  this->java_cp_include_files = java_cp_include_files;
55  }
61  {
62  get_extra_class_refs = func;
63  }
67  void add_load_classes(const std::vector<irep_idt> &classes)
68  {
69  for(const auto &id : classes)
70  java_load_classes.push_back(id);
71  }
72 
73  std::vector<irep_idt> load_entire_jar(const std::string &jar_path);
74 
78  {
80  }
82  const irep_idt &class_name)
83  {
84  return class_map.at(class_name).front();
85  }
86 
87 private:
93  std::string java_cp_include_files;
94 
96  std::vector<irep_idt> java_load_classes;
98 
101 
102  optionalt<std::vector<irep_idt>> read_jar_file(const std::string &jar_path);
103 };
104 
105 #endif // CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H
std::vector< irep_idt > java_load_classes
Classes to be explicitly loaded.
std::function< std::vector< irep_idt >const irep_idt &)> get_extra_class_refs_functiont
A function that yields a list of extra dependencies based on a class name.
parse_tree_with_overlayst & get_parse_tree(java_class_loader_limitt &class_loader_limit, const irep_idt &class_name)
Check through all the places class parse trees can appear and returns the first implementation it fin...
std::map< irep_idt, parse_tree_with_overlayst > parse_tree_with_overridest_mapt
A map from class names to list of parse tree where multiple entries can exist in case of overlay clas...
std::list< java_bytecode_parse_treet > parse_tree_with_overlayst
A list of parse trees supporting overlay classes.
optionalt< std::vector< irep_idt > > read_jar_file(const std::string &jar_path)
fixed_keys_map_wrappert< parse_tree_with_overridest_mapt > get_class_with_overlays_map()
Map from class names to the bytecode parse trees.
void set_java_cp_include_files(const std::string &java_cp_include_files)
Set the argument of the class loader limit java_class_loader_limitt.
nonstd::optional< T > optionalt
Definition: optional.h:35
Base class for maintaining classpath.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Definition: dstring.h:35
Class representing a filter for class file loading.
void add_load_classes(const std::vector< irep_idt > &classes)
Adds the list of classes to the load queue, forcing them to be loaded even without explicit reference...
A wrapper for maps that gives read-write access to elements but without allowing addition or removal ...
void set_extra_class_refs_function(get_extra_class_refs_functiont func)
Sets a function that provides extra dependencies for a particular class.
get_extra_class_refs_functiont get_extra_class_refs
Class responsible to load .class files.
parse_tree_with_overlayst & operator()(const irep_idt &class_name)
const java_bytecode_parse_treet & get_original_class(const irep_idt &class_name)
std::string java_cp_include_files
Either a regular expression matching files that will be allowed to be loaded or a string of the form ...
limit class path loading
std::vector< irep_idt > load_entire_jar(const std::string &jar_path)
Load all class files from a .jar file.
parse_tree_with_overridest_mapt class_map
Map from class names to the bytecode parse trees.