fun main() {
fun convert(x: Double, converter: (Double) -> Double) : Double{
val result = converter(x)
println("$x is converted to $result")
return result
}
fun convertFive(converter: (Int) -> Double) : Double {
val result = converter(5)
println("5 is converted to $result")
return result
}
convert(20.0) { it * 1.8 + 32}
convertFive { it * 1.8 + 32 }
}
// i got this error when i updated my intelliJ Idea and ran this //
Kotlin: [Internal Error] java.lang.ExceptionInInitializerError
We can resolve the java. lang. ExceptionInInitializerError by ensuring that static initializer block of classes does not throw any Runtime Exception. We can resolve also resolve this exception by ensuring that the initializing static variable of classes also doesn't throw any Runtime Exception.
The ExceptionInInitializerError indicates that an unexpected exception has occurred in a static initializer. Basically, when we see this exception, we should know that Java failed to evaluate a static initializer block or to instantiate a static variable.
Class ExceptionInInitializerError. Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.
The problem is that the current version of the Kotlin compiler (1.4.31, 1.5-M1) doesn't work on JDK 16. Please use JDK < 16 for now. Related issue: https://youtrack.jetbrains.com/issue/KT-45566. Try File > Invalidate Caches/Restart... Thanks for contributing an answer to Stack Overflow!
- GeeksforGeeks How to Resolve Java.lang.ExceptionInInitializerError In Java? An unexpected, unwanted event that disturbed the normal flow of a program is called an Exception. 1. Checked Exception
To update the Kotlin plugin go to Settings -> Languages & Frameworks -> Kotlin. Click the check again button to know if you have any new update. If so, then update it and restart, then see if Kotlin REPL is working or not. Show activity on this post. I fixed it by using JDK 15 instead of 16. File -> New -> Project...
I installed IntelliJ IDEA Community Edition 2021.1.3 today and am using JDK-16.0.1 on my linux PC. This also happened in my case. I went through all the settings at first then I found that I had a Kotlin update. After my update the Kotlin REPL started without any error. To update the Kotlin plugin go to Settings -> Languages & Frameworks -> Kotlin.
The problem is that the current version of the Kotlin compiler (1.4.31, 1.5-M1) doesn't work on JDK 16. Please use JDK < 16 for now. Related issue: https://youtrack.jetbrains.com/issue/KT-45566.
Try File > Invalidate Caches/Restart...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With