comparison src/share/vm/classfile/defaultMethods.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 89152779163c 78bbf4d43a14
children 12dcf5ba8b34
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
388 388
389 Method* get_selected_target() { return _selected_target; } 389 Method* get_selected_target() { return _selected_target; }
390 Symbol* get_exception_message() { return _exception_message; } 390 Symbol* get_exception_message() { return _exception_message; }
391 Symbol* get_exception_name() { return _exception_name; } 391 Symbol* get_exception_name() { return _exception_name; }
392 392
393 // Return true if the specified klass has a static method that matches
394 // the name and signature of the target method.
395 bool has_matching_static(InstanceKlass* root) {
396 if (_members.length() > 0) {
397 Pair<Method*,QualifiedState> entry = _members.at(0);
398 Method* impl = root->find_method(entry.first->name(),
399 entry.first->signature());
400 if ((impl != NULL) && impl->is_static()) {
401 return true;
402 }
403 }
404 return false;
405 }
406
407 // Either sets the target or the exception error message 393 // Either sets the target or the exception error message
408 void determine_target(InstanceKlass* root, TRAPS) { 394 void determine_target(InstanceKlass* root, TRAPS) {
409 if (has_target() || throws_exception()) { 395 if (has_target() || throws_exception()) {
410 return; 396 return;
411 } 397 }
431 417
432 if (num_defaults == 0) { 418 if (num_defaults == 0) {
433 // If the root klass has a static method with matching name and signature 419 // If the root klass has a static method with matching name and signature
434 // then do not generate an overpass method because it will hide the 420 // then do not generate an overpass method because it will hide the
435 // static method during resolution. 421 // static method during resolution.
436 if (!has_matching_static(root)) { 422 if (qualified_methods.length() == 0) {
437 if (qualified_methods.length() == 0) { 423 _exception_message = generate_no_defaults_message(CHECK);
438 _exception_message = generate_no_defaults_message(CHECK); 424 } else {
439 } else { 425 assert(root != NULL, "Null root class");
440 assert(root != NULL, "Null root class"); 426 _exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK);
441 _exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK); 427 }
442 } 428 _exception_name = vmSymbols::java_lang_AbstractMethodError();
443 _exception_name = vmSymbols::java_lang_AbstractMethodError();
444 }
445 429
446 // If only one qualified method is default, select that 430 // If only one qualified method is default, select that
447 } else if (num_defaults == 1) { 431 } else if (num_defaults == 1) {
448 _selected_target = qualified_methods.at(default_index); 432 _selected_target = qualified_methods.at(default_index);
449 433
450 } else if (num_defaults > 1 && !has_matching_static(root)) { 434 } else if (num_defaults > 1) {
451 _exception_message = generate_conflicts_message(&qualified_methods,CHECK); 435 _exception_message = generate_conflicts_message(&qualified_methods,CHECK);
452 _exception_name = vmSymbols::java_lang_IncompatibleClassChangeError(); 436 _exception_name = vmSymbols::java_lang_IncompatibleClassChangeError();
453 if (TraceDefaultMethods) { 437 if (TraceDefaultMethods) {
454 _exception_message->print_value_on(tty); 438 _exception_message->print_value_on(tty);
455 tty->print_cr(""); 439 tty->cr();
456 } 440 }
457 } 441 }
458 } 442 }
459 443
460 bool contains_signature(Symbol* query) { 444 bool contains_signature(Symbol* query) {
477 str->indent(); 461 str->indent();
478 print_method(str, _members.at(i).first); 462 print_method(str, _members.at(i).first);
479 if (_members.at(i).second == DISQUALIFIED) { 463 if (_members.at(i).second == DISQUALIFIED) {
480 str->print(" (disqualified)"); 464 str->print(" (disqualified)");
481 } 465 }
482 str->print_cr(""); 466 str->cr();
483 } 467 }
484 468
485 if (_selected_target != NULL) { 469 if (_selected_target != NULL) {
486 print_selected(str, 1); 470 print_selected(str, 1);
487 } 471 }
494 print_method(str, _selected_target); 478 print_method(str, _selected_target);
495 Klass* method_holder = _selected_target->method_holder(); 479 Klass* method_holder = _selected_target->method_holder();
496 if (!method_holder->is_interface()) { 480 if (!method_holder->is_interface()) {
497 tty->print(" : in superclass"); 481 tty->print(" : in superclass");
498 } 482 }
499 str->print_cr(""); 483 str->cr();
500 } 484 }
501 485
502 void print_exception(outputStream* str, int indent) { 486 void print_exception(outputStream* str, int indent) {
503 assert(throws_exception(), "Should be called otherwise"); 487 assert(throws_exception(), "Should be called otherwise");
504 assert(_exception_name != NULL, "exception_name should be set"); 488 assert(_exception_name != NULL, "exception_name should be set");
702 tty->print_cr("Slots that need filling:"); 686 tty->print_cr("Slots that need filling:");
703 streamIndentor si(tty); 687 streamIndentor si(tty);
704 for (int i = 0; i < slots->length(); ++i) { 688 for (int i = 0; i < slots->length(); ++i) {
705 tty->indent(); 689 tty->indent();
706 slots->at(i)->print_on(tty); 690 slots->at(i)->print_on(tty);
707 tty->print_cr(""); 691 tty->cr();
708 } 692 }
709 } 693 }
710 #endif // ndef PRODUCT 694 #endif // ndef PRODUCT
711 return slots; 695 return slots;
712 } 696 }
842 #ifndef PRODUCT 826 #ifndef PRODUCT
843 if (TraceDefaultMethods) { 827 if (TraceDefaultMethods) {
844 streamIndentor si(tty, 2); 828 streamIndentor si(tty, 2);
845 tty->indent().print("Looking for default methods for slot "); 829 tty->indent().print("Looking for default methods for slot ");
846 slot->print_on(tty); 830 slot->print_on(tty);
847 tty->print_cr(""); 831 tty->cr();
848 } 832 }
849 #endif // ndef PRODUCT 833 #endif // ndef PRODUCT
850 834
851 generate_erased_defaults(klass, empty_slots, slot, CHECK); 835 generate_erased_defaults(klass, empty_slots, slot, CHECK);
852 } 836 }
960 944
961 #ifndef PRODUCT 945 #ifndef PRODUCT
962 if (TraceDefaultMethods) { 946 if (TraceDefaultMethods) {
963 tty->print("for slot: "); 947 tty->print("for slot: ");
964 slot->print_on(tty); 948 slot->print_on(tty);
965 tty->print_cr(""); 949 tty->cr();
966 if (method->has_target()) { 950 if (method->has_target()) {
967 method->print_selected(tty, 1); 951 method->print_selected(tty, 1);
968 } else if (method->throws_exception()) { 952 } else if (method->throws_exception()) {
969 method->print_exception(tty, 1); 953 method->print_exception(tty, 1);
970 } 954 }