Let's go to uncomfort zone

Sunday, 28 January 2018

Can you get code from byte code?

Compiler!!!!!! You guys already know compiler converts codes into machine code which can be understood by the computer. But did you ever think about getting code from machine code? If your answer is no or you didn’t know yet about this then this article is for you. In this article I am going to tell you about how can you get structure of your code from the bytecode. This article is too short and sweet, so it's not going to take your too much time xD.

Many people say that you can’t get code from byte code, and some people say that you can get code from byte code. Are they both true? or wrong? Let me tell you, you can not get each line of your code but you can get the structure of the code. So, it will help you to debug in very big projects, and that is why I am going to cover this topic today. Let's start with example in Java.


Here is our small java file in which there are three class members: constructor, variable and method. Now when you compile the java file then it will create .class file.


If you want to get structure of that class from byte code then you have to write “javap filename”. In my case I made java file named nothing so I will type javap nothing and then it will give me something like this......


So, you can see it is giving me the structure. Public class, variable mike, nothing constructor and show method. We can also get the structure of pre-defined classes. Example: java.lang.Object


So, here you can see the structure of java.lang.Object class. By this command you can get structure of any class you want. 
    I hope you got an idea about it, but still if you have any doubt then you can comment down below or you can contact us from our social media pages. Subscribe for instant updates, I will see you in the next article. Goodbye.

2 comments: