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

Function get_method_param_info

src/native.rs:601–681  ·  view source on GitHub ↗
(method: jmethodID)

Source from the content-addressed store, hash-verified

599}
600
601unsafe fn get_method_param_info(method: jmethodID) -> Result<MethodInfo, String> {
602 let mut ret = MethodInfo {
603 mods: get_method_modifiers(method)?,
604 params: Vec::new(),
605 };
606 let is_static = ret.mods & 0x00000008 != 0;
607 let mut sig: *mut c_char = 0 as *mut c_char;
608 let name_res = (**JVMTI_ENV).GetMethodName.unwrap()(JVMTI_ENV, method, ptr::null_mut(), &mut sig, ptr::null_mut());
609 util::unit_or_jvmti_err(name_res)?;
610 // Parse the sig
611 let sig_str = CStr::from_ptr(sig).to_str().map_err(|_| "Error parsing method sig")?;
612 let mut sig_chars = sig_str.chars();
613 if sig_chars.next() != Some('(') { return Result::Err(format!("Str {} missing opening param", sig_str)); }
614 let mut working_str = "".to_string();
615 let mut in_obj = false;
616 let mut slot_counter = 0;
617 if !is_static {
618 ret.params.push(Param {
619 name: "this".to_string(),
620 typ: get_class_signature(get_method_declaring_class(method)?)?,
621 slot: slot_counter,
622 val: None,
623 });
624 slot_counter += 1;
625 }
626 let mut param_counter = 0;
627 loop {
628 match sig_chars.next() {
629 None => {
630 let _ = dealloc(sig as *mut c_char);
631 return Result::Err("Unexpected end of desc".to_string());
632 },
633 Some(c) => match c {
634 ')' => {
635 dealloc(sig)?;
636 return Result::Ok(ret);
637 },
638 ';' if in_obj => {
639 working_str.push(';');
640 ret.params.push(Param {
641 name: format!("arg{}", param_counter),
642 typ: working_str.clone(),
643 slot: slot_counter,
644 val: None,
645 });
646 param_counter += 1;
647 slot_counter += 1;
648 in_obj = false;
649 working_str.clear();
650 },
651 _ if in_obj => working_str.push(c),
652 'L' => {
653 in_obj = true;
654 working_str.push('L');
655 }
656 '[' => working_str.push('['),
657 'B' | 'C' | 'D' | 'F' | 'I' | 'J' | 'S' | 'Z' => {
658 working_str.push(c);

Callers 1

get_frame_paramsFunction · 0.85

Calls 6

get_method_modifiersFunction · 0.85
unit_or_jvmti_errFunction · 0.85
get_class_signatureFunction · 0.85
deallocFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected