Skip to content

Commit 2b53d3b

Browse files
author
Thomas Kiley
authored
Merge pull request #1983 from svorenova/lambda_tg2478_fix
Fix for crashing lambdas in a package [TG-2478]
2 parents f3b1379 + 7d4441d commit 2b53d3b

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed
164 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package LambdaTest;
2+
3+
interface Lamb1 {
4+
public Integer lambFunc1(Integer x);
5+
}
6+
7+
class Test {
8+
9+
public static Integer recvLambda(Integer y, Integer z) {
10+
Lamb1 lmb1 = (x) -> x = y + z; // Initializing in a lambda statement
11+
if (lmb1 != null && z != null) {
12+
return lmb1.lambFunc1(y);
13+
}
14+
return lmb1.lambFunc1(z);
15+
}
16+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
LambdaTest/Test.class
3+
--show-symbol-table --function LambdaTest.Test.recvLambda
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
This is to verify that parsing lambdas in a package does not crash.

src/java_bytecode/java_bytecode_parser.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1777,9 +1777,13 @@ java_bytecode_parsert::parse_method_handle(const method_handle_infot &entry)
17771777
const name_and_type_infot &name_and_type =
17781778
ref_entry.get_name_and_type(pool_entry_lambda);
17791779

1780+
std::string class_name = class_entry.get_name(pool_entry_lambda);
1781+
// replace '.' for '$' (inner classes)
1782+
std::replace(class_name.begin(), class_name.end(), '.', '$');
1783+
// replace '/' for '.' (package)
1784+
std::replace(class_name.begin(), class_name.end(), '/', '.');
17801785
const std::string method_ref =
1781-
class_entry.get_name(pool_entry_lambda) + "." +
1782-
name_and_type.get_name(pool_entry_lambda) + ':' +
1786+
class_name + "." + name_and_type.get_name(pool_entry_lambda) + ':' +
17831787
name_and_type.get_descriptor(pool_entry_lambda);
17841788

17851789
lambda_method_handlet lambda_method_handle;

0 commit comments

Comments
 (0)