Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2f1cb06

Browse files
committedAug 5, 2019
Avoid misleading special characters within lambda synthetic class names
Enough code in cbmc and its users relies on method names having the form 'java::package.Class.method:(type)' that the existing method for synthesising lambda class names, which could yield things like java::synthetic_lambda$main:()V$0.<init>, could cause problems when that colon character in the middle of the name was mistaken for the function name's trailing type information. Similarly we might end up needing to append fake type information to the <init> and apply symbol names to appear "normal" enough.
1 parent f83fd36 commit 2f1cb06

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎jbmc/src/java_bytecode/lambda_synthesis.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,25 @@ Author: Diffblue Ltd.
2424

2525
#include <string.h>
2626

27+
static std::string escape_symbol_special_chars(std::string input)
28+
{
29+
for(auto &c : input)
30+
{
31+
if(c == '$' || c == ':' || c == '.')
32+
c = '_';
33+
}
34+
return input;
35+
}
36+
2737
irep_idt lambda_synthetic_class_name(
2838
const irep_idt &method_identifier,
2939
std::size_t instruction_address)
3040
{
31-
return "java::lambda_synthetic_class$" +
32-
id2string(strip_java_namespace_prefix(method_identifier)) + "$" +
33-
std::to_string(instruction_address);
41+
return
42+
"java::lambda_synthetic_class$" +
43+
escape_symbol_special_chars(
44+
id2string(strip_java_namespace_prefix(method_identifier))) +
45+
"$" + std::to_string(instruction_address);
3446
}
3547

3648
/// Retrieves the symbol of the lambda method associated with the given

0 commit comments

Comments
 (0)
Please sign in to comment.