137
138 // Integer for 0 and 1 are in java/lang/Integer$IntegerCache and are archived
139 ADD_EXCL("sun/invoke/util/ValueConversions", "ONE_INT", // E
140 "ZERO_INT"); // E
141
142 if (CDSConfig::is_dumping_method_handles()) {
143 ADD_EXCL("java/lang/invoke/InvokerBytecodeGenerator", "MEMBERNAME_FACTORY", // D
144 "CD_Object_array", // E same as <...>ConstantUtils.CD_Object_array::CD_Object
145 "INVOKER_SUPER_DESC"); // E same as java.lang.constant.ConstantDescs::CD_Object
146
147 ADD_EXCL("java/lang/runtime/ObjectMethods", "CLASS_IS_INSTANCE", // D
148 "FALSE", // D
149 "TRUE", // D
150 "ZERO"); // D
151 }
152
153 if (CDSConfig::is_dumping_aot_linked_classes()) {
154 ADD_EXCL("java/lang/Package$VersionInfo", "NULL_VERSION_INFO"); // D
155 }
156
157 # undef ADD_EXCL
158
159 if (CDSConfig::is_initing_classes_at_dump_time()) {
160 add_shared_secret_accessors();
161 }
162 ClassLoaderDataGraph::classes_do(this);
163 }
164
165 // We allow only "stateless" accessors in the SharedSecrets class to be AOT-initialized, for example,
166 // in the following pattern:
167 //
168 // class URL {
169 // static {
170 // SharedSecrets.setJavaNetURLAccess(
171 // new JavaNetURLAccess() { ... });
172 // }
173 //
174 // This initializes the field SharedSecrets::javaNetUriAccess, whose type (the inner case in the
175 // above example) has no fields (static or otherwise) and is not a hidden class, so it cannot possibly
176 // capture any transient state from the assembly phase that might become invalid in the production run.
261 log_error(aot, heap)("Please see cdsHeapVerifier.cpp and aotClassInitializer.cpp for details");
262 AOTMetaspace::unrecoverable_writing_error();
263 }
264 }
265
266 class CDSHeapVerifier::CheckStaticFields : public FieldClosure {
267 CDSHeapVerifier* _verifier;
268 InstanceKlass* _ik; // The class whose static fields are being checked.
269 const char** _exclusions;
270 public:
271 CheckStaticFields(CDSHeapVerifier* verifier, InstanceKlass* ik)
272 : _verifier(verifier), _ik(ik) {
273 _exclusions = _verifier->find_exclusion(_ik);
274 }
275
276 void do_field(fieldDescriptor* fd) {
277 if (fd->field_type() != T_OBJECT) {
278 return;
279 }
280
281 oop static_obj_field = _ik->java_mirror()->obj_field(fd->offset());
282 if (static_obj_field != nullptr) {
283 if (_verifier->is_shared_secret_accessor(static_obj_field)) {
284 return;
285 }
286
287 Klass* field_type = static_obj_field->klass();
288 if (_exclusions != nullptr) {
289 for (const char** p = _exclusions; *p != nullptr; p++) {
290 if (fd->name()->equals(*p)) {
291 return;
292 }
293 }
294 }
295
296 if (fd->is_final() && java_lang_String::is_instance(static_obj_field) && fd->has_initial_value()) {
297 // This field looks like like this in the Java source:
298 // static final SOME_STRING = "a string literal";
299 // This string literal has been stored in the shared string table, so it's OK
300 // for the archived objects to refer to it.
|
137
138 // Integer for 0 and 1 are in java/lang/Integer$IntegerCache and are archived
139 ADD_EXCL("sun/invoke/util/ValueConversions", "ONE_INT", // E
140 "ZERO_INT"); // E
141
142 if (CDSConfig::is_dumping_method_handles()) {
143 ADD_EXCL("java/lang/invoke/InvokerBytecodeGenerator", "MEMBERNAME_FACTORY", // D
144 "CD_Object_array", // E same as <...>ConstantUtils.CD_Object_array::CD_Object
145 "INVOKER_SUPER_DESC"); // E same as java.lang.constant.ConstantDescs::CD_Object
146
147 ADD_EXCL("java/lang/runtime/ObjectMethods", "CLASS_IS_INSTANCE", // D
148 "FALSE", // D
149 "TRUE", // D
150 "ZERO"); // D
151 }
152
153 if (CDSConfig::is_dumping_aot_linked_classes()) {
154 ADD_EXCL("java/lang/Package$VersionInfo", "NULL_VERSION_INFO"); // D
155 }
156
157 if (CDSConfig::is_dumping_dynamic_proxies()) {
158 ADD_EXCL("java/lang/reflect/ProxyGenerator", "CD_Object_array"); // D
159 }
160
161 // These are used by BuiltinClassLoader::negativeLookupCache, etc but seem to be
162 // OK. TODO - we should completely disable the caching unless ArchiveLoaderLookupCache
163 // is enabled
164 ADD_EXCL("java/lang/Boolean", "TRUE", // E
165 "FALSE"); // E
166
167 # undef ADD_EXCL
168
169 if (CDSConfig::is_initing_classes_at_dump_time()) {
170 add_shared_secret_accessors();
171 }
172 ClassLoaderDataGraph::classes_do(this);
173 }
174
175 // We allow only "stateless" accessors in the SharedSecrets class to be AOT-initialized, for example,
176 // in the following pattern:
177 //
178 // class URL {
179 // static {
180 // SharedSecrets.setJavaNetURLAccess(
181 // new JavaNetURLAccess() { ... });
182 // }
183 //
184 // This initializes the field SharedSecrets::javaNetUriAccess, whose type (the inner case in the
185 // above example) has no fields (static or otherwise) and is not a hidden class, so it cannot possibly
186 // capture any transient state from the assembly phase that might become invalid in the production run.
271 log_error(aot, heap)("Please see cdsHeapVerifier.cpp and aotClassInitializer.cpp for details");
272 AOTMetaspace::unrecoverable_writing_error();
273 }
274 }
275
276 class CDSHeapVerifier::CheckStaticFields : public FieldClosure {
277 CDSHeapVerifier* _verifier;
278 InstanceKlass* _ik; // The class whose static fields are being checked.
279 const char** _exclusions;
280 public:
281 CheckStaticFields(CDSHeapVerifier* verifier, InstanceKlass* ik)
282 : _verifier(verifier), _ik(ik) {
283 _exclusions = _verifier->find_exclusion(_ik);
284 }
285
286 void do_field(fieldDescriptor* fd) {
287 if (fd->field_type() != T_OBJECT) {
288 return;
289 }
290
291 if (fd->signature()->equals("Ljdk/internal/reflect/ReflectionFactory;")) {
292 return;
293 }
294 oop static_obj_field = _ik->java_mirror()->obj_field(fd->offset());
295 if (static_obj_field != nullptr) {
296 if (_verifier->is_shared_secret_accessor(static_obj_field)) {
297 return;
298 }
299
300 Klass* field_type = static_obj_field->klass();
301 if (_exclusions != nullptr) {
302 for (const char** p = _exclusions; *p != nullptr; p++) {
303 if (fd->name()->equals(*p)) {
304 return;
305 }
306 }
307 }
308
309 if (fd->is_final() && java_lang_String::is_instance(static_obj_field) && fd->has_initial_value()) {
310 // This field looks like like this in the Java source:
311 // static final SOME_STRING = "a string literal";
312 // This string literal has been stored in the shared string table, so it's OK
313 // for the archived objects to refer to it.
|