Exemplo n.º 1
0
        private static long WrapJVM(IntPtr __envp, JniLocalHandle __class, JniLocalHandle obj)
        {
            JNIEnv env = JNIEnv.Wrap(__envp);

            try
            {
                Class          clazz    = env.GetObjectClass(obj);
                RegistryRecord record   = Registry.GetJVMRecord(clazz);
                IJvmProxy      clrProxy = record.CreateCLRProxy(env, obj);
                return(IntHandle.Alloc(clrProxy));
            }
            catch (Exception ex)
            {
                env.ThrowExisting(ex);
            }
            return(0);
        }
Exemplo n.º 2
0
        public static Object WrapCLR(object obj)
        {
            var proxy    = obj as IJvmProxy;
            var clrProxy = proxy as IClrProxy;

            if (proxy != null)
            {
                if (clrProxy != null)
                {
                    return((Object)clrProxy);
                }
                throw new JNIException("Can't wrap JVM instance");
            }
            Type   type = obj.GetType();
            JNIEnv env  = JNIEnv.ThreadEnv;

            RegistryRecord record   = Registry.GetCLRRecord(type);
            JniLocalHandle jvmProxy = record.CreateJVMProxy(env, obj);

            return((Object)record.CreateCLRProxy(env, jvmProxy));
        }