mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
2465459079
The two big pieces here are basic invokedynamic support and a working version of LambdaMetaFactory.metafactory. The latter works by dynamically building a synthetic class with three methods: a static factory method, a constructor for the factory method to call, and a method to satisfy the requested interface which defers to the specified MethodHandle. This work relies heavily on Avian's specific MethodType and MethodHandle implementations, which provide extra, non-standard features to make code generation easier. That means we'll probably need to use Avian's versions of java.lang.invoke.* even when building with the OpenJDK or Android class libraries.
16 lines
328 B
Java
16 lines
328 B
Java
public class InvokeDynamic {
|
|
private interface Operation {
|
|
int operate(int a, int b);
|
|
}
|
|
|
|
private static void expect(boolean v) {
|
|
if (! v) throw new RuntimeException();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
int c = 4;
|
|
Operation op = (a, b) -> a + b - c;
|
|
expect(op.operate(2, 3) == 1);
|
|
}
|
|
}
|