1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
use core::ops::Deref; use swim_jvm_sys::{jthrowable, jvalue}; use crate::error::Result; use crate::object::JObject; use crate::env::JEnv; use crate::convert::{FromJava, IntoJava, TryFromJava, TryIntoJava}; #[derive(Clone, Copy, Debug)] pub struct JThrowable { object: JObject, } unsafe impl Send for JThrowable {} unsafe impl Sync for JThrowable {} impl JThrowable { #[inline] pub fn get_env(&self) -> &JEnv { self.object.get_env() } } impl Deref for JThrowable { type Target = JObject; #[inline] fn deref(&self) -> &JObject { &self.object } } impl FromJava<jthrowable> for JThrowable { #[inline] fn from_java(env: &JEnv, throwable: jthrowable) -> Self { Self { object: JObject::from_java(env, throwable) } } } impl TryFromJava<jthrowable> for JThrowable { #[inline] fn try_from_java(env: &JEnv, throwable: jthrowable) -> Result<Self> { Ok(Self::from_java(env, throwable)) } } impl IntoJava<jthrowable> for JThrowable { #[inline] fn into_java(self, _env: &JEnv) -> jthrowable { self.object.into() } } impl<'a> IntoJava<jthrowable> for &'a JThrowable { #[inline] fn into_java(self, _env: &JEnv) -> jthrowable { self.object.into() } } impl TryIntoJava<jthrowable> for JThrowable { #[inline] fn try_into_java(self, _env: &JEnv) -> Result<jthrowable> { Ok(self.object.into()) } } impl<'a> TryIntoJava<jthrowable> for &'a JThrowable { #[inline] fn try_into_java(self, _env: &JEnv) -> Result<jthrowable> { Ok(self.object.into()) } } impl From<JObject> for JThrowable { #[inline] fn from(object: JObject) -> JThrowable { JThrowable { object: object } } } impl Into<JObject> for JThrowable { #[inline] fn into(self) -> JObject { self.object } } impl<'a> Into<JObject> for &'a JThrowable { #[inline] fn into(self) -> JObject { self.object } } impl Into<jthrowable> for JThrowable { #[inline] fn into(self) -> jthrowable { self.object.into() } } impl<'a> Into<jthrowable> for &'a JThrowable { #[inline] fn into(self) -> jthrowable { self.object.into() } } impl Into<jvalue> for JThrowable { #[inline] fn into(self) -> jvalue { jvalue { l: self.object.into() } } } impl<'a> Into<jvalue> for &'a JThrowable { #[inline] fn into(self) -> jvalue { jvalue { l: self.object.into() } } }