Skip to content

Commit a6e7c4b

Browse files
Refactors interface for exceptions to not use irepts.
1 parent 1134bba commit a6e7c4b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,8 @@ void java_bytecode_convert_methodt::convert(
587587
method_symbol.location=m.source_location;
588588
method_symbol.location.set_function(method_identifier);
589589

590-
std::vector<irept> &exceptions_list = method_type.throws_exceptions();
591590
for(const auto &exception_name : m.throws_exception_table)
592-
exceptions_list.push_back(irept(exception_name));
591+
method_type.add_throws_exceptions(exception_name);
593592

594593
const std::string signature_string = pretty_signature(method_type);
595594

jbmc/src/java_bytecode/java_types.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,17 @@ inline bool can_cast_type<java_class_typet>(const typet &type)
245245
class java_method_typet : public code_typet
246246
{
247247
public:
248-
const std::vector<irept> &throws_exceptions() const
248+
const std::vector<irep_idt> throws_exceptions() const
249249
{
250-
return find(ID_exceptions_thrown_list).get_sub();
250+
std::vector<irep_idt> exceptions;
251+
for(const auto &e : find(ID_exceptions_thrown_list).get_sub())
252+
exceptions.push_back(e.id());
253+
return exceptions;
251254
}
252255

253-
std::vector<irept> &throws_exceptions()
256+
void add_throws_exceptions(irep_idt exception)
254257
{
255-
return add(ID_exceptions_thrown_list).get_sub();
258+
add(ID_exceptions_thrown_list).get_sub().push_back(irept(exception));
256259
}
257260
};
258261

jbmc/unit/java_bytecode/java_bytecode_parser/parse_java_attributes.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,17 +612,18 @@ SCENARIO(
612612
new_symbol_table.lookup_ref("java::ThrowsExceptions.test:()V");
613613
const java_method_typet method =
614614
to_java_method_type(method_symbol.type);
615-
const std::vector<irept> exceptions = method.throws_exceptions();
615+
const std::vector<irep_idt> exceptions = method.throws_exceptions();
616616
REQUIRE(exceptions.size() == 2);
617617
REQUIRE(
618618
std::find(
619-
exceptions.begin(), exceptions.end(), irept("CustomException")) !=
620-
exceptions.end());
619+
exceptions.begin(),
620+
exceptions.end(),
621+
irept("CustomException").id()) != exceptions.end());
621622
REQUIRE(
622623
std::find(
623624
exceptions.begin(),
624625
exceptions.end(),
625-
irept("java.io.IOException")) != exceptions.end());
626+
irept("java.io.IOException").id()) != exceptions.end());
626627
}
627628
}
628629
}

0 commit comments

Comments
 (0)