Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to view bytecode of Class file? [duplicate]

Possible Duplicate:
Is there a java classfile / bytecode editor to edit instructions?

Java source code is compiled into bytecode, which is actually in the class file. Is it possible to view bytecode of a compiled class?

If it is possible, can it be edited?

Is there an eclipse plugin for that available?

like image 369
Abhishek Jain Avatar asked Jul 23 '10 06:07

Abhishek Jain


People also ask

Do .class files contain bytecode?

A Java class file is a file (with the . class filename extension) containing Java bytecode that can be executed on the Java Virtual Machine (JVM).

Is bytecode and class file same?

class file is the byte-code. It is the result of compiling java source code (text) into the intermediate format, byte-code. The byte-code is then interpreted by the JVM and compiled into a language understandable by your CPU.

Can we read bytecode?

Bytecode is an important machine-level language that is executed on the JVM – Java Virtual Machine. Anytime you load a class, it receives a bytecode stream for each method of the class. Whenever you call this method in program execution, the bytecode of this method is called. Javac does both programs.


1 Answers

Yes. You can use the javap command that's included with the JDK to see the byte code of a class. For example:

javap -c com.mypackage.MyClass

There are several libraries and tools that help you to work with Java bytecode, for example ASM and Jasmin.

like image 149
Jesper Avatar answered Sep 19 '22 19:09

Jesper