This discussion is archived
4 Replies Latest reply: Feb 12, 2013 9:16 AM by Tolls RSS

Regarding JIT

800433 Newbie
Currently Being Moderated
Hi All,

I am reading Oracle Docs about JIT. while I am reading from floowing link,

http://docs.oracle.com/cd/E19455-01/806-3461/ch1intro-3/index.html

I got couple of doubts.

1. Why JIT again compiling .class file, when It already compiled? That means Java File got compiled two Times?

2. When we use javac FileName.java , then java file will compiled or parsed?

3. When we use java FileName (classfile) , then JVM invokes and executes .class file. But again what is this JIT and Interpretter?

4. When we call javac tool, then which java compiler got called? (JIT or some other) .

5. If JVM calls a Default constructor, then Object got created? When ever default constructor got executed, Object gets created or not?


Please can any one explain me in detail?
  • 1. Re: Regarding JIT
    Tolls Journeyer
    Currently Being Moderated
    The compiler compiles to byte code.
    This is a platform independent code that the JVM can use, either through the interpreter or have compiled into machine-specific code by the JIT.
  • 2. Re: Regarding JIT
    EJP Guru
    Currently Being Moderated
    1. Why JIT again compiling .class file, when It already compiled?
    The .class file is Java bytecode, not executable. The JIT compiles bytecode to executable code.
    That means Java File got compiled two Times?
    Yes.
    2. When we use javac FileName.java , then java file will compiled or parsed?
    Yes. Both.
    3. When we use java FileName (classfile) , then JVM invokes and executes .class file. But again what is this JIT and Interpreter?
    The JVM, the JIT, the interpreter, it's all the same thing in Java.
    4. When we call javac tool, then which java compiler got called? (JIT or some other).
    Neither. You should be able to figure that out for yourself. 'javac' compiles .java to .class.
    5. If JVM calls a Default constructor, then Object got created?
    Yes, that's what constructors are for.
    When ever default constructor got executed, Object gets created or not?
    Yes.
  • 3. Re: Regarding JIT
    800433 Newbie
    Currently Being Moderated
    When ever default constructor got executed, Object gets created or not?
    
    Yes.
    Then I have another doubt. We Cannot create an Object to an Abstract class. But We can create Reference variable to it. Consider following code
    public abstract class MyAbstract {
         public MyAbstract() {
              System.out.println("My Abstract class Object Created..");
         }
    
    }
    
    class MyClass extends MyAbstract{
         
         public static void main(String[] args) {
              MyAbstract ab=new MyClass();
         }
              
    } 
    When I Run Above code,
    My Abstract class Object Created.. 
    message printing on the screen. How Can an Abstract class Object can be created?
  • 4. Re: Regarding JIT
    Tolls Journeyer
    Currently Being Moderated
    user10137999 wrote:
    Then I have another doubt. We Cannot create an Object to an Abstract class. But We can create Reference variable to it. Consider following code
    public abstract class MyAbstract {
         public MyAbstract() {
              System.out.println("My Abstract class Object Created..");
         }
    
    }
    
    class MyClass extends MyAbstract{
         
         public static void main(String[] args) {
              MyAbstract ab=new MyClass();
         }
              
    } 
    When I Run Above code,
    My Abstract class Object Created.. 
    message printing on the screen. How Can an Abstract class Object can be created?
    No it's not.
    It's created a MyClass object.
    As part of that it has to call the MyAbstract constructor, because MyClass extends that abstract class.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points