Inheritance: java.lang.Object, java.io.Serializable
Beispiel #1
0
		protected override string DetermineCallingFunction() {
			System.Exception e = new System.Exception ();
			java.lang.Class c = vmw.common.TypeUtils.ToClass (e);
			java.lang.reflect.Method m = c.getMethod ("getStackTrace",
				new java.lang.Class [0]);
			java.lang.StackTraceElement [] els = (java.lang.StackTraceElement [])
				m.invoke (e, new object [0]);
			java.lang.StackTraceElement el = els [4];
			return el.getClassName () + "." + _ownerClass + "." + el.getMethodName ();
		}
        /// <summary>
        /// Returns true if the specified object is another
        /// {@code StackTraceElement} instance representing the same execution
        /// point as this instance.  Two stack trace elements {@code a} and
        /// {@code b} are equal if and only if:
        /// <pre>{@code
        ///     equals(a.getFileName(), b.getFileName()) &&
        ///     a.getLineNumber() == b.getLineNumber()) &&
        ///     equals(a.getClassName(), b.getClassName()) &&
        ///     equals(a.getMethodName(), b.getMethodName())
        /// }</pre>
        /// where {@code equals} has the semantics of {@link
        /// java.util.Objects#equals(Object, Object) Objects.equals}.
        /// </summary>
        /// <param name="obj"> the object to be compared with this stack trace element. </param>
        /// <returns> true if the specified object is another
        ///         {@code StackTraceElement} instance representing the same
        ///         execution point as this instance. </returns>
        public override bool Equals(Object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (!(obj is StackTraceElement))
            {
                return(false);
            }
            StackTraceElement e = (StackTraceElement)obj;

            return(e.DeclaringClass.Equals(DeclaringClass) && e.LineNumber_Renamed == LineNumber_Renamed && Objects.Equals(MethodName_Renamed, e.MethodName_Renamed) && Objects.Equals(FileName_Renamed, e.FileName_Renamed));
        }
