jvmti_rs/wrapper/
utils.rs1use core::slice;
2use crate::sys::*;
3use crate::to_modified_utf8;
4use std::os::raw::c_char;
5
6pub fn to_bool(jbool: jboolean) -> bool {
7 if jbool > 0 { true } else { false }
8}
9
10pub fn to_jboolean(value: bool) -> jboolean {
11 if value { 1 } else { 0 }
12}
13
14pub fn slice_raw<'a, T>(data: *const T, len: jint) -> &'a [T] {
15 unsafe {
16 if len == 0 || data.is_null() {
17 return &[];
18 }
19 return slice::from_raw_parts(data, len as usize);
20 }
21}
22
23pub fn stringify(input: *const c_char) -> String {
24 to_modified_utf8(input).into()
25}