void IJvmProxy.Init(JNIEnv env, JniLocalHandle obj) { jvmHandle = env.NewGlobalRef(obj); env.DeleteLocalRef(obj); }
public Object NewObjectArray(int len, Class clazz, IJvmProxy init) { JniLocalHandle res = NewObjectArrayPtr(len, clazz.jvmHandle, init); return Convertor.StrongJ2CpObject(this, res); }
internal Object NewDoubleArray(int len) { JniLocalHandle res = NewDoubleArrayPtr(len); return Convertor.StrongJ2CpObject(this, res); }
private static JniLocalHandle Cast(IntPtr @__envp, JniLocalHandle @__class, JniLocalHandle obj, JniLocalHandle expectedInterface) { JNIEnv env = JNIEnv.Wrap(@__envp); try { Class expectedInterfaceClass = Convertor.StrongJ2CpClass(env, expectedInterface); object real = __IClrProxy.GetObject(env, obj); Type type = real.GetType(); RegistryRecord record = Registry.GetJVMRecord(expectedInterfaceClass); Type reqType = record.CLRInterface; if (!reqType.IsAssignableFrom(type)) { throw new InvalidCastException("Can't convert instance of CLR type " + type + " to " + reqType); } return(record.CreateJVMProxy(env, real)); } catch (Exception ex) { env.ThrowExisting(ex); } return(JniLocalHandle.Zero); }