Search code examples
javacompiler-constructionbytecode

Java bytecode generation


I am writing my own little programming language with compilation into java bytecode as my graduation work, and having troubles with last part - bytecode generation. I already googled for some libraries for it, and even wrote some code using ASM library, but i am very unhappy with this library, because that event/visitor (i don't know how correctly call it) based architecture breaks my brain. So what i need:

  • I need only to generate Java bytecode. Because many comparisons which i looked talked about transforming, i don't need it.
  • I need understand, how bytecode and JVM works.
  • There is no big deal about performance. It should be just acceptable.

And so, what java bytecode generation library more suitable for my case?

P.S. Also, i want to say, that i don't fully reject ASM, maybe it is good, but in this case i need something to understand this architecture, because now i just cant imagine how properly work with it.


Solution

  • I need understand, how bytecode and JVM works.

    Yes. This is likely a major reason why you're having trouble using ASM. Most likely, the library documentation assumes you are already familiar with this. Skimming the Java Virtual Machine Specification will give you a basic idea of how the bytecode stuff works.