Пример #1
0
 public void Init(JNIEnv env, JniLocalHandle handle)
 {
     if (JniLocalHandle.IsNull(handle))
         mJvmHandle = null;
     else
         mJvmHandle = env.NewGlobalRef(handle);
 }
Пример #2
0
 public static unsafe void Unregister(JniHandle clazz, JNIEnv env)
 {
     JNIResult res = env.UnregisterNatives(clazz);
     if (res != JNIResult.JNI_OK)
     {
         throw new JNIException("Can't unbind native methods to class.");
     }
 }
Пример #3
0
        public JavaException(JNIEnv env)
        {
            Type type = GetType();
            mIsClrObject = type.GetCustomAttributes(typeof(JavaClassAttribute), false).Length == 0 && type.GetCustomAttributes(typeof(JavaProxyAttribute), false).Length == 0;

            //if (!mIsClrObject)
            //    GC.SuppressFinalize(this);
        }
Пример #4
0
 public static unsafe void Register(List<JNINativeMethod> registrations, JniHandle clazz, JNIEnv env)
 {
     JNINativeMethod[] methods = registrations.ToArray();
     JNIResult res = env.RegisterNatives(clazz, methods, methods.Length);
     if (res!=JNIResult.JNI_OK)
     {
         throw new JNIException("Can't bind native methods to class. Is it in system classloader?");
     }
 }
Пример #5
0
 public JNIResult AttachCurrentThread(out JNIEnv penv, JavaVMInitArgs? args)
 {
     IntPtr env;
     JNIResult result;
     if (args.HasValue)
     {
         JavaVMInitArgs initArgs = args.Value;
         result = attachCurrentThread.Invoke(native, out env, &initArgs);
     }
     else
     {
         result = attachCurrentThread.Invoke(native, out env, null);
     }
     penv = new JNIEnv(env);
     return result;
 }
Пример #6
0
 public JNIResult AttachCurrentThread(out JNIEnv penv, JavaVMInitArgs? args)
 {
     IntPtr env;
     JNIResult result;
     if (args.HasValue)
     {
         throw new Exception("AttachCurrentThread");
         JavaVMInitArgs initArgs = args.Value;
         result = attachCurrentThread.Invoke(native, out env, IntPtr.Zero);
     }
     else
     {
         result = attachCurrentThread.Invoke(native, out env, IntPtr.Zero);
     }
     penv = new JNIEnv(env);
     return result;
 }
Пример #7
0
 public JNIResult GetEnv(out JNIEnv penv, int version)
 {
     IntPtr env;
     JNIResult result = getEnv.Invoke(native, out env, version);
     penv = new JNIEnv(env);
     return result;
 }
Пример #8
0
 public JNIResult AttachCurrentThreadAsDaemon(out JNIEnv penv, JavaVMInitArgs? args)
 {
     IntPtr env;
     JNIResult result;
     if (args.HasValue)
     {
         throw new Exception("AttachCurrentThreadAsDaemon");
         JavaVMInitArgs value = args.Value;
         result = attachCurrentThreadAsDaemon.Invoke(native, out env, IntPtr.Zero);
     }
     else
     {
         result = attachCurrentThreadAsDaemon.Invoke(native, out env, IntPtr.Zero);
     }
     if (result == JNIResult.JNI_OK)
     {
         penv = new JNIEnv(env);
     }
     else
     {
         penv = null;
     }
     return result;
 }
Пример #9
0
 public void Register(JniHandle clazz, JNIEnv env)
 {
     List<JNINativeMethod> l = new List<JNINativeMethod>();
     l.Add(this);
     Register(l, clazz, env);
 }
Пример #10
0
 public void Init(JNIEnv env, JniLocalHandle handle)
 {
     mJvmHandle = env.NewGlobalRef(handle);
 }
Пример #11
0
 public JavaException(JNIEnv env)
 {
     Type type = GetType();
     mIsClrObject = type.GetCustomAttributes(typeof(JavaClassAttribute), false).Length == 0 && type.GetCustomAttributes(typeof(JavaProxyAttribute), false).Length == 0;
 }