Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8367387

Add @AOTInitialize annotation

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • hotspot

      Class such as jdk.internal.math.MathUtils initialize large arrays in their <clinit>. It's beneficial to AOT-initialize them to improve start-up time:

      @jdk.internal.vm.annotation.AOTInitialize
      final class MathUtils {
          private static final long[] g = { ... over 1200 items ...}

      Note that we already have a @AOTSafeClassInitializer that works slightly differently:

         @AOTInitialize class A {...}
         @AOTSafeClassInitializer class B {...}
       
      Similarity: the annotation takes effect only if the annotated class is included in an AOT cache. (E.g., the class was used in a training run).

      Difference: the JVM will force A to be initialized in the AOT assembly run. A will always be cached in the aot-initialized state.

      The JVM does not force B to be initialized in the AOT assembly run. B will be cached in the aot-initialized state only if it was initialized during the AOT assembly run as a side effect of Java code execution (e.g., in module bootstrap or when linking invokedynamic bytecodes).

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: