Skip to content

Commit 7489e88

Browse files
author
Matthias Güdemann
committed
Support empty jar/war JSON array
1 parent c62e682 commit 7489e88

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/java_bytecode/jar_file.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, kroening@kroening.com
1313

1414
#include <json/json_parser.h>
1515
#include <util/suffix.h>
16+
#include <util/suffix.h>
1617
#include <util/invariant.h>
1718

1819
void jar_filet::open(

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,37 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
7474
java_cp_include_files.substr(1),
7575
get_message_handler(),
7676
json_cp_config))
77-
throw "cannot read JSON input configuration for JAR loading";
77+
throw "cannot read JSON input configuration for JAR/WAR loading";
7878

7979
if(!json_cp_config.is_object())
8080
throw "the JSON file has a wrong format";
81-
jsont include_files=json_cp_config["jar"];
82-
if(!include_files.is_array())
83-
throw "the JSON file has a wrong format";
84-
85-
// add jars from JSON config file to classpath
86-
for(const jsont &file_entry : include_files.array)
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())
8797
{
88-
assert(file_entry.is_string() && has_suffix(file_entry.value, ".jar"));
89-
config.java.classpath.push_back(file_entry.value);
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+
}
90108
}
91109
}
92110
}

0 commit comments

Comments
 (0)