You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,16 @@ Here's how they could look:
37
37
We will then need to modify the backend of scalac to emit
38
38
`invokedynamic` against the `LambdaMetafactory`, passing a method
39
39
handle to the function-body-in-a-method that results from `-Ydelambdafy:method`
40
-
lifted method body.
40
+
lifted method body. This behaviour would be conditional on a flag, and require
41
+
that you have `F1*` on the classpath at runtime. These could be shipped in a
42
+
separate JAR.
43
+
44
+
We could actually do all of this without needing to emit any default methods ourselves; we can simply use a code generator and javac to generate `F1*`!
45
+
46
+
### Optimizer
47
+
48
+
We will need to modify `GenBCodeOpt`'s to understand `indy` calls to spin
49
+
up lambdas so it can still recognize opportunities for closure inlining.
41
50
42
51
### Bridges
43
52
@@ -55,6 +64,9 @@ signature. This is safe as the class is anonymous and only ever
55
64
called through invoke-interface, so no harm done. Seems like a leaner
56
65
representation.
57
66
67
+
Furthermore, by *only* creating the generic signature for anonymous functions,
68
+
we would avoid the rather brutal limitation imposed by erasure for value classes, [SI-6260](https://issues.scala-lang.org/browse/SI-6260).
69
+
58
70
LamdaMetaFactory does have an [advanced API](http://download.java.net/jdk8/docs/api/java/lang/invoke/LambdaMetafactory.html#FLAG_BRIDGES)
59
71
that allows to create additional bridges, if needed. We can also mark
60
72
the closure as serializable, which should be done to be compatible
@@ -72,7 +84,9 @@ This looks like a bug in scalac.
72
84
73
85
## `invokedynamic` calls, courtesy of javac
74
86
75
-
`Test.java` decompiles to:
87
+
[`Test.java`](https://github.com/retronym/java-8-function1/blob/master/src/main/java/scala/runtime/Test.java) contains Java 8 lambdas against `F1` and `F1$mcII$sp`.
88
+
89
+
In the following decompilation, you can see the invokedynamic calls:
76
90
77
91
```
78
92
% `java_home -v 1.8`/bin/javap -v -p -classpath target/scala-2.11.0-M7/classes Test
0 commit comments