cprover
java_class_loader_baset Class Reference

Base class for maintaining classpath. More...

#include <java_class_loader_base.h>

+ Inheritance diagram for java_class_loader_baset:
+ Collaboration diagram for java_class_loader_baset:

Classes

struct  classpath_entryt
 An entry in the classpath. More...
 

Public Member Functions

void clear_classpath ()
 Clear all classpath entries. More...
 
void add_classpath_entry (const std::string &)
 Appends an entry to the class path, used for loading classes. More...
 
- Public Member Functions inherited from messaget
virtual void set_message_handler (message_handlert &_message_handler)
 
message_handlertget_message_handler ()
 
 messaget ()
 
 messaget (const messaget &other)
 
messagetoperator= (const messaget &other)
 
 messaget (message_handlert &_message_handler)
 
virtual ~messaget ()
 
mstreamtget_mstream (unsigned message_level) const
 
mstreamterror () const
 
mstreamtwarning () const
 
mstreamtresult () const
 
mstreamtstatus () const
 
mstreamtstatistics () const
 
mstreamtprogress () const
 
mstreamtdebug () const
 
void conditional_output (mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
 Generate output to message_stream using output_generator if the configured verbosity is at least as high as that of message_stream. More...
 

Static Public Member Functions

static std::string file_to_class_name (const std::string &)
 Convert a file name to the class name. More...
 
static std::string class_name_to_os_file (const irep_idt &)
 Convert a class name to a file name, with OS-dependent syntax. More...
 
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. More...
 
- Static Public Member Functions inherited from messaget
static unsigned eval_verbosity (const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
 Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest. More...
 
static commandt command (unsigned c)
 Create an ECMA-48 SGR (Select Graphic Rendition) command. More...
 

Public Attributes

jar_poolt jar_pool
 a cache for jar_filet, by path name More...
 

Protected Member Functions

optionalt< java_bytecode_parse_treetload_class (const irep_idt &class_name, const classpath_entryt &)
 attempt to load a class from a classpath_entry More...
 
optionalt< java_bytecode_parse_treetget_class_from_jar (const irep_idt &class_name, const std::string &jar_file)
 attempt to load a class from a given jar file More...
 
optionalt< java_bytecode_parse_treetget_class_from_directory (const irep_idt &class_name, const std::string &path)
 attempt to load a class from a given directory More...
 

Protected Attributes

std::list< classpath_entrytclasspath_entries
 List of entries in the classpath. More...
 
- Protected Attributes inherited from messaget
message_handlertmessage_handler
 
mstreamt mstream
 

Additional Inherited Members

- Public Types inherited from messaget
enum  message_levelt {
  M_ERROR =1, M_WARNING =2, M_RESULT =4, M_STATUS =6,
  M_STATISTICS =8, M_PROGRESS =9, M_DEBUG =10
}
 
- Static Public Attributes inherited from messaget
static eomt eom
 
static const commandt reset
 return to default formatting, as defined by the terminal More...
 
static const commandt red
 render text with red foreground color More...
 
static const commandt green
 render text with green foreground color More...
 
static const commandt yellow
 render text with yellow foreground color More...
 
static const commandt blue
 render text with blue foreground color More...
 
static const commandt magenta
 render text with magenta foreground color More...
 
static const commandt cyan
 render text with cyan foreground color More...
 
static const commandt bright_red
 render text with bright red foreground color More...
 
static const commandt bright_green
 render text with bright green foreground color More...
 
static const commandt bright_yellow
 render text with bright yellow foreground color More...
 
static const commandt bright_blue
 render text with bright blue foreground color More...
 
static const commandt bright_magenta
 render text with bright magenta foreground color More...
 
static const commandt bright_cyan
 render text with bright cyan foreground color More...
 
static const commandt bold
 render text with bold font More...
 
static const commandt faint
 render text with faint font More...
 
static const commandt italic
 render italic text More...
 
static const commandt underline
 render underlined text More...
 

Detailed Description

Base class for maintaining classpath.

Definition at line 18 of file java_class_loader_base.h.

Member Function Documentation

◆ add_classpath_entry()

void java_class_loader_baset::add_classpath_entry ( const std::string &  path)

Appends an entry to the class path, used for loading classes.

The argument may be 1) The name of a directory, used for searching for .class files 2) The name of a JAR file

Definition at line 20 of file java_class_loader_base.cpp.

◆ class_name_to_jar_file()

std::string java_class_loader_baset::class_name_to_jar_file ( const irep_idt class_name)
static

Convert a class name to a file name, does the inverse of file_to_class_name.

Parameters
class_namethe name of the class
Returns
the class name converted to file name

Definition at line 87 of file java_class_loader_base.cpp.

◆ class_name_to_os_file()

std::string java_class_loader_baset::class_name_to_os_file ( const irep_idt class_name)
static

Convert a class name to a file name, with OS-dependent syntax.

Parameters
class_namethe name of the class
Returns
the class name converted to file name

Definition at line 106 of file java_class_loader_base.cpp.

◆ clear_classpath()

void java_class_loader_baset::clear_classpath ( )
inline

Clear all classpath entries.

Definition at line 22 of file java_class_loader_base.h.

◆ file_to_class_name()

std::string java_class_loader_baset::file_to_class_name ( const std::string &  file)
static

Convert a file name to the class name.

Java interprets folders as packages, therefore a prefix of ./ is removed if necessary, and all / are converted to .. For example a class file ./com/diffblue/test.class is converted to the class name com.diffblue.test.

Parameters
filethe name of the class file
Returns
the file name converted to Java class name

Definition at line 55 of file java_class_loader_base.cpp.

◆ get_class_from_directory()

optionalt< java_bytecode_parse_treet > java_class_loader_baset::get_class_from_directory ( const irep_idt class_name,
const std::string &  path 
)
protected

attempt to load a class from a given directory

Load class from directory.

Parameters
class_namename of class to load in Java source format
pathdirectory to load from
Returns
optional value of parse tree, empty if class cannot be loaded

Definition at line 179 of file java_class_loader_base.cpp.

◆ get_class_from_jar()

optionalt< java_bytecode_parse_treet > java_class_loader_baset::get_class_from_jar ( const irep_idt class_name,
const std::string &  jar_file 
)
protected

attempt to load a class from a given jar file

Load class from jar file.

Parameters
class_namename of class to load in Java source format
jar_filepath of the jar file
Returns
optional value of parse tree, empty if class cannot be loaded

Definition at line 149 of file java_class_loader_base.cpp.

◆ load_class()

optionalt< java_bytecode_parse_treet > java_class_loader_baset::load_class ( const irep_idt class_name,
const classpath_entryt cp_entry 
)
protected

attempt to load a class from a classpath_entry

Definition at line 128 of file java_class_loader_base.cpp.

Member Data Documentation

◆ classpath_entries

std::list<classpath_entryt> java_class_loader_baset::classpath_entries
protected

List of entries in the classpath.

Definition at line 55 of file java_class_loader_base.h.

◆ jar_pool

jar_poolt java_class_loader_baset::jar_pool

a cache for jar_filet, by path name

Definition at line 38 of file java_class_loader_base.h.


The documentation for this class was generated from the following files: