Skip to content

Commit 5cdfa94

Browse files
author
Thomas Kiley
authored
Merge pull request #1804 from mgudemann/feature/parse_bootstrapmethods_attribute
[TG-2365] Parse `BootstrapMethods` attribute
2 parents ea7975f + 76d4014 commit 5cdfa94

35 files changed

+1841
-0
lines changed

regression/cbmc-java/lambda1/B.class

1.32 KB
Binary file not shown.

regression/cbmc-java/lambda1/B.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class B {
2+
public int y;
3+
4+
public static java.util.function.Function<Double, Double> dmul = x -> x * 3.1415;
5+
6+
public void set(int x) {
7+
y = x;
8+
}
9+
}

regression/cbmc-java/lambda1/C.class

582 Bytes
Binary file not shown.
299 Bytes
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@FunctionalInterface
2+
interface CustomLambda<T> {
3+
boolean is_ok(T t);
4+
}
401 Bytes
Binary file not shown.
4.84 KB
Binary file not shown.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import java.util.function.*;
2+
3+
public class Lambdatest {
4+
5+
class A {
6+
int x;
7+
}
8+
9+
CustomLambda<Integer> custom = x -> true;
10+
BiFunction<Float, Integer, Integer> add = (x0, y0) -> x0.intValue() + y0;
11+
int z = 10;
12+
13+
A a;
14+
B b = new B();
15+
16+
public Integer g(Float x, Integer y, BiFunction<Float, Integer, Integer> fun) {
17+
return fun.apply(x, y);
18+
}
19+
20+
public int f(Float x, Integer y, Integer z) {
21+
Integer tmp = add.apply(x, y);
22+
Function<Integer, Integer> mul = (a) -> a * tmp;
23+
return mul.apply(z);
24+
}
25+
26+
public int i(int x) {
27+
int z = 5;
28+
Function<Integer, Integer> foo = (a) -> a * z;
29+
return foo.apply(x);
30+
}
31+
32+
public int j(int x) {
33+
Function<Integer, Integer> foo = (a) -> a * z;
34+
return foo.apply(x);
35+
}
36+
37+
public int k(int x) {
38+
a.x = 10;
39+
40+
Function<Integer, Integer> foo = (y) -> y * a.x;
41+
return foo.apply(x);
42+
}
43+
44+
public int l(int x) {
45+
b.y = 10;
46+
Function<Integer, Integer> foo = (y) -> {
47+
int r = y * b.y;
48+
b.set(r);
49+
return r;
50+
};
51+
b = new B();
52+
b.y = 14;
53+
return foo.apply(x);
54+
}
55+
56+
public int m(int x) {
57+
b.y = 10;
58+
Function<Integer, Integer> foo = (y) -> {
59+
int r = y * b.y;
60+
b.y = r;
61+
return r;
62+
};
63+
return foo.apply(x);
64+
}
65+
66+
// test static field of different class
67+
public double d(Double x) {
68+
return B.dmul.apply(x);
69+
}
70+
71+
public int capture2(Float a) {
72+
return add.apply(a, 1);
73+
}
74+
75+
public boolean custom(Integer i) {
76+
return custom.is_ok(i);
77+
}
78+
}
79+
80+
class C implements CustomLambda<Integer> {
81+
public boolean is_ok(Integer i) {
82+
return true;
83+
}
84+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Lambdatest.class
3+
--verbosity 10 --show-goto-functions
4+
lambda function reference lambda\$new\$0 in class \"Lambdatest\"
5+
lambda function reference lambda\$new\$1 in class \"Lambdatest\"
6+
lambda function reference lambda\$f\$2 in class \"Lambdatest\"
7+
lambda function reference lambda\$i\$3 in class \"Lambdatest\"
8+
lambda function reference lambda\$j\$4 in class \"Lambdatest\"
9+
lambda function reference lambda\$k\$5 in class \"Lambdatest\"
10+
lambda function reference lambda\$l\$6 in class \"Lambdatest\"
11+
lambda function reference lambda\$m\$7 in class \"Lambdatest\"
12+
lambda function reference lambda\$static\$0 in class \"B\"

src/java_bytecode/java_bytecode_parse_tree.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ void java_bytecode_parse_treet::classt::swap(
3333
other.fields.swap(fields);
3434
other.methods.swap(methods);
3535
other.annotations.swap(annotations);
36+
std::swap(
37+
other.attribute_bootstrapmethods_read, attribute_bootstrapmethods_read);
38+
std::swap(other.lambda_method_handle_map, lambda_method_handle_map);
3639
}
3740

3841
void java_bytecode_parse_treet::output(std::ostream &out) const

0 commit comments

Comments
 (0)