[scala] understanding generated bytecode

View: New views
3 Messages — Rating Filter:   Alert me  

[scala] understanding generated bytecode

by Miguel Garcia :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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




Re: [scala] understanding generated bytecode

by Johannes Rudolph-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 9, 2009 at 11:21 AM, Miguel Garcia <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:<phase> 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?

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

[scala] Re: understanding generated bytecode

by Miguel Garcia :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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/concepts/jimple_editor.html
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