gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:20:03 27 4
gpt4 key购买 nike

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

最佳答案

来自 2.10.4 Scala release notes :

New ByteCode emitter based on ASM

Can target JDK 1.5, 1.6 and 1.7

Emits 1.6 bytecode by default

Old 1.5 backend is deprecated

还有

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

关于何时可以完全使用 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.

还有……

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.

关于java - 我可以在 sbt 构建的混合 scala 2.10/java 项目中使用 java 8 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32126768/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com