Skip to content

Commit e979eef

Browse files
committed
Asymptopically approaching acceptable names.
"org.scala-lang.modules" %% "scala-compat-jdk8" import scala.compat.jdk8._ Subsequent commits will address the under-loved `JFunc`.
1 parent cec8baf commit e979eef

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
## Functional Interfaces for Scala functions
1+
## JDK8 Compatibility Kit for Scala
2+
3+
### Functional Interfaces for Scala functions
24

35
A set of [Functional Interfaces](http://download.java.net/jdk8/docs/api/java/lang/FunctionalInterface.html)
46
for `scala.FunctionN`. These are designed for convenient construction of Scala functions
57
using Java 8 lambda syntax.
68

7-
### Usage
9+
#### Usage
810

911
```java
1012
import scala.concurrent.*;
11-
import static scala.runtime.jfunc.JFunc.*;
13+
import static scala.compat.jdk8.JFunc.*;
1214

1315
class Test {
1416
private static Future<Integer> futureExample(Future<String> future, ExecutionContext ec) {
@@ -17,16 +19,28 @@ class Test {
1719
}
1820
```
1921

20-
[More Examples / Documentation](https://github.com/retronym/java-8-function1/blob/master/src/test/java/scala/runtime/jfunc/Test.java)
22+
[More Examples / Documentation](https://github.com/scala/scala-compat-jdk8/blob/master/src/test/java/scala/compat/jdk8/LambdaTest.java)
23+
24+
### Converters between `s.u.concurrent` and `j.u.concurrent`
25+
26+
TODO
27+
28+
### Converters for `j.u.function`
29+
30+
TODO
31+
32+
### Converters for `j.u.Stream`
33+
34+
TODO
2135

2236
### Hacking
2337

24-
[Code Generator](https://github.com/retronym/java-8-function1/blob/master/project/CodeGen.scala)
38+
[Code Generator](https://github.com/scala/scala-compat-jdk8/blob/master/project/CodeGen.scala)
2539

2640
#### Running Examples
2741

2842
```
29-
% (export JAVA_HOME=`java_home 1.8`; export PATH=$JAVA_HOME/bin:$PATH; sbt 'test:runMain scala.runtime.test.Test')
43+
% (export JAVA_HOME=`java_home 1.8`; export PATH=$JAVA_HOME/bin:$PATH; sbt 'test:runMain scala.compat.jdk8.LambdaTest')
3044
```
3145

3246
### Future work
@@ -35,8 +49,6 @@ class Test {
3549
modify scalac to emit lambdas as calls to the lambda MetaFactory against them.
3650

3751
```java
38-
package scala.runtime;
39-
4052
@FunctionalInterface
4153
public interface JFunction1$mcII$sp extends JFunction1 {
4254
abstract int apply$mcII$sp(int v1);

build.sbt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
scalaVersion := "2.10.3"
22

3+
organization := "org.scala-lang.modules"
4+
5+
name := "scala-compat-jdk8"
6+
37
sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
48
def write(name: String, content: String) = {
5-
val f = dir / "java" / "scala" / "runtime" / "jfunc" / s"${name}.java"
9+
val f = dir / "java" / "scala" / "compat" / "jdk8" / s"${name}.java"
610
IO.write(f, content)
711
f
812
}
@@ -11,7 +15,7 @@ sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
1115

1216
sourceGenerators in Test <+= sourceManaged in Test map { dir =>
1317
def write(name: String, content: String) = {
14-
val f = dir / "java" / "scala" / "runtime" / "jfunc" / s"${name}.java"
18+
val f = dir / "java" / "scala" / "compat" / "jdk8" / s"${name}.java"
1519
IO.write(f, content)
1620
f
1721
}

project/CodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Type {
1717
}
1818

1919
object CodeGen {
20-
def packaging = "package scala.runtime.jfunc;"
20+
def packaging = "package scala.compat.jdk8;"
2121
case class arity(n: Int) {
2222
val ns = (1 to n).toList
2323

src/test/java/scala/runtime/jfunc/Test.java renamed to src/test/java/scala/compat/jdk8/LambdaTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
33
*/
4-
package scala.runtime.jfunc;
4+
package scala.compat.jdk8;
55

66
import scala.runtime.*;
7-
import static scala.runtime.jfunc.TestAPI.*;
8-
import static scala.runtime.jfunc.JFunc.*;
7+
import static scala.compat.jdk8.TestAPI.*;
8+
import static scala.compat.jdk8.JFunc.*;
99

10-
public class Test {
10+
public class LambdaTest {
1111
public static void main(String[] args) {
1212
// Not allowed with Scala 2.10 nor 2.11
1313
// "incompatible types: Function1 is not a functional interface"
@@ -108,3 +108,4 @@ private static String join(String... ss) {
108108
return result;
109109
}
110110
}
111+

0 commit comments

Comments
 (0)