Gradle,“源兼容性"与“目标兼容性"? [英] Gradle, "sourceCompatibility" vs "targetCompatibility"?

查看:51
本文介绍了Gradle,“源兼容性"与“目标兼容性"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sourceCompatibilitytargetCompatibility 之间的关系/区别是什么?当它们设置为不同的值时会发生什么?

What is the relationship/difference between sourceCompatibility and targetCompatibility? What happens when they are set to different values?

根据 Gradle 文档:

sourceCompatibility 是编译 Java 源代码时使用的 Java 版本兼容性."targetCompatibility 是要为其生成类的 Java 版本."

sourceCompatibility is "Java version compatibility to use when compiling Java source." targetCompatibility is "Java version to generate classes for."

我的理解是 targetCompatibility 会生成与特定 Java 版本兼容的 Java 字节码,这是 sourceCompatibility 功能的子集吗?

My understanding is that targetCompatibility will generate java bytecode that is compatible with a specific version of Java, is this a subset of the functionality of sourceCompatibility?

推荐答案

targetCompatibilitysourceCompatibility 映射到 -target release-javac 中的源发布.Source 基本上是源语言级别,target 是生成的字节码级别.

targetCompatibility and sourceCompatibility maps to -target release and -source release in javac. Source is basically the source language level and target is the level of the bytecode that is generated.

更多详细信息可以在 javac 交叉编译部分.

More details can be found in the javac the cross compilation section.

这篇关于Gradle,“源兼容性"与“目标兼容性"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