示例#1
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public double CallDoubleMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            double res = callDoubleMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
示例#2
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public bool CallBooleanMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            bool res = callBooleanMethod(envPtr, obj, methodIdNative.native, args) != 0;

            ExceptionTest();
            return(res);
        }
示例#3
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public long CallLongMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            long res = callLongMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
示例#4
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public char CallCharMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            var res = (char)callCharMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
示例#5
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public void NewObject(Class clazz, MethodId methodID, IJvmProxy obj, params Value[] args)
        {
            JniLocalHandle res = newObject(envPtr, clazz.jvmHandle, methodID.native, args);

            ExceptionTest();
            obj.Init(this, res);
        }
示例#6
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public IObject NewObject(Class clazz, MethodId methodID, params Value[] args)
        {
            JniLocalHandle res = newObject(envPtr, clazz.jvmHandle, methodID.native, args);

            ExceptionTest();
            return(Convertor.FullJ2C <IJvmProxy>(this, res));
        }
示例#7
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public JniLocalHandle NewObjectPtr(JniHandle clazz, MethodId methodID, params Value[] args)
        {
            JniLocalHandle res = newObject(envPtr, clazz, methodID.native, args);

            ExceptionTest();
            return(res);
        }
示例#8
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public float CallFloatMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            float res = callFloatMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
示例#9
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public Method ToReflectedMethod(Class cls, MethodId methodId, bool isStatic)
        {
            JniLocalHandle res = toReflectedMethod.Invoke(envPtr, cls.jvmHandle, methodId.native,
                                                          isStatic ? (byte)1 : (byte)0);

            ExceptionTest();
            return(Convertor.StrongJ2Cp <Method>(this, res));
        }
示例#10
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        private TRes CallStaticMethod <TRes>(Class clazz, string method, string sig, params Value[] args)
        {
            MethodId idNative = GetStaticMethodID(clazz, method, sig);

            if (idNative != null)
            {
                if (typeof(IObject).IsAssignableFrom(typeof(TRes)) ||
                    (typeof(object) == (typeof(TRes)) ||
                     typeof(Delegate).IsAssignableFrom(typeof(TRes)))
                    )
                {
                    return(CallStaticObjectMethod <TRes>(clazz, idNative, args));
                }
                if (typeof(string).IsAssignableFrom(typeof(TRes)))
                {
                    return(CallStaticObjectMethod <TRes>(clazz, idNative, args));
                }
                if (typeof(int).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticIntMethod(clazz, idNative, args));
                }
                if (typeof(bool).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticBooleanMethod(clazz, idNative, args));
                }
                if (typeof(long).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticLongMethod(clazz, idNative, args));
                }
                if (typeof(double).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticDoubleMethod(clazz, idNative, args));
                }
                if (typeof(byte).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticByteMethod(clazz, idNative, args));
                }
                if (typeof(short).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticShortMethod(clazz, idNative, args));
                }
                if (typeof(float).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticFloatMethod(clazz, idNative, args));
                }
                if (typeof(char).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticCharMethod(clazz, idNative, args));
                }
                if (typeof(byte).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallStaticByteMethod(clazz, idNative, args));
                }
            }
            throw new ArgumentException();
        }
示例#11
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public void CallVoidMethod(IJvmProxy obj, MethodId methodId, params Value[] args)
        {
#if DEBUG
            if (Bridge.Setup.VeryVerbose)
            {
                Console.WriteLine("IJvmProxy : " + obj.GetType().FullName);
            }
#endif
            CallVoidMethod(obj.JvmHandle, methodId, args);
        }
示例#12
0
        public IObject NewObject(Class clazz, string method, string sig, params object[] args)
        {
            MethodId idNative = GetMethodID(clazz, method, sig);

            if (idNative != null)
            {
                return(NewObject(clazz, idNative, Convertor.ConverArgs(this, args)));
            }
            throw new ArgumentException();
        }
示例#13
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        private TRes CallMethod <TRes>(IJvmProxy obj, string method, string sig, params Value[] args)
        {
            MethodId idNative = GetMethodID(GetObjectClass(obj), method, sig);

            if (idNative != null)
            {
                if (typeof(IObject).IsAssignableFrom(typeof(TRes)) ||
                    typeof(object) == (typeof(TRes)) ||
                    typeof(Delegate).IsAssignableFrom(typeof(TRes)))
                {
                    return(CallObjectMethod <TRes>(obj, idNative, args));
                }
                if (typeof(string).IsAssignableFrom(typeof(TRes)))
                {
                    return(CallObjectMethod <TRes>(obj, idNative, args));
                }
                if (typeof(int).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallIntMethod(obj, idNative, args));
                }
                if (typeof(bool).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallBooleanMethod(obj, idNative, args));
                }
                if (typeof(long).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallLongMethod(obj, idNative, args));
                }
                if (typeof(double).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallDoubleMethod(obj, idNative, args));
                }
                if (typeof(byte).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallByteMethod(obj, idNative, args));
                }
                if (typeof(short).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallShortMethod(obj, idNative, args));
                }
                if (typeof(float).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallFloatMethod(obj, idNative, args));
                }
                if (typeof(char).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallCharMethod(obj, idNative, args));
                }
                if (typeof(byte).IsAssignableFrom(typeof(TRes)))
                {
                    return((TRes)(object)CallByteMethod(obj, idNative, args));
                }
            }
            throw new ArgumentException();
        }
