I have simple code as below
package prashant;
public class CheckObject {
}
I used javap -c CheckObject and got below bytecode :
Compiled from "CheckObject.java"
public class prashant.CheckObject {
public prashant.CheckObject();
Code:
0: aload_0
1: invokespecial #8 // Method java/lang/Object."<init>":()V
4: return
}
as in older version of Java implicitly compiler was adding extends Object in byte code as :
public class prashant.CheckObject extends java.lang.Object
so i have two question regarding extends Object:
1) is it not added, because of any performance hit?
2) in which java version it got changed?
java version used to compile this code is 1.6.0_45.
You're printing a disassembly, not the raw bytecode, and the disassembly is designed to be human-readable. An object with no declared superclass necessarily extends Object
(as shown by the comment on the constructor), and so listing it is redundant.