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_AOTLINKEDCLASSTABLE_HPP
26 #define SHARE_CDS_AOTLINKEDCLASSTABLE_HPP
27 
28 #include "utilities/globalDefinitions.hpp"
29 
30 template <typename T> class Array;
31 class InstanceKlass;
32 class SerializeClosure;
33 
34 // Classes to be buik-loaded, in the "linked" state, at VM bootstrap.
35 //
36 // AOTLinkedClassTable is produced by AOTClassLinker when an AOTCache is assembled.
37 //
38 // AOTLinkedClassTable is consumed by AOTLinkedClassBulkLoader when an AOTCache is used
39 // in a production run.
40 //
41 class AOTLinkedClassTable {
42   // The VM may load up to 2 CDS archives -- static and dynamic. Each
43   // archive can have its own AOTLinkedClassTable.
44   static AOTLinkedClassTable _for_static_archive;
45   static AOTLinkedClassTable _for_dynamic_archive;
46 
47   Array<InstanceKlass*>* _boot;  // only java.base classes
48   Array<InstanceKlass*>* _boot2; // boot classes in other modules
49   Array<InstanceKlass*>* _platform;
50   Array<InstanceKlass*>* _app;
51 
52 public:
53   AOTLinkedClassTable() :
54     _boot(nullptr), _boot2(nullptr),
55     _platform(nullptr), _app(nullptr) {}
56 
57   static AOTLinkedClassTable* for_static_archive()  { return &_for_static_archive; }
58   static AOTLinkedClassTable* for_dynamic_archive() { return &_for_dynamic_archive; }
59 
60   static AOTLinkedClassTable* get(bool is_static_archive) {
61     return is_static_archive ? for_static_archive() : for_dynamic_archive();
62   }
63 
64   Array<InstanceKlass*>* boot()     const { return _boot;     }
65   Array<InstanceKlass*>* boot2()    const { return _boot2;    }
66   Array<InstanceKlass*>* platform() const { return _platform; }
67   Array<InstanceKlass*>* app()      const { return _app;      }
68 
69   void set_boot    (Array<InstanceKlass*>* value) { _boot     = value; }
70   void set_boot2   (Array<InstanceKlass*>* value) { _boot2    = value; }
71   void set_platform(Array<InstanceKlass*>* value) { _platform = value; }
72   void set_app     (Array<InstanceKlass*>* value) { _app      = value; }
73 
74   void serialize(SerializeClosure* soc);
75 };
76 
77 #endif // SHARE_CDS_AOTLINKEDCLASSTABLE_HPP