22 const std::string &path,
29 if(std::ifstream(path).good())
36 log.
warning() <<
"Warning: failed to access JAR file `" << path <<
"'"
49 log.
warning() <<
"Warning: failed to access directory `" << path <<
"'"
63 std::string result =
file;
68 result.resize(result.size() - 6);
74 result = std::string(result, 2, std::string::npos);
77 result = std::string(result, 2, std::string::npos);
81 for(std::string::iterator it = result.begin(); it != result.end(); it++)
95 std::string result =
id2string(class_name);
98 for(std::string::iterator it = result.begin(); it != result.end(); it++)
114 std::string result =
id2string(class_name);
117 for(std::string::iterator it = result.begin(); it != result.end(); it++)
139 switch(cp_entry.
kind)
141 case classpath_entryt::JAR:
144 case classpath_entryt::DIRECTORY:
159 const std::string &jar_file,
169 if(!
data.has_value())
172 log.
debug() <<
"Getting class '" << class_name <<
"' from JAR " << jar_file
175 std::istringstream istream(*
data);
178 catch(
const std::runtime_error &)
180 log.
error() <<
"failed to open JAR file '" << jar_file <<
"'"
194 const std::string &path,
201 if(std::ifstream(full_path))
204 log.
debug() <<
"Getting class '" << class_name <<
"' from file "
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
void add_classpath_entry(const std::string &, message_handlert &)
Appends an entry to the class path, used for loading classes.
optionalt< java_bytecode_parse_treet > get_class_from_jar(const irep_idt &class_name, const std::string &jar_file, message_handlert &)
attempt to load a class from a given jar file
optionalt< java_bytecode_parse_treet > load_class(const irep_idt &class_name, const classpath_entryt &, message_handlert &)
attempt to load a class from a classpath_entry
jar_poolt jar_pool
a cache for jar_filet, by path name
static std::string class_name_to_os_file(const irep_idt &)
Convert a class name to a file name, with OS-dependent syntax.
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.
std::list< classpath_entryt > classpath_entries
List of entries in the classpath.
static std::string file_to_class_name(const std::string &)
Convert a file name to the class name.
optionalt< java_bytecode_parse_treet > get_class_from_directory(const irep_idt &class_name, const std::string &path, message_handlert &)
attempt to load a class from a given directory
Class that provides messages with a built-in verbosity 'level'.
mstreamt & warning() const
bool has_prefix(const std::string &s, const std::string &prefix)
bool is_directory(const std::string &path)
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
const std::string & id2string(const irep_idt &d)
optionalt< java_bytecode_parse_treet > java_bytecode_parse(std::istream &istream, const irep_idt &class_name, message_handlert &message_handler, bool skip_instructions)
Attempt to parse a Java class from the given stream.
nonstd::optional< T > optionalt
#define UNREACHABLE
This should be used to mark dead code.
An entry in the classpath.
bool has_suffix(const std::string &s, const std::string &suffix)