241 private: 242 void location_details(outputStream* ss, const Method* method) const; 243 void reason_details(outputStream* ss) const; 244 void frame_details(outputStream* ss) const; 245 void bytecode_details(outputStream* ss, const Method* method) const; 246 void handler_details(outputStream* ss, const Method* method) const; 247 void stackmap_details(outputStream* ss, const Method* method) const; 248 }; 249 250 // A new instance of this class is created for each class being verified 251 class ClassVerifier : public StackObj { 252 private: 253 Thread* _thread; 254 GrowableArray<Symbol*>* _symbols; // keep a list of symbols created 255 256 Symbol* _exception_type; 257 char* _message; 258 259 ErrorContext _error_context; // contains information about an error 260 261 // Used to detect illegal jumps over calls to super() nd this() in ctors. 262 int32_t _furthest_jump; 263 264 void verify_method(methodHandle method, TRAPS); 265 char* generate_code_data(methodHandle m, u4 code_length, TRAPS); 266 void verify_exception_handler_table(u4 code_length, char* code_data, 267 int& min, int& max, TRAPS); 268 void verify_local_variable_table(u4 code_length, char* code_data, TRAPS); 269 270 VerificationType cp_ref_index_to_type( 271 int index, constantPoolHandle cp, TRAPS) { 272 return cp_index_to_type(cp->klass_ref_index_at(index), cp, THREAD); 273 } 274 275 bool is_protected_access( 276 instanceKlassHandle this_class, Klass* target_class, 277 Symbol* field_name, Symbol* field_sig, bool is_method); 278 279 void verify_cp_index(u2 bci, constantPoolHandle cp, int index, TRAPS); 280 void verify_cp_type(u2 bci, int index, constantPoolHandle cp, 281 unsigned int types, TRAPS); 282 void verify_cp_class_type(u2 bci, int index, constantPoolHandle cp, TRAPS); 283 390 391 Klass* load_class(Symbol* name, TRAPS); 392 393 int change_sig_to_verificationType( 394 SignatureStream* sig_type, VerificationType* inference_type, TRAPS); 395 396 VerificationType cp_index_to_type(int index, constantPoolHandle cp, TRAPS) { 397 return VerificationType::reference_type(cp->klass_name_at(index)); 398 } 399 400 // Keep a list of temporary symbols created during verification because 401 // their reference counts need to be decrememented when the verifier object 402 // goes out of scope. Since these symbols escape the scope in which they're 403 // created, we can't use a TempNewSymbol. 404 Symbol* create_temporary_symbol( 405 const Symbol* s, int begin, int end, TRAPS); 406 Symbol* create_temporary_symbol(const char *s, int length, TRAPS); 407 408 TypeOrigin ref_ctx(const char* str, TRAPS); 409 410 // Keep track of the furthest branch done in a method to make sure that 411 // there are no branches over calls to super() or this() from inside of 412 // a constructor. 413 int32_t furthest_jump() { return _furthest_jump; } 414 415 void set_furthest_jump(int32_t target) { 416 _furthest_jump = target; 417 } 418 419 void update_furthest_jump(int32_t target) { 420 if (target > _furthest_jump) _furthest_jump = target; 421 } 422 423 }; 424 425 inline int ClassVerifier::change_sig_to_verificationType( 426 SignatureStream* sig_type, VerificationType* inference_type, TRAPS) { 427 BasicType bt = sig_type->type(); 428 switch (bt) { 429 case T_OBJECT: 430 case T_ARRAY: 431 { 432 Symbol* name = sig_type->as_symbol(CHECK_0); 433 // Create another symbol to save as signature stream unreferences 434 // this symbol. 435 Symbol* name_copy = 436 create_temporary_symbol(name, 0, name->utf8_length(), CHECK_0); 437 assert(name_copy == name, "symbols don't match"); 438 *inference_type = 439 VerificationType::reference_type(name_copy); 440 return 1; 441 } 442 case T_LONG: | 241 private: 242 void location_details(outputStream* ss, const Method* method) const; 243 void reason_details(outputStream* ss) const; 244 void frame_details(outputStream* ss) const; 245 void bytecode_details(outputStream* ss, const Method* method) const; 246 void handler_details(outputStream* ss, const Method* method) const; 247 void stackmap_details(outputStream* ss, const Method* method) const; 248 }; 249 250 // A new instance of this class is created for each class being verified 251 class ClassVerifier : public StackObj { 252 private: 253 Thread* _thread; 254 GrowableArray<Symbol*>* _symbols; // keep a list of symbols created 255 256 Symbol* _exception_type; 257 char* _message; 258 259 ErrorContext _error_context; // contains information about an error 260 261 void verify_method(methodHandle method, TRAPS); 262 char* generate_code_data(methodHandle m, u4 code_length, TRAPS); 263 void verify_exception_handler_table(u4 code_length, char* code_data, 264 int& min, int& max, TRAPS); 265 void verify_local_variable_table(u4 code_length, char* code_data, TRAPS); 266 267 VerificationType cp_ref_index_to_type( 268 int index, constantPoolHandle cp, TRAPS) { 269 return cp_index_to_type(cp->klass_ref_index_at(index), cp, THREAD); 270 } 271 272 bool is_protected_access( 273 instanceKlassHandle this_class, Klass* target_class, 274 Symbol* field_name, Symbol* field_sig, bool is_method); 275 276 void verify_cp_index(u2 bci, constantPoolHandle cp, int index, TRAPS); 277 void verify_cp_type(u2 bci, int index, constantPoolHandle cp, 278 unsigned int types, TRAPS); 279 void verify_cp_class_type(u2 bci, int index, constantPoolHandle cp, TRAPS); 280 387 388 Klass* load_class(Symbol* name, TRAPS); 389 390 int change_sig_to_verificationType( 391 SignatureStream* sig_type, VerificationType* inference_type, TRAPS); 392 393 VerificationType cp_index_to_type(int index, constantPoolHandle cp, TRAPS) { 394 return VerificationType::reference_type(cp->klass_name_at(index)); 395 } 396 397 // Keep a list of temporary symbols created during verification because 398 // their reference counts need to be decrememented when the verifier object 399 // goes out of scope. Since these symbols escape the scope in which they're 400 // created, we can't use a TempNewSymbol. 401 Symbol* create_temporary_symbol( 402 const Symbol* s, int begin, int end, TRAPS); 403 Symbol* create_temporary_symbol(const char *s, int length, TRAPS); 404 405 TypeOrigin ref_ctx(const char* str, TRAPS); 406 407 }; 408 409 inline int ClassVerifier::change_sig_to_verificationType( 410 SignatureStream* sig_type, VerificationType* inference_type, TRAPS) { 411 BasicType bt = sig_type->type(); 412 switch (bt) { 413 case T_OBJECT: 414 case T_ARRAY: 415 { 416 Symbol* name = sig_type->as_symbol(CHECK_0); 417 // Create another symbol to save as signature stream unreferences 418 // this symbol. 419 Symbol* name_copy = 420 create_temporary_symbol(name, 0, name->utf8_length(), CHECK_0); 421 assert(name_copy == name, "symbols don't match"); 422 *inference_type = 423 VerificationType::reference_type(name_copy); 424 return 1; 425 } 426 case T_LONG: |