0
Exceptions.kt内联函数:呼叫科特林从Java
@Suppress("NOTHING_TO_INLINE")
inline fun generateStyleNotCorrectException(key: String, value: String) =
AOPException(key + " = " + value)
在科特林:
fun inKotlin(key: String, value: String) {
throw generateStyleNotCorrectException(key, value) }
它工作在科特林和内联函数。
但在Java代码中使用时,它只是不能被内联, 和仍然正常的静态方法调用(从反编译的内容所示)。
事情是这样的:
public static final void inJava(String key, String value) throws AOPException {
throw ExceptionsKt.generateStyleNotCorrectException(key, value);
// when decompiled, it has the same contents as before , not the inlined contents.
}
为什么会首先期望Java编译器可以神奇地内联函数? Java知道Java方法。它应该如何知道其他语言的概念? – GhostCat