Hello,
I just wrote the Kotlin version for this benchmark: https://github.com/kostya/benchmarks/tree/master/base64. When I run the program with Kotlin 0.11.569 I get this error:
Exception in thread “main” java.lang.NoClassDefFoundError: kotlin/jvm/internal/Reflection
at _DefaultPackage.<clinit>(Base64.kt)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Reflection
Don’t understand what I’m doing wrong/what is happening. Any hints? Strange thing is that using println does not compile: Error:(33, 5) Kotlin: Unresolved reference: println. So I changed to System.out.println which works.
Thanks, Oliver
Kotlin code:
import java.lang
fun main(args: Array<String>) {
val enc = sun.misc.BASE64Encoder()
val dec = sun.misc.BASE64Decoder()val STR_SIZE = 10000000
val TRIES = 100
val buffer = StringBuffer()
for (i in 0…STR_SIZE - 1) {
buffer.append(“a”)
}
val str = lang.String(buffer.toString())
var str2 = “”
var t = System.nanoTime()
var s = 0
for (i in 1…TRIES) {
str2 = enc.encode(str.getBytes())
s += str2.length()
}System.out.println(“encode: " + s + ”, " + (System.nanoTime() - t) / 1e9)
s = 0
for (i in 1…TRIES) {
val str3 = dec.decodeBuffer(str2)
s += str3.size()
}System.out.println(“decode: " + s + ”, " + (System.nanoTime() - t) / 1e9)
}