Skip to content

Commit 9f87a80

Browse files
author
thk123
committed
Assertion on unmatched ; for parsing reference types
1 parent 5922826 commit 9f87a80

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/java_bytecode/java_types.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ std::vector<typet> parse_list_types(
341341
/// \param class_name_prefix: The name of the class to use to prefix any found
342342
/// generic types
343343
/// \return The reference type if parsed correctly, no value if parsing fails.
344-
optionalt<reference_typet>
345-
build_class_name(const std::string src, const std::string &class_name_prefix)
344+
reference_typet
345+
build_class_name(const std::string &src, const std::string &class_name_prefix)
346346
{
347347
PRECONDITION(src[0] == 'L');
348-
// ends on ;
349-
if(src[src.size() - 1] != ';')
350-
return optionalt<reference_typet>();
348+
349+
// All reference types must end on a ;
350+
PRECONDITION(src[src.size() - 1] == ';');
351351

352352
std::string container_class = gather_full_class_name(src);
353353
std::string identifier = "java::" + container_class;
@@ -536,12 +536,7 @@ typet java_type_from_string(
536536
}
537537
case 'L':
538538
{
539-
const optionalt<reference_typet> &class_type =
540-
build_class_name(src, class_name_prefix);
541-
if(class_type)
542-
return class_type.value();
543-
else
544-
return nil_typet();
539+
return build_class_name(src, class_name_prefix);
545540
}
546541
case '*':
547542
case '+':

0 commit comments

Comments
 (0)