public static String StrongJ2CpString(JNIEnv env, JniLocalHandle obj) { if (JniHandle.IsNull(obj)) { return(null); } return(String.CreateProxy(env, obj)); }
public static Class StrongJ2CpClass(JNIEnv env, JniLocalHandle obj) { if (JniHandle.IsNull(obj)) { return(null); } return(Class.CreateProxy(env, obj)); }
public static string StrongJp2CString(JNIEnv env, JniLocalHandle obj) { if (JniHandle.IsNull(obj)) { return(null); } object res = __IClrProxy.GetObject(env, obj); return((string)res); }
public static string StrongJ2CString(JNIEnv env, JniLocalHandle obj) { if (JniHandle.IsNull(obj)) { return(null); } string res = env.ConvertToString(obj); return(res); }
public static TRes StrongJp2C <TRes>(JNIEnv env, JniLocalHandle obj) { if (JniHandle.IsNull(obj)) { return(default(TRes)); } object res = __IClrProxy.GetObject(env, obj); return((TRes)res); }
public static TRes StrongJ2Cp <TRes>(JNIEnv env, JniLocalHandle obj) where TRes : IJvmProxy { if (JniHandle.IsNull(obj)) { return(default(TRes)); } Class clazz = env.GetObjectClass(obj); RegistryRecord record = Registry.GetJVMRecord(clazz); return((TRes)record.CreateCLRProxy(env, obj)); }
public static object StrongJ2CpUntyped(IntPtr ptr) { JNIEnv env = JNIEnv.ThreadEnv; JniLocalHandle obj = ptr; if (JniHandle.IsNull(obj)) { return(null); } Class clazz = env.GetObjectClass(obj); RegistryRecord record = Registry.GetJVMRecord(clazz); return(record.CreateCLRProxyNoDelete(env, obj)); }
public static TRes ArrayStrongJp2C <TRes, TElem>(JNIEnv env, JniLocalHandle array) where TRes : class //should be TRes : Array { if (JniHandle.IsNull(array)) { return(default(TRes)); } int length = env.GetArrayLength(array); var res = new TElem[length]; for (int i = 0; i < length; i++) { JniLocalHandle elementPtr = env.GetObjectArrayElementPtr(array, i); var element = StrongJp2C <TElem>(env, elementPtr); res.SetValue(element, i); } return((TRes)(object)res); }
public static TRes StrongJ2CpDelegate <TRes>(JNIEnv env, JniLocalHandle obj) where TRes : class //Delegate { #if DEBUG if (!typeof(Delegate).IsAssignableFrom(typeof(TRes))) { throw new ArgumentException("expected delegate"); } #endif if (JniHandle.IsNull(obj)) { return(default(TRes)); } object res = __IClrProxy.GetObject(env, obj); if (res == null) { //that's delegate implemented in Java RegistryRecord delRecord = Registry.GetCLRRecord(typeof(TRes)); IJvmProxy jvmProxy = delRecord.CreateCLRProxy(env, obj); return((TRes)(object)Delegate.CreateDelegate(typeof(TRes), jvmProxy, delRecord.JVMDelegateInvoke)); } return((TRes)res); }