Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning about Java bytecode and the JVM

In a recent question asked recently my simple minded answer highlighted many of my misconceptions about Java, the JVM, and how the code gets compiled and run. This has created a desire in me to take my understanding to a lower level. I have no problems with the low level understanding like assembly how ever bytecode and the JVM confound me. How object oriented code gets broken down on a low level is lost to me. I was wondering if anyone had any suggestion on how to learn about the JVM, bytecode and the lower level functioning of Java. Are there any utilities out there that allow you to write and run bytecode directly as I believe hands on experience with something is the best way to grow in understanding of it? Additionally and reading suggestions on this topic would be appreciated.

Edit: Secondary question. So I have a kinda sub question, the answers gave me an interesting idea to learn about the jvm, what would the plausibility of writing a really simple language like brainf**k or Ook only in a readable syntax (maybe I could even develop it to support oo eventually) that compiles into bytecode be? Would that be a good learning experience?

like image 644
faceless1_14 Avatar asked Jul 30 '09 14:07

faceless1_14


People also ask

What is JVM and bytecode in Java?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation.

What is the relation between JVM and bytecode?

Bytecode is the compiled format for Java programs. Once a Java program has been converted to bytecode, it can be transferred across a network and executed by Java Virtual Machine (JVM). Bytecode files generally have a . class extension.


1 Answers

Suggested reading: the JVM spec.

You might also want to play with BCEL - there are other libraries around for manipulating bytecode, but that's probably the best known one.

like image 193
Jon Skeet Avatar answered Sep 17 '22 00:09

Jon Skeet