Java 互操作性:如何在 Kotlin 中声明编译时数组常量?
我有这个Java注释声明,并希望在Kotlin中使用它
class CurlCommand {
Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
var groups: Array<String>? = null
}
编译器报告TYPE_MISMATCH必需:kotlin。Array<kotlin.字符串> 已找到:kotlin。字符串
我试过了
Parameter(names = Array<String>(1, {i-> "-groups"}), description = "Comma-separated list of group names to be run")
var groups: Array<String>? = null
并得到“错误:(20,23)Kotlin:注释参数必须是编译时常量”
如何满足 Kotlin 编译器的要求?
Java简单地接受
@Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
public String groups;