我可以在sbt构建的混合scala 2.10 / java项目中使用java 8吗?

时间:2022-11-25 19:37:30

To what degree can I use java 8 in a mixed java / scala 2.10 sbt project?
Can I emit java 8 bytecode? Use java 8 language features? Or are there features in scala 2.11 that are necessary? Is there an interop story?

我可以在混合java / scala 2.10 sbt项目中使用java 8到什么程度?我可以发出java 8字节码吗?使用java 8语言功能?或者scala 2.11中是否有必要的功能?是否存在互操作故事?

1 个解决方案

#1


8  

From the 2.10.4 Scala release notes:

从2.10.4 Scala发行说明:

New ByteCode emitter based on ASM

基于ASM的新ByteCode发射器

Can target JDK 1.5, 1.6 and 1.7

可以针对JDK 1.5,1.6和1.7

Emits 1.6 bytecode by default

默认情况下发出1.6字节码

Old 1.5 backend is deprecated

旧的1.5后端已被弃用

Also

The official Scala 2.12 distribution will be built for Java 8 (and thus require it).

官方的Scala 2.12发行版将为Java 8构建(因此需要它)。

More background info of when you can expect to fully use Java 8:

有关何时可以完全使用Java 8的更多背景信息:

The Scala 2.11.x series targets Java 6, with (evolving) experimental >support for Java 8. In 2.11.1, Java 8 support is mostly limited to reading >Java 8 bytecode and parsing Java 8 source. Stay tuned for more complete >(experimental) Java 8 support. The next major release, 2.12, will most >likely target Java 8 by default.

Scala 2.11.x系列针对Java 6,具有(不断发展的)实验性支持Java 8.在2.11.1中,Java 8支持主要限于读取> Java 8字节码和解析Java 8源代码。请继续关注更完整的>(实验性)Java 8支持。下一个主要版本2.12将默认大多数可能是Java 8的目标。

And...

Planned future Java 8-centric additions for Scala 2.12 include Java 8 >style closures, which will allow the Scala compiler to emit closure >classes (lambdas) just as you can with Java 8. There’s also planned lambda >syntax for SAM types. Again, in Java 8 fashion, this lets you instantiate >any type with one single abstract method by passing a lambda, improving >the user experiences for libraries written for Java 8 in Scala.

计划中的Scala 2.12未来以Java 8为中心的新增功能包括Java 8>样式闭包,这将允许Scala编译器像Java 8一样发出闭包>类(lambdas)。还有SAM类型的lambda语法。同样,在Java 8方式中,这允许您通过传递lambda来实例化>任何类型的一个抽象方法,改进> Scala中为Java 8编写的库的用户体验。

#1


8  

From the 2.10.4 Scala release notes:

从2.10.4 Scala发行说明:

New ByteCode emitter based on ASM

基于ASM的新ByteCode发射器

Can target JDK 1.5, 1.6 and 1.7

可以针对JDK 1.5,1.6和1.7

Emits 1.6 bytecode by default

默认情况下发出1.6字节码

Old 1.5 backend is deprecated

旧的1.5后端已被弃用

Also

The official Scala 2.12 distribution will be built for Java 8 (and thus require it).

官方的Scala 2.12发行版将为Java 8构建(因此需要它)。

More background info of when you can expect to fully use Java 8:

有关何时可以完全使用Java 8的更多背景信息:

The Scala 2.11.x series targets Java 6, with (evolving) experimental >support for Java 8. In 2.11.1, Java 8 support is mostly limited to reading >Java 8 bytecode and parsing Java 8 source. Stay tuned for more complete >(experimental) Java 8 support. The next major release, 2.12, will most >likely target Java 8 by default.

Scala 2.11.x系列针对Java 6,具有(不断发展的)实验性支持Java 8.在2.11.1中,Java 8支持主要限于读取> Java 8字节码和解析Java 8源代码。请继续关注更完整的>(实验性)Java 8支持。下一个主要版本2.12将默认大多数可能是Java 8的目标。

And...

Planned future Java 8-centric additions for Scala 2.12 include Java 8 >style closures, which will allow the Scala compiler to emit closure >classes (lambdas) just as you can with Java 8. There’s also planned lambda >syntax for SAM types. Again, in Java 8 fashion, this lets you instantiate >any type with one single abstract method by passing a lambda, improving >the user experiences for libraries written for Java 8 in Scala.

计划中的Scala 2.12未来以Java 8为中心的新增功能包括Java 8>样式闭包,这将允许Scala编译器像Java 8一样发出闭包>类(lambdas)。还有SAM类型的lambda语法。同样,在Java 8方式中,这允许您通过传递lambda来实例化>任何类型的一个抽象方法,改进> Scala中为Java 8编写的库的用户体验。