CBMC
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 &, message_handlert &)
 Appends an entry to the class path, used for loading classes. 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...
 

Public Attributes

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

Protected Member Functions

std::optional< java_bytecode_parse_treetload_class (const irep_idt &class_name, const classpath_entryt &, message_handlert &)
 attempt to load a class from a classpath_entry More...
 
std::optional< java_bytecode_parse_treetget_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 More...
 
std::optional< java_bytecode_parse_treetget_class_from_directory (const irep_idt &class_name, const std::string &path, message_handlert &)
 attempt to load a class from a given directory More...
 

Protected Attributes

std::list< classpath_entrytclasspath_entries
 List of entries in the classpath. More...
 

Detailed Description

Base class for maintaining classpath.

Definition at line 22 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,
message_handlert message_handler 
)

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 22 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 94 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 113 of file java_class_loader_base.cpp.

◆ clear_classpath()

void java_class_loader_baset::clear_classpath ( )
inline

Clear all classpath entries.

Definition at line 26 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 62 of file java_class_loader_base.cpp.

◆ get_class_from_directory()

std::optional< java_bytecode_parse_treet > java_class_loader_baset::get_class_from_directory ( const irep_idt class_name,
const std::string &  path,
message_handlert message_handler 
)
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
message_handlermessage handler
Returns
optional value of parse tree, empty if class cannot be loaded

Definition at line 193 of file java_class_loader_base.cpp.

◆ get_class_from_jar()

std::optional< java_bytecode_parse_treet > java_class_loader_baset::get_class_from_jar ( const irep_idt class_name,
const std::string &  jar_file,
message_handlert message_handler 
)
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
message_handlermessage handler
Returns
optional value of parse tree, empty if class cannot be loaded

Definition at line 158 of file java_class_loader_base.cpp.

◆ load_class()

std::optional< java_bytecode_parse_treet > java_class_loader_baset::load_class ( const irep_idt class_name,
const classpath_entryt cp_entry,
message_handlert message_handler 
)
protected

attempt to load a class from a classpath_entry

Definition at line 135 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 59 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 42 of file java_class_loader_base.h.


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