Skip to content

Commit ecb171e

Browse files
committed
Move method context check before symbol value assignment
The previous check was right at the beginning of convert_single_method, meaning that for an "excluded" method, we would have never entered java_bytecode_convert_method, which assigns more than just the symbol value (body of a method), e.g. parameter identifiers. The only information that we want to omit for excluded methods is their bodies / symbol values. This is why the new check is just before the assignment of symbol values, making sure that parameter identifiers and other meta-information of the method are correctly assigned for excluded methods.
1 parent fd28d0d commit ecb171e

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ static irep_idt get_method_identifier(
425425

426426
void java_bytecode_convert_methodt::convert(
427427
const symbolt &class_symbol,
428-
const methodt &m)
428+
const methodt &m,
429+
const optionalt<prefix_filtert> &method_context)
429430
{
430431
// Construct the fully qualified method name
431432
// (e.g. "my.package.ClassName.myMethodName:(II)I") and query the symbol table
@@ -605,8 +606,12 @@ void java_bytecode_convert_methodt::convert(
605606
if((!m.is_abstract) && (!m.is_native))
606607
{
607608
code_blockt code(convert_parameter_annotations(m, method_type));
608-
code.append(convert_instructions(m));
609-
method_symbol.value = std::move(code);
609+
// Do not convert if method is not in context
610+
if(!method_context || (*method_context)(id2string(method_identifier)))
611+
{
612+
code.append(convert_instructions(m));
613+
method_symbol.value = std::move(code);
614+
}
610615
}
611616
}
612617

@@ -3184,7 +3189,8 @@ void java_bytecode_convert_method(
31843189
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
31853190
java_string_library_preprocesst &string_preprocess,
31863191
const class_hierarchyt &class_hierarchy,
3187-
bool threading_support)
3192+
bool threading_support,
3193+
optionalt<prefix_filtert> method_context)
31883194

31893195
{
31903196
java_bytecode_convert_methodt java_bytecode_convert_method(
@@ -3197,7 +3203,7 @@ void java_bytecode_convert_method(
31973203
class_hierarchy,
31983204
threading_support);
31993205

3200-
java_bytecode_convert_method(class_symbol, method);
3206+
java_bytecode_convert_method(class_symbol, method, method_context);
32013207
}
32023208

32033209
/// Returns true iff method \p methodid from class \p classname is

jbmc/src/java_bytecode/java_bytecode_convert_method.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/symbol_table.h>
2121

2222
class class_hierarchyt;
23+
class prefix_filtert;
2324

2425
void java_bytecode_initialize_parameter_names(
2526
symbolt &method_symbol,
@@ -37,7 +38,8 @@ void java_bytecode_convert_method(
3738
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
3839
java_string_library_preprocesst &string_preprocess,
3940
const class_hierarchyt &class_hierarchy,
40-
bool threading_support);
41+
bool threading_support,
42+
optionalt<prefix_filtert> method_context);
4143

4244
void create_method_stub_symbol(
4345
const irep_idt &identifier,

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ class java_bytecode_convert_methodt:public messaget
6161
typedef methodt::local_variable_tablet local_variable_tablet;
6262
typedef methodt::local_variablet local_variablet;
6363

64-
void operator()(const symbolt &class_symbol, const methodt &method)
64+
void operator()(
65+
const symbolt &class_symbol,
66+
const methodt &method,
67+
const optionalt<prefix_filtert> method_context)
6568
{
66-
convert(class_symbol, method);
69+
convert(class_symbol, method, method_context);
6770
}
6871

6972
typedef uint16_t method_offsett;
@@ -290,7 +293,10 @@ class java_bytecode_convert_methodt:public messaget
290293
bool allow_merge = true);
291294

292295
// conversion
293-
void convert(const symbolt &class_symbol, const methodt &);
296+
void convert(
297+
const symbolt &class_symbol,
298+
const methodt &,
299+
const optionalt<prefix_filtert> &method_context);
294300

295301
code_blockt convert_parameter_annotations(
296302
const methodt &method,

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,12 +1173,6 @@ bool java_bytecode_languaget::convert_single_method(
11731173
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
11741174
lazy_class_to_declared_symbols_mapt &class_to_declared_symbols)
11751175
{
1176-
// Do not convert if method is not in context
1177-
if(method_context && !(*method_context)(id2string(function_id)))
1178-
{
1179-
return false;
1180-
}
1181-
11821176
const symbolt &symbol = symbol_table.lookup_ref(function_id);
11831177

11841178
// Nothing to do if body is already loaded
@@ -1312,7 +1306,8 @@ bool java_bytecode_languaget::convert_single_method(
13121306
std::move(needed_lazy_methods),
13131307
string_preprocess,
13141308
class_hierarchy,
1315-
threading_support);
1309+
threading_support,
1310+
method_context);
13161311
INVARIANT(declaring_class(symbol), "Method must have a declaring class.");
13171312
return false;
13181313
}

0 commit comments

Comments
 (0)