Exceptions.kt:fonction en ligne d'appel Kotlin de Java
@Suppress("NOTHING_TO_INLINE")
inline fun generateStyleNotCorrectException(key: String, value: String) =
AOPException(key + " = " + value)
En Kotlin:
fun inKotlin(key: String, value: String) {
throw generateStyleNotCorrectException(key, value) }
Il travaille dans Kotlin et la fonction est inline.
Mais quand il est utilisé dans le code Java, il peut tout simplement pas être inline, et encore un appel de méthode statique normale (vu du contenu décompilés).
Quelque chose comme ceci:
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.
}
Pourquoi attendre en premier lieu que le compilateur Java puisse magiquement intégrer des fonctions? Java connaît les méthodes Java. Comment devrait-il connaître les concepts dans d'autres langues? – GhostCat