In the FIRST PROGRAM series, Part 1 , i have explained how to write , compile and run your java program using command prompt. Even you can write it in Eclipse IDE that i have explained here.
In both the case after compiling we get the .class file and in the Tools Series Part1 , i have explained decompling .class file.
After following above post, when you will open .class file with Cavaj decompiler you will find something that was not written by you.
This is the code that you had written:
public class Abc {
public static void main(String[] args) {
System.out.println("hello java");
}
}
Now When you will open .class file in decompiler you will find following code:
Now you can differentiate both code ( the code written by you and code that you get after decompilation). This code contains lots of extra code that you have not written in your .java file.
1st extra line of code :import statement==>import java.io.PrintStream ;
2nd extra line of code : default constructor
public Abc(){
}
I will explain about these line of codes in upcoming code, here i want you to focus on some extra work done by compiler beside just converting .java file into .class.As a summary we can conclude compiler does following, step by step
- compiler optimizes your code ( i will explain this in variable section)
- compiler puts extra lines of code for compilation (don't rely on compiler for lots of codes)
- then it performs the syntax checking.
- and if compiler finds all syntax correct then it generates .class file
This is just overview of what the compiler did for complete compilation. In coming post i will be explaining detail of it with sequence of questions and answers.
No comments:
Post a Comment