# HG changeset patch # User thartmann # Date 1495437250 -7200 # Node ID 8f941bab493f6d42cca56b6d6824ac065a64aa24 # Parent 34c47915ae050e4ecdc0d57279fbb09afaf49b5f 8180565: Null pointer dereferences of ConstMethod::method() Summary: We need to check ConstMethod::method() for NULL before dereferencing. Reviewed-by: kvn, iignatyev diff -r 34c47915ae05 -r 8f941bab493f src/share/vm/oops/constMethod.cpp --- a/src/share/vm/oops/constMethod.cpp Fri May 19 15:32:17 2017 +0530 +++ b/src/share/vm/oops/constMethod.cpp Mon May 22 09:14:10 2017 +0200 @@ -407,8 +407,12 @@ ResourceMark rm; assert(is_constMethod(), "must be constMethod"); st->print_cr("%s", internal_name()); - st->print(" - method: " INTPTR_FORMAT " ", p2i((address)method())); - method()->print_value_on(st); st->cr(); + Method* m = method(); + st->print(" - method: " INTPTR_FORMAT " ", p2i((address)m)); + if (m != NULL) { + m->print_value_on(st); + } + st->cr(); if (has_stackmap_table()) { st->print(" - stackmap data: "); stackmap_data()->print_value_on(st); @@ -421,7 +425,12 @@ void ConstMethod::print_value_on(outputStream* st) const { assert(is_constMethod(), "must be constMethod"); st->print(" const part of method " ); - method()->print_value_on(st); + Method* m = method(); + if (m != NULL) { + m->print_value_on(st); + } else { + st->print("NULL"); + } } #if INCLUDE_SERVICES @@ -461,7 +470,7 @@ // Verification can occur during oop construction before the method or // other fields have been initialized. - guarantee(method()->is_method(), "should be method"); + guarantee(method() != NULL && method()->is_method(), "should be method"); address m_end = (address)((intptr_t) this + size()); address compressed_table_start = code_end();