< prev index next >

src/hotspot/share/runtime/signature.cpp

Print this page
rev 52849 : [mq]: q-mirror-reflection


  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 "memory/oopFactory.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/instanceKlass.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "oops/symbol.hpp"
  33 #include "oops/typeArrayKlass.hpp"

  34 #include "runtime/signature.hpp"
  35 
  36 // Implementation of SignatureIterator
  37 
  38 // Signature syntax:
  39 //
  40 // Signature  = "(" {Parameter} ")" ReturnType.
  41 // Parameter  = FieldType.
  42 // ReturnType = FieldType | "V".
  43 // FieldType  = "B" | "C" | "D" | "F" | "I" | "J" | "S" | "Z" | "L" ClassName ";" | "Q" ValueClassName ";" | "[" FieldType.
  44 // ClassName  = string.
  45 
  46 
  47 SignatureIterator::SignatureIterator(Symbol* signature) {
  48   _signature       = signature;
  49   _parameter_index = 0;
  50 }
  51 
  52 void SignatureIterator::expect(char c) {
  53   if (_signature->byte_at(_index) != c) fatal("expecting %c", c);


 386 }
 387 
 388 Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain,
 389                                    FailureMode failure_mode, TRAPS) {
 390   if (!is_object())  return NULL;
 391   Symbol* name = as_symbol(CHECK_NULL);
 392   if (failure_mode == ReturnNull) {
 393     return SystemDictionary::resolve_or_null(name, class_loader, protection_domain, THREAD);
 394   } else {
 395     bool throw_error = (failure_mode == NCDFError);
 396     return SystemDictionary::resolve_or_fail(name, class_loader, protection_domain, throw_error, THREAD);
 397   }
 398 }
 399 
 400 oop SignatureStream::as_java_mirror(Handle class_loader, Handle protection_domain,
 401                                     FailureMode failure_mode, TRAPS) {
 402   if (!is_object())
 403     return Universe::java_mirror(type());
 404   Klass* klass = as_klass(class_loader, protection_domain, failure_mode, CHECK_NULL);
 405   if (klass == NULL)  return NULL;
 406   return klass->java_mirror();
 407 }
 408 
 409 Symbol* SignatureStream::as_symbol_or_null() {
 410   // Create a symbol from for string _begin _end
 411   ResourceMark rm;
 412 
 413   int begin = _begin;
 414   int end   = _end;
 415 
 416   if (_type == T_OBJECT || _type == T_VALUETYPE) {
 417     begin++;
 418     end--;
 419     if (begin == end) {
 420       return vmSymbols::java_lang_Object();
 421     }
 422   }
 423 
 424   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
 425   for (int index = begin; index < end; index++) {
 426     buffer[index - begin] = _signature->byte_at(index);




  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 "memory/oopFactory.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/instanceKlass.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "oops/symbol.hpp"
  33 #include "oops/typeArrayKlass.hpp"
  34 #include "oops/valueKlass.hpp"
  35 #include "runtime/signature.hpp"
  36 
  37 // Implementation of SignatureIterator
  38 
  39 // Signature syntax:
  40 //
  41 // Signature  = "(" {Parameter} ")" ReturnType.
  42 // Parameter  = FieldType.
  43 // ReturnType = FieldType | "V".
  44 // FieldType  = "B" | "C" | "D" | "F" | "I" | "J" | "S" | "Z" | "L" ClassName ";" | "Q" ValueClassName ";" | "[" FieldType.
  45 // ClassName  = string.
  46 
  47 
  48 SignatureIterator::SignatureIterator(Symbol* signature) {
  49   _signature       = signature;
  50   _parameter_index = 0;
  51 }
  52 
  53 void SignatureIterator::expect(char c) {
  54   if (_signature->byte_at(_index) != c) fatal("expecting %c", c);


 387 }
 388 
 389 Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain,
 390                                    FailureMode failure_mode, TRAPS) {
 391   if (!is_object())  return NULL;
 392   Symbol* name = as_symbol(CHECK_NULL);
 393   if (failure_mode == ReturnNull) {
 394     return SystemDictionary::resolve_or_null(name, class_loader, protection_domain, THREAD);
 395   } else {
 396     bool throw_error = (failure_mode == NCDFError);
 397     return SystemDictionary::resolve_or_fail(name, class_loader, protection_domain, throw_error, THREAD);
 398   }
 399 }
 400 
 401 oop SignatureStream::as_java_mirror(Handle class_loader, Handle protection_domain,
 402                                     FailureMode failure_mode, TRAPS) {
 403   if (!is_object())
 404     return Universe::java_mirror(type());
 405   Klass* klass = as_klass(class_loader, protection_domain, failure_mode, CHECK_NULL);
 406   if (klass == NULL)  return NULL;
 407   return _type == T_VALUETYPE ? ValueKlass::cast(InstanceKlass::cast(klass))->value_mirror() : klass->java_mirror();
 408 }
 409 
 410 Symbol* SignatureStream::as_symbol_or_null() {
 411   // Create a symbol from for string _begin _end
 412   ResourceMark rm;
 413 
 414   int begin = _begin;
 415   int end   = _end;
 416 
 417   if (_type == T_OBJECT || _type == T_VALUETYPE) {
 418     begin++;
 419     end--;
 420     if (begin == end) {
 421       return vmSymbols::java_lang_Object();
 422     }
 423   }
 424 
 425   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
 426   for (int index = begin; index < end; index++) {
 427     buffer[index - begin] = _signature->byte_at(index);


< prev index next >