示例#14
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        internal void CallStaticVoidMethod(Class clazz, string method, string sig, params Value[] args)
        {
            MethodId idNative = GetStaticMethodID(clazz, method, sig);

            if (idNative != null)
            {
                CallStaticVoidMethod(clazz, idNative, args);
                return;
            }
            throw new ArgumentException();
        }
示例#15
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public byte CallStaticByteMethod(Class clazz, MethodId methodIdNative, params Value[] args)
        {
#if DEBUG
            if (Bridge.Setup.VeryVerbose)
            {
                Console.WriteLine("CallStaticByteMethod : " + clazz.FullName);
            }
#endif
            byte res = callStaticByteMethod(envPtr, clazz.jvmHandle, methodIdNative.native, args);
            ExceptionTest();
            return(res);
        }
示例#16
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public void CallStaticVoidMethod(Class clazz, MethodId methodIdNative, params Value[] args)
        {
#if DEBUG
            if (Bridge.Setup.VeryVerbose)
            {
                Console.WriteLine("CallStaticVoidMethod : " + clazz.FullName);
            }
#endif
            callStaticVoidMethod(envPtr, clazz.jvmHandle, methodIdNative.native, args);
            //TODO result could be tested in Java 1.6
            ExceptionTest();
        }
示例#17
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public char CallCharMethod(IJvmProxy obj, MethodId methodIdNative, params Value[] args)
        {
#if DEBUG
            if (Bridge.Setup.VeryVerbose)
            {
                Console.WriteLine("CallCharMethod : " + obj.GetType().FullName);
            }
#endif
            var res = (char)callCharMethod(envPtr, obj.JvmHandle, methodIdNative.native, args);
            ExceptionTest();
            return(res);
        }
示例#18
0
 public JniLocalHandle CallStaticObjectMethodPtr(Class clazz, MethodId methodIdNative, params Value[] args)
 {
     #if DEBUG
     if (Bridge.Setup.VeryVerbose)
     {
         Console.WriteLine("CallStaticObjectMethodPtr : " + clazz.FullName);
     }
     #endif
     JniLocalHandle res = callStaticObjectMethod(envPtr, clazz.jvmHandle, methodIdNative.native, args);
     ExceptionTest();
     return res;
 }
示例#19
0
        public JniLocalHandle CallObjectMethodPtr(IJvmProxy obj, MethodId methodIdNative, params Value[] args)
        {
#if DEBUG
            if (Bridge.Setup.VeryVerbose)
            {
                Console.WriteLine("CallObjectMethodPtr : " + obj.GetType().FullName);
            }
#endif
            JniLocalHandle res = callObjectMethod(envPtr, obj.JvmHandle, methodIdNative.native, args);
            ExceptionTest();
            return(res);
        }
示例#20
0
 public JniLocalHandle CallObjectMethodPtr(IJvmProxy obj, MethodId methodIdNative, params Value[] args)
 {
     #if DEBUG
     if (Bridge.Setup.VeryVerbose)
     {
         Console.WriteLine("CallObjectMethodPtr : " + obj.GetType().FullName);
     }
     #endif
     JniLocalHandle res = callObjectMethod(envPtr, obj.JvmHandle, methodIdNative.native, args);
     ExceptionTest();
     return res;
 }
示例#21
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        private int CallIntMethod(IJvmProxy obj, string method, string sig, params Value[] args)
        {
            Class objectClass = GetObjectClass(obj);

            if (objectClass != null)
            {
                MethodId methodId = GetMethodID(objectClass, method, sig);
                if (methodId != null)
                {
                    return(CallIntMethod(obj, methodId, args));
                }
            }
            throw new ArgumentException();
        }
示例#22
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public TRes CallObjectMethod <TRes>(IJvmProxy obj, MethodId methodIdNative, params Value[] args)
        {
            JniLocalHandle res = CallObjectMethodPtr(obj, methodIdNative, args);

            return(Convertor.FullJ2C <TRes>(this, res));
        }
示例#23
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
        public TRes CallStaticObjectMethod <TRes>(Class clazz, MethodId methodIdNative, params Value[] args)
        {
            JniLocalHandle res = CallStaticObjectMethodPtr(clazz, methodIdNative, args);

            return(Convertor.FullJ2C <TRes>(this, res));
        }
示例#24
0
        private static void Init()
        {
            if (initDone)
            {
                return;
            }
            try
            {
                initDone = true;
                // sun JVM specific
                JNIEnv env = JNIEnv.ThreadEnv;
                dbClazz = env.FindClass("java/nio/DirectByteBuffer");

                // java 7 and above
                ctor = env.GetMethodIDNoThrow(dbClazz, "<init>", "(IJLjava/io/FileDescriptor;Ljava/lang/Runnable;)V");
                if (ctor == null)
                {
                    // java 6 and below
                    ctor = env.GetMethodIDNoThrow(dbClazz, "<init>", "(IJLjava/lang/Runnable;)V");
                    jdk6 = true;
                }
            }
            catch (Exception)
            {
            }
        }
示例#25
0
文件: JNIEnv.cs 项目: cd37ycs/jni4net
 public void CallVoidMethod(JniHandle obj, MethodId methodId, params Value[] args)
 {
     callVoidMethod(envPtr, obj, methodId.native, args);
     //TODO result could be tested in Java 1.6
     ExceptionTest();
 }