Skip to content

Commit 017ff20

Browse files
committed
Update README.md
1 parent d430364 commit 017ff20

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ Here's how they could look:
3737
We will then need to modify the backend of scalac to emit
3838
`invokedynamic` against the `LambdaMetafactory`, passing a method
3939
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.
4150

4251
### Bridges
4352

@@ -55,6 +64,9 @@ signature. This is safe as the class is anonymous and only ever
5564
called through invoke-interface, so no harm done. Seems like a leaner
5665
representation.
5766

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+
5870
LamdaMetaFactory does have an [advanced API](http://download.java.net/jdk8/docs/api/java/lang/invoke/LambdaMetafactory.html#FLAG_BRIDGES)
5971
that allows to create additional bridges, if needed. We can also mark
6072
the closure as serializable, which should be done to be compatible
@@ -72,7 +84,9 @@ This looks like a bug in scalac.
7284

7385
## `invokedynamic` calls, courtesy of javac
7486

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:
7690

7791
```
7892
% `java_home -v 1.8`/bin/javap -v -p -classpath target/scala-2.11.0-M7/classes Test

0 commit comments

Comments
 (0)