Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2021 12:52
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save keynmol/c3ceb91c08c50f0b6c56068514c2021a to your computer and use it in GitHub Desktop.
A script to dump bytecode in plaintext

This is a simple script to help me see the bytecode when plaing with Scala 3.

All it does is parallelises the calls to javap command that should available if you have JDK installed.


Just Ammonite -

It's excellent.


For example, running it in watch mode, pointing it at the target folder with classes:

amm -w --classesFolder $(pwd)/scala3/target/scala-3.0.0-M3/classes --bytecodeFolder $(pwd)/bytecode-scala

WARNING: the script will delete all *.bytecode files (and only them) from the target folder

import $ivy.`org.scala-lang.modules::scala-parallel-collections:1.0.0`
import scala.collection.parallel.CollectionConverters._
import ammonite.ops._
import os.ProcessOutput
def process(classFile: os.Path, bytecodeFile: os.Path): Unit = {
println(s"Processing ${classFile}")
val args =
stdout = ProcessOutput.makePathRedirect(bytecodeFile),
stderr = os.Inherit
def main(classesFolder: os.Path, bytecodeFolder: os.Path) = {
os.walk(bytecodeFolder).filter(_.ext == "bytecode").foreach { p =>
val allClassfiles = os.walk(classesFolder).filter(_.ext == "class") + ".bytecode")).par.foreach {
case (absPath, filename) =>
val target = bytecodeFolder / filename
process(absPath, target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment