7 Replies Latest reply: Apr 22, 2010 9:42 PM by 807557 RSS

    Combination of using VM args while building init and compilation lists?

    807557
      Is there any specific combination of using following VM args in RTS

      -XX:+RTSJBuildCompilationList
      -XX:+RTSJBuildClassInitializationList
      -Drtsj.precompile=nhrt.precompile
      -Drtsj.preinit=itc.preinit

      I have generated precompile and preinit lists using -XX:+RTSJBuildCompilationList -XX:+RTSJBuildClassInitializationList by running my application multiple times. I want to leave all these options enabled so that my list got updated everytime when I run my app. But I got ExceptionInInitialization error. Following are the combinations that I tried

      Case 1.
      -XX:+RTSJBuildCompilationList \
      -XX:+RTSJBuildClassInitializationList \
      -Drtsj.precompile=nhrt.precompile \
      -Drtsj.preinit=itc.preinit

      Error occurred during initialization of VM
      java.lang.ExceptionInInitializerError


      Case 2.

      -XX:+RTSJBuildCompilationList \
      -Drtsj.precompile=nhrt.precompile \
      -Drtsj.preinit=itc.preinit"

      Program runs fine


      Case 3.

      -Drtsj.precompile=nhrt.precompile \
      -Drtsj.preinit=itc.preinit"

      Program runs fine

      Case 2.

      -Drtsj.preinit=itc.preinit \
      -Drtsj.precompile=nhrt.precompile"


      Program runs fine.
        • 1. Re: Combination of using VM args while building init and compilation lists?
          807557
          Also is there any difference betwwen -XX:CompilationList and -Drtsj.precompile switches?

          I also tried -XX:UseITC shorthand but it also gives same ExceptionInInitialization error.
          • 2. Re: Combination of using VM args while building init and compilation lists?
            807557
            Assuming you are using JRTS 2.2 your case #1 and -XX:+UseITC are equivalent.

            For your other cases it depends on what the files contain when you launch the VM.

            There was an ordering bug in JRTS 2.1 that could more easily lead to the problem you describe.

            In some rare cases the order in which classes are pre-initialized can be generated incorrectly. In that case try running java_g and using the -XX:+TraceExceptions flag to see what the original exception is (sorry but this is a noisy option due to all the ClassDefNotFoundErrors you get during normal class loading). If you find what exception is causing the ExceptionInInitializerError then see what class it occurred in and move that class to later in the preinit list.

            David Holmes
            • 3. Re: Combination of using VM args while building init and compilation lists?
              807557
              I got the class name and I put it to the end of itc.preinit file but still same error.

              I have following questions

              My itc.preinit file is having approx 1200 class names and nhrt.precompile file has ~4500 method names.
              I understand that -XX:+RTSJBuildCompilationList switch is used to build nhrt.precompile file. Once this switch is removed no further addition will happen to nhrt.precompile list but it can be asked to RTS VM to prec ompile classes specified in this file by using switch -Drtsj.precompile=nhrt.precompile.

              But what I am observing by enabling -XX:PrintCompilation switch is that around 800 methods got compiled if I specify following VM args only

              -Drtsj.precompile=nhrt.precompile -Drtsj.preinit=itc.preinit

              If I add -XX:+RTSJBuildClassInitializationList also around 4500 method got compiled. Why?

              If I also add -XX:+RTSJBuildClassInitializationList i got ExceptionInInitializerError.
              • 4. Re: Combination of using VM args while building init and compilation lists?
                807557
                Prashant-Goel wrote:
                I got the class name and I put it to the end of itc.preinit file but still same error.
                Strange. Could you see what the actual exception was? Is this a JDK class or an application class?
                I have following questions

                My itc.preinit file is having approx 1200 class names and nhrt.precompile file has ~4500 method names.
                I understand that -XX:+RTSJBuildCompilationList switch is used to build nhrt.precompile file. Once this switch is removed no further addition will happen to nhrt.precompile list but it can be asked to RTS VM to prec ompile classes specified in this file by using switch -Drtsj.precompile=nhrt.precompile.

                But what I am observing by enabling -XX:PrintCompilation switch is that around 800 methods got compiled if I specify following VM args only

                -Drtsj.precompile=nhrt.precompile -Drtsj.preinit=itc.preinit

                If I add -XX:+RTSJBuildClassInitializationList also around 4500 method got compiled. Why?

                If I also add -XX:+RTSJBuildClassInitializationList i got ExceptionInInitializerError.
                I'll see if I can duplicate this using a fairly simple program.

                David Holmes
                • 5. Re: Combination of using VM args while building init and compilation lists?
                  807557
                  dontwantto wrote:
                  Strange. Could you see what the actual exception was? Is this a JDK class or an application class?
                  This is an application class and it has code like this
                  public class A {
                  public static A  a = new A(B.b)
                  }
                  Where B is another class like A having public static final member b of type B.
                  • 6. Re: Combination of using VM args while building init and compilation lists?
                    807557
                    Prashant-Goel wrote:
                    This is an application class and it has code like this
                    public class A {
                    public static A  a = new A(B.b)
                    }
                    Where B is another class like A having public static final member b of type B.
                    Where does B appear in the preinit list relative to A?

                    Does B also refer to A ie there is a circular dependency between them?

                    David Holmes
                    • 7. Re: Combination of using VM args while building init and compilation lists?
                      807557
                      Prashant-Goel wrote:
                      My itc.preinit file is having approx 1200 class names and nhrt.precompile file has ~4500 method names.
                      I understand that -XX:+RTSJBuildCompilationList switch is used to build nhrt.precompile file. Once this switch is removed no further addition will happen to nhrt.precompile list but it can be asked to RTS VM to prec ompile classes specified in this file by using switch -Drtsj.precompile=nhrt.precompile.

                      But what I am observing by enabling -XX:PrintCompilation switch is that around 800 methods got compiled if I specify following VM args only

                      -Drtsj.precompile=nhrt.precompile -Drtsj.preinit=itc.preinit

                      If I add -XX:+RTSJBuildClassInitializationList also around 4500 method got compiled. Why?
                      Sorry, I forgot that ITC operation changed between JRTS 2.1 and 2.2. The release notes mention that ITC has new functionality in 2.2 but did not make it clear that the means by which ITC is used had changed.

                      In 2.1:

                      http://java.sun.com/javase/technologies/realtime/reference/doc_2.1/release/JavaRTSCompilation.html

                      We have:

                      If you specify this list at VM start-up, it is passed to Java RTS in a file whose name is specified with the rtsj.precompile property on the command line, as in the following example:
                          java <vm-options> \
                                  -Drtsj.precompile=<precompile-file-name> <your-program>
                      However, in 2.2 we no longer use these properties in association with the command-line invocation of ITC:

                      http://java.sun.com/javase/technologies/realtime/reference/doc_2.1/release/JavaRTSCompilation.html

                      If you specify this list at VM start-up, it is passed to Java RTS in a file whose name (with its absolute path) is specified on the command line, as in the following example:
                          java <vm-options> \
                          -XX:CompilationList=<compilation-file-name> <your-program>
                      If you use
                      -XX:CompilationList=nhrt.precompile -XX:PreInitList=itc.preinit
                      then all should be right.
                      If I add -XX:+RTSJBuildClassInitializationList also around 4500 method got compiled. Why?
                      Did you mean RTSJBuildCompilationList ? When you generate a list the VM will implicitly use the same list, if it exists - this is a consequence of the input list and the output list having the same filename.

                      David Holmes