Do not include kotlin-reflect at runtime by default in codegen tests
Change some tests to either include reflection or to avoid using it
This commit is contained in:
committed by
Alexander Udalov
parent
20e36438e2
commit
2564a2f91f
@@ -1,3 +1,5 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate {
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ class K
|
||||
|
||||
fun box(): String {
|
||||
val args = MyClass::class.java.getAnnotation(JavaAnn::class.java).args
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
val argName1 = args[0].java.simpleName ?: "fail 1"
|
||||
val argName2 = args[1].java.simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
|
||||
compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt
Vendored
+2
-2
@@ -20,7 +20,7 @@ class MyJavaClass {}
|
||||
|
||||
fun box(): String {
|
||||
val args = MyJavaClass::class.java.getAnnotation(JavaAnn::class.java).args
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
val argName1 = args[0].java.simpleName ?: "fail 1"
|
||||
val argName2 = args[1].java.simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,5 +17,5 @@ class OK
|
||||
fun box(): String {
|
||||
val ann = MyClass::class.java.getAnnotation(JavaAnn::class.java)
|
||||
if (ann == null) return "fail: cannot find JavaAnn on MyClass"
|
||||
return ann.value.simpleName!!
|
||||
return ann.value.java.simpleName!!
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -20,5 +20,5 @@ class MyJavaClass {}
|
||||
fun box(): String {
|
||||
val ann = MyJavaClass::class.java.getAnnotation(JavaAnn::class.java)
|
||||
if (ann == null) return "fail: cannot find JavaAnn on MyClass"
|
||||
return ann.value.simpleName!!
|
||||
return ann.value.java.simpleName!!
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ class K
|
||||
|
||||
fun box(): String {
|
||||
val args = MyClass::class.java.getAnnotation(JavaAnn::class.java).value
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
val argName1 = args[0].java.simpleName ?: "fail 1"
|
||||
val argName2 = args[1].java.simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ class K
|
||||
|
||||
fun box(): String {
|
||||
val args = MyJavaClass::class.java.getAnnotation(JavaAnn::class.java).value
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
val argName1 = args[0].java.simpleName ?: "fail 1"
|
||||
val argName2 = args[1].java.simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
@@ -11,7 +13,6 @@ public class J {
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
// FULL_JDK
|
||||
|
||||
import java.lang.reflect.*
|
||||
import kotlin.reflect.*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: test/J.java
|
||||
|
||||
package test;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package test
|
||||
|
||||
inline fun <reified T> className() = T::class.simpleName
|
||||
inline fun <reified T : Any> className() = T::class.java.simpleName
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
Vendored
+6
-2
@@ -1,3 +1,5 @@
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
|
||||
class A {
|
||||
class B(val result: String)
|
||||
|
||||
@@ -8,9 +10,11 @@ class A {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
|
||||
(A::q).set(a, arrayOf(arrayOf(A.B("array"))))
|
||||
val aq = A::class.members.single { it.name == "q" } as KMutableProperty1<A, Array<Array<A.B>>>
|
||||
aq.set(a, arrayOf(arrayOf(A.B("array"))))
|
||||
if (a.q!![0][0].result != "array") return "Fail array"
|
||||
|
||||
(A::p).set(a, A.B("OK"))
|
||||
val ap = A::class.members.single { it.name == "p" } as KMutableProperty1<A, A.B>
|
||||
ap.set(a, A.B("OK"))
|
||||
return a.p!!.result
|
||||
}
|
||||
|
||||
@@ -1460,6 +1460,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionName.kt")
|
||||
public void testLocalFunctionName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/local/localFunctionName.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localLocal.kt")
|
||||
public void testLocalLocal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/local/localLocal.kt");
|
||||
|
||||
-6
@@ -2493,12 +2493,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionName.kt")
|
||||
public void testLocalFunctionName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/functions/localFunctionName.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("platformName.kt")
|
||||
public void testPlatformName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/functions/platformName.kt");
|
||||
|
||||
@@ -187,9 +187,9 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
protected GeneratedClassLoader createClassLoader() {
|
||||
return new GeneratedClassLoader(
|
||||
generateClassesInFile(),
|
||||
configurationKind == ConfigurationKind.NO_KOTLIN_REFLECT ?
|
||||
ForTestCompileRuntime.runtimeJarClassLoader() :
|
||||
ForTestCompileRuntime.runtimeAndReflectJarClassLoader(),
|
||||
configurationKind.getWithReflection()
|
||||
? ForTestCompileRuntime.runtimeAndReflectJarClassLoader()
|
||||
: ForTestCompileRuntime.runtimeJarClassLoader(),
|
||||
getClassPathURLs()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ class ReflectionClassLoaderTest : CodegenTestCase() {
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL)
|
||||
configurationKind = ConfigurationKind.ALL
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(configurationKind)
|
||||
}
|
||||
|
||||
private fun Class<*>.methodByName(name: String) = declaredMethods.single { it.name == name }
|
||||
|
||||
Reference in New Issue
Block a user