--- old/src/share/vm/oops/cpCacheOop.cpp Fri Feb 1 10:28:02 2013 +++ new/src/share/vm/oops/cpCacheOop.cpp Fri Feb 1 10:28:02 2013 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -470,6 +470,23 @@ return false; } +// a constant pool cache entry should never contain old or obsolete methods +bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() { + if (is_vfinal()) { + methodOop m = (methodOop)_f2; + // Return false if _f2 refers to an old or an obsolete method. + // _f2 == NULL || !m->is_method() are just as unexpected here. + return (m != NULL && m->is_method() && !m->is_old() && !m->is_obsolete()); + } else if ((oop)_f1 == NULL || !((oop)_f1)->is_method()) { + // _f1 == NULL || !_f1->is_method() are OK here + return true; + } + + methodOop m = (methodOop)_f1; + // return false if _f1 refers to an old or an obsolete method + return (!m->is_old() && !m->is_obsolete()); +} + bool ConstantPoolCacheEntry::is_interesting_method_entry(klassOop k) { if (!is_method_entry()) { // not a method entry so not interesting by default @@ -492,7 +509,7 @@ } assert(m != NULL && m->is_method(), "sanity check"); - if (m == NULL || !m->is_method() || m->method_holder() != k) { + if (m == NULL || !m->is_method() || (k != NULL && m->method_holder() != k)) { // robustness for above sanity checks or method is not in // the interesting class return false; @@ -504,16 +521,25 @@ void ConstantPoolCacheEntry::print(outputStream* st, int index) const { // print separator - if (index == 0) tty->print_cr(" -------------"); + if (index == 0) { + // adds a searchable prefix when RedefineClasses() tracing is enabled + RC_TRACE_NO_CR(0x00004000, ("")); + tty->print_cr(" -------------"); + } // print entry + RC_TRACE_NO_CR(0x00004000, ("")); tty->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); if (is_secondary_entry()) tty->print_cr("[%5d|secondary]", main_entry_index()); else tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index()); + RC_TRACE_NO_CR(0x00004000, ("")); tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)(oop)_f1); + RC_TRACE_NO_CR(0x00004000, ("")); tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); + RC_TRACE_NO_CR(0x00004000, ("")); tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); + RC_TRACE_NO_CR(0x00004000, ("")); tty->print_cr(" -------------"); } @@ -576,4 +602,25 @@ } } } +} + +// the constant pool cache should never contain old or obsolete methods +bool constantPoolCacheOopDesc::check_no_old_or_obsolete_entries() { + for (int i = 1; i < length(); i++) { + if (entry_at(i)->is_interesting_method_entry(NULL) && + !entry_at(i)->check_no_old_or_obsolete_entries()) { + return false; + } + } + return true; +} + +void constantPoolCacheOopDesc::dump_cache() { + for (int i = 1; i < length(); i++) { + if (entry_at(i)->is_interesting_method_entry(NULL)) { + // adds a searchable prefix when RedefineClasses() tracing is enabled + RC_TRACE_NO_CR(0x00004000, ("")); + entry_at(i)->print(tty, i); + } + } }