This page is no longer maintained — Please continue to the home page at www.scala-lang.org

understanding generated bytecode

2 replies
Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.

Hi,

I've been exploring what the nsc generated bytecode looks like, using the
following decompiler

McGill's "Dava" Java Decompiler http://www.sable.mcgill.ca/dava/

One of the explicit goals of Dava is to generate compilable Java from
non-Java bytecode (that's the idea).
Some things work and others don't. Has anybody tried other ways to get a
high-level view of nsc-generated bytecode?
Soot itself provides bytecode-level languages (Grimp in particular),
comments on that are also welcome.

Somewhat related to the above, there's an enhancement ticket:
FindBugs should be run during nightly tests,
http://lampsvn.epfl.ch/trac/scala/ticket/571
Experience reports on that would also be welcome :-)

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

Johannes Rudolph
Joined: 2008-12-17,
User offline. Last seen 29 weeks 21 hours ago.
Re: understanding generated bytecode

On Mon, Nov 9, 2009 at 11:21 AM, Miguel Garcia wrote:
> I've been exploring what the nsc generated bytecode looks like, using the
> following decompiler
>
>  McGill's "Dava" Java Decompiler http://www.sable.mcgill.ca/dava/
>
> One of the explicit goals of Dava is to generate compilable Java from
> non-Java bytecode (that's the idea).
> Some things work and others don't. Has anybody tried other ways to get a
> high-level view of nsc-generated bytecode?

You can use scalac -Xprint: to get an idea of what scalac is
doing. Especially using -Xprint:jvm should give something very close
to bytecodes. Low-level inspection tools are javap and scalap (though,
I don't know what the latter one does exactly. IMO it just prints the
serialized scala signatures).

What do you expect from a high-level view of bytecodes?

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: understanding generated bytecode

Johannes,

Yes, javap and scalap show what's inside the generated .class files but
still I would prefer an IDE-level bytecode browser (with navigation, too?).
So I might settle on the Eclipse plugin for Soot, which can for example
display bytecode using the Grimp notation (well, the following screenshot
shows Jimple, but conveys the idea):
http://www.sable.mcgill.ca/soot/eclipse/ca.mcgill.sable.soot/doc/concept...
unless someone suggests sthg better.

After getting an overview of some (not all :-) of the name mangling and
codegen patterns, I *would like* later to try some bytecode-level automatic
verfication techniques, e.g.
http://www-sop.inria.fr/everest/BML/Introduction.html#Introduction
or the aforementioned Findbugs.

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland