File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -204,8 +204,21 @@ void java_bytecode_languaget::set_language_options(const optionst &options)
204
204
{
205
205
const std::string filename = options.get_option (" static-values" );
206
206
jsont tmp_json;
207
- if (!parse_json (filename, *message_handler, tmp_json))
208
- static_values_json = std::move (tmp_json);
207
+ if (parse_json (filename, *message_handler, tmp_json))
208
+ {
209
+ warning () << " Provided JSON file for static-values cannot be parsed; it"
210
+ << " will be ignored." << messaget::eom;
211
+ }
212
+ else
213
+ {
214
+ if (!tmp_json.is_object ())
215
+ {
216
+ warning () << " Provided JSON file for static-values is not a JSON "
217
+ << " object; it will be ignored." << messaget::eom;
218
+ }
219
+ else
220
+ static_values_json = std::move (to_json_object (tmp_json));
221
+ }
209
222
}
210
223
211
224
if (options.is_set (" context-include" ) || options.is_set (" context-exclude" ))
Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ class java_bytecode_languaget:public languaget
232
232
// / JSON which contains initial values of static fields (right
233
233
// / after the static initializer of the class was run). This is read from the
234
234
// / --static-values command-line option.
235
- optionalt<jsont > static_values_json;
235
+ optionalt<json_objectt > static_values_json;
236
236
237
237
// list of classes to force load even without reference from the entry point
238
238
std::vector<irep_idt> java_load_classes;
Original file line number Diff line number Diff line change @@ -769,20 +769,19 @@ code_ifthenelset get_clinit_wrapper_body(
769
769
770
770
code_blockt get_user_specified_clinit_body (
771
771
const irep_idt &class_id,
772
- const optionalt<jsont > &static_values_json,
772
+ const optionalt<json_objectt > &static_values_json,
773
773
symbol_table_baset &symbol_table,
774
774
message_handlert &message_handler,
775
775
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
776
776
size_t max_user_array_length,
777
777
std::unordered_map<std::string, object_creation_referencet> &references)
778
778
{
779
779
const irep_idt &real_clinit_name = clinit_function_name (class_id);
780
- if (static_values_json.has_value () && static_values_json-> is_object () )
780
+ if (static_values_json.has_value ())
781
781
{
782
- const auto &json_object = to_json_object (*static_values_json);
783
782
const auto class_entry =
784
- json_object. find (id2string (strip_java_namespace_prefix (class_id)));
785
- if (class_entry != json_object. end ())
783
+ static_values_json-> find (id2string (strip_java_namespace_prefix (class_id)));
784
+ if (class_entry != static_values_json-> end ())
786
785
{
787
786
const auto &class_json_value = class_entry->second ;
788
787
if (class_json_value.is_object ())
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ code_ifthenelset get_clinit_wrapper_body(
76
76
// / \return the body of the user_specified_clinit function as a code block.
77
77
code_blockt get_user_specified_clinit_body (
78
78
const irep_idt &class_id,
79
- const optionalt<jsont > &static_values_json,
79
+ const optionalt<json_objectt > &static_values_json,
80
80
symbol_table_baset &symbol_table,
81
81
message_handlert &message_handler,
82
82
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
You can’t perform that action at this time.
0 commit comments