Files
kotlin/compiler/testData/codegen/box/reflection/annotations/classLiteralWithVoidDefault.kt
Alexander Udalov 38fd2b9ed6 Fix reflection-related codegen tests on JDK 9+
In JDK 9, Class.simpleName changed behavior for local/anonymous Kotlin
classes (see KT-23072), this is why we now check for both variants of
the name in tests. Also, the format of annotation arguments changed a
little, where float parameters no longer have the trailing "f", and
class literals are rendered with ".class" at the end
2019-01-25 10:14:25 +01:00

30 lines
644 B
Kotlin
Vendored

// WITH_REFLECT
// TARGET_BACKEND: JVM
// FILE: Anno.java
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Anno {
Class<?> value() default void.class;
}
// FILE: test.kt
import kotlin.test.assertTrue
class C {
@Anno
fun f1() {}
@Anno(Void::class)
fun f2() {}
}
fun box(): String {
assertTrue("\\[@Anno\\(value=void(\\.class)?\\)\\]".toRegex().matches(C::f1.annotations.toString()))
assertTrue("\\[@Anno\\(value=(class )?java.lang.Void(\\.class)?\\)\\]".toRegex().matches(C::f2.annotations.toString()))
return "OK"
}