1 use crate::{ 2 descriptors::Desc, 3 errors::*, 4 objects::{AutoLocal, GlobalRef, JClass, JObject}, 5 strings::JNIString, 6 JNIEnv, 7 }; 8 9 impl<'a, T> Desc<'a, JClass<'a>> for T 10 where 11 T: Into<JNIString>, 12 { lookup(self, env: &JNIEnv<'a>) -> Result<JClass<'a>>13 fn lookup(self, env: &JNIEnv<'a>) -> Result<JClass<'a>> { 14 env.find_class(self) 15 } 16 } 17 18 impl<'a, 'b> Desc<'a, JClass<'a>> for JObject<'b> { lookup(self, env: &JNIEnv<'a>) -> Result<JClass<'a>>19 fn lookup(self, env: &JNIEnv<'a>) -> Result<JClass<'a>> { 20 env.get_object_class(self) 21 } 22 } 23 24 /// This conversion assumes that the `GlobalRef` is a pointer to a class object. 25 impl<'a, 'b> Desc<'a, JClass<'b>> for &'b GlobalRef { lookup(self, _: &JNIEnv<'a>) -> Result<JClass<'b>>26 fn lookup(self, _: &JNIEnv<'a>) -> Result<JClass<'b>> { 27 Ok(self.as_obj().into()) 28 } 29 } 30 31 /// This conversion assumes that the `AutoLocal` is a pointer to a class object. 32 impl<'a, 'b, 'c> Desc<'a, JClass<'b>> for &'b AutoLocal<'c, '_> 33 where 34 'c: 'b, 35 { lookup(self, _: &JNIEnv<'a>) -> Result<JClass<'b>>36 fn lookup(self, _: &JNIEnv<'a>) -> Result<JClass<'b>> { 37 Ok(self.as_obj().into()) 38 } 39 } 40