All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.shakelang.util.jvmlib.ClassFileReader.kt Maven / Gradle / Ivy

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)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy