1 /*
  2  * Copyright (c) 1997, 2021, 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 "classfile/symbolTable.hpp"
 27 #include "classfile/systemDictionary.hpp"
 28 #include "classfile/vmSymbols.hpp"
 29 #include "memory/oopFactory.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "memory/universe.hpp"
 32 #include "oops/instanceKlass.hpp"
 33 #include "oops/klass.inline.hpp"
 34 #include "oops/oop.inline.hpp"
 35 #include "oops/symbol.hpp"
 36 #include "oops/typeArrayKlass.hpp"
 37 #include "oops/inlineKlass.inline.hpp"
 38 #include "runtime/fieldDescriptor.inline.hpp"
 39 #include "runtime/handles.inline.hpp"
 40 #include "runtime/safepointVerifiers.hpp"
 41 #include "runtime/signature.hpp"
 42 
 43 // Implementation of SignatureIterator
 44 
 45 // Signature syntax:
 46 //
 47 // Signature  = "(" {Parameter} ")" ReturnType.
 48 // Parameter  = FieldType.
 49 // ReturnType = FieldType | "V".
 50 // FieldType  = "B" | "C" | "D" | "F" | "I" | "J" | "S" | "Z" | "L" ClassName ";" | "Q" ValueClassName ";" | "[" FieldType.
 51 // ClassName  = string.
 52 
 53 // The ClassName string can be any JVM-style UTF8 string except:
 54 //  - an empty string (the empty string is never a name of any kind)
 55 //  - a string which begins or ends with slash '/' (the package separator)
 56 //  - a string which contains adjacent slashes '//' (no empty package names)
 57 //  - a string which contains a semicolon ';' (the end-delimiter)
 58 //  - a string which contains a left bracket '[' (the array marker)
 59 //  - a string which contains a dot '.' (the external package separator)
 60 //
 61 // Other "meta-looking" characters, such as '(' and '<' and '+',
 62 // are perfectly legitimate within a class name, for the JVM.
 63 // Class names which contain double slashes ('a//b') and non-initial
 64 // brackets ('a[b]') are reserved for possible enrichment of the
 65 // type language.
 66 
 67 void SignatureIterator::set_fingerprint(fingerprint_t fingerprint) {
 68   if (!fp_is_valid(fingerprint)) {
 69     _fingerprint = fingerprint;
 70     _return_type = T_ILLEGAL;
 71   } else if (fingerprint != _fingerprint) {
 72     assert(_fingerprint == zero_fingerprint(), "consistent fingerprint values");
 73     _fingerprint = fingerprint;
 74     _return_type = fp_return_type(fingerprint);
 75   }
 76 }
 77 
 78 BasicType SignatureIterator::return_type() {
 79   if (_return_type == T_ILLEGAL) {
 80     SignatureStream ss(_signature);
 81     ss.skip_to_return_type();
 82     _return_type = ss.type();
 83     assert(_return_type != T_ILLEGAL, "illegal return type");
 84   }
 85   return _return_type;
 86 }
 87 
 88 bool SignatureIterator::fp_is_valid_type(BasicType type, bool for_return_type) {
 89   assert(type != (BasicType)fp_parameters_done, "fingerprint is incorrectly at done");
 90   assert(((int)type & ~fp_parameter_feature_mask) == 0, "fingerprint feature mask yielded non-zero value");
 91   return (is_java_primitive(type) ||
 92           is_reference_type(type) ||
 93           (for_return_type && type == T_VOID));
 94 }
 95 
 96 ArgumentSizeComputer::ArgumentSizeComputer(Symbol* signature)
 97   : SignatureIterator(signature)
 98 {
 99   _size = 0;
100   do_parameters_on(this);  // non-virtual template execution
101 }
102 
103 ArgumentCount::ArgumentCount(Symbol* signature)
104   : SignatureIterator(signature)
105 {
106   _size = 0;
107   do_parameters_on(this);  // non-virtual template execution
108 }
109 
110 ReferenceArgumentCount::ReferenceArgumentCount(Symbol* signature)
111   : SignatureIterator(signature)
112 {
113   _refs = 0;
114   do_parameters_on(this);  // non-virtual template execution
115 }
116 
117 void Fingerprinter::compute_fingerprint_and_return_type(bool static_flag) {
118   // See if we fingerprinted this method already
119   if (_method != NULL) {
120     assert(!static_flag, "must not be passed by caller");
121     static_flag = _method->is_static();
122     _fingerprint = _method->constMethod()->fingerprint();
123 
124     if (_fingerprint != zero_fingerprint()) {
125       _return_type = _method->result_type();
126       assert(is_java_type(_return_type), "return type must be a java type");
127       return;
128     }
129 
130     if (_method->size_of_parameters() > fp_max_size_of_parameters) {
131       _fingerprint = overflow_fingerprint();
132       _method->constMethod()->set_fingerprint(_fingerprint);
133       // as long as we are here compute the return type:
134       _return_type = ResultTypeFinder(_method->signature()).type();
135       assert(is_java_type(_return_type), "return type must be a java type");
136       return;
137     }
138   }
139 
140   // Note:  This will always take the slow path, since _fp==zero_fp.
141   initialize_accumulator();
142   do_parameters_on(this);
143   assert(fp_is_valid_type(_return_type, true), "bad result type");
144 
145   // Fill in the return type and static bits:
146   _accumulator |= _return_type << fp_static_feature_size;
147   if (static_flag) {
148     _accumulator |= fp_is_static_bit;
149   } else {
150     _param_size += 1;  // this is the convention for Method::compute_size_of_parameters
151   }
152 
153   // Detect overflow.  (We counted _param_size correctly.)
154   if (_method == NULL && _param_size > fp_max_size_of_parameters) {
155     // We did a one-pass computation of argument size, return type,
156     // and fingerprint.
157     _fingerprint = overflow_fingerprint();
158     return;
159   }
160 
161   assert(_shift_count < BitsPerLong,
162          "shift count overflow %d (%d vs. %d): %s",
163          _shift_count, _param_size, fp_max_size_of_parameters,
164          _signature->as_C_string());
165   assert((_accumulator >> _shift_count) == fp_parameters_done, "must be zero");
166 
167   // This is the result, along with _return_type:
168   _fingerprint = _accumulator;
169 
170   // Cache the result on the method itself:
171   if (_method != NULL) {
172     _method->constMethod()->set_fingerprint(_fingerprint);
173   }
174 }
175 
176 // Implementation of SignatureStream
177 
178 static inline BasicType decode_signature_char(int ch) {
179   switch (ch) {
180 #define EACH_SIG(ch, bt, ignore) \
181     case ch: return bt;
182     SIGNATURE_TYPES_DO(EACH_SIG, ignore)
183 #undef EACH_SIG
184   }
185   return (BasicType)0;
186 }
187 
188 SignatureStream::SignatureStream(const Symbol* signature,
189                                  bool is_method) {
190   assert(!is_method || signature->starts_with(JVM_SIGNATURE_FUNC),
191          "method signature required");
192   _signature = signature;
193   _limit = signature->utf8_length();
194   int oz = (is_method ? _s_method : _s_field);
195   _state = oz;
196   _begin = _end = oz; // skip first '(' in method signatures
197   _array_prefix = 0;  // just for definiteness
198 
199   // assigning java/lang/Object to _previous_name means we can
200   // avoid a number of NULL checks in the parser
201   _previous_name = vmSymbols::java_lang_Object();
202   _names = NULL;
203   next();
204 }
205 
206 SignatureStream::~SignatureStream() {
207   if (_previous_name == vmSymbols::java_lang_Object()) {
208     // no names were created
209     assert(_names == NULL, "_names unexpectedly created");
210     return;
211   }
212 
213   // decrement refcount for names created during signature parsing
214   _previous_name->decrement_refcount();
215   if (_names != NULL) {
216     for (int i = 0; i < _names->length(); i++) {
217       _names->at(i)->decrement_refcount();
218     }
219   }
220 }
221 
222 inline int SignatureStream::scan_type(BasicType type) {
223   const u1* base = _signature->bytes();
224   int end = _end;
225   int limit = _limit;
226   const u1* tem;
227   switch (type) {
228   case T_OBJECT:
229   case T_INLINE_TYPE:
230     tem = (const u1*) memchr(&base[end], JVM_SIGNATURE_ENDCLASS, limit - end);
231     return (tem == NULL ? limit : tem + 1 - base);
232 
233   case T_ARRAY:
234     while ((end < limit) && ((char)base[end] == JVM_SIGNATURE_ARRAY)) { end++; }
235     _array_prefix = end - _end;  // number of '[' chars just skipped
236     if (Signature::has_envelope(base[end])) {
237       tem = (const u1 *) memchr(&base[end], JVM_SIGNATURE_ENDCLASS, limit - end);
238       return (tem == NULL ? limit : tem + 1 - base);
239     }
240     // Skipping over a single character for a primitive type.
241     assert(is_java_primitive(decode_signature_char(base[end])), "only primitives expected");
242     return end + 1;
243 
244   default:
245     // Skipping over a single character for a primitive type (or void).
246     assert(!is_reference_type(type), "only primitives or void expected");
247     return end + 1;
248   }
249 }
250 
251 void SignatureStream::next() {
252   const Symbol* sig = _signature;
253   int len = _limit;
254   if (_end >= len) { set_done(); return; }
255   _begin = _end;
256   int ch = sig->char_at(_begin);
257   if (ch == JVM_SIGNATURE_ENDFUNC) {
258     assert(_state == _s_method, "must be in method");
259     _state = _s_method_return;
260     _begin = ++_end;
261     if (_end >= len) { set_done(); return; }
262     ch = sig->char_at(_begin);
263   }
264   BasicType bt = decode_signature_char(ch);
265   assert(ch == type2char(bt), "bad signature char %c/%d", ch, ch);
266   _type = bt;
267   _end = scan_type(bt);
268 }
269 
270 int SignatureStream::skip_whole_array_prefix() {
271   assert(_type == T_ARRAY, "must be");
272 
273   // we are stripping all levels of T_ARRAY,
274   // so we must decode the next character
275   int whole_array_prefix = _array_prefix;
276   int new_begin = _begin + whole_array_prefix;
277   _begin = new_begin;
278   int ch = _signature->char_at(new_begin);
279   BasicType bt = decode_signature_char(ch);
280   assert(ch == type2char(bt), "bad signature char %c/%d", ch, ch);
281   _type = bt;
282   assert(bt != T_VOID && bt != T_ARRAY, "bad signature type");
283   // Don't bother to re-scan, since it won't change the value of _end.
284   return whole_array_prefix;
285 }
286 
287 bool Signature::is_valid_array_signature(const Symbol* sig) {
288   assert(sig->utf8_length() > 1, "this should already have been checked");
289   assert(sig->char_at(0) == JVM_SIGNATURE_ARRAY, "this should already have been checked");
290   // The first character is already checked
291   int i = 1;
292   int len = sig->utf8_length();
293   // First skip all '['s
294   while(i < len - 1 && sig->char_at(i) == JVM_SIGNATURE_ARRAY) i++;
295 
296   // Check type
297   switch(sig->char_at(i)) {
298   case JVM_SIGNATURE_BYTE:
299   case JVM_SIGNATURE_CHAR:
300   case JVM_SIGNATURE_DOUBLE:
301   case JVM_SIGNATURE_FLOAT:
302   case JVM_SIGNATURE_INT:
303   case JVM_SIGNATURE_LONG:
304   case JVM_SIGNATURE_SHORT:
305   case JVM_SIGNATURE_BOOLEAN:
306     // If it is an array, the type is the last character
307     return (i + 1 == len);
308   case JVM_SIGNATURE_CLASS:
309   case JVM_SIGNATURE_INLINE_TYPE:
310     // If it is an object, the last character must be a ';'
311     return sig->char_at(len - 1) == JVM_SIGNATURE_ENDCLASS;
312   }
313   return false;
314 }
315 
316 BasicType Signature::basic_type(int ch) {
317   BasicType btcode = decode_signature_char(ch);
318   if (btcode == 0)  return T_ILLEGAL;
319   return btcode;
320 }
321 
322 Symbol* Signature::strip_envelope(const Symbol* signature) {
323   assert(has_envelope(signature), "precondition");
324   return SymbolTable::new_symbol((char*) signature->bytes() + 1,
325                                  signature->utf8_length() - 2);
326 }
327 
328 static const int jl_len = 10, object_len = 6, jl_object_len = jl_len + object_len;
329 static const char jl_str[] = "java/lang/";
330 
331 #ifdef ASSERT
332 static bool signature_symbols_sane() {
333   static bool done;
334   if (done)  return true;
335   done = true;
336   // test some tense code that looks for common symbol names:
337   assert(vmSymbols::java_lang_Object()->utf8_length() == jl_object_len &&
338          vmSymbols::java_lang_Object()->starts_with(jl_str, jl_len) &&
339          vmSymbols::java_lang_Object()->ends_with("Object", object_len) &&
340          vmSymbols::java_lang_Object()->is_permanent() &&
341          vmSymbols::java_lang_String()->utf8_length() == jl_object_len &&
342          vmSymbols::java_lang_String()->starts_with(jl_str, jl_len) &&
343          vmSymbols::java_lang_String()->ends_with("String", object_len) &&
344          vmSymbols::java_lang_String()->is_permanent(),
345          "sanity");
346   return true;
347 }
348 #endif //ASSERT
349 
350 // returns a symbol; the caller is responsible for decrementing it
351 Symbol* SignatureStream::find_symbol() {
352   // Create a symbol from for string _begin _end
353   int begin = raw_symbol_begin();
354   int end   = raw_symbol_end();
355 
356   const char* symbol_chars = (const char*)_signature->base() + begin;
357   int len = end - begin;
358 
359   // Quick check for common symbols in signatures
360   assert(signature_symbols_sane(), "incorrect signature sanity check");
361   if (len == jl_object_len &&
362       memcmp(symbol_chars, jl_str, jl_len) == 0) {
363     if (memcmp("String", symbol_chars + jl_len, object_len) == 0) {
364       return vmSymbols::java_lang_String();
365     } else if (memcmp("Object", symbol_chars + jl_len, object_len) == 0) {
366       return vmSymbols::java_lang_Object();
367     }
368   }
369 
370   Symbol* name = _previous_name;
371   if (name->equals(symbol_chars, len)) {
372     return name;
373   }
374 
375   // Save names for cleaning up reference count at the end of
376   // SignatureStream scope.
377   name = SymbolTable::new_symbol(symbol_chars, len);
378 
379   // Only allocate the GrowableArray for the _names buffer if more than
380   // one name is being processed in the signature.
381   if (!_previous_name->is_permanent()) {
382     if (_names == NULL) {
383       _names = new GrowableArray<Symbol*>(10);
384     }
385     _names->push(_previous_name);
386   }
387   _previous_name = name;
388   return name;
389 }
390 
391 InlineKlass* SignatureStream::as_inline_klass(InstanceKlass* holder) {
392   JavaThread* THREAD = JavaThread::current();
393   Handle class_loader(THREAD, holder->class_loader());
394   Handle protection_domain(THREAD, holder->protection_domain());
395   Klass* k = as_klass(class_loader, protection_domain, SignatureStream::ReturnNull, THREAD);
396   assert(k != NULL && !HAS_PENDING_EXCEPTION, "unresolved inline klass");
397   return InlineKlass::cast(k);
398 }
399 
400 Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain,
401                                  FailureMode failure_mode, TRAPS) {
402   if (!is_reference()) {
403     return NULL;
404   }
405   Symbol* name = as_symbol();
406   Klass* k = NULL;
407   if (failure_mode == ReturnNull) {
408     // Note:  SD::resolve_or_null returns NULL for most failure modes,
409     // but not all.  Circularity errors, invalid PDs, etc., throw.
410     k = SystemDictionary::resolve_or_null(name, class_loader, protection_domain, CHECK_NULL);
411   } else if (failure_mode == CachedOrNull) {
412     NoSafepointVerifier nsv;  // no loading, now, we mean it!
413     assert(!HAS_PENDING_EXCEPTION, "");
414     k = SystemDictionary::find_instance_klass(name, class_loader, protection_domain);
415     // SD::find does not trigger loading, so there should be no throws
416     // Still, bad things can happen, so we CHECK_NULL and ask callers
417     // to do likewise.
418     return k;
419   } else {
420     // The only remaining failure mode is NCDFError.
421     // The test here allows for an additional mode CNFException
422     // if callers need to request the reflective error instead.
423     bool throw_error = (failure_mode == NCDFError);
424     k = SystemDictionary::resolve_or_fail(name, class_loader, protection_domain, throw_error, CHECK_NULL);
425   }
426 
427   return k;
428 }
429 
430 oop SignatureStream::as_java_mirror(Handle class_loader, Handle protection_domain,
431                                     FailureMode failure_mode, TRAPS) {
432   if (!is_reference()) {
433     return Universe::java_mirror(type());
434   }
435   Klass* klass = as_klass(class_loader, protection_domain, failure_mode, CHECK_NULL);
436   if (klass == NULL) {
437     return NULL;
438   }
439   return has_Q_descriptor() ? InlineKlass::cast(klass)->val_mirror()
440                             : klass->java_mirror();
441 }
442 
443 void SignatureStream::skip_to_return_type() {
444   while (!at_return_type()) {
445     next();
446   }
447 }
448 
449 ResolvingSignatureStream::ResolvingSignatureStream(Symbol* signature,
450                                                    Handle class_loader,
451                                                    Handle protection_domain,
452                                                    bool is_method)
453   : SignatureStream(signature, is_method),
454     _class_loader(class_loader), _protection_domain(protection_domain)
455 {
456   initialize_load_origin(NULL);
457 }
458 
459 ResolvingSignatureStream::ResolvingSignatureStream(Symbol* signature, Klass* load_origin, bool is_method)
460   : SignatureStream(signature, is_method)
461 {
462   assert(load_origin != NULL, "");
463   initialize_load_origin(load_origin);
464 }
465 
466 ResolvingSignatureStream::ResolvingSignatureStream(const Method* method)
467   : SignatureStream(method->signature(), true)
468 {
469   initialize_load_origin(method->method_holder());
470 }
471 
472 ResolvingSignatureStream::ResolvingSignatureStream(fieldDescriptor& field)
473   : SignatureStream(field.signature(), false)
474 {
475   initialize_load_origin(field.field_holder());
476 }
477 
478 void ResolvingSignatureStream::cache_handles() {
479   assert(_load_origin != NULL, "");
480   JavaThread* current = JavaThread::current();
481   _class_loader = Handle(current, _load_origin->class_loader());
482   _protection_domain = Handle(current, _load_origin->protection_domain());
483 }
484 
485 Klass* ResolvingSignatureStream::as_klass_if_loaded(TRAPS) {
486   Klass* klass = as_klass(CachedOrNull, THREAD);
487   // SD::find does not trigger loading, so there should be no throws
488   // Still, bad things can happen, so we CHECK_NULL and ask callers
489   // to do likewise.
490   if (HAS_PENDING_EXCEPTION) {
491     CLEAR_PENDING_EXCEPTION;
492   }
493   return klass;
494 }
495 
496 #ifdef ASSERT
497 extern bool signature_constants_sane(); // called from basic_types_init()
498 
499 bool signature_constants_sane() {
500   // for the lookup table, test every 8-bit code point, and then some:
501   for (int i = -256; i <= 256; i++) {
502     int btcode = 0;
503     switch (i) {
504 #define EACH_SIG(ch, bt, ignore) \
505     case ch: { btcode = bt; break; }
506     SIGNATURE_TYPES_DO(EACH_SIG, ignore)
507 #undef EACH_SIG
508     }
509     int btc = decode_signature_char(i);
510     assert(btc == btcode, "misconfigured table: %d => %d not %d", i, btc, btcode);
511   }
512   return true;
513 }
514 
515 bool SignatureVerifier::is_valid_method_signature(const Symbol* sig) {
516   const char* method_sig = (const char*)sig->bytes();
517   ssize_t len = sig->utf8_length();
518   ssize_t index = 0;
519   if (method_sig != NULL && len > 1 && method_sig[index] == JVM_SIGNATURE_FUNC) {
520     ++index;
521     while (index < len && method_sig[index] != JVM_SIGNATURE_ENDFUNC) {
522       ssize_t res = is_valid_type(&method_sig[index], len - index);
523       if (res == -1) {
524         return false;
525       } else {
526         index += res;
527       }
528     }
529     if (index < len && method_sig[index] == JVM_SIGNATURE_ENDFUNC) {
530       // check the return type
531       ++index;
532       return (is_valid_type(&method_sig[index], len - index) == (len - index));
533     }
534   }
535   return false;
536 }
537 
538 bool SignatureVerifier::is_valid_type_signature(const Symbol* sig) {
539   const char* type_sig = (const char*)sig->bytes();
540   ssize_t len = sig->utf8_length();
541   return (type_sig != NULL && len >= 1 &&
542           (is_valid_type(type_sig, len) == len));
543 }
544 
545 // Checks to see if the type (not to go beyond 'limit') refers to a valid type.
546 // Returns -1 if it is not, or the index of the next character that is not part
547 // of the type.  The type encoding may end before 'limit' and that's ok.
548 ssize_t SignatureVerifier::is_valid_type(const char* type, ssize_t limit) {
549   ssize_t index = 0;
550 
551   // Iterate over any number of array dimensions
552   while (index < limit && type[index] == JVM_SIGNATURE_ARRAY) ++index;
553   if (index >= limit) {
554     return -1;
555   }
556   switch (type[index]) {
557     case JVM_SIGNATURE_BYTE:
558     case JVM_SIGNATURE_CHAR:
559     case JVM_SIGNATURE_FLOAT:
560     case JVM_SIGNATURE_DOUBLE:
561     case JVM_SIGNATURE_INT:
562     case JVM_SIGNATURE_LONG:
563     case JVM_SIGNATURE_SHORT:
564     case JVM_SIGNATURE_BOOLEAN:
565     case JVM_SIGNATURE_VOID:
566       return index + 1;
567     case JVM_SIGNATURE_INLINE_TYPE: // fall through
568     case JVM_SIGNATURE_CLASS:
569       for (index = index + 1; index < limit; ++index) {
570         char c = type[index];
571         switch (c) {
572           case JVM_SIGNATURE_ENDCLASS:
573             return index + 1;
574           case '\0': case JVM_SIGNATURE_DOT: case JVM_SIGNATURE_ARRAY:
575             return -1;
576           default: ; // fall through
577         }
578       }
579       // fall through
580     default: ; // fall through
581   }
582   return -1;
583 }
584 
585 #endif // ASSERT
586 
587 // Adds an argument to the signature
588 void SigEntry::add_entry(GrowableArray<SigEntry>* sig, BasicType bt, Symbol* symbol, int offset) {
589   sig->append(SigEntry(bt, offset, symbol));
590   if (bt == T_LONG || bt == T_DOUBLE) {
591     sig->append(SigEntry(T_VOID, offset, symbol)); // Longs and doubles take two stack slots
592   }
593 }
594 
595 // Returns true if the argument at index 'i' is not an inline type delimiter
596 bool SigEntry::skip_value_delimiters(const GrowableArray<SigEntry>* sig, int i) {
597   return (sig->at(i)._bt != T_INLINE_TYPE &&
598           (sig->at(i)._bt != T_VOID || sig->at(i-1)._bt == T_LONG || sig->at(i-1)._bt == T_DOUBLE));
599 }
600 
601 // Fill basic type array from signature array
602 int SigEntry::fill_sig_bt(const GrowableArray<SigEntry>* sig, BasicType* sig_bt) {
603   int count = 0;
604   for (int i = 0; i < sig->length(); i++) {
605     if (skip_value_delimiters(sig, i)) {
606       sig_bt[count++] = sig->at(i)._bt;
607     }
608   }
609   return count;
610 }
611 
612 // Create a temporary symbol from the signature array
613 TempNewSymbol SigEntry::create_symbol(const GrowableArray<SigEntry>* sig) {
614   ResourceMark rm;
615   int length = sig->length();
616   char* sig_str = NEW_RESOURCE_ARRAY(char, 2*length + 3);
617   int idx = 0;
618   sig_str[idx++] = '(';
619   for (int i = 0; i < length; i++) {
620     BasicType bt = sig->at(i)._bt;
621     if (bt == T_INLINE_TYPE || bt == T_VOID) {
622       // Ignore
623     } else {
624       if (bt == T_ARRAY) {
625         bt = T_OBJECT; // We don't know the element type, treat as Object
626       }
627       sig_str[idx++] = type2char(bt);
628       if (bt == T_OBJECT) {
629         sig_str[idx++] = ';';
630       }
631     }
632   }
633   sig_str[idx++] = ')';
634   // Add a dummy return type. It won't be used but SignatureStream needs it.
635   sig_str[idx++] = 'V';
636   sig_str[idx++] = '\0';
637   return SymbolTable::new_symbol(sig_str);
638 }