< prev index next >

src/hotspot/share/runtime/signature.hpp

Print this page




 361   Symbol*      _signature;
 362   int          _begin;
 363   int          _end;
 364   BasicType    _type;
 365   bool         _at_return_type;
 366   GrowableArray<Symbol*>* _names;  // symbols created while parsing signature
 367 
 368  public:
 369   bool at_return_type() const                    { return _at_return_type; }
 370   bool is_done() const;
 371   void next_non_primitive(int t);
 372   void next() {
 373     Symbol* sig = _signature;
 374     int len = sig->utf8_length();
 375     if (_end >= len) {
 376       _end = len + 1;
 377       return;
 378     }
 379 
 380     _begin = _end;
 381     int t = sig->byte_at(_begin);
 382     switch (t) {
 383       case 'B': _type = T_BYTE;    break;
 384       case 'C': _type = T_CHAR;    break;
 385       case 'D': _type = T_DOUBLE;  break;
 386       case 'F': _type = T_FLOAT;   break;
 387       case 'I': _type = T_INT;     break;
 388       case 'J': _type = T_LONG;    break;
 389       case 'S': _type = T_SHORT;   break;
 390       case 'Z': _type = T_BOOLEAN; break;
 391       case 'V': _type = T_VOID;    break;
 392       default : next_non_primitive(t);
 393                 return;
 394     }
 395     _end++;
 396   }
 397 
 398   SignatureStream(Symbol* signature, bool is_method = true);
 399   ~SignatureStream();
 400 
 401   bool is_object() const;                        // True if this argument is an object
 402   bool is_array() const;                         // True if this argument is an array
 403   BasicType type() const                         { return _type; }
 404   Symbol* as_symbol(TRAPS);
 405   enum FailureMode { ReturnNull, CNFException, NCDFError };
 406   Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 407   oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 408   const jbyte* raw_bytes()  { return _signature->bytes() + _begin; }
 409   int          raw_length() { return _end - _begin; }
 410 
 411   // return same as_symbol except allocation of new symbols is avoided.
 412   Symbol* as_symbol_or_null();
 413 
 414   // count the number of references in the signature
 415   int reference_parameter_count();
 416 };
 417 
 418 class SignatureVerifier : public StackObj {
 419   public:
 420     // Returns true if the symbol is valid method or type signature
 421     static bool is_valid_signature(Symbol* sig);
 422 
 423     static bool is_valid_method_signature(Symbol* sig);
 424     static bool is_valid_type_signature(Symbol* sig);
 425   private:
 426 
 427     static ssize_t is_valid_type(const char*, ssize_t);
 428     static bool invalid_name_char(char);


 361   Symbol*      _signature;
 362   int          _begin;
 363   int          _end;
 364   BasicType    _type;
 365   bool         _at_return_type;
 366   GrowableArray<Symbol*>* _names;  // symbols created while parsing signature
 367 
 368  public:
 369   bool at_return_type() const                    { return _at_return_type; }
 370   bool is_done() const;
 371   void next_non_primitive(int t);
 372   void next() {
 373     Symbol* sig = _signature;
 374     int len = sig->utf8_length();
 375     if (_end >= len) {
 376       _end = len + 1;
 377       return;
 378     }
 379 
 380     _begin = _end;
 381     int t = sig->char_at(_begin);
 382     switch (t) {
 383       case 'B': _type = T_BYTE;    break;
 384       case 'C': _type = T_CHAR;    break;
 385       case 'D': _type = T_DOUBLE;  break;
 386       case 'F': _type = T_FLOAT;   break;
 387       case 'I': _type = T_INT;     break;
 388       case 'J': _type = T_LONG;    break;
 389       case 'S': _type = T_SHORT;   break;
 390       case 'Z': _type = T_BOOLEAN; break;
 391       case 'V': _type = T_VOID;    break;
 392       default : next_non_primitive(t);
 393                 return;
 394     }
 395     _end++;
 396   }
 397 
 398   SignatureStream(Symbol* signature, bool is_method = true);
 399   ~SignatureStream();
 400 
 401   bool is_object() const;                        // True if this argument is an object
 402   bool is_array() const;                         // True if this argument is an array
 403   BasicType type() const                         { return _type; }
 404   Symbol* as_symbol(TRAPS);
 405   enum FailureMode { ReturnNull, CNFException, NCDFError };
 406   Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 407   oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
 408   const u1* raw_bytes()  { return _signature->bytes() + _begin; }
 409   int       raw_length() { return _end - _begin; }
 410 
 411   // return same as_symbol except allocation of new symbols is avoided.
 412   Symbol* as_symbol_or_null();
 413 
 414   // count the number of references in the signature
 415   int reference_parameter_count();
 416 };
 417 
 418 class SignatureVerifier : public StackObj {
 419   public:
 420     // Returns true if the symbol is valid method or type signature
 421     static bool is_valid_signature(Symbol* sig);
 422 
 423     static bool is_valid_method_signature(Symbol* sig);
 424     static bool is_valid_type_signature(Symbol* sig);
 425   private:
 426 
 427     static ssize_t is_valid_type(const char*, ssize_t);
 428     static bool invalid_name_char(char);
< prev index next >