Use -source/target 1.6 for Java sources in codegen tests

In cases when the test has the JVM_TARGET directive, use that one for
Java compilation as well.

Otherwise, for box tests, the corresponding test in `JvmTarget6OnJvm6`
(module `:compiler:tests-different-jdk`) will fail. However, it affects
all codegen tests, so fix a bunch of them which use Java 8+ features to
explicitly compile with JVM target 1.8. In particular, this obsoletes
the SKIP_JDK6 directive in those tests because "JVM_TARGET: 1.8" also
skips it for JDK 6.

The check for IS_SOURCE_6_STILL_SUPPORTED is needed in order to still be
able to run tests in the project while only having a single JDK > 11
installed, and having all of the env vars JDK_16, JDK_17, JDK_18
pointing to that JDK.
This commit is contained in:
Alexander Udalov
2020-11-16 18:53:10 +01:00
parent 7b4e0b2f5d
commit 7b5544ebd3
17 changed files with 50 additions and 35 deletions
@@ -1,6 +1,4 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
public interface Base {
@@ -12,6 +10,7 @@ public interface Base {
}
// FILE: main.kt
// JVM_TARGET: 1.8
public interface BaseKotlin : Base {
}
@@ -1,6 +1,4 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
public interface Base {
@@ -12,6 +10,7 @@ public interface Base {
}
// FILE: main.kt
// JVM_TARGET: 1.8
public interface BaseKotlin : Base {
override fun getValue() = "OK"
+1 -2
View File
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
@@ -18,8 +17,8 @@ public interface Base2 extends Base {
}
}
// FILE: main.kt
// JVM_TARGET: 1.8
interface KBase : Base
+1 -1
View File
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
@@ -18,6 +17,7 @@ public interface Base2 extends Base {
// FILE: main.kt
// JVM_TARGET: 1.8
interface KBase : Base {
override fun test() = "O" + getValue()
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
@@ -11,6 +10,8 @@ public interface Base {
}
// FILE: main.kt
// JVM_TARGET: 1.8
class Fail : Base {
override fun getValue() = "Fail"
}
+2 -1
View File
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
@@ -11,6 +10,8 @@ public interface Base extends KBase {
}
// FILE: main.kt
// JVM_TARGET: 1.8
interface KBase {
fun getValue(): String
+2 -1
View File
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
@@ -11,6 +10,8 @@ public interface Base {
}
// FILE: main.kt
// JVM_TARGET: 1.8
class Fail : Base {
override fun getValue() = "Fail"
}
+2 -1
View File
@@ -1,6 +1,5 @@
// !LANGUAGE: -NoDelegationToJavaDefaultInterfaceMembers
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Base.java
@@ -13,6 +12,8 @@ public interface Base {
}
// FILE: main.kt
// JVM_TARGET: 1.8
class OK : Base {
override fun getValue() = "OK"
}
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// SKIP_JDK6
// See KT-8135
// We could generate runtime assertion on call site for 'generic<NOT_NULL_TYPE>()' below.
@@ -24,11 +23,12 @@ fun <T> generic(j: J) = j.nullT<T>()
import org.jetbrains.annotations.NotNull;
public class J {
public <T> @NotNull T nullT() {
@NotNull
public <T> T nullT() {
return null;
}
public void test() {
TestKt.withAssertion(this);
}
}
}
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Simple.java
@@ -9,6 +8,7 @@ public interface Simple {
}
// FILE: main.kt
// JVM_TARGET: 1.8
interface KInterface: Simple {
override fun test(s: String): String {
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: Test.java
@@ -12,6 +11,7 @@ interface Test<T> {
}
// FILE: main.kt
// JVM_TARGET: 1.8
class Child : Test<String> {
override fun call() : String {
@@ -1,4 +1,3 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// FILE: JavaCall.java
@@ -24,6 +23,7 @@ interface Test {
}
// FILE: sam.kt
// JVM_TARGET: 1.8
fun box(): String {
val lambda = { "X" }
+2 -2
View File
@@ -1,5 +1,5 @@
// SKIP_JDK6
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// FILE: Test.kt
open class KFoo {
fun foo(): String {
@@ -17,4 +17,4 @@ public interface JBar {
default String getBar() {
return "OK";
}
}
}
@@ -1,5 +1,4 @@
// TARGET_BACKEND: JVM
// SKIP_JDK6
// FILE: I.java
interface I {
default String ifun() { return "fail"; }
@@ -14,6 +13,7 @@ public class Z {
public class Zz extends Z implements I {}
// FILE: multipleImplFromJava.kt
// JVM_TARGET: 1.8
class Cc : Zz()