Kotlin: how to pass array to Java annotation

As an example from Kotlin docs

// Kotlin 1.2+:
@OneOf(names = ["abc", "foo", "bar"]) 
class C

// Older Kotlin versions:
@OneOf(names = arrayOf("abc", "foo", "bar")) 
class D

The value parameter is automatically converted to a vararg parameter in Kotlin, as described in http://kotlinlang.org/docs/reference/annotations.html#java-annotations.

The correct syntax for this particular case is @OneOf("m", "f")


In Kotlin 1.2, it supports array literal in annotation. So the below syntax becomes valid in Kotlin 1.2:

@OneOf(value = ["m", "f"])