diff --git a/src/java_bytecode/java_bytecode_convert_method.cpp b/src/java_bytecode/java_bytecode_convert_method.cpp index 287babedb41..ff36658dc75 100644 --- a/src/java_bytecode/java_bytecode_convert_method.cpp +++ b/src/java_bytecode/java_bytecode_convert_method.cpp @@ -120,13 +120,9 @@ static bool operator==(const irep_idt &what, const patternt &pattern) return pattern==what; } -// name contains or -bool java_bytecode_convert_methodt::is_constructor( - const class_typet::methodt &method) +static bool is_constructor(const irep_idt &method_name) { - const std::string &name(id2string(method.get_name())); - const std::string::size_type &npos(std::string::npos); - return npos!=name.find("") || npos!=name.find(""); + return id2string(method_name).find("") != std::string::npos; } exprt::operandst java_bytecode_convert_methodt::pop(std::size_t n) @@ -345,7 +341,7 @@ void java_bytecode_convert_method_lazy( else member_type.set_access(ID_default); - if(method_symbol.base_name=="") + if(is_constructor(method_symbol.base_name)) { method_symbol.pretty_name= id2string(class_symbol.pretty_name)+"."+ @@ -537,7 +533,7 @@ void java_bytecode_convert_methodt::convert( // The pretty name of a constructor includes the base name of the class // instead of the internal method name "". For regular methods, it's // just the base name of the method. - if(method_symbol.base_name=="") + if(is_constructor(method_symbol.base_name)) { method_symbol.pretty_name = id2string(class_symbol.pretty_name) + "." + id2string(class_symbol.base_name) + "()"; @@ -1271,9 +1267,7 @@ codet java_bytecode_convert_methodt::convert_instructions( // constructors. if(statement=="invokespecial") { - if( - id2string(arg0.get(ID_identifier)).find("") != - std::string::npos) + if(is_constructor(arg0.get(ID_identifier))) { if(needed_lazy_methods) needed_lazy_methods->add_needed_class(classname); diff --git a/src/java_bytecode/java_bytecode_convert_method_class.h b/src/java_bytecode/java_bytecode_convert_method_class.h index b7ea7d0748e..930bc62ae62 100644 --- a/src/java_bytecode/java_bytecode_convert_method_class.h +++ b/src/java_bytecode/java_bytecode_convert_method_class.h @@ -161,10 +161,6 @@ class java_bytecode_convert_methodt:public messaget void pop_residue(std::size_t n); void push(const exprt::operandst &o); - /// Determines whether the `method` is a constructor or a static initializer, - /// by checking whether its name equals either or - bool is_constructor(const class_typet::methodt &method); - /// Returns true iff the slot index of the local variable of a method (coming /// from the LVT) is a parameter of that method. Assumes that /// `slots_for_parameters` is initialized upon call.