Skip to content

Instantly share code, notes, and snippets.

@lrytz
Created September 3, 2015 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrytz/2a497020e8dfe01448a6 to your computer and use it in GitHub Desktop.
Save lrytz/2a497020e8dfe01448a6 to your computer and use it in GitHub Desktop.
def readClass(bytes: Array[Byte]): ClassNode = {
val node = new ClassNode()
new ClassReader(bytes).accept(node, Array[Attribute](InlineInfoAttributePrototype), 0)
node
}
def readClass(filename: String): ClassNode = {
val f = new java.io.RandomAccessFile(filename, "r")
val b = new Array[Byte](f.length.toInt)
f.read(b)
readClass(b)
}
@lrytz
Copy link
Author

lrytz commented Sep 3, 2015

val cn = readClass("/Users/luc/scala/scala/sandbox/Test$.class")
import scala.collection.convert.decorateAsScala._
val m = cn.methods.iterator.asScala.find(_.name == "delayedEndpoint$Test$1").head

@lrytz
Copy link
Author

lrytz commented Sep 3, 2015

import scala.tools.nsc.backend.jvm._
AsmUtils.textify(...) // overlaods for class,  method, insn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment