18

I want a JVM assembler that is straightforward and simple. It should take a text file written in the mnemonic language described in The Java Virtual Machine Specification and produce class files, i.e. bytecode.

To be clear: I don't want a library that can generate class files from invocations of an API.

What are the current statuses of the JVM assemblers? Do they support invokedynamic (not mandatory to me, but an advantage)? On what operative system can I use them? What are their individual pros and cons?

daveloyall
  • 2,140
  • 21
  • 23
Staffan Nöteberg
  • 4,095
  • 1
  • 19
  • 17
  • 1
    Note that the JVM spec does **not** provide a full language for building complete `class` files. It does contain the bytecode, but not the necessary "plumbing" (e.g. how are methods declared, how are class hierarchies written in "assembly", ...). So any JVM assembler would need to "invent" that. – Joachim Sauer May 30 '11 at 13:19
  • @Joachim That's a good point. Any creative plumbing is OK for me. – Staffan Nöteberg May 30 '11 at 13:20

2 Answers2

12

Some time has passed, and now there is an alternative to Jasmin called Krakatau.

From the README.txt:

The Krakatau assembler is intended as a replacement for Jasmin, and was originally written due to the limitations of Jasmin. It is mostly backwards compatible with Jasmin's syntax, though not necessarily with the extensions introduced in JasminXT. However, Krakatau offers many new features, most importantly the ability to directly specify constant pool references.

At this time, it seems that Krakatau was last updated a month ago, and Jasmin was last updated nine years ago.

Krakatau does support invokedynamic and utilizes the same instruction names as are used in the JVMS.

Krakatau is implemented in Python. Personally, I like my Java tools to be implemented in Java, but given the nature of this tool (constructing class files from non-Java source) and the lack of competition in this niche, I'll give it a chance.

daveloyall
  • 2,140
  • 21
  • 23
  • 1
    FYI, there's also [this project](https://github.com/alexkasko/krakatau-java) which uses Jython to present Krakatau in a form factor more palatable to Java developers. – daveloyall Apr 01 '14 at 21:36
8

Jasmin is the de facto standard. Recent versions support invokedynamic. It's written in Java, so it's portable.

gustafc
  • 28,465
  • 7
  • 73
  • 99