@@ -624,10 +624,14 @@ std::optional<typet> java_type_from_string(
624624 {
625625 std::size_t e_pos=src.rfind (' )' );
626626 if (e_pos==std::string::npos)
627- return {};
627+ {
628+ throw unsupported_java_class_signature_exceptiont (
629+ " Failed to find function signature closing delimiter" );
630+ }
628631
629632 auto return_type = java_type_from_string (
630633 std::string (src, e_pos + 1 , std::string::npos), class_name_prefix);
634+ CHECK_RETURN (return_type.has_value ());
631635
632636 std::vector<typet> param_types =
633637 parse_list_types (src.substr (0 , e_pos + 1 ), class_name_prefix, ' (' , ' )' );
@@ -648,10 +652,14 @@ std::optional<typet> java_type_from_string(
648652 // If this is a reference array, we generate a plain array[reference]
649653 // with void* members, but note the real type in ID_element_type.
650654 if (src.size ()<=1 )
651- return {};
655+ {
656+ throw unsupported_java_class_signature_exceptiont (
657+ " Failed to find array signature closing delimiter" );
658+ }
652659 char subtype_letter=src[1 ];
653660 auto subtype = java_type_from_string (
654661 src.substr (1 , std::string::npos), class_name_prefix);
662+ CHECK_RETURN (subtype.has_value ());
655663 if (subtype_letter==' L' || // [L denotes a reference array of some sort.
656664 subtype_letter==' [' || // Array-of-arrays
657665 subtype_letter==' T' ) // Array of generic types
@@ -681,11 +689,11 @@ std::optional<typet> java_type_from_string(
681689 INVARIANT (src[src.size ()-1 ]==' ;' , " Generic type name must end on ';'." );
682690 PRECONDITION (!class_name_prefix.empty ());
683691 irep_idt type_var_name (class_name_prefix+" ::" +src.substr (1 , src.size ()-2 ));
692+ auto lang_object = java_type_from_string (" Ljava/lang/Object;" );
693+ CHECK_RETURN (lang_object.has_value ());
684694 return java_generic_parametert (
685695 type_var_name,
686- to_struct_tag_type (
687- to_java_reference_type (*java_type_from_string (" Ljava/lang/Object;" ))
688- .base_type ()));
696+ to_struct_tag_type (to_java_reference_type (*lang_object).base_type ()));
689697 }
690698 case ' L' :
691699 {
@@ -781,13 +789,13 @@ std::vector<typet> java_generic_type_from_string(
781789
782790 std::string type_var_name (
783791 " java::" +class_name+" ::" +signature.substr (0 , bound_sep));
784- std::string bound_type (signature.substr (bound_sep+1 , var_sep-bound_sep));
785-
792+ std::string bound_type_str (
793+ signature.substr (bound_sep + 1 , var_sep - bound_sep));
794+ auto bound_type = java_type_from_string (bound_type_str, class_name);
795+ CHECK_RETURN (bound_type.has_value ());
786796 java_generic_parametert type_var_type (
787797 type_var_name,
788- to_struct_tag_type (
789- to_java_reference_type (*java_type_from_string (bound_type, class_name))
790- .base_type ()));
798+ to_struct_tag_type (to_java_reference_type (*bound_type).base_type ()));
791799
792800 types.push_back (type_var_type);
793801 signature=signature.substr (var_sep+1 , std::string::npos);
@@ -809,8 +817,11 @@ static std::string slash_to_dot(const std::string &src)
809817struct_tag_typet java_classname (const std::string &id)
810818{
811819 if (!id.empty () && id[0 ]==' [' )
812- return to_struct_tag_type (
813- to_java_reference_type (*java_type_from_string (id)).base_type ());
820+ {
821+ auto array_type = java_type_from_string (id);
822+ CHECK_RETURN (array_type.has_value ());
823+ return to_struct_tag_type (to_java_reference_type (*array_type).base_type ());
824+ }
814825
815826 std::string class_name=id;
816827
@@ -1014,6 +1025,7 @@ void get_dependencies_from_generic_parameters(
10141025 {
10151026 auto type_from_string =
10161027 java_type_from_string (signature, erase_type_arguments (signature));
1028+ CHECK_RETURN (type_from_string.has_value ());
10171029 get_dependencies_from_generic_parameters_rec (*type_from_string, refs);
10181030 }
10191031 }
@@ -1053,6 +1065,7 @@ java_generic_struct_tag_typet::java_generic_struct_tag_typet(
10531065{
10541066 set (ID_C_java_generic_symbol, true );
10551067 const auto base_type = java_type_from_string (base_ref, class_name_prefix);
1068+ CHECK_RETURN (base_type.has_value ());
10561069 PRECONDITION (is_java_generic_type (*base_type));
10571070 const java_generic_typet &gen_base_type = to_java_generic_type (*base_type);
10581071 INVARIANT (
0 commit comments