File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes JVM opcodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JVM opcodes " Watch "JVM opcodes " New topic

JVM opcodes

Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 159

I'm a Java developer since 2002 and recently I noticed that my knowledge about the JVM was bad. So I started to read some things in the JVM specification. Ofcourse subjects like opcodes/bytecode are discussed. I liked those opcode instruction code, but how useful is it to have (some) knowledge about that?
Are there any advantages of knowing opcodes and be able to read it? Can it improve my java skills in general? Just curious

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

No, the JVM specification is nice to know if you need to or want to implement a JVM. A general peek at some parts might be useful to understand if something is defined as a specification or is just an implementation detail. But generally no - knowing or reading the JVM spec is not important to your Java skills, and knowing opcodes and what not is not going to help in any way.

Jayesh A Lalwani
Saloon Keeper

Joined: Jan 17, 2008
Posts: 2746

If you are going to use the ASM library, you will need to know opcodes (although there are ways of using ASM without learning all the opcodes.. it has a utility that will generate opcodes from a template for you) Besides that you shouldn;t really need to know opcodes

I have to say that knowing opcodes makes you sound like a badass, though. So, if you have time to learn it, you might want to learn them just for the bragging rights.
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 159

I understand that for example opcode aload_0 has hex representation 2A and means 'this' and that this by itself is not very important to know. But can viewing opcode instructions be useful for things like debugging? It's hard to find some uses of opcodes/bytecode, so probably is not that exciting...
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
I would not have thought reading opcodes is any good for debugging. The people who need to know opcodes are compiler writers, and similar. If you are trying to compile an Eiffel program, for example, so it runs on a JVM, you need to know the opcodes to put into your compiler.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

The JDK includes a tool, javap, with which you can disassemble class files (use the -c option to do that). You'll get to see the implementation of methods in the form of JVM assembly language, with opcodes.

Sometimes it's useful to be able to understand what happens exactly in a class, but I wouldn't say it's really an important thing to know for most Java developers.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: JVM opcodes
It's not a secret anymore!