Skip to content

Commit 3ab1fc9

Browse files
committed
Updates requested in the PR.
1 parent c81b38f commit 3ab1fc9

File tree

1 file changed

+70
-64
lines changed

1 file changed

+70
-64
lines changed

src/java-class-info/java_class_info.cpp

Lines changed: 70 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,20 @@ int cmdline_optionst::doit()
110110
{
111111
if(!json_array_element.is_string())
112112
{
113+
std::stringstream sstr;
114+
sstr
115+
<< "Encountered a non-string element in the array of paths "
116+
<< "in the input JSON file.";
113117
msg.warning()
114-
<< "WARNING: Encountered a non-string element in the array of paths "
115-
<< "in the input JSON file. Skipping this record."
118+
<< "WARNING: "
119+
<< sstr.str()
120+
<< " Skipping this file."
116121
<< messaget::eom;
122+
errors.push_back(json_stringt(sstr.str()));
123+
ret_code=-7;
117124
continue;
118125
}
119126

120-
jsont class_json;
121127
const std::string &class_file_pathname=json_array_element.value;
122128
if(!fileutl_file_exists(class_file_pathname))
123129
{
@@ -131,77 +137,28 @@ int cmdline_optionst::doit()
131137
<< sstr.str()
132138
<< " Skipping this file."
133139
<< messaget::eom;
134-
class_json=json_stringt(sstr.str());
140+
errors.push_back(json_stringt(sstr.str()));
135141
ret_code=-7;
142+
continue;
136143
}
137-
else
138-
{
139-
try
140-
{
141-
java_bytecode_parse_treet parse_tree;
142-
if(java_bytecode_parse(
143-
class_file_pathname,
144-
parse_tree,
145-
ui_message_handler))
146-
{
147-
std::stringstream sstr;
148-
sstr
149-
<< "The load of Java class file '"
150-
<< class_file_pathname
151-
<< "' specified in '"
152-
<< in_json_pathname
153-
<< "' has failed (by error return code from "
154-
<< "'java_bytecode_parse').";
155-
msg.warning()
156-
<< "WARNING: "
157-
<< sstr.str()
158-
<< " Skipping this file."
159-
<< messaget::eom;
160-
class_json=json_stringt(sstr.str());
161-
ret_code=-7;
162-
}
163-
else
164-
{
165-
INVARIANT(parse_tree.loading_successful,
166-
"False returned from 'java_bytecode_parse' should imply "
167-
"'parse_tree.loading_successful' is True.");
168144

169-
json_objectt class_props;
170-
{
171-
class_props["name"]=
172-
json_stringt(id2string(parse_tree.parsed_class.name));
173-
class_props["extends"]=
174-
json_stringt(id2string(parse_tree.parsed_class.extends));
175-
{
176-
json_arrayt interfaces;
177-
for(auto const &interface : parse_tree.parsed_class.implements)
178-
interfaces.push_back(json_stringt(id2string(interface)));
179-
class_props["implements"]=interfaces;
180-
}
181-
class_props["is_abstract"]=jsont::json_boolean(
182-
parse_tree.parsed_class.is_abstract);
183-
class_props["is_public"]=jsont::json_boolean(
184-
parse_tree.parsed_class.is_public);
185-
class_props["is_private"]=jsont::json_boolean(
186-
parse_tree.parsed_class.is_private);
187-
class_props["is_protected"]=jsont::json_boolean(
188-
parse_tree.parsed_class.is_protected);
189-
class_props["is_enum"]=jsont::json_boolean(
190-
parse_tree.parsed_class.is_enum);
191-
}
192-
class_json=class_props;
193-
}
194-
}
195-
catch(...)
145+
jsont class_json;
146+
try
147+
{
148+
java_bytecode_parse_treet parse_tree;
149+
if(java_bytecode_parse(
150+
class_file_pathname,
151+
parse_tree,
152+
ui_message_handler))
196153
{
197154
std::stringstream sstr;
198155
sstr
199156
<< "The load of Java class file '"
200157
<< class_file_pathname
201158
<< "' specified in '"
202159
<< in_json_pathname
203-
<< "' has failed (by throwing an exception)."
204-
<< "";
160+
<< "' has failed (by error return code from "
161+
<< "'java_bytecode_parse').";
205162
msg.warning()
206163
<< "WARNING: "
207164
<< sstr.str()
@@ -210,6 +167,55 @@ int cmdline_optionst::doit()
210167
class_json=json_stringt(sstr.str());
211168
ret_code=-7;
212169
}
170+
else
171+
{
172+
INVARIANT(parse_tree.loading_successful,
173+
"False returned from 'java_bytecode_parse' should imply "
174+
"'parse_tree.loading_successful' is True.");
175+
176+
json_objectt class_props;
177+
{
178+
class_props["name"]=
179+
json_stringt(id2string(parse_tree.parsed_class.name));
180+
class_props["extends"]=
181+
json_stringt(id2string(parse_tree.parsed_class.extends));
182+
{
183+
json_arrayt interfaces;
184+
for(auto const &interface : parse_tree.parsed_class.implements)
185+
interfaces.push_back(json_stringt(id2string(interface)));
186+
class_props["implements"]=interfaces;
187+
}
188+
class_props["is_abstract"]=jsont::json_boolean(
189+
parse_tree.parsed_class.is_abstract);
190+
class_props["is_public"]=jsont::json_boolean(
191+
parse_tree.parsed_class.is_public);
192+
class_props["is_private"]=jsont::json_boolean(
193+
parse_tree.parsed_class.is_private);
194+
class_props["is_protected"]=jsont::json_boolean(
195+
parse_tree.parsed_class.is_protected);
196+
class_props["is_enum"]=jsont::json_boolean(
197+
parse_tree.parsed_class.is_enum);
198+
}
199+
class_json=class_props;
200+
}
201+
}
202+
catch(...)
203+
{
204+
std::stringstream sstr;
205+
sstr
206+
<< "The load of Java class file '"
207+
<< class_file_pathname
208+
<< "' specified in '"
209+
<< in_json_pathname
210+
<< "' has failed (by throwing an exception)."
211+
<< "";
212+
msg.warning()
213+
<< "WARNING: "
214+
<< sstr.str()
215+
<< " Skipping this file."
216+
<< messaget::eom;
217+
class_json=json_stringt(sstr.str());
218+
ret_code=-7;
213219
}
214220
if(class_json.is_string())
215221
errors.push_back(class_json);

0 commit comments

Comments
 (0)