Skip to content

Commit 27d0ae0

Browse files
author
Daniel Kroening
committed
java_class_loadert::load_entire_jar now returns the classes loaded
1 parent 7797757 commit 27d0ae0

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ bool java_bytecode_languaget::parse(
235235
if(main_class.empty())
236236
{
237237
status() << "JAR file without entry point: loading class files" << eom;
238-
java_class_loader.load_entire_jar(path);
239-
for(const auto &kv : java_class_loader.get_jar_index(path))
240-
main_jar_classes.push_back(kv.first);
238+
const auto classes = java_class_loader.load_entire_jar(path);
239+
for(const auto &c : classes)
240+
main_jar_classes.push_back(c);
241241
}
242242
else
243243
java_class_loader.add_classpath_entry(path);

jbmc/src/java_bytecode/java_class_loader.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,23 +238,29 @@ java_class_loadert::get_parse_tree(
238238
return parse_trees;
239239
}
240240

241-
/// Load all class files from a .jar file, and store name of .jar in
242-
/// `classpath_entreies`.
241+
/// Load all class files from a .jar file
243242
/// \param jar_path: the path for the .jar to load
244-
void java_class_loadert::load_entire_jar(
243+
std::vector<irep_idt> java_class_loadert::load_entire_jar(
245244
const std::string &jar_path)
246245
{
247246
jar_index_optcreft jar_index = read_jar_file(jar_path);
248247
if(!jar_index)
249-
return;
248+
return {};
250249

251250
classpath_entries.push_front(
252251
classpath_entryt(classpath_entryt::JAR, jar_path));
253252

253+
std::vector<irep_idt> classes;
254+
254255
for(const auto &e : jar_index->get())
256+
{
255257
operator()(e.first);
258+
classes.push_back(e.first);
259+
}
256260

257261
classpath_entries.pop_front();
262+
263+
return classes;
258264
}
259265

260266
java_class_loadert::jar_index_optcreft java_class_loadert::read_jar_file(

jbmc/src/java_bytecode/java_class_loader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class java_class_loadert:public messaget
9797
static std::string file_to_class_name(const std::string &);
9898
static std::string class_name_to_file(const irep_idt &);
9999

100-
void load_entire_jar(const std::string &jar_path);
100+
std::vector<irep_idt> load_entire_jar(const std::string &jar_path);
101101

102102
const jar_indext &get_jar_index(const std::string &jar_path)
103103
{

0 commit comments

Comments
 (0)