commonMain.com.shakelang.util.jvmlib.ClassFileReader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jvmlib-jvm Show documentation
Show all versions of jvmlib-jvm Show documentation
A library for jvm stuff in java
The newest version!
package com.shakelang.util.jvmlib
import com.shakelang.util.io.streaming.input.CountingInputStream
import com.shakelang.util.io.streaming.input.DataInputStream
import com.shakelang.util.io.streaming.input.InputStream
object ClassFileReader {
fun readClass(input: InputStream): com.shakelang.util.jvmlib.infos.ClassInfo {
val counter = CountingInputStream(input)
val stream = DataInputStream(counter)
try {
return com.shakelang.util.jvmlib.infos.ClassInfo.fromStream(stream)
} catch (e: Throwable) {
throw RuntimeException("Error at position 0x${counter.count.toString(16)} while parsing class", e)
}
}
}