-
Notifications
You must be signed in to change notification settings - Fork 276
[TG-2365] Parse BootstrapMethods
attribute
#1804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e79a655
603aced
01dcda5
f765a0d
6d44836
0e40081
3ac7d09
e3ff312
b56e42e
ca5dae4
463ffe1
e0ccb12
f79e895
ebdcfb1
ba8b958
db1f3b5
9b8a73e
76d4014
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
public class B { | ||
public int y; | ||
|
||
public static java.util.function.Function<Double, Double> dmul = x -> x * 3.1415; | ||
|
||
public void set(int x) { | ||
y = x; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@FunctionalInterface | ||
interface CustomLambda<T> { | ||
boolean is_ok(T t); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import java.util.function.*; | ||
|
||
public class Lambdatest { | ||
|
||
class A { | ||
int x; | ||
} | ||
|
||
CustomLambda<Integer> custom = x -> true; | ||
BiFunction<Float, Integer, Integer> add = (x0, y0) -> x0.intValue() + y0; | ||
int z = 10; | ||
|
||
A a; | ||
B b = new B(); | ||
|
||
public Integer g(Float x, Integer y, BiFunction<Float, Integer, Integer> fun) { | ||
return fun.apply(x, y); | ||
} | ||
|
||
public int f(Float x, Integer y, Integer z) { | ||
Integer tmp = add.apply(x, y); | ||
Function<Integer, Integer> mul = (a) -> a * tmp; | ||
return mul.apply(z); | ||
} | ||
|
||
public int i(int x) { | ||
int z = 5; | ||
Function<Integer, Integer> foo = (a) -> a * z; | ||
return foo.apply(x); | ||
} | ||
|
||
public int j(int x) { | ||
Function<Integer, Integer> foo = (a) -> a * z; | ||
return foo.apply(x); | ||
} | ||
|
||
public int k(int x) { | ||
a.x = 10; | ||
|
||
Function<Integer, Integer> foo = (y) -> y * a.x; | ||
return foo.apply(x); | ||
} | ||
|
||
public int l(int x) { | ||
b.y = 10; | ||
Function<Integer, Integer> foo = (y) -> { | ||
int r = y * b.y; | ||
b.set(r); | ||
return r; | ||
}; | ||
b = new B(); | ||
b.y = 14; | ||
return foo.apply(x); | ||
} | ||
|
||
public int m(int x) { | ||
b.y = 10; | ||
Function<Integer, Integer> foo = (y) -> { | ||
int r = y * b.y; | ||
b.y = r; | ||
return r; | ||
}; | ||
return foo.apply(x); | ||
} | ||
|
||
// test static field of different class | ||
public double d(Double x) { | ||
return B.dmul.apply(x); | ||
} | ||
|
||
public int capture2(Float a) { | ||
return add.apply(a, 1); | ||
} | ||
|
||
public boolean custom(Integer i) { | ||
return custom.is_ok(i); | ||
} | ||
} | ||
|
||
class C implements CustomLambda<Integer> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is true, I'll add some check for it. This was done to see different instances of lambda functions in .class files. |
||
public boolean is_ok(Integer i) { | ||
return true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
Lambdatest.class | ||
--verbosity 10 --show-goto-functions | ||
lambda function reference lambda\$new\$0 in class \"Lambdatest\" | ||
lambda function reference lambda\$new\$1 in class \"Lambdatest\" | ||
lambda function reference lambda\$f\$2 in class \"Lambdatest\" | ||
lambda function reference lambda\$i\$3 in class \"Lambdatest\" | ||
lambda function reference lambda\$j\$4 in class \"Lambdatest\" | ||
lambda function reference lambda\$k\$5 in class \"Lambdatest\" | ||
lambda function reference lambda\$l\$6 in class \"Lambdatest\" | ||
lambda function reference lambda\$m\$7 in class \"Lambdatest\" | ||
lambda function reference lambda\$static\$0 in class \"B\" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to annotate this with
@FunctionalInterface
or is it worth leaving this out of our java in order to avoid accidentally introducing any dependency on this optional annotation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not both? 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the annotation, this won't introduce a dependency as the annotation isn't used in any way in JBMC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.