What Do we Know about ByteCode

Vikas Taank
3 min readMay 28, 2024
  • Bytecode is an intermediate representation of a program, halfway between human readable source and machine code.
  • Bytecode is produced by javac from Java source code files.
  • Some high-level language features have been compiled away and don’t appear in bytecode. For example, Java’s looping constructs (for, while, and the like) are gone, turned into bytecode branch instructions.
  • Each opcode is represented by a single byte (hence the name bytecode).
  • Bytecode is an abstract representation, not “machine code for an imaginary CPU.”
  • Bytecode can be further compiled to machine code, usually “just in time.”

When talking about bytecode, there can be a slight chicken-and-egg problem. To fully understand what’s going on, we need to understand both bytecode and the runtime environment that it executes in.

Bytecode is something that gets executed by JRE.

Understanding the operation of the stack machine that the JVM uses is critical to understanding bytecode.

One of the most obvious ways that the JVM doesn’t look like a hardware CPU (such as an x64 or ARM chip) is that the JVM doesn’t have processor registers and instead uses a stack for all calculations and operations.

--

--

Vikas Taank

I am new to Medium, trying to articulate my learnings so far . Please Join medium to read my articles. Please support- https://ko-fi.com/vikastaank