Exemplo n.º 1
0
        public DisposableObjectCollection <JvmThreadReference> GetAllThreads(JvmNativeEnvironment nativeEnvironment)
        {
            DisposableObjectCollection <JvmThreadReference> result = new DisposableObjectCollection <JvmThreadReference>();

            int    threadsCount;
            IntPtr threads;

            ThrowOnFailure(_rawInterface.GetAllThreads(_env, out threadsCount, out threads));
            try
            {
                unsafe
                {
                    jthread *rawThreads = (jthread *)threads;
                    for (int i = 0; i < threadsCount; i++)
                    {
                        result.Add(new JvmThreadReference(this, nativeEnvironment, rawThreads[i], true));
                    }
                }

                return(result);
            }
            finally
            {
                if (threads != IntPtr.Zero)
                {
                    Deallocate(threads);
                }
            }
        }
 internal JvmThreadGroupReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jthreadGroup handle, bool freeLocalReference)
     : base(environment, nativeEnvironment, handle, freeLocalReference)
 {
     Contract.Requires(environment != null);
     Contract.Requires(nativeEnvironment != null);
     Contract.Requires(handle != jthreadGroup.Null);
 }
        internal SafeJvmWeakGlobalReferenceHandle(JvmNativeEnvironment nativeEnvironment, jweak handle, bool ownsHandle)
            : base(ownsHandle)
        {
            Contract.Requires <ArgumentNullException>(nativeEnvironment != null, "nativeEnvironment");

            _nativeEnvironment = nativeEnvironment;
            SetHandle(handle.Handle);
        }
Exemplo n.º 4
0
        internal JvmObjectReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jobject handle, bool freeLocalReference)
        {
            Contract.Requires <ArgumentNullException>(environment != null, "environment");
            Contract.Requires <ArgumentNullException>(nativeEnvironment != null, "nativeEnvironment");
            Contract.Requires <ArgumentException>(handle != jobject.Null);

            _environment = environment;
            _handle      = nativeEnvironment.NewWeakGlobalReference(handle);
        }
Exemplo n.º 5
0
        internal JvmThreadReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jthread handle, bool freeLocalReference)
            : base(environment, nativeEnvironment, handle, freeLocalReference)
        {
            Contract.Requires(environment != null);
            Contract.Requires(nativeEnvironment != null);
            Contract.Requires(handle != jthread.Null);

            // quick experiment to see if the lifetime of thread references is killing the process.
            pinnedReferences.Add(base.Handle);
        }
Exemplo n.º 6
0
        public static JvmThreadReference FromHandle(JvmEnvironment environment, JNIEnvHandle jniEnv, jthread threadHandle, bool freeLocalReference)
        {
            if (threadHandle == jthread.Null)
            {
                return(null);
            }

            JvmNativeEnvironment nativeEnvironment = environment.GetNativeFunctionTable(jniEnv);

            return(new JvmThreadReference(environment, nativeEnvironment, threadHandle, freeLocalReference));
        }
Exemplo n.º 7
0
        public static JvmObjectReference FromHandle(JvmEnvironment environment, JNIEnvHandle jniEnv, jobject objectHandle, bool freeLocalReference)
        {
            if (objectHandle == jobject.Null)
            {
                return(null);
            }

            JvmNativeEnvironment nativeEnvironment = environment.GetNativeFunctionTable(jniEnv);

            return(new JvmObjectReference(environment, nativeEnvironment, objectHandle, freeLocalReference));
        }
Exemplo n.º 8
0
        public static JvmClassReference FromHandle(JvmEnvironment environment, JNIEnvHandle jniEnv, jclass classHandle, bool freeLocalReference)
        {
            if (classHandle == jclass.Null)
            {
                return(null);
            }

            JvmNativeEnvironment nativeEnvironment = environment.GetNativeFunctionTable(jniEnv);

            return(new JvmClassReference(environment, nativeEnvironment, classHandle, freeLocalReference));
        }
Exemplo n.º 9
0
        public DisposableObjectCollection <JvmObjectReference> GetOwnedMonitorInfo(JvmThreadReference thread, JvmNativeEnvironment nativeEnvironment)
        {
            DisposableObjectCollection <JvmObjectReference> result = new DisposableObjectCollection <JvmObjectReference>();

            int    ownedMonitorCount;
            IntPtr ownedMonitors;

            ThrowOnFailure(_rawInterface.GetOwnedMonitorInfo(_env, (jthread)thread, out ownedMonitorCount, out ownedMonitors));
            try
            {
                unsafe
                {
                    jobject *rawMonitors = (jobject *)ownedMonitors;
                    for (int i = 0; i < ownedMonitorCount; i++)
                    {
                        result.Add(new JvmObjectReference(this, nativeEnvironment, rawMonitors[i], true));
                    }
                }

                return(result);
            }
            finally
            {
                if (ownedMonitors != IntPtr.Zero)
                {
                    Deallocate(ownedMonitors);
                }
            }
        }
Exemplo n.º 10
0
 internal JvmClassReference(JvmEnvironment environment, JvmNativeEnvironment nativeEnvironment, jclass handle, bool freeLocalReference)
     : base(environment, nativeEnvironment, handle, freeLocalReference)
 {
 }