< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.hpp

Print this page

  1 /*
  2  * Copyright (c) 2014, 2023, 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_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
 26 #define SHARE_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
 27 
 28 #include "cds/cds_globals.hpp"
 29 #include "cds/filemap.hpp"
 30 #include "cds/dumpTimeClassInfo.hpp"
 31 #include "cds/lambdaProxyClassDictionary.hpp"

 32 #include "cds/runTimeClassInfo.hpp"
 33 #include "classfile/classLoaderData.hpp"
 34 #include "classfile/packageEntry.hpp"
 35 #include "classfile/systemDictionary.hpp"
 36 #include "oops/klass.hpp"
 37 #include "oops/oopHandle.hpp"

 38 
 39 
 40 /*===============================================================================
 41 
 42     Handling of the classes in the AppCDS archive
 43 
 44     To ensure safety and to simplify the implementation, archived classes are
 45     "segregated" into 2 types. The following rules describe how they
 46     are stored and looked up.
 47 
 48 [1] Category of archived classes
 49 
 50     There are 2 disjoint groups of classes stored in the AppCDS archive:
 51 
 52     BUILTIN:              These classes may be defined ONLY by the BOOT/PLATFORM/APP
 53                           loaders.
 54 
 55     UNREGISTERED:         These classes may be defined ONLY by a ClassLoader
 56                           instance that's not listed above (using fingerprint matching)
 57 

127   SharedClassLoadingMark(Thread* current, InstanceKlass* ik) : THREAD(current), _klass(ik) {}
128   ~SharedClassLoadingMark() {
129     assert(THREAD != nullptr, "Current thread is nullptr");
130     assert(_klass != nullptr, "InstanceKlass is nullptr");
131     if (HAS_PENDING_EXCEPTION) {
132       if (_klass->is_shared()) {
133         _klass->set_shared_loading_failed();
134       }
135     }
136   }
137 };
138 
139 class SystemDictionaryShared: public SystemDictionary {
140   friend class ExcludeDumpTimeSharedClasses;
141   friend class CleanupDumpTimeLambdaProxyClassTable;
142 
143   struct ArchiveInfo {
144     RunTimeSharedDictionary _builtin_dictionary;
145     RunTimeSharedDictionary _unregistered_dictionary;
146     LambdaProxyClassDictionary _lambda_proxy_class_dictionary;

147 
148     const RunTimeLambdaProxyClassInfo* lookup_lambda_proxy_class(LambdaProxyClassKey* key) {
149       return _lambda_proxy_class_dictionary.lookup(key, key->hash(), 0);
150     }
151 





152     void print_on(const char* prefix, outputStream* st);
153     void print_table_statistics(const char* prefix, outputStream* st);
154   };
155 
156 public:
157   enum : char {
158     FROM_FIELD_IS_PROTECTED = 1 << 0,
159     FROM_IS_ARRAY           = 1 << 1,
160     FROM_IS_OBJECT          = 1 << 2
161   };
162 
163 private:
164 
165   static DumpTimeSharedClassTable* _dumptime_table;
166   static DumpTimeLambdaProxyClassDictionary* _dumptime_lambda_proxy_class_dictionary;
167 



168   static ArchiveInfo _static_archive;
169   static ArchiveInfo _dynamic_archive;
170 
171   static ArchiveInfo* get_archive(bool is_static_archive) {
172     return is_static_archive ? &_static_archive : &_dynamic_archive;
173   }
174 
175   static InstanceKlass* load_shared_class_for_builtin_loader(
176                                                Symbol* class_name,
177                                                Handle class_loader,
178                                                TRAPS);
179   static InstanceKlass* acquire_class_for_current_thread(
180                                  InstanceKlass *ik,
181                                  Handle class_loader,
182                                  Handle protection_domain,
183                                  const ClassFileStream* cfs,
184                                  TRAPS);
185 
186   // Guaranteed to return non-null value for non-shared classes.
187   // k must not be a shared class.
188   static DumpTimeClassInfo* get_info(InstanceKlass* k);
189   static DumpTimeClassInfo* get_info_locked(InstanceKlass* k);
190 
191   static void write_dictionary(RunTimeSharedDictionary* dictionary,
192                                bool is_builtin);
193   static void write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary* dictionary);

194   static void cleanup_lambda_proxy_class_dictionary();

195   static void reset_registered_lambda_proxy_class(InstanceKlass* ik);
196   static bool is_jfr_event_class(InstanceKlass *k);
197   static bool is_registered_lambda_proxy_class(InstanceKlass* ik);
198   static bool check_for_exclusion_impl(InstanceKlass* k);
199   static void remove_dumptime_info(InstanceKlass* k) NOT_CDS_RETURN;
200   static bool has_been_redefined(InstanceKlass* k);
201   static InstanceKlass* retrieve_lambda_proxy_class(const RunTimeLambdaProxyClassInfo* info) NOT_CDS_RETURN_(nullptr);
202 
203   DEBUG_ONLY(static bool _class_loading_may_happen;)
204 
205 public:








206   static bool is_hidden_lambda_proxy(InstanceKlass* ik);
207   static bool is_early_klass(InstanceKlass* k);   // Was k loaded while JvmtiExport::is_early_phase()==true
208   static bool has_archived_enum_objs(InstanceKlass* ik);
209   static void set_has_archived_enum_objs(InstanceKlass* ik);
210 
211   static InstanceKlass* find_builtin_class(Symbol* class_name);
212 
213   static const RunTimeClassInfo* find_record(RunTimeSharedDictionary* static_dict,
214                                                    RunTimeSharedDictionary* dynamic_dict,
215                                                    Symbol* name);
216 
217   static bool has_platform_or_app_classes();
218 
219   // Called by PLATFORM/APP loader only
220   static InstanceKlass* find_or_load_shared_class(Symbol* class_name,
221                                                Handle class_loader,
222                                                TRAPS);
223 

224 
225   static void allocate_shared_data_arrays(int size, TRAPS);
226 
227   static bool is_builtin_loader(ClassLoaderData* loader_data);
228 
229   static InstanceKlass* lookup_super_for_unregistered_class(Symbol* class_name,
230                                                             Symbol* super_name,  bool is_superclass);
231 
232   static void initialize() NOT_CDS_RETURN;
233   static void init_dumptime_info(InstanceKlass* k) NOT_CDS_RETURN;
234   static void handle_class_unloading(InstanceKlass* k) NOT_CDS_RETURN;
235 




236   static Dictionary* boot_loader_dictionary() {
237     return ClassLoaderData::the_null_class_loader_data()->dictionary();
238   }
239 
240   static void update_shared_entry(InstanceKlass* klass, int id);
241   static void set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs);
242 
243   static InstanceKlass* lookup_from_stream(Symbol* class_name,
244                                            Handle class_loader,
245                                            Handle protection_domain,
246                                            const ClassFileStream* st,
247                                            TRAPS);
248   // "verification_constraints" are a set of checks performed by
249   // VerificationType::is_reference_assignable_from when verifying a shared class during
250   // dump time.
251   //
252   // With AppCDS, it is possible to override archived classes by calling
253   // ClassLoader.defineClass() directly. SystemDictionary::load_shared_class() already
254   // ensures that you cannot load a shared class if its super type(s) are changed. However,
255   // we need an additional check to ensure that the verification_constraints did not change

266                                      InstanceKlass* lambda_ik,
267                                      Symbol* invoked_name,
268                                      Symbol* invoked_type,
269                                      Symbol* method_type,
270                                      Method* member_method,
271                                      Symbol* instantiated_method_type, TRAPS) NOT_CDS_RETURN;
272   static void add_to_dump_time_lambda_proxy_class_dictionary(LambdaProxyClassKey& key,
273                                                              InstanceKlass* proxy_klass) NOT_CDS_RETURN;
274   static InstanceKlass* get_shared_lambda_proxy_class(InstanceKlass* caller_ik,
275                                                       Symbol* invoked_name,
276                                                       Symbol* invoked_type,
277                                                       Symbol* method_type,
278                                                       Method* member_method,
279                                                       Symbol* instantiated_method_type) NOT_CDS_RETURN_(nullptr);
280   static InstanceKlass* get_shared_nest_host(InstanceKlass* lambda_ik) NOT_CDS_RETURN_(nullptr);
281   static InstanceKlass* prepare_shared_lambda_proxy_class(InstanceKlass* lambda_ik,
282                                                           InstanceKlass* caller_ik, TRAPS) NOT_CDS_RETURN_(nullptr);
283   static bool check_linking_constraints(Thread* current, InstanceKlass* klass) NOT_CDS_RETURN_(false);
284   static void record_linking_constraint(Symbol* name, InstanceKlass* klass,
285                                      Handle loader1, Handle loader2) NOT_CDS_RETURN;
286   static bool is_builtin(InstanceKlass* k) {
287     return (k->shared_classpath_index() != UNREGISTERED_INDEX);
288   }
289   static bool add_unregistered_class(Thread* current, InstanceKlass* k);
290 
291   static void check_excluded_classes();
292   static bool check_for_exclusion(InstanceKlass* k, DumpTimeClassInfo* info);
293   static void validate_before_archiving(InstanceKlass* k);
294   static bool is_excluded_class(InstanceKlass* k);
295   static void set_excluded(InstanceKlass* k);
296   static void set_excluded_locked(InstanceKlass* k);
297   static bool warn_excluded(InstanceKlass* k, const char* reason);
298   static void dumptime_classes_do(class MetaspaceClosure* it);
299   static size_t estimate_size_for_archive();
300   static void write_to_archive(bool is_static_archive = true);
301   static void adjust_lambda_proxy_class_dictionary();



302   static void serialize_dictionary_headers(class SerializeClosure* soc,
303                                            bool is_static_archive = true);
304   static void serialize_vm_classes(class SerializeClosure* soc);
305   static void print() { return print_on(tty); }
306   static void print_on(outputStream* st) NOT_CDS_RETURN;
307   static void print_shared_archive(outputStream* st, bool is_static = true) NOT_CDS_RETURN;
308   static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
309   static bool is_dumptime_table_empty() NOT_CDS_RETURN_(true);
310   static bool is_supported_invokedynamic(BootstrapInfo* bsi) NOT_CDS_RETURN_(false);
311   DEBUG_ONLY(static bool class_loading_may_happen() {return _class_loading_may_happen;})
312 




















313 #ifdef ASSERT
314   // This object marks a critical period when writing the CDS archive. During this
315   // period, the JVM must not load any new classes, so as to avoid adding new
316   // items in the SystemDictionaryShared::_dumptime_table.
317   class NoClassLoadingMark: public StackObj {
318   public:
319     NoClassLoadingMark() {
320       assert(_class_loading_may_happen, "must not be nested");
321       _class_loading_may_happen = false;
322     }
323     ~NoClassLoadingMark() {
324       _class_loading_may_happen = true;
325     }
326   };
327 #endif
328 
329   template <typename T>
330   static unsigned int hash_for_shared_dictionary_quick(T* ptr) {
331     assert(MetaspaceObj::is_shared((const MetaspaceObj*)ptr), "must be");
332     assert(ptr > (T*)SharedBaseAddress, "must be");
333     uintx offset = uintx(ptr) - uintx(SharedBaseAddress);
334     return primitive_hash<uintx>(offset);
335   }
336 
337   static unsigned int hash_for_shared_dictionary(address ptr);


338 };
339 
340 #endif // SHARE_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP

  1 /*
  2  * Copyright (c) 2014, 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_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
 26 #define SHARE_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
 27 
 28 #include "cds/cds_globals.hpp"
 29 #include "cds/filemap.hpp"
 30 #include "cds/dumpTimeClassInfo.hpp"
 31 #include "cds/lambdaProxyClassDictionary.hpp"
 32 #include "cds/methodDataDictionary.hpp"
 33 #include "cds/runTimeClassInfo.hpp"
 34 #include "classfile/classLoaderData.hpp"
 35 #include "classfile/packageEntry.hpp"
 36 #include "classfile/systemDictionary.hpp"
 37 #include "oops/klass.hpp"
 38 #include "oops/oopHandle.hpp"
 39 #include "oops/trainingData.hpp"
 40 
 41 
 42 /*===============================================================================
 43 
 44     Handling of the classes in the AppCDS archive
 45 
 46     To ensure safety and to simplify the implementation, archived classes are
 47     "segregated" into 2 types. The following rules describe how they
 48     are stored and looked up.
 49 
 50 [1] Category of archived classes
 51 
 52     There are 2 disjoint groups of classes stored in the AppCDS archive:
 53 
 54     BUILTIN:              These classes may be defined ONLY by the BOOT/PLATFORM/APP
 55                           loaders.
 56 
 57     UNREGISTERED:         These classes may be defined ONLY by a ClassLoader
 58                           instance that's not listed above (using fingerprint matching)
 59 

129   SharedClassLoadingMark(Thread* current, InstanceKlass* ik) : THREAD(current), _klass(ik) {}
130   ~SharedClassLoadingMark() {
131     assert(THREAD != nullptr, "Current thread is nullptr");
132     assert(_klass != nullptr, "InstanceKlass is nullptr");
133     if (HAS_PENDING_EXCEPTION) {
134       if (_klass->is_shared()) {
135         _klass->set_shared_loading_failed();
136       }
137     }
138   }
139 };
140 
141 class SystemDictionaryShared: public SystemDictionary {
142   friend class ExcludeDumpTimeSharedClasses;
143   friend class CleanupDumpTimeLambdaProxyClassTable;
144 
145   struct ArchiveInfo {
146     RunTimeSharedDictionary _builtin_dictionary;
147     RunTimeSharedDictionary _unregistered_dictionary;
148     LambdaProxyClassDictionary _lambda_proxy_class_dictionary;
149     MethodDataInfoDictionary _method_info_dictionary;
150 
151     const RunTimeLambdaProxyClassInfo* lookup_lambda_proxy_class(LambdaProxyClassKey* key) {
152       return _lambda_proxy_class_dictionary.lookup(key, key->hash(), 0);
153     }
154 
155     const RunTimeMethodDataInfo* lookup_method_info(Method* m) {
156       MethodDataKey key(m);
157       return _method_info_dictionary.lookup(&key, key.hash(), 0);
158     }
159 
160     void print_on(const char* prefix, outputStream* st);
161     void print_table_statistics(const char* prefix, outputStream* st);
162   };
163 
164 public:
165   enum : char {
166     FROM_FIELD_IS_PROTECTED = 1 << 0,
167     FROM_IS_ARRAY           = 1 << 1,
168     FROM_IS_OBJECT          = 1 << 2
169   };
170 
171 private:
172 
173   static DumpTimeSharedClassTable* _dumptime_table;
174   static DumpTimeLambdaProxyClassDictionary* _dumptime_lambda_proxy_class_dictionary;
175 
176   static DumpTimeMethodInfoDictionary* _dumptime_method_info_dictionary;
177   static DumpTimeMethodInfoDictionary* _cloned_dumptime_method_info_dictionary;
178 
179   static ArchiveInfo _static_archive;
180   static ArchiveInfo _dynamic_archive;
181 
182   static ArchiveInfo* get_archive(bool is_static_archive) {
183     return is_static_archive ? &_static_archive : &_dynamic_archive;
184   }
185 
186   static InstanceKlass* load_shared_class_for_builtin_loader(
187                                                Symbol* class_name,
188                                                Handle class_loader,
189                                                TRAPS);
190   static InstanceKlass* acquire_class_for_current_thread(
191                                  InstanceKlass *ik,
192                                  Handle class_loader,
193                                  Handle protection_domain,
194                                  const ClassFileStream* cfs,
195                                  TRAPS);
196 





197   static void write_dictionary(RunTimeSharedDictionary* dictionary,
198                                bool is_builtin);
199   static void write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary* dictionary);
200   static void write_method_info_dictionary(MethodDataInfoDictionary* dictionary);
201   static void cleanup_lambda_proxy_class_dictionary();
202   static void cleanup_method_info_dictionary();
203   static void reset_registered_lambda_proxy_class(InstanceKlass* ik);

204   static bool is_registered_lambda_proxy_class(InstanceKlass* ik);
205   static bool check_for_exclusion_impl(InstanceKlass* k);
206   static void remove_dumptime_info(InstanceKlass* k) NOT_CDS_RETURN;

207   static InstanceKlass* retrieve_lambda_proxy_class(const RunTimeLambdaProxyClassInfo* info) NOT_CDS_RETURN_(nullptr);
208 
209   DEBUG_ONLY(static bool _class_loading_may_happen;)
210 
211 public:
212   // Guaranteed to return non-null value for non-shared classes.
213   // k must not be a shared class.
214   static DumpTimeClassInfo* get_info(InstanceKlass* k);
215   static DumpTimeClassInfo* get_info_locked(InstanceKlass* k);
216   static DumpTimeSharedClassTable* dumptime_table() { return _dumptime_table; }
217 
218   static bool has_been_redefined(InstanceKlass* k);
219   static bool is_jfr_event_class(InstanceKlass *k);
220   static bool is_hidden_lambda_proxy(InstanceKlass* ik);
221   static bool is_early_klass(InstanceKlass* k);   // Was k loaded while JvmtiExport::is_early_phase()==true
222   static bool has_archived_enum_objs(InstanceKlass* ik);
223   static void set_has_archived_enum_objs(InstanceKlass* ik);
224 
225   static InstanceKlass* find_builtin_class(Symbol* class_name);
226 
227   static const RunTimeClassInfo* find_record(RunTimeSharedDictionary* static_dict,
228                                                    RunTimeSharedDictionary* dynamic_dict,
229                                                    Symbol* name);
230 
231   static bool has_platform_or_app_classes();
232 
233   // Called by PLATFORM/APP loader only
234   static InstanceKlass* find_or_load_shared_class(Symbol* class_name,
235                                                Handle class_loader,
236                                                TRAPS);
237 
238   static void preload_archived_classes(TRAPS);
239 
240   static void allocate_shared_data_arrays(int size, TRAPS);
241 
242   static bool is_builtin_loader(ClassLoaderData* loader_data);
243 
244   static InstanceKlass* lookup_super_for_unregistered_class(Symbol* class_name,
245                                                             Symbol* super_name,  bool is_superclass);
246 
247   static void initialize() NOT_CDS_RETURN;
248   static void init_dumptime_info(InstanceKlass* k) NOT_CDS_RETURN;
249   static void handle_class_unloading(InstanceKlass* k) NOT_CDS_RETURN;
250 
251   static bool can_be_preinited(InstanceKlass* ik);
252   static bool can_be_preinited_locked(InstanceKlass* ik);
253   static void reset_preinit_check();
254 
255   static Dictionary* boot_loader_dictionary() {
256     return ClassLoaderData::the_null_class_loader_data()->dictionary();
257   }
258 
259   static void update_shared_entry(InstanceKlass* klass, int id);
260   static void set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs);
261 
262   static InstanceKlass* lookup_from_stream(Symbol* class_name,
263                                            Handle class_loader,
264                                            Handle protection_domain,
265                                            const ClassFileStream* st,
266                                            TRAPS);
267   // "verification_constraints" are a set of checks performed by
268   // VerificationType::is_reference_assignable_from when verifying a shared class during
269   // dump time.
270   //
271   // With AppCDS, it is possible to override archived classes by calling
272   // ClassLoader.defineClass() directly. SystemDictionary::load_shared_class() already
273   // ensures that you cannot load a shared class if its super type(s) are changed. However,
274   // we need an additional check to ensure that the verification_constraints did not change

285                                      InstanceKlass* lambda_ik,
286                                      Symbol* invoked_name,
287                                      Symbol* invoked_type,
288                                      Symbol* method_type,
289                                      Method* member_method,
290                                      Symbol* instantiated_method_type, TRAPS) NOT_CDS_RETURN;
291   static void add_to_dump_time_lambda_proxy_class_dictionary(LambdaProxyClassKey& key,
292                                                              InstanceKlass* proxy_klass) NOT_CDS_RETURN;
293   static InstanceKlass* get_shared_lambda_proxy_class(InstanceKlass* caller_ik,
294                                                       Symbol* invoked_name,
295                                                       Symbol* invoked_type,
296                                                       Symbol* method_type,
297                                                       Method* member_method,
298                                                       Symbol* instantiated_method_type) NOT_CDS_RETURN_(nullptr);
299   static InstanceKlass* get_shared_nest_host(InstanceKlass* lambda_ik) NOT_CDS_RETURN_(nullptr);
300   static InstanceKlass* prepare_shared_lambda_proxy_class(InstanceKlass* lambda_ik,
301                                                           InstanceKlass* caller_ik, TRAPS) NOT_CDS_RETURN_(nullptr);
302   static bool check_linking_constraints(Thread* current, InstanceKlass* klass) NOT_CDS_RETURN_(false);
303   static void record_linking_constraint(Symbol* name, InstanceKlass* klass,
304                                      Handle loader1, Handle loader2) NOT_CDS_RETURN;
305   static bool is_builtin(const InstanceKlass* k) {
306     return (k->shared_classpath_index() != UNREGISTERED_INDEX);
307   }
308   static bool add_unregistered_class(Thread* current, InstanceKlass* k);
309 
310   static void check_excluded_classes();
311   static bool check_for_exclusion(InstanceKlass* k, DumpTimeClassInfo* info);
312   static void validate_before_archiving(InstanceKlass* k);
313   static bool is_excluded_class(InstanceKlass* k);
314   static void set_excluded(InstanceKlass* k);
315   static void set_excluded_locked(InstanceKlass* k);
316   static bool warn_excluded(InstanceKlass* k, const char* reason);
317   static void dumptime_classes_do(class MetaspaceClosure* it);
318   static size_t estimate_size_for_archive();
319   static void write_to_archive(bool is_static_archive = true);
320   static void adjust_lambda_proxy_class_dictionary();
321 
322   static void adjust_method_info_dictionary();
323 
324   static void serialize_dictionary_headers(class SerializeClosure* soc,
325                                            bool is_static_archive = true);
326   static void serialize_vm_classes(class SerializeClosure* soc);
327   static void print() { return print_on(tty); }
328   static void print_on(outputStream* st) NOT_CDS_RETURN;
329   static void print_shared_archive(outputStream* st, bool is_static = true) NOT_CDS_RETURN;
330   static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
331   static bool is_dumptime_table_empty() NOT_CDS_RETURN_(true);
332   static bool is_supported_invokedynamic(BootstrapInfo* bsi) NOT_CDS_RETURN_(false);
333   DEBUG_ONLY(static bool class_loading_may_happen() {return _class_loading_may_happen;})
334 
335   static MethodData* lookup_method_data(Method* m) {
336     const RunTimeMethodDataInfo* info = _dynamic_archive.lookup_method_info(m);
337     if (info != nullptr) {
338       return info->method_data();
339     }
340     return nullptr;
341   }
342 
343   static MethodCounters* lookup_method_counters(Method* m) {
344     const RunTimeMethodDataInfo* info = _dynamic_archive.lookup_method_info(m);
345     if (info != nullptr) {
346       return info->method_counters();
347     }
348     return nullptr;
349   }
350 
351   // Do not archive any new InstanceKlasses that are loaded after this method is called.
352   // This avoids polluting the archive with classes that are only used by GenerateJLIClassesHelper.
353   static void ignore_new_classes();
354 
355 #ifdef ASSERT
356   // This object marks a critical period when writing the CDS archive. During this
357   // period, the JVM must not load any new classes, so as to avoid adding new
358   // items in the SystemDictionaryShared::_dumptime_table.
359   class NoClassLoadingMark: public StackObj {
360   public:
361     NoClassLoadingMark() {
362       assert(_class_loading_may_happen, "must not be nested");
363       _class_loading_may_happen = false;
364     }
365     ~NoClassLoadingMark() {
366       _class_loading_may_happen = true;
367     }
368   };
369 #endif
370 
371   template <typename T>
372   static unsigned int hash_for_shared_dictionary_quick(T* ptr) {
373     assert(MetaspaceObj::is_shared((const MetaspaceObj*)ptr), "must be");
374     assert(ptr > (T*)SharedBaseAddress, "must be");
375     uintx offset = uintx(ptr) - uintx(SharedBaseAddress);
376     return primitive_hash<uintx>(offset);
377   }
378 
379   static unsigned int hash_for_shared_dictionary(address ptr);
380   static const char* class_loader_name_for_shared(Klass* k);
381   static void create_loader_positive_lookup_cache(TRAPS);
382 };
383 
384 #endif // SHARE_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
< prev index next >