Exemplo n.º 1
0
        public double CallDoubleMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            double res = callDoubleMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
Exemplo n.º 2
0
        public bool CallBooleanMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            bool res = callBooleanMethod(envPtr, obj, methodIdNative.native, args) != 0;

            ExceptionTest();
            return(res);
        }
Exemplo n.º 3
0
        public long CallLongMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            long res = callLongMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
Exemplo n.º 4
0
        public char CallCharMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            var res = (char)callCharMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        public JniLocalHandle NewObjectPtr(JniHandle clazz, MethodId methodID, params Value[] args)
        {
            JniLocalHandle res = newObject(envPtr, clazz, methodID.native, args);

            ExceptionTest();
            return(res);
        }
Exemplo n.º 8
0
        public float CallFloatMethod(JniHandle obj, MethodId methodIdNative, params Value[] args)
        {
            float res = callFloatMethod(envPtr, obj, methodIdNative.native, args);

            ExceptionTest();
            return(res);
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        public TRes CallObjectMethod <TRes>(IJvmProxy obj, MethodId methodIdNative, params Value[] args)
        {
            JniLocalHandle res = CallObjectMethodPtr(obj, methodIdNative, args);

            return(Convertor.FullJ2C <TRes>(this, res));
        }
Exemplo n.º 23
0
        public TRes CallStaticObjectMethod <TRes>(Class clazz, MethodId methodIdNative, params Value[] args)
        {
            JniLocalHandle res = CallStaticObjectMethodPtr(clazz, methodIdNative, args);

            return(Convertor.FullJ2C <TRes>(this, res));
        }
Exemplo n.º 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)
            {
            }
        }
Exemplo n.º 25
0
 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();
 }