Skip to content

Commit 8f71a23

Browse files
thk123tautschnig
thk123
authored andcommitted
Do not allow getting type from descriptor to fail
There should be no unsupported cases here.
1 parent 6f1084e commit 8f71a23

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,10 @@ void java_bytecode_parsert::get_class_refs()
574574
field_type, parse_tree.class_refs);
575575
get_class_refs_rec(field_type);
576576
}
577-
else if(const auto field_type = java_type_from_string(field.descriptor))
578-
get_class_refs_rec(*field_type);
577+
else
578+
{
579+
get_class_refs_rec(*java_type_from_string(field.descriptor));
580+
}
579581
}
580582

581583
for(const auto &method : parse_tree.parsed_class.methods)
@@ -594,8 +596,10 @@ void java_bytecode_parsert::get_class_refs()
594596
method_type, parse_tree.class_refs);
595597
get_class_refs_rec(method_type);
596598
}
597-
else if(const auto method_type = java_type_from_string(method.descriptor))
598-
get_class_refs_rec(*method_type);
599+
else
600+
{
601+
get_class_refs_rec(*java_type_from_string(method.descriptor));
602+
}
599603

600604
for(const auto &var : method.local_variable_table)
601605
{
@@ -609,8 +613,10 @@ void java_bytecode_parsert::get_class_refs()
609613
var_type, parse_tree.class_refs);
610614
get_class_refs_rec(var_type);
611615
}
612-
else if(const auto var_type = java_type_from_string(var.descriptor))
613-
get_class_refs_rec(*var_type);
616+
else
617+
{
618+
get_class_refs_rec(*java_type_from_string(var.descriptor));
619+
}
614620
}
615621
}
616622
}
@@ -668,9 +674,7 @@ void java_bytecode_parsert::get_annotation_value_class_refs(const exprt &value)
668674
if(const auto &symbol_expr = expr_try_dynamic_cast<symbol_exprt>(value))
669675
{
670676
const irep_idt &value_id = symbol_expr->get_identifier();
671-
const auto value_type = java_type_from_string(id2string(value_id));
672-
if(value_type.has_value())
673-
get_class_refs_rec(*value_type);
677+
get_class_refs_rec(*java_type_from_string(id2string(value_id)));
674678
}
675679
else if(const auto &array_expr = expr_try_dynamic_cast<array_exprt>(value))
676680
{

0 commit comments

Comments
 (0)