@@ -81,6 +81,11 @@ void java_class_loadert::add_classpath_entry(const std::string &path)
8181 }
8282}
8383
84+ // / Load class from jar file.
85+ // / \param class_name: name of class to load in Java source format
86+ // / \param jar_file: path of the jar file
87+ // / \param jar_index: the index of the jar file
88+ // / \return optional value of parse tree, empty if class cannot be loaded
8489optionalt<java_bytecode_parse_treet> java_class_loadert::get_class_from_jar (
8590 const irep_idt &class_name,
8691 const std::string &jar_file,
@@ -102,6 +107,11 @@ optionalt<java_bytecode_parse_treet> java_class_loadert::get_class_from_jar(
102107 return java_bytecode_parse (istream, get_message_handler ());
103108}
104109
110+ // / Check if class is an overlay class by searching for `ID_overlay_class` in
111+ // / its list of annotations. TODO(nathan) give a short explanation about what
112+ // / overlay classes are.
113+ // / \param c: a `classt` object from a java byte code parse tree
114+ // / \return true if parsed class is an overlay class, else false
105115static bool is_overlay_class (const java_bytecode_parse_treet::classt &c)
106116{
107117 return java_bytecode_parse_treet::find_annotation (
@@ -228,6 +238,9 @@ java_class_loadert::get_parse_tree(
228238 return parse_trees;
229239}
230240
241+ // / Load all class files from a .jar file, and store name of .jar in
242+ // / `classpath_entreies`.
243+ // / \param jar_path: the path for the .jar to load
231244void java_class_loadert::load_entire_jar (
232245 const std::string &jar_path)
233246{
@@ -280,6 +293,12 @@ java_class_loadert::jar_index_optcreft java_class_loadert::read_jar_file(
280293 return std::cref (jar_index);
281294}
282295
296+ // / Convert a file name to the class name. Java interprets folders as packages,
297+ // / therefore a prefix of `./` is removed if necessary, and all `/` are
298+ // / converted to `.`. For example a class file `./com/diffblue/test.class` is
299+ // / converted to the class name `com.diffblue.test`.
300+ // / \param file: the name of the class file
301+ // / \return the file name converted to Java class name
283302std::string java_class_loadert::file_to_class_name (const std::string &file)
284303{
285304 std::string result=file;
@@ -307,6 +326,10 @@ std::string java_class_loadert::file_to_class_name(const std::string &file)
307326 return result;
308327}
309328
329+ // / Convert a class name to a file name, does the inverse of \ref
330+ // / file_to_class_name.
331+ // / \param class_name: the name of the class
332+ // / \return the class name converted to file name
310333std::string java_class_loadert::class_name_to_file (const irep_idt &class_name)
311334{
312335 std::string result=id2string (class_name);
0 commit comments