JIT compiler and nested classes

Q1. how does JIT compile on fly and improve the performance ?
Q2. how is system.out.println(argument) implemented in java ? is it that system is a class in which out is a static nested class and println is a static method in out?

Hello rishiluvsjava,
Q1. How does JIT compile on fly and improve the performance?
The following answer was taken from "The Java HotSpot Performance Engine Architecure: A White Paper About Sun's Second Generation Performance Technology" to view the full document go to:
http://java.sun.com/products/hotspot/whitepaper.html
Just-In-Time (JIT) compilers are essentially fast traditional compilers that translate the Java-technology bytecodes into native machine code on-the-fly. A JIT runs on the end-user's machine which actually executes the bytecodes, and compiles each method the first time it is executed.
Q2. How is System.out.println(argument) implemented in java ? is it that system is a class in which out is a static nested class and println is a static method in out?
From the Java docs:
System is a public final class in the java.lang package. It has three fields:
static PrintStream err    // The "standard" error output stream.
static InputStream in    // The "standard" input stream.
static PrintStream out  //The "standard" output stream.println is one of the methods in the java.io.PrintStream class.
-Merwyn,
Developer Technical Support,
http://www.sun.com/developers/support.

Similar Messages

  • Difference between JIT compiler and Execution engine...

    where does bytecode get generated???is is in the JIT compiler or in the execution engine???What actually is the process happening inside JVM???can anybody help me in knowing this???

    where does bytecode get generated?Bytecode is the output of javac, the j2se sdk java source compiler.
    is it in the JIT compiler or in the execution engine?No, and No.
    What actually is the process happening inside JVM?The bytecode of the classes to be used
    is loaded and verified
    For an application the main() method of the primary class is launched.
    can anybody help me in knowing this?Unknown.
    We can tell you the answers to the questions you seem to be asking.
    It would help if you could be a bit more specific.

  • Writing a compiler with Compiler and Runtime class

    I am writing a simple compiler that uses the Compiler class to compile a program and the Runtime class to execute the java file. However, I am having trouble located the .class file, and displaying the results when the file is executed. The following code is a segment of my program. Does anyone have any suggestions?
    try
                   saveFile();
                   //Process p = Runtime.getRuntime().exec("javac "+fileName.getName());
              Process p = null;
                   //JOptionPane.showMessageDialog(null,"Compile Message "+p.getErrorStream(), "Message:                
                   ",JOptionPane.ERROR_MESSAGE);
                   s = fileName.getName();
                   int truncStart = s.indexOf(".java");
                   compiled = java.lang.Compiler.compileClasses(s);
                   s = s.substring(0,truncStart);
                   JOptionPane.showMessageDialog(null,"Compile File "+s, "Compile File : ",JOptionPane.ERROR_MESSAGE);
                   p = Runtime.getRuntime().exec("java "+s);
              

    OK, I think I need a delay between my compile stmt and my exec stmt. If anybody has had a similiar problem please let me know how you resolved it. Here is my code so far.
    try
                   saveFile();
              Process p = null;
                   s = fileName.getName();
                   String[] command = {"javac","c:/"+s};
                   try
                   JOptionPane.showMessageDialog(null,"Compile File "+s, "Compile File : ",JOptionPane.ERROR_MESSAGE);
                   p = Runtime.getRuntime().exec(command);
                   catch (Exception q)
                   JOptionPane.showMessageDialog(null,"Compile Error:"                
    +q.toString(),"Error!",JOptionPane.ERROR_MESSAGE);
                   int truncStart = s.indexOf(".java");
                   s = s.substring(0,truncStart);
                   String[] command2 = {"java", "c:/"+s};
                   try
                   JOptionPane.showMessageDialog(null,"Exec. File "+s, "Exec. File : ",JOptionPane.ERROR_MESSAGE);
                   p = Runtime.getRuntime().exec(command2);
                   catch(Exception y)
                   JOptionPane.showMessageDialog(null,"Exec Error :"+y.toString(),"Error!",JOptionPane.ERROR_MESSAGE);
                   }

  • How can I compile and run other java classes from within an application?

    Hello there everyone! I really hope that someone can help me. I am writing a program that must be able to compile and run other java classes that are in different files, much like development environments like Kawa or Forte allow you to do.
    There has to be a way of doing this ( I hope!! ), but i can't seem to find it!!
    I have tried using this command to compile:
    Runtime.getRuntime().exec ("c:\\programs\\javac className.java");
    ...and this one to run:
    Runtime.getRuntime().exec ("c:\\programs\\java className");
    ...but neither works!!! I can compile and run classes that are in the same file as my application, but I can't get it to work at all for files in different directories or files.
    PLEASE, PLEASE, PLEASE help me - i've run out of ideas, and i need this to be working in 3 days!!!
    Thank you very much for any help anyone can give me, I really appreciate it!! Thanks again!!
    Adrian ( ...in distress!! )

    public class JavaCompiler{
       public static void main(String[] args)throws Exception{ //sorry bout the laziness
          if(args == null || args.length != 1){
             System.out.println("Usage: java JavaCompiler MyClass.java");
             System.exit(0);
          String className = args[0];
          Runtime rt = Runtime.getRuntime();
          Process p = rt.exec("javac " + className); //consider setting cpath for this
          p.waitFor();
          //now try to run after it is done.
          p = rt.exec("java " + className.substring(0, (className.length() - ".java".length()));
          p.waitFor();
          //do some other stuff
    }This should get you going. You may consider looking into the System.getProperty() method in order to determine the type of OS it is running on in order to findo out what command to run. I know that the sun tool listed above is nice, but by my understanding the sun tools provided are not guaranteed to stay the same. I'm no expert on this matter, but that is one of the reasons there is no API documentation for those tools. Also, I don't believe those tools come packaged with the JRE. (Of course if you are making an IDE it will be expected that the user has an sdk installed. Good luck with figuring this thing out.

  • Nested classes and separate files in Javadoc...

    Hello. I am writing an application, and it has several .java files, and some of the classes contained therein contain nested classes, for example
    ClassOne.java
    class ClassOne
    // stuff
       class innerClassOne
          //more stuff
    }ClassTwo.java
    class ClassTwo
    // stuff
       class innerClassTwo
          //more stuff
    }What I want to do is generate documentation like the online java documentation for my app, that is, documentation that will contain ALL the classes and nested classes involved, and link everything that comes in java already to the sun online java docs.
    I've figured out the -link command for javadoc, and I can make that work, but I've run into some other snags.
    1.) Javadoc isn't finding or documenting my nested classes, despite them being marked up. Google does not wish to help.
    2.) Some classes reference other classes of mine that aren't conatined in the same .java file, but do exist in their own .java files in the dame local directory. Javadoc does not like this, and gives errors.
    3.) Running javadoc on one file at a time overwrites the old file's documentation, thus I cannot seem to get an index.html javadoc file that links to all my classes, nor can I get the classes to link to each other.
    What do I need to do to fix these?

    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
        int i;
        static class Bar {
            int j = i; // WRONG! Bar class is static context
    }~

  • Regarding JIT compiler

    Hi,
    I would like to know what is a JIT compiler and how it works.My understanding of JIT compiler is that it is a compiler that takes in as input the bytecode and gives native code as output which is then interpretted by interpretter.I guess JIT compiler helps in speedig up the loops, but i dont know how.Could someone explain JIT and its features in detail or provide a useful link where i could get these details.
    Thanks!!Have a Great Day!
    vivek

    Hi,
    Thanks a lot guys. Well both the artciles were great.So to my understanding now......the portion of code which is bieng compiled by JIT need not be interpretted by Interprettor......am i right?so what JIT does is ...it converts the bytecode into series of intsructions that are understood by the underlying microporocessor......and the mp executes the instructions.......am i correct?
    i have another doubt.......take a small pece of program which has no loop.........
    int a =5;
    int b= 6;
    int c= a +b;
    in this case if u use JIT compiler time taken will be
    time taken by JIT to convert bytecode to machin code + time taken by CPU to execute the entire code.
    in the caseof using interprettor :
    well i guess interpretter executes each line at a time, so it converts the byte code into machine code one line at a time and CPU executes it.
    so time taken is
    time taken by Interprettor to convert each line of bytecode to machine code + time taken by CPU to execute each line of code.
    SO I guess JIT compiler wud be faster.SO wudnt it be advantageous over inteprettor in all cases?Or does JIT compiler waste time in optimizing small pieces of code which does not reqiure optimization in which cases interpretter is quicker?
    Thanks!
    Vivek

  • Compiling Nested Classes and Interfaces

    I am looking for documentation about compiling nested classes and interfaces. I have found something in the JVM Specification, but there does not explain how a nested class is compiled and what is included in the top level class to mark a "place holder" to the nested class. The JVM Specification in this topic cite the web page http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html that does not exists any more.
    My root problem is that: I am compiling a class with a private nested class, but in the class file generated TopLevelClass$NestedClass.class the class does not have the private modifier. So I am not understanding why the "private" modifier was removed during compilation.
    I performed the same test with a protected nested class and the result was the nested class with the public modifier. So I am not understanding why the "protected" modifier was changed to "public".
    Thanks in advance,
    Mardoqueu.

    This should not be happening. What compiler are you using? If it's a reasonably recent Sun compiler, could you post a minimal example?

  • How to compile and register a Java CFX tag with multiple class files?

    All-
    If this is the wrong forum for CFX questions, please let me
    know.
    I need to determine how to compile and register a Java CFX
    tag that contains multiple class files. One class file implements
    the CustomTag interface and the other class files implement various
    supporting classes. All of the documentation that I have found
    talks about using a single class file. I am assuming that a JAR
    file will be involved, but I am not sure of the specifics.
    Thanks in advance for your help.
    -Josh

    Yes, it will involve a jar. Use your java IDE (eclipse,
    etcetera ..) to create a jar containing all of the classes. Check
    your ide's documentation for how to create jar files. After you
    have created the jar, place the jar in the CF class path so CF will
    recognize it. For example the {cf_root}/WEB-INF/lib directory. CF
    must be restarted before it will detect the new jar. After
    restarting CF, register the CFX tag in the ColdFusion Administrator
    using the name of the class that implements the CustomTag
    interface.
    Though it is worth noting you can also instantiate java
    classes directly from ColdFusion (ie without using a CFX
    tag).

  • Nested Classes and Static Methods

    I was perusing the Java Tutorials on Nested Classes and I came across this...
    [http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html|http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html]
    I was reading the documentation and I read a slightly confusing statement. I was hoping some further discussion could clarify the matter. The documentation on "Nested Classes" says (I highlighted the two statements, in bold, I am having trouble piecing together.)
    Static Nested Classes
    As with class methods and variables, a static nested class is associated with its outer class. And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class ? it can use them only through an object reference.
    Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.
    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?

    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
        int i;
        static class Bar {
            int j = i; // WRONG! Bar class is static context
    }~

  • Nested and inner classes

    What's the difference between them? As far as i can tell, a nested class is usually public and a inner class is almost always private. Can some one please provide an example?
    Thanks a lot guys.

    inner classes == nested classes - static classes
    In other words, inner class should belongs to the instance of the enclosing class.

  • Compiler Errors With Class Definitions and Clients

    Hi there, I need help with some code, here it is.
    import java.util.*;
    import java.text.*;
    public class InvestCalc {
         //declaration of instance variables
         private double interest, principal;
         //default constructor, sets interest and principal to zero
         public InvestCalc() {
              interest = 0.0;
              principal = 0.0;
         //overloaded constructor
         public InvestCalc( double startInterest, double startPrincipal) {
              interest = startInterest;
              principal = startPrincipal;
         //accessor methods for instance variables
         public double getRate() {
              return interest;
         public double getPrincipal() {
              return principal;
         //mutator methods
         public void setRate(double newInterest) {
              interest = newInterest;
         public void setPrincipal(double newPrincipal) {
              principal = newPrincipal;
         //String toString() method
         public String toString() {
              return "Interest Rate: " + percent.format(interest) + ", Principal: " + DOLLAR_FORMAT.format(principal);     
         //futureValue(int year) method
         public double futureValue(int year) {
              double futureValue = Math.pow((1 + interest), year)*principal;
              return futureValue;
         //public static final class variables
         public static final int shortTerm = 5;
         public static final int middleTerm = 10;
         public static final int longTerm = 20;
         //public void display Table() method
         public void displayTable() {
              System.out.println("Year" + "\t" + "Interest Rate" + "\t\t" + "Principal" + "\t\t" + "Future Value");
              System.out.println(shortTerm + "\t" + percent.format(interest) + "\t\t\t" + DOLLAR_FORMAT.format(principal) + "\t\t" + DOLLAR_FORMAT.format(futureValue(shortTerm)));
              System.out.println(middleTerm + "\t" + percent.format(interest) + "\t\t\t" + DOLLAR_FORMAT.format(principal) + "\t\t" + DOLLAR_FORMAT.format(futureValue(middleTerm)));
              System.out.println(longTerm + "\t" + percent.format(interest) + "\t\t\t" + DOLLAR_FORMAT.format(principal) + "\t\t" + DOLLAR_FORMAT.format(futureValue(longTerm)));
         //formatting section
         public static final NumberFormat DOLLAR_FORMAT = NumberFormat.getCurrencyInstance();
         public static final DecimalFormat percent = new DecimalFormat("##0.00%");
    import java.util.*;
    public class InvestCalcApp {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              //declare Scanner class and interest, principal vars
              Scanner input = new Scanner(System.in);          
              double interest, principal;     //vars for the interest rate and initial investment
              //instantiate a default object of the InvestCalc class
              InvestCalc value1 = new InvestCalc();
              System.out.println("Default InvestCalc Object");
              System.out.println(value1.toString()+ "\n");
              //query for interest and principal
              System.out.print("Enter an interest rate in decimal format: ");
              interest = input.nextDouble();
              System.out.print("Enter the initial investment value: ");
              principal = input.nextDouble();
              //change object and output
              value1.setRate(interest);
              value1.setPrincipal(principal);
              System.out.println("Updated InvestCalc Object");
              System.out.println(value1.toString());
              //test the futureValue method and the DOLLAR_FORMAT static class variable
              System.out.println("Value after 1 year " + InvestCalc.DOLLAR_FORMAT.format(value1.futureValue(1)) + "\n");     
              value1.displayTable();     
              //query for another interest and principal
              System.out.print("Enter another interest rate in decimal format: ");
              interest = input.nextDouble();
              System.out.print("Enter another initial investment value: ");
              principal = input.nextDouble();
              //instantiate an object of the InvestCalc class
              InvestCalc value2 = new InvestCalc(interest, principal);
              System.out.println("Non-Default InvestCalc Object");
              System.out.println(value2.toString()+ "\n");
              value2.displayTable();
    }When I compile InvestCalc.java it compiles; however, when I compile InvestCalcApp.java I receive 5 errors:
    InvestCalcApp.java:15: cannot find symbol
    symbol : class InvestCalc
    location: class InvestCalcApp
                     InvestCalc value1 = new InvestCalc();
    InvestCalcApp.java:15: cannot find symbol
    symbol : class InvestCalc
    location: class InvestCalcApp
                     InvestCalc value1 = new InvestCalc();
    InvestCalcApp.java:32: package InvestCalc does not exist
                                  System.out.println("Value after 1 year " + InvestCalc.DOLLAR_FORMAT.format(value1.futureValue(1)) + "\n");
    InvestCalcApp.java:42: cannot find symbol
    symbol : class InvestCalc
    location: class InvestCalcApp
                     InvestCalc value2 = new InvestCalc(interest, principal);
    InvestCalcApp.java:42: cannot find symbol
    symbol : class InvestCalc
    location: class InvestCalcApp
                     InvestCalc value2 = new InvestCalc(interest, principal);Sorry if that's a lot of reading, but I need help, I'm new at this and not quite sure what those errors mean. Thanks

    The errors mean the compiler can not find the InvestCalc class. The compiler looks for classes using the Classpath. It might work if you use a command likejavac -cp . InvestCalcApp.javaThis command tells javac to look in the current directory for dependent classes.

  • Compiling (in memory) and Loading classes on fly

    Hiya,
    I have following classes:
    public class Vehicle {Protected Sting reg;}
    public class Car extends Vehicle
    (public void print(){System.out.println(reg);}}
    These classes (or different ones) are stored in one text file. The program must read these files then compile and load them dynamically in memory.
    The link below authored by DCHSW deals with one class only (compile and loading) however it fails with more then one class particularly when it is subclassed.
    http://forum.java.sun.com/thread.jsp?thread=347467&forum=4&message=1439418
    How can we get the code mentioned at link above to compile (in memory) and load subclasses like the ones mentioned above.
    Thanks
    Derik

    Hiya,
    I have following classes:
    public class Vehicle {Protected Sting reg;}
    public class Car extends Vehicle
    (public void print(){System.out.println(reg);}}
    These classes (or different ones) are stored in one
    text file. The program must read these files then
    compile and load them dynamically in memory.
    The link below authored by DCHSW deals with one class
    only (compile and loading) however it fails with more
    then one class particularly when it is subclassed.
    Read the following post for full description of the problem
    http://forum.java.sun.com/thread.jsp?forum=4&thread=417724
    Any ideas?
    Thanks
    Derik
    http://forum.java.sun.com/thread.jsp?thread=347467&foru
    =4&message=1439418
    How can we get the code mentioned at link above to
    compile (in memory) and load subclasses like the ones
    mentioned above.
    Thanks
    Derik

  • Compiling and putting java classes in database schema

    hi..good evening to all...
    I have total 7 java classes which i have to compile and put in the database schema. those 7 classes are interdependent on each other thats why there is a particular order of execution.
    i want to compile and put them in the schema thorugh the command line.
    i have tried doing this one by one by executing the following command in cmd...
    D:\>loadjava -u username/password@sid -v -resolve javaclassname.java
    then its working fine..
    But i have to do this in one time i.e i have to compile and put all the 7 classes in schema by a single command.
    Thats why i have put all the 7 classes one by one in the required order...save the file as 'java_sources.java' and then run the following command...
    D:\>loadjava -u username/password@sid -v -resolve java_sources.java
    but it is not working... :(
    please help...thanks in advance

    Hi,
    It is not required to load one by one class files into the schema. Can create a jar file for all the class files and load the jar file using the '-o' option in loadjava
    eg:
    loadjava -u username/password@sid -v -r -o jar_file_name.jarI hope you might use any IDE to develop the java class files. All the IDE have option to develop jar file if not get oracle JDeveloper for easy option.
    Check the version of jdk used in your oracle server and use appropiate version of Jdeveloepr and compile the classes.
    If your class files use any builtin library jar files those also need to be loaded.
    As thomaso said if pasted with errors can resovle easier
    NB:
    http://download.oracle.com/docs/cd/B10500_01/java.920/a96659/02_load.htm

  • Flex RPC mapping Java nested classes to ActionScript classes

    We are calling a Java method in our project using
    RemoteObject the value returned by the java method is a ArrayList
    containing instances of a class say ParentClass with some nested
    classes.
    The structure of ParentClass(Java) is something like this
    class ParentClass {
    //some primitives
    private ChildClassA childAInstance;
    private ChildClassB childBInstance;
    //getters setters
    We have created similar class structure on the ActionScript
    side, the ActionScript classes(ParentClass,ChildClassA
    ,ChildClassB) have been properly annotated with the [RemoteClass]
    metadata tag,
    The problem is that though i'm getting the primitive data
    members of the ParentClass through RPC in my corresponding AS
    ParentClass class i'm getting an runtime exception trying to access
    ChildClassA,ChildClassB members.
    Am i missing something, exactly the same scenario is
    mentioned in this article
    http://www.adobe.com/devnet/flex/articles/complex_data.html
    But the Object.registerClass method mentioned in the tutorial
    is giving me compilation error, the sample code attached with the
    article is corrupt zip too.
    Please help me out on this

    JAXB will create classes from an XML schema, SAX is a parser library and JAXP is a library of XML a bunch of XML tools.
    I don't care for JAXB too much. I would skip it and go right to the JAX-RPC spec (WebServices).

  • JDWP reference implementation does not return anonymous nested classes?

    Using
    $ java -version
    java version "1.6.0_22"
    Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
    Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
    it appears that when I connect with JDWP and issue a NestedTypes command, the result does not include anonymous nested types. The only references to this that I could find is a comment in a svn commit at apache (http://mail-archives.apache.org/mod_mbox/harmony-commits/200611.mbox/%[email protected]%3E)
    Is this intentional and desired? Is there a way to get all of the nested types, including the anonymous ones? I could do ClassesBySignature with "package.ClassName$*" as the signature and filter out doubly nested classes, but that seems overly complicated.

    exept, you can NOT have an implementation of an
    abstract class (which foundPlugin) is without an
    implementation of all it's subclasses (such as
    argsObject) You're mistaken in a couple of ways here.
    First, a nested class is not the same as a subclass.
    Second, a concrete class must have implementations for all its methods, but it can still have an abstract nested class.
    Third, you can have an instance of a concrete class that has abstract subclasses. Object is concrete and has many concrete subclasses. Classes don't know anything about their subclasses.
    This compiles.
    public abstract class AbOut {
      public abstract class AbIn {  public abstract void bar(); }
    public class ConcOut extends AbOut {
      public abstract class AbIn2 { public abstract void foo();}
    foundPlugin MUST have an implementation
    of argsObject, according to the rules of java,And you think this because...?
    You read it in the JLS? Citation please.
    You tried to compile and it failed? My sample above demonstrates the countereample. If I'm misunderstanding what you're talking about, please post an example
    Or maybe you just thought it had to be that way because that seemed the most intuitive and when it wasn't, rather than trying to understand or adjust your thinking, you figured it would be more fun to throw a hissy fit and call Java "stupid"?

Maybe you are looking for

  • Reader 9.4 won't open on Windows 7 64-bit

    Have a strange issue with installing Reader 9.4 on a new Windows 7 64-bit setup. Program installs without any issue at all, but when opening it from the start menu or opening a PDF document, the cursor is busy for a few seconds and then returns to no

  • LCD TV v's Monitor

    Hi All, Firstly I really don't know much about LCD TV's, Monitors etc... We need to buy a new tv for our bedroom and we are thinking a smaller (30'') LCD tv would be the way to go. Now I know they have DVI input so I can also use it as a display for

  • Can't buy iPhoto, iMovie and GarageBand

    Hello I can't buy apps iPhoto, iMovie and GarageBand there is mentioned instead of price only "accept" but when I clicked on it and wrote my Apple ID I received error message. My Mac Mini was bought from another person but fully reinstalled. Can anyo

  • How to use "Adjustment Level " in automatic adjustments rule

    Now we are setting up BPC for legal consolidation. we use BPC 7.0MS SP4 Version. I want to use some result of automatic adjustment rules for source data, so I tried to use adjustment level in automatic adjustments rules. I was setting up A rule's (to

  • Prompt user for input when rdp with same user as logged in

    What I am trying to achieve: user dragos is logged in on a domain computer. When I connect with rdp with the username dragos on the computer I want user dragos to be asked if he allows the connection or not not to be taken over. When you connect as d