1

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.

2

2 Answers 2

3

I suggest you look at using a higher level library like ByteBuddy however, what I do is generate Java code have it compiled at runtime e.g. Java Runtime Compiler

Reading a debugging Java code is often easier than doing the same for byte code.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

I already learned some bytecode basics, and very low-level bytecode manipulation in ASM it is not that thing, that i scary about. But i never hear before about this event-based model, and i don't know how to correctly work with it except tutorial examples.
@saroff Well, the only thing I can suggest is: pick the tutorial example that looks closest to what you're trying to do, start modifying it, and post a more specific question to SO when you get stuck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.