Mercurial > hg > graal-jvmci-8
diff src/share/vm/oops/instanceKlass.cpp @ 22933:1a9c5e6e13b7
8067662: "java.lang.NullPointerException: Method name is null" from StackTraceElement.<init>
Summary: use method cpref and klass version to provide meaningful methods name in stacktraces
Reviewed-by: coleenp, dcubed
author | sspitsyn |
---|---|
date | Wed, 08 Apr 2015 14:20:09 -0700 |
parents | fdde6a70ea85 |
children | d8f133adf05d 6f31df24cec0 |
line wrap: on
line diff
--- a/src/share/vm/oops/instanceKlass.cpp Wed Sep 03 12:45:14 2014 +0200 +++ b/src/share/vm/oops/instanceKlass.cpp Wed Apr 08 14:20:09 2015 -0700 @@ -3747,6 +3747,22 @@ } // end has_previous_version() +InstanceKlass* InstanceKlass::get_klass_version(int version) { + if (constants()->version() == version) { + return this; + } + PreviousVersionWalker pvw(Thread::current(), (InstanceKlass*)this); + for (PreviousVersionNode * pv_node = pvw.next_previous_version(); + pv_node != NULL; pv_node = pvw.next_previous_version()) { + ConstantPool* prev_cp = pv_node->prev_constant_pool(); + if (prev_cp->version() == version) { + return prev_cp->pool_holder(); + } + } + return NULL; // None found +} + + Method* InstanceKlass::method_with_idnum(int idnum) { Method* m = NULL; if (idnum < methods()->length()) { @@ -3765,6 +3781,37 @@ return m; } + +Method* InstanceKlass::method_with_orig_idnum(int idnum) { + if (idnum >= methods()->length()) { + return NULL; + } + Method* m = methods()->at(idnum); + if (m != NULL && m->orig_method_idnum() == idnum) { + return m; + } + // Obsolete method idnum does not match the original idnum + for (int index = 0; index < methods()->length(); ++index) { + m = methods()->at(index); + if (m->orig_method_idnum() == idnum) { + return m; + } + } + // None found, return null for the caller to handle. + return NULL; +} + + +Method* InstanceKlass::method_with_orig_idnum(int idnum, int version) { + InstanceKlass* holder = get_klass_version(version); + if (holder == NULL) { + return NULL; // The version of klass is gone, no method is found + } + Method* method = holder->method_with_orig_idnum(idnum); + return method; +} + + jint InstanceKlass::get_cached_class_file_len() { return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file); }