Beispiel #3
0
    public static void getThreadInfo1(long[] ids, int maxDepth, object result)
    {
#if !FIRST_PASS
        System.Reflection.ConstructorInfo[] constructors = typeof(java.lang.management.ThreadInfo).GetConstructors(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        foreach (System.Reflection.ConstructorInfo constructor in constructors)
        {
            if (constructor.GetParameters().Length == 9)
            {
                java.lang.Thread[] threads = (java.lang.Thread[])getThreads();
                java.lang.management.ThreadInfo[] threadInfos = (java.lang.management.ThreadInfo[])result;
                for (int i = 0; i < ids.Length; i++)
                {
                    long id = ids[i];
                    for (int t = 0; t < threads.Length; t++)
                    {
                        if (threads[t].getId() == id)
                        {
                            java.lang.Thread thread = threads[t];

                            int state;
                            // invers to sun.misc.VM.toThreadState
                            switch (thread.getState().ordinal())
                            {
                            case (int)java.lang.Thread.State.__Enum.RUNNABLE:
                                state = JVMTI_THREAD_STATE_RUNNABLE;
                                break;

                            case (int)java.lang.Thread.State.__Enum.BLOCKED:
                                state = JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER;
                                break;

                            case (int)java.lang.Thread.State.__Enum.WAITING:
                                state = JVMTI_THREAD_STATE_WAITING_INDEFINITELY;
                                break;

                            case (int)java.lang.Thread.State.__Enum.TIMED_WAITING:
                                state = JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT;
                                break;

                            case (int)java.lang.Thread.State.__Enum.TERMINATED:
                                state = JVMTI_THREAD_STATE_TERMINATED;
                                break;

                            case (int)java.lang.Thread.State.__Enum.NEW:
                                state = JVMTI_THREAD_STATE_ALIVE;
                                break;

                            default:
                                state = 0;
                                break;
                            }
                            //TODO set in state JMM_THREAD_STATE_FLAG_SUSPENDED if the thread is suspended

                            java.lang.StackTraceElement[] stacktrace = thread.getStackTrace();
                            if (maxDepth >= 0 && maxDepth < stacktrace.Length)
                            {
                                java.lang.StackTraceElement[] temp = new java.lang.StackTraceElement[maxDepth];
                                System.Array.Copy(stacktrace, temp, temp.Length);
                                stacktrace = temp;
                            }

                            object[] parameters = new object[9];
                            parameters[0] = thread;                     // thread
                            parameters[1] = state;                      // state
                                                                        // lockObj
                                                                        // lockOwner
                            parameters[4]  = 0;                         // blockedCount
                            parameters[5]  = 0;                         // blockedTime
                            parameters[6]  = -1;                        // waitedCount
                            parameters[7]  = 0;                         // waitedTime
                            parameters[8]  = stacktrace;                // stackTrace
                            threadInfos[i] = (java.lang.management.ThreadInfo)constructor.Invoke(parameters);
                            break;
                        }
                    }
                }
                return;
            }
        }
        throw new java.lang.InternalError("Constructor for java.lang.management.ThreadInfo not find.");
#endif
    }
	public static void getThreadInfo1(long[] ids, int maxDepth, object result)
	{
#if !FIRST_PASS

        System.Reflection.ConstructorInfo[] constructors = typeof(java.lang.management.ThreadInfo).GetConstructors( System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        foreach (System.Reflection.ConstructorInfo constructor in constructors)
        {
            if (constructor.GetParameters().Length == 9)
            {
                java.lang.Thread[] threads = (java.lang.Thread[])getThreads();
                java.lang.management.ThreadInfo[] threadInfos = (java.lang.management.ThreadInfo[])result;
                for (int i = 0; i < ids.Length; i++)
                {
                    long id = ids[i];
                    for (int t = 0; t < threads.Length; t++)
                    {
                        if (threads[t].getId() == id)
                        {
                            java.lang.Thread thread = threads[t];

                            int state;
                            // invers to sun.misc.VM.toThreadState
                            switch(thread.getState().ordinal())
                            {
                                case (int)java.lang.Thread.State.__Enum.RUNNABLE:
                                    state = JVMTI_THREAD_STATE_RUNNABLE;
                                    break;
                                case (int)java.lang.Thread.State.__Enum.BLOCKED:
                                    state = JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER;
                                    break;
                                case (int)java.lang.Thread.State.__Enum.WAITING:
                                    state = JVMTI_THREAD_STATE_WAITING_INDEFINITELY;
                                    break;
                                case (int)java.lang.Thread.State.__Enum.TIMED_WAITING:
                                    state = JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT;
                                    break;
                                case (int)java.lang.Thread.State.__Enum.TERMINATED:
                                    state = JVMTI_THREAD_STATE_TERMINATED;
                                    break;
                                case (int)java.lang.Thread.State.__Enum.NEW:
                                    state = JVMTI_THREAD_STATE_ALIVE;
                                    break;
                                default:
                                    state = 0;
                                    break;
                            }
                            //TODO set in state JMM_THREAD_STATE_FLAG_SUSPENDED if the thread is suspended

                            java.lang.StackTraceElement[] stacktrace = thread.getStackTrace();
                            if (maxDepth >= 0 && maxDepth < stacktrace.Length)
                            {
                                java.lang.StackTraceElement[] temp = new java.lang.StackTraceElement[maxDepth];
                                System.Array.Copy(stacktrace, temp, temp.Length);
                                stacktrace = temp;
                            }

                            object[] parameters = new object[9];
                            parameters[0] = thread;                     // thread
                            parameters[1] = state;                      // state
                                                                        // lockObj
                                                                        // lockOwner
                            parameters[4] = 0;                          // blockedCount
                            parameters[5] = 0;                          // blockedTime
                            parameters[6] = -1;                         // waitedCount
                            parameters[7] = 0;                          // waitedTime
                            parameters[8] = stacktrace;                 // stackTrace
                            threadInfos[i] = (java.lang.management.ThreadInfo)constructor.Invoke(parameters);
                            break;
                        }
                    }
                }
                return;
            }
        }
        throw new java.lang.InternalError("Constructor for java.lang.management.ThreadInfo not find.");
#endif
    }