Question

I looking for a way to inspect the generated bytecode which easily integrates into either SBT or the Eclipse Scala IDE.

I guess the default approach would be to:

  • enter console in SBT
  • run :javap -c ClassToAnalyze

However, I'm working on JVM version 1.7 (Scala version 2.10.0) and I simply get:

:javap not yet working with java 1.7

Are there any alternatives to inspect/analyze the generated bytecode?

Was it helpful?

Solution

Both the following work for me with java 1.7

  • :javap in the Scala 2.11 REPL
  • the javap tool of the Java 1.7 JDK

Now, to integrate that with SBT or Eclipse, you could make use of the JDK's javap in the same way as any other executable compatible with the command-line.

EDIT running external commands is not cross-platform of course, but in the case of SBT "scripts" you can refer to:

OTHER TIPS

A couple of years ago I put together a simple sbt plugin that dumps the output of the ASM textifier to disk for a whole project, which you might find more convenient than javap.

https://github.com/hcoles/sbt-bytecode

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top