1 /* 2 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_CDS_AOTLINKEDCLASSBULKLOADER_HPP 26 #define SHARE_CDS_AOTLINKEDCLASSBULKLOADER_HPP 27 28 #include "memory/allStatic.hpp" 29 #include "memory/allocation.hpp" 30 #include "runtime/handles.hpp" 31 #include "utilities/exceptions.hpp" 32 #include "utilities/macros.hpp" 33 34 class AOTLinkedClassTable; 35 class ClassLoaderData; 36 class InstanceKlass; 37 class SerializeClosure; 38 template <typename T> class Array; 39 40 // During a Production Run, the AOTLinkedClassBulkLoader loads all classes from 41 // a AOTLinkedClassTable into their respective ClassLoaders. This happens very early 42 // in the JVM bootstrap stage, before any application code is executed. 43 // 44 class AOTLinkedClassBulkLoader : AllStatic { 45 enum class LoaderKind : int { 46 BOOT, 47 BOOT2, 48 PLATFORM, 49 APP 50 }; 51 52 static bool _preloading_non_javavase_classes; 53 static Array<InstanceKlass*>* _unregistered_classes_from_preimage; 54 55 static void load_classes_in_loader(JavaThread* current, LoaderKind loader_kind, oop class_loader_oop); 56 static void load_table(AOTLinkedClassTable* table, LoaderKind loader_kind, Handle loader, TRAPS); 57 static void initiate_loading(JavaThread* current, const char* category, Handle loader, Array<InstanceKlass*>* classes); 58 static void load_classes_impl(LoaderKind loader_kind, Array<InstanceKlass*>* classes, const char* category, Handle loader, TRAPS); 59 static void load_class_quick(InstanceKlass* ik, ClassLoaderData* loader_data, Handle domain, TRAPS); 60 static void load_hidden_class(ClassLoaderData* loader_data, InstanceKlass* ik, TRAPS); 61 static void maybe_init_or_link(Array<InstanceKlass*>* classes, TRAPS); 62 63 static void replay_training_at_init(Array<InstanceKlass*>* classes, TRAPS) NOT_CDS_RETURN; 64 65 public: 66 static void serialize(SerializeClosure* soc, bool is_static_archive); 67 static void record_unregistered_classes(); 68 69 static void load_javabase_boot_classes(JavaThread* current); 70 static void load_non_javabase_boot_classes(JavaThread* current); 71 static void load_platform_classes(JavaThread* current); 72 static void load_app_classes(JavaThread* current); 73 74 static void init_javabase_preloaded_classes(TRAPS) NOT_CDS_RETURN; 75 static void replay_training_at_init_for_preloaded_classes(TRAPS) NOT_CDS_RETURN; 76 static bool class_preloading_finished(); 77 78 static void print_counters_on(outputStream* st) NOT_CDS_RETURN; 79 }; 80 81 #endif // SHARE_CDS_AOTLINKEDCLASSBULKLOADER_HPP