Skip to content

Commit 40b647f

Browse files
author
Matthias Güdemann
committed
Restructure java_bytecode_language
1 parent 7489e88 commit 40b647f

File tree

2 files changed

+44
-39
lines changed

2 files changed

+44
-39
lines changed

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
6868
java_cp_include_files=cmd.get_value("java-cp-include-files");
6969
// load file list from JSON file
7070
if(java_cp_include_files[0]=='@')
71-
{
72-
jsont json_cp_config;
73-
if(parse_json(
74-
java_cp_include_files.substr(1),
75-
get_message_handler(),
76-
json_cp_config))
77-
throw "cannot read JSON input configuration for JAR/WAR loading";
78-
79-
if(!json_cp_config.is_object())
80-
throw "the JSON file has a wrong format";
81-
jsont include_jar_files=json_cp_config["jar"];
82-
if(!include_jar_files.is_null())
83-
{
84-
if(!include_jar_files.is_array())
85-
throw "the JSON file has a wrong format";
86-
87-
// add jars from JSON config file to classpath
88-
for(const jsont &file_entry : include_jar_files.array)
89-
{
90-
assert(file_entry.is_string() &&
91-
has_suffix(file_entry.value, ".jar"));
92-
config.java.classpath.push_back(file_entry.value);
93-
}
94-
}
95-
jsont include_war_files=json_cp_config["war"];
96-
if(!include_war_files.is_null())
97-
{
98-
if(!include_war_files.is_array())
99-
throw "the JSON file has a wrong format";
100-
101-
// add wars from JSON config file to classpath
102-
for(const jsont &file_entry : include_war_files.array)
103-
{
104-
assert(file_entry.is_string() &&
105-
has_suffix(file_entry.value, ".war"));
106-
config.java.classpath.push_back(file_entry.value);
107-
}
108-
}
109-
}
71+
load_from_archive_files(java_cp_include_files.substr(1));
11072
}
11173
else
11274
java_cp_include_files=".*";
@@ -480,3 +442,45 @@ bool java_bytecode_languaget::to_expr(
480442
java_bytecode_languaget::~java_bytecode_languaget()
481443
{
482444
}
445+
446+
void java_bytecode_languaget::load_from_archive_files(
447+
const std::string &json_config)
448+
{
449+
jsont json_cp_config;
450+
if(parse_json(
451+
json_config,
452+
get_message_handler(),
453+
json_cp_config))
454+
throw "cannot read JSON input configuration for JAR/WAR loading";
455+
456+
if(!json_cp_config.is_object())
457+
throw "the JSON file has a wrong format";
458+
jsont include_jar_files=json_cp_config["jar"];
459+
if(!include_jar_files.is_null())
460+
{
461+
if(!include_jar_files.is_array())
462+
throw "the JSON file has a wrong format";
463+
464+
// add jars from JSON config file to classpath
465+
for(const jsont &file_entry : include_jar_files.array)
466+
{
467+
assert(file_entry.is_string() &&
468+
has_suffix(file_entry.value, ".jar"));
469+
config.java.classpath.push_back(file_entry.value);
470+
}
471+
}
472+
jsont include_war_files=json_cp_config["war"];
473+
if(!include_war_files.is_null())
474+
{
475+
if(!include_war_files.is_array())
476+
throw "the JSON file has a wrong format";
477+
478+
// add wars from JSON config file to classpath
479+
for(const jsont &file_entry : include_war_files.array)
480+
{
481+
assert(file_entry.is_string() &&
482+
has_suffix(file_entry.value, ".war"));
483+
config.java.classpath.push_back(file_entry.value);
484+
}
485+
}
486+
}

src/java_bytecode/java_bytecode_language.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class java_bytecode_languaget:public languaget
139139
protected:
140140
bool do_ci_lazy_method_conversion(symbol_tablet &, lazy_methodst &);
141141
const select_pointer_typet &get_pointer_type_selector() const;
142+
void load_from_archive_files(const std::string &);
142143

143144
irep_idt main_class;
144145
std::vector<irep_idt> main_jar_classes;

0 commit comments

Comments
 (0)