@@ -81,6 +81,11 @@ void java_class_loadert::add_classpath_entry(const std::string &path)
81
81
}
82
82
}
83
83
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
84
89
optionalt<java_bytecode_parse_treet> java_class_loadert::get_class_from_jar (
85
90
const irep_idt &class_name,
86
91
const std::string &jar_file,
@@ -102,6 +107,11 @@ optionalt<java_bytecode_parse_treet> java_class_loadert::get_class_from_jar(
102
107
return java_bytecode_parse (istream, get_message_handler ());
103
108
}
104
109
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
105
115
static bool is_overlay_class (const java_bytecode_parse_treet::classt &c)
106
116
{
107
117
return java_bytecode_parse_treet::find_annotation (
@@ -228,6 +238,9 @@ java_class_loadert::get_parse_tree(
228
238
return parse_trees;
229
239
}
230
240
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
231
244
void java_class_loadert::load_entire_jar (
232
245
const std::string &jar_path)
233
246
{
@@ -280,6 +293,12 @@ java_class_loadert::jar_index_optcreft java_class_loadert::read_jar_file(
280
293
return std::cref (jar_index);
281
294
}
282
295
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
283
302
std::string java_class_loadert::file_to_class_name (const std::string &file)
284
303
{
285
304
std::string result=file;
@@ -307,6 +326,10 @@ std::string java_class_loadert::file_to_class_name(const std::string &file)
307
326
return result;
308
327
}
309
328
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
310
333
std::string java_class_loadert::class_name_to_file (const irep_idt &class_name)
311
334
{
312
335
std::string result=id2string (class_name);
0 commit comments