1 /*
  2  * Copyright (c) 2022, 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 #include "precompiled.hpp"
 26 #include "cds/aotClassLinker.hpp"
 27 #include "cds/aotConstantPoolResolver.hpp"
 28 #include "cds/archiveBuilder.hpp"
 29 #include "cds/cdsConfig.hpp"
 30 #include "classfile/systemDictionary.hpp"
 31 #include "classfile/systemDictionaryShared.hpp"
 32 #include "classfile/vmClasses.hpp"
 33 #include "interpreter/bytecodeStream.hpp"
 34 #include "interpreter/interpreterRuntime.hpp"
 35 #include "memory/resourceArea.hpp"
 36 #include "oops/constantPool.inline.hpp"
 37 #include "oops/instanceKlass.hpp"
 38 #include "oops/klass.inline.hpp"
 39 #include "runtime/handles.inline.hpp"
 40 
 41 AOTConstantPoolResolver::ClassesTable* AOTConstantPoolResolver::_processed_classes = nullptr;
 42 
 43 void AOTConstantPoolResolver::initialize() {
 44   assert(_processed_classes == nullptr, "must be");
 45   _processed_classes = new (mtClass)ClassesTable();
 46 }
 47 
 48 void AOTConstantPoolResolver::dispose() {
 49   assert(_processed_classes != nullptr, "must be");
 50   delete _processed_classes;
 51   _processed_classes = nullptr;
 52 }
 53 
 54 // Returns true if we CAN PROVE that cp_index will always resolve to
 55 // the same information at both dump time and run time. This is a
 56 // necessary (but not sufficient) condition for pre-resolving cp_index
 57 // during CDS archive assembly.
 58 bool AOTConstantPoolResolver::is_resolution_deterministic(ConstantPool* cp, int cp_index) {
 59   assert(!is_in_archivebuilder_buffer(cp), "sanity");
 60 
 61   if (cp->tag_at(cp_index).is_klass()) {
 62     // We require cp_index to be already resolved. This is fine for now, are we
 63     // currently archive only CP entries that are already resolved.
 64     Klass* resolved_klass = cp->resolved_klass_at(cp_index);
 65     return resolved_klass != nullptr && is_class_resolution_deterministic(cp->pool_holder(), resolved_klass);
 66   } else if (cp->tag_at(cp_index).is_invoke_dynamic()) {
 67     return is_indy_resolution_deterministic(cp, cp_index);
 68   } else if (cp->tag_at(cp_index).is_field() ||
 69              cp->tag_at(cp_index).is_method() ||
 70              cp->tag_at(cp_index).is_interface_method()) {
 71     int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
 72     if (!cp->tag_at(klass_cp_index).is_klass()) {
 73       // Not yet resolved
 74       return false;
 75     }
 76     Klass* k = cp->resolved_klass_at(klass_cp_index);
 77     if (!is_class_resolution_deterministic(cp->pool_holder(), k)) {
 78       return false;
 79     }
 80 
 81     if (!k->is_instance_klass()) {
 82       // TODO: support non instance klasses as well.
 83       return false;
 84     }
 85 
 86     // Here, We don't check if this entry can actually be resolved to a valid Field/Method.
 87     // This method should be called by the ConstantPool to check Fields/Methods that
 88     // have already been successfully resolved.
 89     return true;
 90   } else {
 91     return false;
 92   }
 93 }
 94 
 95 bool AOTConstantPoolResolver::is_class_resolution_deterministic(InstanceKlass* cp_holder, Klass* resolved_class) {
 96   assert(!is_in_archivebuilder_buffer(cp_holder), "sanity");
 97   assert(!is_in_archivebuilder_buffer(resolved_class), "sanity");
 98 
 99   if (resolved_class->is_instance_klass()) {
100     InstanceKlass* ik = InstanceKlass::cast(resolved_class);
101 
102     if (!ik->is_shared() && SystemDictionaryShared::is_excluded_class(ik)) {
103       return false;
104     }
105 
106     if (cp_holder->is_subtype_of(ik)) {
107       // All super types of ik will be resolved in ik->class_loader() before
108       // ik is defined in this loader, so it's safe to archive the resolved klass reference.
109       return true;
110     }
111 
112     if (CDSConfig::is_dumping_aot_linked_classes()) {
113       // Need to call try_add_candidate instead of is_candidate, as this may be called
114       // before AOTClassLinker::add_candidates().
115       if (AOTClassLinker::try_add_candidate(ik)) {
116         return true;
117       } else {
118         return false;
119       }
120     } else if (AOTClassLinker::is_vm_class(ik)) {
121       if (ik->class_loader() != cp_holder->class_loader()) {
122         // At runtime, cp_holder() may not be able to resolve to the same
123         // ik. For example, a different version of ik may be defined in
124         // cp->pool_holder()'s loader using MethodHandles.Lookup.defineClass().
125         return false;
126       } else {
127         return true;
128       }
129     } else {
130       return false;
131     }
132   } else if (resolved_class->is_objArray_klass()) {
133     Klass* elem = ObjArrayKlass::cast(resolved_class)->bottom_klass();
134     if (elem->is_instance_klass()) {
135       return is_class_resolution_deterministic(cp_holder, InstanceKlass::cast(elem));
136     } else if (elem->is_typeArray_klass()) {
137       return true;
138     } else {
139       return false;
140     }
141   } else if (resolved_class->is_typeArray_klass()) {
142     return true;
143   } else {
144     return false;
145   }
146 }
147 
148 void AOTConstantPoolResolver::dumptime_resolve_constants(InstanceKlass* ik, TRAPS) {
149   if (!ik->is_linked()) {
150     return;
151   }
152   bool first_time;
153   _processed_classes->put_if_absent(ik, &first_time);
154   if (!first_time) {
155     // We have already resolved the constants in class, so no need to do it again.
156     return;
157   }
158 
159   constantPoolHandle cp(THREAD, ik->constants());
160   for (int cp_index = 1; cp_index < cp->length(); cp_index++) { // Index 0 is unused
161     switch (cp->tag_at(cp_index).value()) {
162     case JVM_CONSTANT_String:
163       resolve_string(cp, cp_index, CHECK); // may throw OOM when interning strings.
164       break;
165     }
166   }
167 }
168 
169 // This works only for the boot/platform/app loaders
170 Klass* AOTConstantPoolResolver::find_loaded_class(Thread* current, oop class_loader, Symbol* name) {
171   HandleMark hm(current);
172   Handle h_loader(current, class_loader);
173   Klass* k = SystemDictionary::find_instance_or_array_klass(current, name, h_loader);
174   if (k != nullptr) {
175     return k;
176   }
177   if (h_loader() == SystemDictionary::java_system_loader()) {
178     return find_loaded_class(current, SystemDictionary::java_platform_loader(), name);
179   } else if (h_loader() == SystemDictionary::java_platform_loader()) {
180     return find_loaded_class(current, nullptr, name);
181   } else {
182     assert(h_loader() == nullptr, "This function only works for boot/platform/app loaders %p %p %p",
183            cast_from_oop<address>(h_loader()),
184            cast_from_oop<address>(SystemDictionary::java_system_loader()),
185            cast_from_oop<address>(SystemDictionary::java_platform_loader()));
186   }
187 
188   return nullptr;
189 }
190 
191 Klass* AOTConstantPoolResolver::find_loaded_class(Thread* current, ConstantPool* cp, int class_cp_index) {
192   Symbol* name = cp->klass_name_at(class_cp_index);
193   return find_loaded_class(current, cp->pool_holder()->class_loader(), name);
194 }
195 
196 #if INCLUDE_CDS_JAVA_HEAP
197 void AOTConstantPoolResolver::resolve_string(constantPoolHandle cp, int cp_index, TRAPS) {
198   if (CDSConfig::is_dumping_heap()) {
199     int cache_index = cp->cp_to_object_index(cp_index);
200     ConstantPool::string_at_impl(cp, cp_index, cache_index, CHECK);
201   }
202 }
203 #endif
204 
205 void AOTConstantPoolResolver::preresolve_class_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list) {
206   if (!SystemDictionaryShared::is_builtin_loader(ik->class_loader_data())) {
207     return;
208   }
209 
210   JavaThread* THREAD = current;
211   constantPoolHandle cp(THREAD, ik->constants());
212   for (int cp_index = 1; cp_index < cp->length(); cp_index++) {
213     if (cp->tag_at(cp_index).value() == JVM_CONSTANT_UnresolvedClass) {
214       if (preresolve_list != nullptr && preresolve_list->at(cp_index) == false) {
215         // This class was not resolved during trial run. Don't attempt to resolve it. Otherwise
216         // the compiler may generate less efficient code.
217         continue;
218       }
219       if (find_loaded_class(current, cp(), cp_index) == nullptr) {
220         // Do not resolve any class that has not been loaded yet
221         continue;
222       }
223       Klass* resolved_klass = cp->klass_at(cp_index, THREAD);
224       if (HAS_PENDING_EXCEPTION) {
225         CLEAR_PENDING_EXCEPTION; // just ignore
226       } else {
227         log_trace(cds, resolve)("Resolved class  [%3d] %s -> %s", cp_index, ik->external_name(),
228                                 resolved_klass->external_name());
229       }
230     }
231   }
232 }
233 
234 void AOTConstantPoolResolver::preresolve_field_and_method_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list) {
235   JavaThread* THREAD = current;
236   constantPoolHandle cp(THREAD, ik->constants());
237   if (cp->cache() == nullptr) {
238     return;
239   }
240   for (int i = 0; i < ik->methods()->length(); i++) {
241     Method* m = ik->methods()->at(i);
242     BytecodeStream bcs(methodHandle(THREAD, m));
243     while (!bcs.is_last_bytecode()) {
244       bcs.next();
245       Bytecodes::Code raw_bc = bcs.raw_code();
246       switch (raw_bc) {
247       case Bytecodes::_getfield:
248       case Bytecodes::_putfield:
249         maybe_resolve_fmi_ref(ik, m, raw_bc, bcs.get_index_u2(), preresolve_list, THREAD);
250         if (HAS_PENDING_EXCEPTION) {
251           CLEAR_PENDING_EXCEPTION; // just ignore
252         }
253         break;
254       case Bytecodes::_invokehandle:
255       case Bytecodes::_invokespecial:
256       case Bytecodes::_invokevirtual:
257       case Bytecodes::_invokeinterface:
258         maybe_resolve_fmi_ref(ik, m, raw_bc, bcs.get_index_u2(), preresolve_list, THREAD);
259         if (HAS_PENDING_EXCEPTION) {
260           CLEAR_PENDING_EXCEPTION; // just ignore
261         }
262         break;
263       default:
264         break;
265       }
266     }
267   }
268 }
269 
270 void AOTConstantPoolResolver::maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m, Bytecodes::Code bc, int raw_index,
271                                            GrowableArray<bool>* preresolve_list, TRAPS) {
272   methodHandle mh(THREAD, m);
273   constantPoolHandle cp(THREAD, ik->constants());
274   HandleMark hm(THREAD);
275   int cp_index = cp->to_cp_index(raw_index, bc);
276 
277   if (cp->is_resolved(raw_index, bc)) {
278     return;
279   }
280 
281   if (preresolve_list != nullptr && preresolve_list->at(cp_index) == false) {
282     // This field wasn't resolved during the trial run. Don't attempt to resolve it. Otherwise
283     // the compiler may generate less efficient code.
284     return;
285   }
286 
287   int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
288   if (find_loaded_class(THREAD, cp(), klass_cp_index) == nullptr) {
289     // Do not resolve any field/methods from a class that has not been loaded yet.
290     return;
291   }
292 
293   Klass* resolved_klass = cp->klass_ref_at(raw_index, bc, CHECK);
294 
295   switch (bc) {
296   case Bytecodes::_getfield:
297   case Bytecodes::_putfield:
298     InterpreterRuntime::resolve_get_put(bc, raw_index, mh, cp, false /*initialize_holder*/, CHECK);
299     break;
300 
301   case Bytecodes::_invokevirtual:
302   case Bytecodes::_invokespecial:
303   case Bytecodes::_invokeinterface:
304     InterpreterRuntime::cds_resolve_invoke(bc, raw_index, cp, CHECK);
305     break;
306 
307   case Bytecodes::_invokehandle:
308     InterpreterRuntime::cds_resolve_invokehandle(raw_index, cp, CHECK);
309     break;
310 
311   default:
312     ShouldNotReachHere();
313   }
314 
315   if (log_is_enabled(Trace, cds, resolve)) {
316     ResourceMark rm(THREAD);
317     bool resolved = cp->is_resolved(raw_index, bc);
318     Symbol* name = cp->name_ref_at(raw_index, bc);
319     Symbol* signature = cp->signature_ref_at(raw_index, bc);
320     log_trace(cds, resolve)("%s %s [%3d] %s -> %s.%s:%s",
321                             (resolved ? "Resolved" : "Failed to resolve"),
322                             Bytecodes::name(bc), cp_index, ik->external_name(),
323                             resolved_klass->external_name(),
324                             name->as_C_string(), signature->as_C_string());
325   }
326 }
327 
328 void AOTConstantPoolResolver::preresolve_indy_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list) {
329   JavaThread* THREAD = current;
330   constantPoolHandle cp(THREAD, ik->constants());
331   if (!CDSConfig::is_dumping_invokedynamic() || cp->cache() == nullptr) {
332     return;
333   }
334 
335   assert(preresolve_list != nullptr, "preresolve_indy_cp_entries() should not be called for "
336          "regenerated LambdaForm Invoker classes, which should not have indys anyway.");
337 
338   Array<ResolvedIndyEntry>* indy_entries = cp->cache()->resolved_indy_entries();
339   for (int i = 0; i < indy_entries->length(); i++) {
340     ResolvedIndyEntry* rie = indy_entries->adr_at(i);
341     int cp_index = rie->constant_pool_index();
342     if (preresolve_list->at(cp_index) == true) {
343       if (!rie->is_resolved() && is_indy_resolution_deterministic(cp(), cp_index)) {
344         InterpreterRuntime::cds_resolve_invokedynamic(i, cp, THREAD);
345         if (HAS_PENDING_EXCEPTION) {
346           CLEAR_PENDING_EXCEPTION; // just ignore
347         }
348       }
349       if (log_is_enabled(Trace, cds, resolve)) {
350         ResourceMark rm(THREAD);
351         log_trace(cds, resolve)("%s indy   [%3d] %s",
352                                 rie->is_resolved() ? "Resolved" : "Failed to resolve",
353                                 cp_index, ik->external_name());
354       }
355     }
356   }
357 }
358 
359 // Check the MethodType signatures used by parameters to the indy BSMs. Make sure we don't
360 // use types that have been excluded, or else we might end up creating MethodTypes that cannot be stored
361 // in the AOT cache.
362 bool AOTConstantPoolResolver::check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret) {
363   ResourceMark rm;
364   for (SignatureStream ss(sig); !ss.is_done(); ss.next()) {
365     if (ss.is_reference()) {
366       Symbol* type = ss.as_symbol();
367       Klass* k = find_loaded_class(Thread::current(), cp->pool_holder()->class_loader(), type);
368       if (k == nullptr) {
369         return false;
370       }
371 
372       if (SystemDictionaryShared::should_be_excluded(k)) {
373         if (log_is_enabled(Warning, cds, resolve)) {
374           ResourceMark rm;
375           log_warning(cds, resolve)("Cannot aot-resolve Lambda proxy because %s is excluded", k->external_name());
376         }
377         return false;
378       }
379 
380       if (ss.at_return_type() && return_type_ret != nullptr) {
381         *return_type_ret = k;
382       }
383     }
384   }
385   return true;
386 }
387 
388 bool AOTConstantPoolResolver::check_lambda_metafactory_signature(ConstantPool* cp, Symbol* sig) {
389   Klass* k;
390   if (!check_methodtype_signature(cp, sig, &k)) {
391     return false;
392   }
393 
394   // <k> is the interface type implemented by the lambda proxy
395   if (!k->is_interface()) {
396     // cp->pool_holder() doesn't look like a valid class generated by javac
397     return false;
398   }
399 
400 
401   // The linked lambda callsite has an instance of the interface implemented by this lambda. If this
402   // interface requires its <clinit> to be executed, then we must delay the execution to the production run
403   // as <clinit> can have side effects ==> exclude such cases.
404   InstanceKlass* intf = InstanceKlass::cast(k);
405   bool exclude = intf->interface_needs_clinit_execution_as_super();
406   if (log_is_enabled(Debug, cds, resolve)) {
407     ResourceMark rm;
408     log_debug(cds, resolve)("%s aot-resolve Lambda proxy of interface type %s",
409                             exclude ? "Cannot" : "Can", k->external_name());
410   }
411   return !exclude;
412 }
413 
414 bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i) {
415   int mt_index = cp->operand_argument_index_at(bsms_attribute_index, arg_i);
416   if (!cp->tag_at(mt_index).is_method_type()) {
417     // malformed class?
418     return false;
419   }
420 
421   Symbol* sig = cp->method_type_signature_at(mt_index);
422   if (log_is_enabled(Debug, cds, resolve)) {
423     ResourceMark rm;
424     log_debug(cds, resolve)("Checking MethodType for LambdaMetafactory BSM arg %d: %s", arg_i, sig->as_C_string());
425   }
426 
427   return check_methodtype_signature(cp, sig);
428 }
429 
430 bool AOTConstantPoolResolver::check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i) {
431   int mh_index = cp->operand_argument_index_at(bsms_attribute_index, arg_i);
432   if (!cp->tag_at(mh_index).is_method_handle()) {
433     // malformed class?
434     return false;
435   }
436 
437   Symbol* sig = cp->method_handle_signature_ref_at(mh_index);
438   if (log_is_enabled(Debug, cds, resolve)) {
439     ResourceMark rm;
440     log_debug(cds, resolve)("Checking MethodType of MethodHandle for LambdaMetafactory BSM arg %d: %s", arg_i, sig->as_C_string());
441   }
442   return check_methodtype_signature(cp, sig);
443 }
444 
445 bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp, int cp_index) {
446   assert(cp->tag_at(cp_index).is_invoke_dynamic(), "sanity");
447   if (!CDSConfig::is_dumping_invokedynamic()) {
448     return false;
449   }
450 
451   InstanceKlass* pool_holder = cp->pool_holder();
452   if (!SystemDictionaryShared::is_builtin(pool_holder)) {
453     return false;
454   }
455 
456   int bsm = cp->bootstrap_method_ref_index_at(cp_index);
457   int bsm_ref = cp->method_handle_index_at(bsm);
458   Symbol* bsm_name = cp->uncached_name_ref_at(bsm_ref);
459   Symbol* bsm_signature = cp->uncached_signature_ref_at(bsm_ref);
460   Symbol* bsm_klass = cp->klass_name_at(cp->uncached_klass_ref_index_at(bsm_ref));
461 
462   // We currently support only StringConcatFactory::makeConcatWithConstants() and LambdaMetafactory::metafactory()
463   // We should mark the allowed BSMs in the JDK code using a private annotation.
464   // See notes on RFE JDK-8342481.
465 
466   if (bsm_klass->equals("java/lang/invoke/StringConcatFactory") &&
467       bsm_name->equals("makeConcatWithConstants") &&
468       bsm_signature->equals("(Ljava/lang/invoke/MethodHandles$Lookup;"
469                              "Ljava/lang/String;"
470                              "Ljava/lang/invoke/MethodType;"
471                              "Ljava/lang/String;"
472                              "[Ljava/lang/Object;"
473                             ")Ljava/lang/invoke/CallSite;")) {
474     Symbol* factory_type_sig = cp->uncached_signature_ref_at(cp_index);
475     if (log_is_enabled(Debug, cds, resolve)) {
476       ResourceMark rm;
477       log_debug(cds, resolve)("Checking StringConcatFactory callsite signature [%d]: %s", cp_index, factory_type_sig->as_C_string());
478     }
479 
480     Klass* k;
481     if (!check_methodtype_signature(cp, factory_type_sig, &k)) {
482       return false;
483     }
484     if (k != vmClasses::String_klass()) {
485       // bad class file?
486       return false;
487     }
488 
489     return true;
490   }
491 
492   if (bsm_klass->equals("java/lang/invoke/LambdaMetafactory") &&
493       bsm_name->equals("metafactory") &&
494       bsm_signature->equals("(Ljava/lang/invoke/MethodHandles$Lookup;"
495                              "Ljava/lang/String;"
496                              "Ljava/lang/invoke/MethodType;"
497                              "Ljava/lang/invoke/MethodType;"
498                              "Ljava/lang/invoke/MethodHandle;"
499                              "Ljava/lang/invoke/MethodType;"
500                             ")Ljava/lang/invoke/CallSite;")) {
501     /*
502      * An indy callsite is associated with the following MethodType and MethodHandles:
503      *
504      * https://github.com/openjdk/jdk/blob/580eb62dc097efeb51c76b095c1404106859b673/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java#L293-L309
505      *
506      * MethodType factoryType         The expected signature of the {@code CallSite}.  The
507      *                                parameter types represent the types of capture variables;
508      *                                the return type is the interface to implement.   When
509      *                                used with {@code invokedynamic}, this is provided by
510      *                                the {@code NameAndType} of the {@code InvokeDynamic}
511      *
512      * MethodType interfaceMethodType Signature and return type of method to be
513      *                                implemented by the function object.
514      *
515      * MethodHandle implementation    A direct method handle describing the implementation
516      *                                method which should be called (with suitable adaptation
517      *                                of argument types and return types, and with captured
518      *                                arguments prepended to the invocation arguments) at
519      *                                invocation time.
520      *
521      * MethodType dynamicMethodType   The signature and return type that should
522      *                                be enforced dynamically at invocation time.
523      *                                In simple use cases this is the same as
524      *                                {@code interfaceMethodType}.
525      */
526     Symbol* factory_type_sig = cp->uncached_signature_ref_at(cp_index);
527     if (log_is_enabled(Debug, cds, resolve)) {
528       ResourceMark rm;
529       log_debug(cds, resolve)("Checking indy callsite signature [%d]: %s", cp_index, factory_type_sig->as_C_string());
530     }
531 
532     if (!check_lambda_metafactory_signature(cp, factory_type_sig)) {
533       return false;
534     }
535 
536     int bsms_attribute_index = cp->bootstrap_methods_attribute_index(cp_index);
537     int arg_count = cp->operand_argument_count_at(bsms_attribute_index);
538     if (arg_count != 3) {
539       // Malformed class?
540       return false;
541     }
542 
543     // interfaceMethodType
544     if (!check_lambda_metafactory_methodtype_arg(cp, bsms_attribute_index, 0)) {
545       return false;
546     }
547 
548     // implementation
549     if (!check_lambda_metafactory_methodhandle_arg(cp, bsms_attribute_index, 1)) {
550       return false;
551     }
552 
553     // dynamicMethodType
554     if (!check_lambda_metafactory_methodtype_arg(cp, bsms_attribute_index, 2)) {
555       return false;
556     }
557 
558     return true;
559   }
560 
561   return false;
562 }
563 #ifdef ASSERT
564 bool AOTConstantPoolResolver::is_in_archivebuilder_buffer(address p) {
565   if (!Thread::current()->is_VM_thread() || ArchiveBuilder::current() == nullptr) {
566     return false;
567   } else {
568     return ArchiveBuilder::current()->is_in_buffer_space(p);
569   }
570 }
571 #endif