Switch default JVM target to 1.8

#KT-29405 Fixed
This commit is contained in:
Alexander Udalov
2021-01-21 17:12:46 +01:00
parent 509ed64917
commit d022bb0248
52 changed files with 247 additions and 164 deletions
@@ -58,7 +58,7 @@ class OriginCollectingClassBuilderFactory(private val builderMode: ClassBuilderM
}
override fun asBytes(builder: ClassBuilder): ByteArray {
val classWriter = ClassWriter(0)
val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS)
(builder as OriginCollectingClassBuilder).classNode.accept(classWriter)
return classWriter.toByteArray()
}
@@ -66,4 +66,4 @@ class OriginCollectingClassBuilderFactory(private val builderMode: ClassBuilderM
override fun asText(builder: ClassBuilder) = throw UnsupportedOperationException()
override fun close() {}
}
}
@@ -71,7 +71,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(
value = "-jvm-target",
valueDescription = "<version>",
description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.6"
description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.8"
)
var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description)
@@ -36,7 +36,7 @@ enum class JvmTarget(
companion object {
@JvmField
val DEFAULT = JVM_1_6
val DEFAULT = JVM_1_8
@JvmStatic
fun fromString(string: String) = values().find { it.description == string }
@@ -14315,6 +14315,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt");
}
@Test
@TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt")
public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt");
}
@Test
@TestMetadata("function255.kt")
public void testFunction255() throws Exception {
@@ -35848,6 +35854,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt");
}
@Test
@TestMetadata("interfaceHashCode_1_6.kt")
public void testInterfaceHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt");
}
@Test
@TestMetadata("kt14243.kt")
public void testKt14243() throws Exception {
@@ -640,6 +640,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/boxingOptimization/fold.kt");
}
@Test
@TestMetadata("hashCodeOnNonNull.kt")
public void testHashCodeOnNonNull() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/boxingOptimization/hashCodeOnNonNull.kt");
}
@Test
@TestMetadata("inlineClassesAndInlinedLambda.kt")
public void testInlineClassesAndInlinedLambda() throws Exception {
@@ -3119,9 +3125,9 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
}
@Test
@TestMetadata("hashCode.kt")
public void testHashCode() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/hashCode/hashCode.kt");
@TestMetadata("hashCode_1_6.kt")
public void testHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/hashCode/hashCode_1_6.kt");
}
@Test
@@ -1,41 +1,41 @@
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A0 /* A0*/ {
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A1 /* A1*/ {
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A2 /* A2*/ {
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A3 /* A3*/ {
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A4 /* A4*/ {
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A5 /* A5*/ {
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER})
@java.lang.annotation.Target(value = {java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE})
@kotlin.annotation.Target(allowedTargets = {kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.TYPE})
public abstract @interface A6 /* A6*/ {
}
+1 -1
View File
@@ -6,7 +6,7 @@ where possible options include:
-include-runtime Include Kotlin runtime into the resulting JAR
-java-parameters Generate metadata for Java 1.8 reflection on method parameters
-jdk-home <path> Include a custom JDK from the specified location into the classpath instead of the default JAVA_HOME
-jvm-target <version> Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.6
-jvm-target <version> Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.8
-module-name <name> Name of the generated .kotlin_module file
-no-jdk Don't automatically include the Java runtime into the classpath
-no-reflect Don't automatically include Kotlin reflection into the classpath
@@ -1,5 +1,6 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// JVM_TARGET: 1.6
@Target(AnnotationTarget.TYPE)
annotation class A
@@ -0,0 +1,71 @@
// !LANGUAGE: +FunctionTypesWithBigArity
// WITH_RUNTIME
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.6
// FILE: J.java
// import kotlin.jvm.functions.Arity;
import kotlin.jvm.functions.FunctionN;
import kotlin.Unit;
import java.util.Arrays;
public class J {
// TODO: uncomment arity as soon as Arity is introduced
public static void test(/* @Arity(30) */ FunctionN<Unit> f) {
Object o = new Object();
for (int i = 0; i < 42; i++) {
if (i == 30) continue;
Object[] args = new Object[i];
Arrays.fill(args, o);
try {
f.invoke(args);
} catch (IllegalArgumentException e) {
// OK
if (!e.getMessage().contains("30")) {
throw new AssertionError("Exception must specify the expected number of arguments: " + e.getMessage(), e);
}
continue;
} catch (Throwable e) {
throw new AssertionError(
"Incorrect exception (IllegalArgumentException expected): " + e.getClass().getName() + ", i = " + i, e
);
}
throw new AssertionError("IllegalArgumentException expected, but nothing was thrown, i = " + i);
}
}
}
// FILE: K.kt
fun foo(
p00: Any?, p01: Any?, p02: Any?, p03: Any?, p04: Any?, p05: Any?, p06: Any?, p07: Any?, p08: Any?, p09: Any?,
p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?,
p20: Any?, p21: Any?, p22: Any?, p23: Any?, p24: Any?, p25: Any?, p26: Any?, p27: Any?, p28: Any?, p29: Any?
) {}
class Fun : (Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?,
Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?) -> Unit {
override fun invoke(
p00: Any?, p01: Any?, p02: Any?, p03: Any?, p04: Any?, p05: Any?, p06: Any?, p07: Any?, p08: Any?, p09: Any?,
p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?,
p20: Any?, p21: Any?, p22: Any?, p23: Any?, p24: Any?, p25: Any?, p26: Any?, p27: Any?, p28: Any?, p29: Any?
) {}
}
fun box(): String {
val lambda: Function30<
Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?,
Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?,
Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?,
Unit> = { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> }
@Suppress("DEPRECATION_ERROR")
J.test(lambda as kotlin.jvm.functions.FunctionN<Unit>)
@Suppress("DEPRECATION_ERROR")
J.test(::foo as kotlin.jvm.functions.FunctionN<Unit>)
@Suppress("DEPRECATION_ERROR")
J.test(Fun() as kotlin.jvm.functions.FunctionN<Unit>)
return "OK"
}
@@ -1,6 +1,7 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
// JVM_TARGET: 1.6
import kotlin.reflect.KClass
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface I
class C : I { fun foo() = super<I>.hashCode() }
@@ -0,0 +1,11 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// JVM_TARGET: 1.6
interface I
class C : I { fun foo() = super<I>.hashCode() }
fun box(): String {
C().foo()
return "OK"
}
@@ -0,0 +1,11 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
fun foo() {
val x: Int? = 6
val hc = x!!.hashCode()
}
// 1 java/lang/Integer.hashCode \(I\)I
// 0 java/lang/Integer.valueOf
// 0 intValue
@@ -4,4 +4,4 @@ fun box(): String {
return "OK"
}
// 1 INVOKESTATIC java/lang/Integer.valueOf
// 0 INVOKESTATIC java/lang/Integer.valueOf
@@ -15,9 +15,6 @@ fun foo() {
val b = arrayOfNulls<Int>(4)
b[100] = 5
val x: Int? = 6
val hc = x!!.hashCode()
val y: Int? = 7
val z: Int? = 8
val res = y === z
@@ -26,5 +23,5 @@ fun foo() {
val c2: Any = if (1 != one) 0 else "abc"
}
// 9 java/lang/Integer.valueOf
// 8 java/lang/Integer.valueOf
// 0 intValue
@@ -1,3 +1,5 @@
// JVM_TARGET: 1.6
fun box(): String {
true.hashCode()
1.toByte().hashCode()
@@ -9,7 +9,7 @@ inline class UInt(val value: Int)
fun test(u1: UInt, u2: UInt) {
val a = u1.value
val b = u1.value.hashCode() // box int to call hashCode
val b = u1.value.hashCode()
val c = u1.value + u2.value
}
@@ -18,5 +18,5 @@ fun test(u1: UInt, u2: UInt) {
// 0 INVOKESTATIC UInt\$Erased.box
// 0 INVOKEVIRTUAL UInt.unbox
// 1 valueOf
// 0 intValue
// 0 valueOf
// 0 intValue
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// JVM_TARGET: 1.6
val ua = 1234U
val ub = 5678U
@@ -1,55 +1,55 @@
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:6:5: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:6:5: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineFun {}
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:7:5: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:7:5: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineGetter
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:8:5: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:8:5: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineGetter = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:11:5: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:11:5: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineSetter = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:13:5: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:13:5: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
allInline
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:14:5: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:14:5: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
allInline = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:17:10: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:17:10: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
base.inlineFunBase {}
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:18:10: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:18:10: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
base.inlineGetterBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:19:10: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:19:10: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
base.inlineGetterBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:22:10: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:22:10: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
base.inlineSetterBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:24:10: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:24:10: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
base.allInlineBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:25:10: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:25:10: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
base.allInlineBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:32:9: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:32:9: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineFunBase {}
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:33:9: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:33:9: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineGetterBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:34:9: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:34:9: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineGetterBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:37:9: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:37:9: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineSetterBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:39:9: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:39:9: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
allInlineBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:40:9: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/source.kt:40:9: error: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
allInlineBase = 1
^
COMPILATION_ERROR
@@ -1,20 +1,20 @@
warning: language version 1.3 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:8:9: warning: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:8:9: warning: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineFunBase {}
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:9:9: warning: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:9:9: warning: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineGetterBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:10:9: warning: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:10:9: warning: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineGetterBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:13:9: warning: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:13:9: warning: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
inlineSetterBase = 1
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:15:9: warning: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:15:9: warning: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
allInlineBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:16:9: warning: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
compiler/testData/compileKotlinAgainstCustomBinaries/wrongInlineTarget/warningsOnly_1_3.kt:16:9: warning: cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
allInlineBase = 1
^
OK
@@ -1,11 +0,0 @@
// !WITH_NEW_INFERENCE
// FULL_JDK
import java.util.stream.Collectors
import java.util.stream.IntStream
fun main() {
val xs = IntStream.range(0, 10).mapToObj { it.toString() }
.collect(Collectors.toList())
xs[0]
}
+2 -2
View File
@@ -1,11 +1,11 @@
// !WITH_NEW_INFERENCE
// FIR_IDENTICAL
// FULL_JDK
import java.util.stream.Collectors
import java.util.stream.IntStream
fun main() {
val xs = IntStream.<!INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>range<!>(0, 10).mapToObj { it.toString() }
val xs = IntStream.range(0, 10).mapToObj { it.toString() }
.collect(Collectors.toList())
xs[0]
}
@@ -1,3 +1,4 @@
// !JVM_TARGET: 1.6
// FILE: JavaInterface.java
public interface JavaInterface {
@@ -1,3 +1,4 @@
// !JVM_TARGET: 1.6
// FILE: JavaInterface.java
public interface JavaInterface {
@@ -1,3 +1,4 @@
// !JVM_TARGET: 1.6
// FILE: JavaInterfaceBase.java
public interface JavaInterfaceBase {
@@ -1,3 +1,4 @@
// !JVM_TARGET: 1.6
// FILE: JavaInterfaceBase.java
public interface JavaInterfaceBase {
@@ -1,4 +1,5 @@
//!LANGUAGE: -DefaultMethodsCallFromJava6TargetError
// !LANGUAGE: -DefaultMethodsCallFromJava6TargetError
// !JVM_TARGET: 1.6
// FILE: JavaInterface.java
public interface JavaInterface {
@@ -1,4 +1,5 @@
//!LANGUAGE: -DefaultMethodsCallFromJava6TargetError
// !LANGUAGE: -DefaultMethodsCallFromJava6TargetError
// !JVM_TARGET: 1.6
// FILE: JavaInterface.java
public interface JavaInterface {
@@ -1,32 +0,0 @@
// FILE: I.java
public interface I {
int a = 1;
static void foo() {}
}
// FILE: C.java
public class C implements I {
static int b = 1;
static void bar() {}
}
// FILE: test.kt
class K : C()
fun main() {
I.a
I.foo()
C.a
C.b
C.<!UNRESOLVED_REFERENCE!>foo<!>()
C.bar()
K.<!UNRESOLVED_REFERENCE!>a<!>
K.<!UNRESOLVED_REFERENCE!>b<!>
K.<!UNRESOLVED_REFERENCE!>foo<!>()
K.<!UNRESOLVED_REFERENCE!>bar<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: I.java
public interface I {
@@ -18,7 +19,7 @@ class K : C()
fun main() {
I.a
I.<!INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>foo<!>()
I.foo()
C.a
C.b
@@ -1,3 +1,4 @@
// !JVM_TARGET: 1.6
// FILE: Test.java
public interface Test {
default String test() {
@@ -1,3 +1,4 @@
// !JVM_TARGET: 1.6
// FILE: Test.java
public interface Test {
default String test() {
@@ -1,32 +0,0 @@
// FULL_JDK
// FILE: test.kt
@file:Suppress("UNUSED_PARAMETER")
import java.util.Comparator
abstract class DataView {
abstract val presentationName: String
}
fun <A> comboBox(
model: SortedComboBoxModel<A>,
graphProperty: GraphProperty<A>,
) {}
class GraphProperty<B>
fun test() {
val presentationName: (DataView) -> String = { it.presentationName }
val parentComboBoxModel/*: SortedComboBoxModel<DataView>*/ = SortedComboBoxModel(Comparator.comparing(presentationName))
comboBox(parentComboBoxModel, GraphProperty<DataView>())
}
// FILE: SortedComboBoxModel.java
import java.util.Comparator;
public class SortedComboBoxModel<C> {
public SortedComboBoxModel(Comparator<? super C> comparator) {
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FULL_JDK
// FILE: test.kt
@@ -18,7 +19,7 @@ class GraphProperty<B>
fun test() {
val presentationName: (DataView) -> String = { it.presentationName }
val parentComboBoxModel/*: SortedComboBoxModel<DataView>*/ = SortedComboBoxModel(Comparator.<!INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>comparing<!>(presentationName))
val parentComboBoxModel/*: SortedComboBoxModel<DataView>*/ = SortedComboBoxModel(Comparator.comparing(presentationName))
comboBox(parentComboBoxModel, GraphProperty<DataView>())
}
@@ -29,4 +30,4 @@ import java.util.Comparator;
public class SortedComboBoxModel<C> {
public SortedComboBoxModel(Comparator<? super C> comparator) {
}
}
}
@@ -1,13 +0,0 @@
// !WITH_NEW_INFERENCE
// FULL_JDK
import java.util.stream.*
interface A : Collection<String> {
override fun stream(): Stream<String> = Stream.of()
}
fun foo(x: List<String>, y: A) {
x.stream().filter { it.length > 0 }.collect(Collectors.toList())
y.stream().filter { it.length > 0 }
}
@@ -1,10 +1,10 @@
// !WITH_NEW_INFERENCE
// FIR_IDENTICAL
// FULL_JDK
import java.util.stream.*
interface A : Collection<String> {
override fun stream(): Stream<String> = Stream.<!INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>of<!>()
override fun stream(): Stream<String> = Stream.of()
}
fun foo(x: List<String>, y: A) {
@@ -28,7 +28,7 @@ class A {
interface B {
companion object {
<!JVM_STATIC_IN_INTERFACE_1_6!>@JvmStatic fun a1()<!> {
@JvmStatic fun a1() {
}
}
@@ -1,5 +1,7 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// !LANGUAGE: +JvmStaticInInterface
// !JVM_TARGET: 1.6
interface B {
companion object {
@JvmStatic fun a1() {
@@ -1,5 +1,7 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// !LANGUAGE: +JvmStaticInInterface
// !JVM_TARGET: 1.6
interface B {
companion object {
<!JVM_STATIC_IN_INTERFACE_1_6!>@JvmStatic fun a1()<!> {
@@ -2,7 +2,7 @@
abstract class A : MutableList<String> {
override fun sort(/*0*/ p0: java.util.Comparator<in String>) {
super.<!DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>sort<!>(p0)
super.sort(p0)
}
}
@@ -14315,6 +14315,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt");
}
@Test
@TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt")
public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt");
}
@Test
@TestMetadata("function255.kt")
public void testFunction255() throws Exception {
@@ -36048,6 +36054,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt");
}
@Test
@TestMetadata("interfaceHashCode_1_6.kt")
public void testInterfaceHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt");
}
@Test
@TestMetadata("kt14243.kt")
public void testKt14243() throws Exception {
@@ -640,6 +640,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/boxingOptimization/fold.kt");
}
@Test
@TestMetadata("hashCodeOnNonNull.kt")
public void testHashCodeOnNonNull() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/boxingOptimization/hashCodeOnNonNull.kt");
}
@Test
@TestMetadata("inlineClassesAndInlinedLambda.kt")
public void testInlineClassesAndInlinedLambda() throws Exception {
@@ -2987,9 +2993,9 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
@Test
@TestMetadata("hashCode.kt")
public void testHashCode() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/hashCode/hashCode.kt");
@TestMetadata("hashCode_1_6.kt")
public void testHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/hashCode/hashCode_1_6.kt");
}
@Test
@@ -14315,6 +14315,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt");
}
@Test
@TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt")
public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt");
}
@Test
@TestMetadata("function255.kt")
public void testFunction255() throws Exception {
@@ -35848,6 +35854,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt");
}
@Test
@TestMetadata("interfaceHashCode_1_6.kt")
public void testInterfaceHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt");
}
@Test
@TestMetadata("kt14243.kt")
public void testKt14243() throws Exception {
@@ -640,6 +640,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/boxingOptimization/fold.kt");
}
@Test
@TestMetadata("hashCodeOnNonNull.kt")
public void testHashCodeOnNonNull() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/boxingOptimization/hashCodeOnNonNull.kt");
}
@Test
@TestMetadata("inlineClassesAndInlinedLambda.kt")
public void testInlineClassesAndInlinedLambda() throws Exception {
@@ -3119,9 +3125,9 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
}
@Test
@TestMetadata("hashCode.kt")
public void testHashCode() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/hashCode/hashCode.kt");
@TestMetadata("hashCode_1_6.kt")
public void testHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/hashCode/hashCode_1_6.kt");
}
@Test
@@ -12582,6 +12582,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt");
}
@TestMetadata("callWithIncorrectNumberOfArguments_1_6.kt")
public void testCallWithIncorrectNumberOfArguments_1_6() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments_1_6.kt");
}
@TestMetadata("function255.kt")
public void testFunction255() throws Exception {
runTest("compiler/testData/codegen/box/functions/bigArity/function255.kt");
@@ -29503,6 +29508,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/super/interfaceHashCode.kt");
}
@TestMetadata("interfaceHashCode_1_6.kt")
public void testInterfaceHashCode_1_6() throws Exception {
runTest("compiler/testData/codegen/box/super/interfaceHashCode_1_6.kt");
}
@TestMetadata("kt14243.kt")
public void testKt14243() throws Exception {
runTest("compiler/testData/codegen/box/super/kt14243.kt");
@@ -526,9 +526,9 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
}
fun testWrongInlineTarget() {
val library = compileLibrary("library", additionalOptions = listOf("-jvm-target", "1.8"))
val library = compileLibrary("library", additionalOptions = listOf("-jvm-target", "11"))
compileKotlin("source.kt", tmpdir, listOf(library))
compileKotlin("source.kt", tmpdir, listOf(library), additionalOptions = listOf("-jvm-target", "1.8"))
compileKotlin(
"warningsOnly_1_3.kt", tmpdir, listOf(library),
@@ -104,7 +104,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
Assert.assertFalse(compilerArguments!!.autoAdvanceLanguageVersion)
Assert.assertFalse(compilerArguments!!.autoAdvanceApiVersion)
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
Assert.assertEquals(
"-Xallow-no-source-files -Xdump-declarations-to=tmpTest",
compilerSettings!!.additionalArguments
@@ -158,7 +158,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
Assert.assertEquals("1.3", languageLevel!!.versionString)
Assert.assertEquals("1.0", apiLevel!!.versionString)
Assert.assertEquals(JvmPlatforms.jvm16, targetPlatform)
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
Assert.assertEquals(
"-Xallow-no-source-files -Xdump-declarations-to=tmpTest",
compilerSettings!!.additionalArguments
@@ -38,7 +38,7 @@ object JvmIdePlatformKind : IdePlatformKind<JvmIdePlatformKind>() {
message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform",
level = DeprecationLevel.ERROR
)
override fun getDefaultPlatform(): Platform = Platform(JvmTarget.JVM_1_6)
override fun getDefaultPlatform(): Platform = Platform(JvmTarget.DEFAULT)
override fun createArguments(): CommonCompilerArguments {
return K2JVMCompilerArguments()
+1 -1
View File
@@ -31,7 +31,7 @@ class A {
<error descr="[WRONG_ANNOTATION_TARGET] This annotation is not applicable to target 'interface'">@JvmStatic</error>
interface B {
companion object {
<error descr="[JVM_STATIC_IN_INTERFACE_1_6] '@JvmStatic' annotation in interface supported only with JVM target 1.8 and above. Recompile with '-jvm-target 1.8'\"">@JvmStatic fun a1()</error> {
@JvmStatic fun a1() {
}
}
@@ -1,4 +1,3 @@
// ERROR: Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'
import java.util.stream.Stream
abstract class A : List<String> {
@@ -23,9 +23,9 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption
var jdkHome: kotlin.String?
/**
* Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.6
* Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.8
* Possible values: "1.6", "1.8", "9", "10", "11", "12", "13", "14", "15"
* Default value: "1.6"
* Default value: "1.8"
*/
var jvmTarget: kotlin.String
@@ -62,7 +62,7 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
private var jvmTargetField: kotlin.String? = null
override var jvmTarget: kotlin.String
get() = jvmTargetField ?: "1.6"
get() = jvmTargetField ?: "1.8"
set(value) {
jvmTargetField = value
}
@@ -137,7 +137,7 @@ internal fun org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments.fi
includeRuntime = false
javaParameters = false
jdkHome = null
jvmTarget = "1.6"
jvmTarget = "1.8"
moduleName = null
noJdk = false
noReflect = true