MCPcopy Create free account
hub / github.com/cretz/stackparam / Java_java_lang_Throwable_stackParamFillInStackTrace

Function Java_java_lang_Throwable_stackParamFillInStackTrace

src/native.rs:53–88  ·  view source on GitHub ↗
(jni_env: *mut JNIEnv,
                                                                             this: jobject,
                                                                             thread: 

Source from the content-addressed store, hash-verified

51#[no_mangle]
52#[allow(non_snake_case)]
53pub unsafe extern "C" fn Java_java_lang_Throwable_stackParamFillInStackTrace(jni_env: *mut JNIEnv,
54 this: jobject,
55 thread: jthread) -> jobject {
56 // This is needed in case of failure, we need to at least set the field to something
57 unsafe fn set_param_to_null_ignore_err(jni_env: *mut JNIEnv, this: jobject) {
58 let field = get_stack_params_field(jni_env).unwrap_or(ptr::null_mut());
59 if !field.is_null() {
60 (**jni_env).SetObjectField.unwrap()(jni_env, this, field, ptr::null_mut());
61 let _ = util::result_or_jni_ex((), jni_env);
62 }
63 }
64
65 // Do nothing before vm init (i.e. before our static is set)
66 if JVMTI_ENV.is_null() {
67 set_param_to_null_ignore_err(jni_env, this);
68 return this;
69 }
70
71 // TODO: there are a ton of exception fills happening on startup that are slowing things down and
72 // are not relayed to the user. We should either skip filling those, or find a way to make the fill
73 // cheaper (bunch of string allocs)
74 if log_enabled!(Debug) {
75 let class_name = class_sig_from_obj(jni_env, this).unwrap_or("<unknown>".to_string());
76 debug!("Asking to fill for {}", class_name);
77 }
78
79 // Populate the field, swallow the err
80 match populate_stack_params(jni_env, this, thread) {
81 Result::Err(err_str) => {
82 debug!("Stack param fill err: {}", err_str);
83 set_param_to_null_ignore_err(jni_env, this);
84 },
85 Result::Ok(()) => ()
86 };
87 return this;
88}
89
90unsafe fn append_param_to_string(jni_env: *mut JNIEnv, this: jobject) -> Result<jobject, String> {
91 // First call the original one, then take the result and append our stuff via static call

Callers

nothing calls this directly

Calls 3

class_sig_from_objFunction · 0.85
populate_stack_paramsFunction · 0.85

Tested by

no test coverage detected