< prev index next >

src/share/vm/classfile/defaultMethods.cpp

Print this page


   1 /*
   2  * Copyright (c) 2012, 2018, 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  *


 489     streamIndentor si(str, indent * 2);
 490     str->indent().print_cr("%s: %s", _exception_name->as_C_string(), _exception_message->as_C_string());
 491   }
 492 #endif // ndef PRODUCT
 493 };
 494 
 495 Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const {
 496   return SymbolTable::new_symbol("No qualifying defaults found", THREAD);
 497 }
 498 
 499 Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const {
 500   stringStream ss;
 501   ss.print("Method ");
 502   Symbol* name = method->name();
 503   Symbol* signature = method->signature();
 504   ss.write((const char*)klass_name->bytes(), klass_name->utf8_length());
 505   ss.print(".");
 506   ss.write((const char*)name->bytes(), name->utf8_length());
 507   ss.write((const char*)signature->bytes(), signature->utf8_length());
 508   ss.print(" is abstract");
 509   return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL);
 510 }
 511 
 512 Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const {
 513   stringStream ss;
 514   ss.print("Conflicting default methods:");
 515   for (int i = 0; i < methods->length(); ++i) {
 516     Method* method = methods->at(i);
 517     Symbol* klass = method->klass_name();
 518     Symbol* name = method->name();
 519     ss.print(" ");
 520     ss.write((const char*)klass->bytes(), klass->utf8_length());
 521     ss.print(".");
 522     ss.write((const char*)name->bytes(), name->utf8_length());
 523   }
 524   return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL);
 525 }
 526 
 527 
 528 class StateRestorer;
 529 
 530 // StatefulMethodFamily is a wrapper around a MethodFamily that maintains the
 531 // qualification state during hierarchy visitation, and applies that state
 532 // when adding members to the MethodFamily
 533 class StatefulMethodFamily : public ResourceObj {
 534   friend class StateRestorer;
 535  private:
 536   QualifiedState _qualification_state;
 537 
 538   void set_qualification_state(QualifiedState state) {
 539     _qualification_state = state;
 540   }
 541 
 542  protected:
 543   MethodFamily* _method_family;
 544 


   1 /*
   2  * Copyright (c) 2012, 2019, 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  *


 489     streamIndentor si(str, indent * 2);
 490     str->indent().print_cr("%s: %s", _exception_name->as_C_string(), _exception_message->as_C_string());
 491   }
 492 #endif // ndef PRODUCT
 493 };
 494 
 495 Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const {
 496   return SymbolTable::new_symbol("No qualifying defaults found", THREAD);
 497 }
 498 
 499 Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const {
 500   stringStream ss;
 501   ss.print("Method ");
 502   Symbol* name = method->name();
 503   Symbol* signature = method->signature();
 504   ss.write((const char*)klass_name->bytes(), klass_name->utf8_length());
 505   ss.print(".");
 506   ss.write((const char*)name->bytes(), name->utf8_length());
 507   ss.write((const char*)signature->bytes(), signature->utf8_length());
 508   ss.print(" is abstract");
 509   return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD);
 510 }
 511 
 512 Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const {
 513   stringStream ss;
 514   ss.print("Conflicting default methods:");
 515   for (int i = 0; i < methods->length(); ++i) {
 516     Method* method = methods->at(i);
 517     Symbol* klass = method->klass_name();
 518     Symbol* name = method->name();
 519     ss.print(" ");
 520     ss.write((const char*)klass->bytes(), klass->utf8_length());
 521     ss.print(".");
 522     ss.write((const char*)name->bytes(), name->utf8_length());
 523   }
 524   return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD);
 525 }
 526 
 527 
 528 class StateRestorer;
 529 
 530 // StatefulMethodFamily is a wrapper around a MethodFamily that maintains the
 531 // qualification state during hierarchy visitation, and applies that state
 532 // when adding members to the MethodFamily
 533 class StatefulMethodFamily : public ResourceObj {
 534   friend class StateRestorer;
 535  private:
 536   QualifiedState _qualification_state;
 537 
 538   void set_qualification_state(QualifiedState state) {
 539     _qualification_state = state;
 540   }
 541 
 542  protected:
 543   MethodFamily* _method_family;
 544 


< prev index next >