< prev index next >

src/java.base/share/classes/jdk/internal/loader/BootLoader.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -68,13 +68,17 @@
  
      // ClassLoaderValue map for the boot class loader
      private static final ConcurrentHashMap<?, ?> CLASS_LOADER_VALUE_MAP
          = new ConcurrentHashMap<>();
  
-     // native libraries loaded by the boot class loader
-     private static final NativeLibraries NATIVE_LIBS
-         = NativeLibraries.newInstance(null);
+     // Holder has the field(s) that need to be initialized during JVM bootstrap even if
+     // the outer is aot-initialized.
+     private static class Holder {
+         // native libraries loaded by the boot class loader
+         private static final NativeLibraries NATIVE_LIBS
+             = NativeLibraries.newInstance(null);
+     }
  
      /**
       * Returns the unnamed module for the boot loader.
       */
      public static Module getUnnamedModule() {

@@ -97,11 +101,11 @@
  
      /**
       * Returns NativeLibraries for the boot class loader.
       */
      public static NativeLibraries getNativeLibraries() {
-         return NATIVE_LIBS;
+         return Holder.NATIVE_LIBS;
      }
  
      /**
       * Returns {@code true} if there is a class path associated with the
       * BootLoader.
< prev index next >