harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r350181 [56/198] - in /incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core: ./ depends/ depends/files/ depends/jars/ depends/libs/ depends/libs/linux.IA32/ depends/libs/win.IA32/ depends/oss/ depends/oss/linux.IA32/ depends/oss/win.I...
Date Thu, 01 Dec 2005 06:04:00 GMT
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Thread.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Thread.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Thread.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Thread.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,693 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang;
+
+/**
+ * This class must be implemented by the vm vendor. The documented methods must
+ * be implemented to support other provided class implementations in this
+ * package. A Thread is a unit of concurrent execution in Java. It has its own
+ * call stack for methods being called and their parameters. Threads in the same
+ * VM interact and synchronize by the use of shared Objects and monitors
+ * associated with these objects. Synchronized methods and part of the API in
+ * Object also allow Threads to cooperate. When a Java program starts executing
+ * there is an implicit Thread (called "main") which is automatically created by
+ * the VM. This Thread belongs to a ThreadGroup (also called "main") which is
+ * automatically created by the bootstrap sequence by the VM as well.
+ * 
+ * @see java.lang.Object
+ * @see java.lang.ThreadGroup
+ */
+public class Thread implements Runnable {
+
+	public final static int MAX_PRIORITY = 10; // Maximum allowed priority for
+
+	// a thread
+	public final static int MIN_PRIORITY = 1; // Minimum allowed priority for
+
+	// a thread
+	public final static int NORM_PRIORITY = 5; // Normal priority for a thread
+
+	Object slot1;
+
+	Object slot2;
+
+	Object slot3;
+
+	/**
+	 * Constructs a new Thread with no runnable object and a newly generated
+	 * name. The new Thread will belong to the same ThreadGroup as the Thread
+	 * calling this constructor.
+	 * 
+	 * @see java.lang.ThreadGroup
+	 */
+	public Thread() {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with a runnable object and a newly generated
+	 * name. The new Thread will belong to the same ThreadGroup as the Thread
+	 * calling this constructor.
+	 * 
+	 * @param runnable
+	 *            a java.lang.Runnable whose method <code>run</code> will be
+	 *            executed by the new Thread
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.Runnable
+	 */
+	public Thread(Runnable runnable) {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with a runnable object and name provided. The new
+	 * Thread will belong to the same ThreadGroup as the Thread calling this
+	 * constructor.
+	 * 
+	 * @param runnable
+	 *            a java.lang.Runnable whose method <code>run</code> will be
+	 *            executed by the new Thread
+	 * @param threadName
+	 *            Name for the Thread being created
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.Runnable
+	 */
+	public Thread(Runnable runnable, String threadName) {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with no runnable object and the name provided.
+	 * The new Thread will belong to the same ThreadGroup as the Thread calling
+	 * this constructor.
+	 * 
+	 * @param threadName
+	 *            Name for the Thread being created
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.Runnable
+	 */
+	public Thread(String threadName) {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with a runnable object and a newly generated
+	 * name. The new Thread will belong to the ThreadGroup passed as parameter.
+	 * 
+	 * @param group
+	 *            ThreadGroup to which the new Thread will belong
+	 * @param runnable
+	 *            a java.lang.Runnable whose method <code>run</code> will be
+	 *            executed by the new Thread
+	 * @exception SecurityException
+	 *                if <code>group.checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @exception IllegalThreadStateException
+	 *                if <code>group.destroy()</code> has already been done
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.Runnable
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 */
+	public Thread(ThreadGroup group, Runnable runnable) {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with a runnable object, the given name and
+	 * belonging to the ThreadGroup passed as parameter.
+	 * 
+	 * @param group
+	 *            ThreadGroup to which the new Thread will belong
+	 * @param runnable
+	 *            a java.lang.Runnable whose method <code>run</code> will be
+	 *            executed by the new Thread
+	 * @param threadName
+	 *            Name for the Thread being created
+	 * @param stack
+	 *            Platform dependent stack size
+	 * @exception SecurityException
+	 *                if <code>group.checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @exception IllegalThreadStateException
+	 *                if <code>group.destroy()</code> has already been done
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.Runnable
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 */
+	public Thread(ThreadGroup group, Runnable runnable, String threadName,
+			long stack) {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with a runnable object, the given name and
+	 * belonging to the ThreadGroup passed as parameter.
+	 * 
+	 * @param group
+	 *            ThreadGroup to which the new Thread will belong
+	 * @param runnable
+	 *            a java.lang.Runnable whose method <code>run</code> will be
+	 *            executed by the new Thread
+	 * @param threadName
+	 *            Name for the Thread being created
+	 * @exception SecurityException
+	 *                if <code>group.checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @exception IllegalThreadStateException
+	 *                if <code>group.destroy()</code> has already been done
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.Runnable
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 */
+	public Thread(ThreadGroup group, Runnable runnable, String threadName) {
+		super();
+	}
+
+	/**
+	 * Constructs a new Thread with no runnable object, the given name and
+	 * belonging to the ThreadGroup passed as parameter.
+	 * 
+	 * @param group
+	 *            ThreadGroup to which the new Thread will belong
+	 * @param threadName
+	 *            Name for the Thread being created
+	 * @exception SecurityException
+	 *                if <code>group.checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @exception IllegalThreadStateException
+	 *                if <code>group.destroy()</code> has already been done
+	 * @see java.lang.ThreadGroup
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 */
+	public Thread(ThreadGroup group, String threadName) {
+		super();
+	}
+
+	/**
+	 * Returns the number of active threads in the running thread's ThreadGroup
+	 * 
+	 * @return Number of Threads
+	 */
+	public static int activeCount() {
+		return 0;
+	}
+
+	/**
+	 * This method is used for operations that require approval from a
+	 * SecurityManager. If there's none installed, this method is a no-op. If
+	 * there's a SecurityManager installed ,
+	 * <code>checkAccess(Ljava.lang.Thread;)</code> is called for that
+	 * SecurityManager.
+	 * 
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 */
+	public final void checkAccess() {
+		return;
+	}
+
+	/**
+	 * Returns the number of stack frames in this thread.
+	 * 
+	 * @return Number of stack frames
+	 * @deprecated The results of this call were never well defined. To make
+	 *             things worse, it would depend if the Thread was suspended or
+	 *             not, and suspend was deprecated too.
+	 */
+	public int countStackFrames() {
+		return 0;
+	}
+
+	/**
+	 * Answers the instance of Thread that corresponds to the running Thread
+	 * which calls this method.
+	 * 
+	 * @return a java.lang.Thread corresponding to the code that called
+	 *         <code>currentThread()</code>
+	 */
+	public static Thread currentThread() {
+		return null;
+	};
+
+	/**
+	 * Destroys the receiver without any monitor cleanup. Not implemented.
+	 * 
+	 */
+	public void destroy() {
+		return;
+	}
+
+	/**
+	 * Prints a text representation of the stack for this Thread.
+	 * 
+	 */
+	public static void dumpStack() {
+		return;
+	}
+
+	/**
+	 * Copies an array with all Threads which are in the same ThreadGroup as the
+	 * receiver - and subgroups - into the array <code>threads</code> passed
+	 * as parameter. If the array passed as parameter is too small no exception
+	 * is thrown - the extra elements are simply not copied.
+	 * 
+	 * @param threads
+	 *            array into which the Threads will be copied
+	 * @return How many Threads were copied over
+	 * @exception SecurityException
+	 *                if the installed SecurityManager fails
+	 *                <code>checkAccess(Ljava.lang.Thread;)</code>
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 */
+	public static int enumerate(Thread[] threads) {
+		return 0;
+	}
+
+	/**
+	 * Returns the context ClassLoader for the receiver.
+	 * 
+	 * @return ClassLoader The context ClassLoader
+	 * @see java.lang.ClassLoader
+	 * @see #getContextClassLoader()
+	 */
+	public ClassLoader getContextClassLoader() {
+		return null;
+	}
+
+	/**
+	 * Answers the name of the receiver.
+	 * 
+	 * @return the receiver's name (a java.lang.String)
+	 */
+	public final String getName() {
+		return null;
+	}
+
+	/**
+	 * Answers the priority of the receiver.
+	 * 
+	 * @return the receiver's priority (an <code>int</code>)
+	 * @see Thread#setPriority
+	 */
+	public final int getPriority() {
+		return 0;
+	}
+
+	/**
+	 * Answers the ThreadGroup to which the receiver belongs
+	 * 
+	 * @return the receiver's ThreadGroup
+	 */
+	public final ThreadGroup getThreadGroup() {
+		return null;
+	}
+
+	/**
+	 * A sample implementation of this method is provided by the reference
+	 * implementation. It must be included, as it is called by ThreadLocal.get()
+	 * and InheritableThreadLocal.get(). Return the value associated with the
+	 * ThreadLocal in the receiver
+	 * 
+	 * @param local
+	 *            ThreadLocal to perform the lookup
+	 * @return the value of the ThreadLocal
+	 * @see #setThreadLocal
+	 */
+	Object getThreadLocal(ThreadLocal local) {
+		return null;
+	}
+
+	/**
+	 * Posts an interrupt request to the receiver
+	 * 
+	 * @exception SecurityException
+	 *                if <code>group.checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @see java.lang.SecurityException
+	 * @see java.lang.SecurityManager
+	 * @see Thread#interrupted
+	 * @see Thread#isInterrupted
+	 */
+	public void interrupt() {
+		return;
+	}
+
+	/**
+	 * Answers a <code>boolean</code> indicating whether the current Thread (
+	 * <code>currentThread()</code>) has a pending interrupt request (
+	 * <code>true</code>) or not (<code>false</code>). It also has the
+	 * side-effect of clearing the flag.
+	 * 
+	 * @return a <code>boolean</code>
+	 * @see Thread#currentThread
+	 * @see Thread#interrupt
+	 * @see Thread#isInterrupted
+	 */
+	public static boolean interrupted() {
+		return false;
+	};
+
+	/**
+	 * Answers <code>true</code> if the receiver has already been started and
+	 * still runs code (hasn't died yet). Answers <code>false</code> either if
+	 * the receiver hasn't been started yet or if it has already started and run
+	 * to completion and died.
+	 * 
+	 * @return a <code>boolean</code>
+	 * @see Thread#start
+	 */
+	public final boolean isAlive() {
+		return false;
+	}
+
+	/**
+	 * Answers a <code>boolean</code> indicating whether the receiver is a
+	 * daemon Thread (<code>true</code>) or not (<code>false</code>) A
+	 * daemon Thread only runs as long as there are non-daemon Threads running.
+	 * When the last non-daemon Thread ends, the whole program ends no matter if
+	 * it had daemon Threads still running or not.
+	 * 
+	 * @return a <code>boolean</code>
+	 * @see Thread#setDaemon
+	 */
+	public final boolean isDaemon() {
+		return false;
+	}
+
+	/**
+	 * Answers a <code>boolean</code> indicating whether the receiver has a
+	 * pending interrupt request (<code>true</code>) or not (
+	 * <code>false</code>)
+	 * 
+	 * @return a <code>boolean</code>
+	 * @see Thread#interrupt
+	 * @see Thread#interrupted
+	 */
+	public boolean isInterrupted() {
+		return false;
+	}
+
+	/**
+	 * Blocks the current Thread (<code>Thread.currentThread()</code>) until
+	 * the receiver finishes its execution and dies.
+	 * 
+	 * @exception InterruptedException
+	 *                if <code>interrupt()</code> was called for the receiver
+	 *                while it was in the <code>join()</code> call
+	 * @see Object#notifyAll
+	 * @see java.lang.ThreadDeath
+	 */
+	public final void join() throws InterruptedException {
+		return;
+	}
+
+	/**
+	 * Blocks the current Thread (<code>Thread.currentThread()</code>) until
+	 * the receiver finishes its execution and dies or the specified timeout
+	 * expires, whatever happens first.
+	 * 
+	 * @param timeoutInMilliseconds
+	 *            The maximum time to wait (in milliseconds).
+	 * @exception InterruptedException
+	 *                if <code>interrupt()</code> was called for the receiver
+	 *                while it was in the <code>join()</code> call
+	 * @see Object#notifyAll
+	 * @see java.lang.ThreadDeath
+	 */
+	public final void join(long timeoutInMilliseconds)
+			throws InterruptedException {
+		return;
+	}
+
+	/**
+	 * Blocks the current Thread (<code>Thread.currentThread()</code>) until
+	 * the receiver finishes its execution and dies or the specified timeout
+	 * expires, whatever happens first.
+	 * 
+	 * @param timeoutInMilliseconds
+	 *            The maximum time to wait (in milliseconds).
+	 * @param nanos
+	 *            Extra nanosecond precision
+	 * @exception InterruptedException
+	 *                if <code>interrupt()</code> was called for the receiver
+	 *                while it was in the <code>join()</code> call
+	 * @see Object#notifyAll
+	 * @see java.lang.ThreadDeath
+	 */
+	public final void join(long timeoutInMilliseconds, int nanos)
+			throws InterruptedException {
+		return;
+	}
+
+	/**
+	 * This is a no-op if the receiver was never suspended, or suspended and
+	 * already resumed. If the receiver is suspended, however, makes it resume
+	 * to the point where it was when it was suspended.
+	 * 
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @see Thread#suspend()
+	 * @deprecated Used with deprecated method Thread.suspend().
+	 */
+	public final void resume() {
+		return;
+	}
+
+	/**
+	 * Calls the <code>run()</code> method of the Runnable object the receiver
+	 * holds. If no Runnable is set, does nothing.
+	 * 
+	 * @see Thread#start
+	 */
+	public void run() {
+		return;
+	}
+
+	/**
+	 * Set the context ClassLoader for the receiver.
+	 * 
+	 * @param cl
+	 *            The context ClassLoader
+	 * @see java.lang.ClassLoader
+	 * @see #getContextClassLoader()
+	 */
+	public void setContextClassLoader(ClassLoader cl) {
+		return;
+	}
+
+	/**
+	 * Set if the receiver is a daemon Thread or not. This can only be done
+	 * before the Thread starts running.
+	 * 
+	 * @param isDaemon
+	 *            A boolean indicating if the Thread should be daemon or not
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @see Thread#isDaemon
+	 */
+	public final void setDaemon(boolean isDaemon) {
+		return;
+	}
+
+	/**
+	 * Sets the name of the receiver.
+	 * 
+	 * @param threadName
+	 *            new name for the Thread
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @see Thread#getName
+	 */
+	public final void setName(String threadName) {
+		return;
+	}
+
+	/**
+	 * Sets the priority of the receiver. Note that the final priority set may
+	 * not be the parameter that was passed - it will depend on the receiver's
+	 * ThreadGroup. The priority cannot be set to be higher than the receiver's
+	 * ThreadGroup's maxPriority().
+	 * 
+	 * @param priority
+	 *            new priority for the Thread
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @exception IllegalArgumentException
+	 *                if the new priority is greater than Thread.MAX_PRIORITY or
+	 *                less than Thread.MIN_PRIORITY
+	 * @see Thread#getPriority
+	 */
+	public final void setPriority(int priority) {
+		return;
+	}
+
+	/**
+	 * A sample implementation of this method is provided by the reference
+	 * implementation. It must be included, as it is called by ThreadLocal.set()
+	 * and InheritableThreadLocal.set(). Set the value associated with the
+	 * ThreadLocal in the receiver to be <code>value</code>.
+	 * 
+	 * @param local
+	 *            ThreadLocal to set
+	 * @param value
+	 *            new value for the ThreadLocal
+	 * @see #getThreadLocal
+	 */
+	void setThreadLocal(ThreadLocal local, Object value) {
+		return;
+	}
+
+	/**
+	 * Causes the thread which sent this message to sleep an interval of time
+	 * (given in milliseconds). The precision is not guaranteed - the Thread may
+	 * sleep more or less than requested.
+	 * 
+	 * @param time
+	 *            The time to sleep in milliseconds.
+	 * @exception InterruptedException
+	 *                if <code>interrupt()</code> was called for this Thread
+	 *                while it was sleeping
+	 * @see Thread#interrupt()
+	 */
+
+	public static void sleep(long time) throws InterruptedException {
+		return;
+	}
+
+	/**
+	 * Causes the thread which sent this message to sleep an interval of time
+	 * (given in milliseconds). The precision is not guaranteed - the Thread may
+	 * sleep more or less than requested.
+	 * 
+	 * @param time
+	 *            The time to sleep in milliseconds.
+	 * @param nanos
+	 *            Extra nanosecond precision
+	 * @exception InterruptedException
+	 *                if <code>interrupt()</code> was called for this Thread
+	 *                while it was sleeping
+	 * @see Thread#interrupt()
+	 */
+	public static void sleep(long time, int nanos) throws InterruptedException {
+		return;
+	};
+
+	/**
+	 * Starts the new Thread of execution. The <code>run()</code> method of
+	 * the receiver will be called by the receiver Thread itself (and not the
+	 * Thread calling <code>start()</code>).
+	 * 
+	 * @exception IllegalThreadStateException
+	 *                Unspecified in the Java language specification
+	 * @see Thread#run
+	 */
+	public void start() {
+		return;
+	}
+
+	/**
+	 * Requests the receiver Thread to stop and throw ThreadDeath. The Thread is
+	 * resumed if it was suspended and awakened if it was sleeping, so that it
+	 * can proceed to throw ThreadDeath.
+	 * 
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @deprecated
+	 */
+	public final void stop() {
+		return;
+	}
+
+	/**
+	 * Requests the receiver Thread to stop and throw the
+	 * <code>throwable()</code>. The Thread is resumed if it was suspended
+	 * and awakened if it was sleeping, so that it can proceed to throw the
+	 * <code>throwable()</code>.
+	 * 
+	 * @param throwable
+	 *            Throwable object to be thrown by the Thread
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @exception NullPointerException
+	 *                if <code>throwable()</code> is <code>null</code>
+	 * @deprecated
+	 */
+	public final void stop(Throwable throwable) {
+		return;
+	}
+
+	/**
+	 * This is a no-op if the receiver is suspended. If the receiver
+	 * <code>isAlive()</code> however, suspended it until
+	 * <code>resume()</code> is sent to it. Suspend requests are not queued,
+	 * which means that N requests are equivalenet to just one - only one resume
+	 * request is needed in this case.
+	 * 
+	 * @exception SecurityException
+	 *                if <code>checkAccess()</code> fails with a
+	 *                SecurityException
+	 * @see Thread#resume()
+	 * @deprecated May cause deadlocks.
+	 */
+	public final void suspend() {
+		return;
+	}
+
+	/**
+	 * Answers a string containing a concise, human-readable description of the
+	 * receiver.
+	 * 
+	 * @return a printable representation for the receiver.
+	 */
+	public String toString() {
+		return null;
+	}
+
+	/**
+	 * Causes the thread which sent this message to yield execution to another
+	 * Thread that is ready to run. The actual scheduling is
+	 * implementation-dependent.
+	 * 
+	 */
+	public static void yield() {
+		return;
+	};
+
+	/**
+	 * Returns whether the current thread has a monitor lock on the specified
+	 * object.
+	 * 
+	 * @param object
+	 *            the object to test for the monitor lock
+	 * @return true when the current thread has a monitor lock on the specified
+	 *         object
+	 */
+	public static boolean holdsLock(Object object) {
+		return false;
+	};
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ThreadGroup.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ThreadGroup.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ThreadGroup.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ThreadGroup.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,850 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang;
+
+/**
+ * An implementation of this class is provided, but the documented constructors
+ * are used by the vm specific implementation to create the required "system"
+ * and "main" ThreadGroups. The documented methods are used by java.lang.Thread
+ * to add and remove Threads from their ThreadGroups.
+ * 
+ * ThreadGroups are containers of Threads and ThreadGroups, therefore providing
+ * a tree-like structure to organize Threads. The root ThreadGroup name is
+ * "system" and it has no parent ThreadGroup. All other ThreadGroups have
+ * exactly one parent ThreadGroup. All Threads belong to exactly one
+ * ThreadGroup.
+ * 
+ * @see Thread
+ * @see SecurityManager
+ */
+
+public class ThreadGroup {
+	// Name of this ThreadGroup
+	private String name;
+
+	// Maximum priority for Threads inside this ThreadGroup
+	private int maxPriority = Thread.MAX_PRIORITY;
+
+	// The ThreadGroup to which this ThreadGroup belongs
+	ThreadGroup parent = null;
+
+	int numThreads = 0;
+
+	// The Threads this ThreadGroup contains
+	private Thread[] childrenThreads = new Thread[5];
+
+	// The number of children groups
+	int numGroups = 0; 
+
+	// The ThreadGroups this ThreadGroup contains
+	private ThreadGroup[] childrenGroups = new ThreadGroup[3];
+
+	// Locked when using the childrenGroups field
+	private Object childrenGroupsLock = new Object();
+
+	// Locked when using the childrenThreads field
+	private Object childrenThreadsLock = new Object();
+
+	// Whether this ThreadGroup is a daemon ThreadGroup or not
+	private boolean isDaemon = false;
+
+	// Whether this ThreadGroup has already been destroyed or not
+	private boolean isDestroyed = false;
+
+	// Memory space to associate all new threads with
+	private long memorySpace;
+
+	/**
+	 * Used by the JVM to create the "system" ThreadGroup. Construct a
+	 * ThreadGroup instance, and assign the name "system".
+	 */
+	private ThreadGroup() {
+		name = "system";
+	}
+
+	/**
+	 * Constructs a new ThreadGroup with the name provided. The new ThreadGroup
+	 * will be child of the ThreadGroup to which the
+	 * <code>Thread.currentThread()</code> belongs.
+	 * 
+	 * @param name
+	 *            Name for the ThreadGroup being created
+	 * 
+	 * @throws SecurityException
+	 *             if <code>checkAccess()</code> for the parent group fails
+	 *             with a SecurityException
+	 * 
+	 * @see java.lang.Thread#currentThread
+	 */
+
+	public ThreadGroup(String name) {
+		this(Thread.currentThread().getThreadGroup(), name);
+	}
+
+	/**
+	 * Constructs a new ThreadGroup with the name provided, as child of the
+	 * ThreadGroup <code>parent</code>
+	 * 
+	 * @param parent
+	 *            Parent ThreadGroup
+	 * @param name
+	 *            Name for the ThreadGroup being created
+	 * 
+	 * @throws NullPointerException
+	 *             if <code>parent<code> is <code>null<code>
+	 * @throws		SecurityException 				if <code>checkAccess()</code> for the parent group fails with a SecurityException
+	 * @throws		IllegalThreadStateException 	if <code>parent<code> has been destroyed already
+	 */
+	public ThreadGroup(ThreadGroup parent, String name) {
+		super();
+		if (Thread.currentThread() != null) {
+			// If parent is null we must throw NullPointerException, but that
+			// will be done "for free" with the message send below
+			parent.checkAccess();
+		}
+
+		this.name = name;
+		this.setParent(parent);
+		if (parent != null) {
+			this.setMaxPriority(parent.getMaxPriority());
+			if (parent.isDaemon())
+				this.setDaemon(true);
+		}
+	}
+
+	/**
+	 * Initialize the "main" ThreadGroup
+	 */
+	ThreadGroup(ThreadGroup parent) {
+		this.name = "main";
+		this.setParent(parent);
+	}
+
+	/**
+	 * Returns the number of Threads which are children of the receiver,
+	 * directly or indirectly.
+	 * 
+	 * @return Number of children Threads
+	 */
+
+	public int activeCount() {
+		int count = numThreads;
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				count += this.childrenGroups[i].activeCount();
+		}
+		return count;
+	}
+
+	/**
+	 * Returns the number of ThreadGroups which are children of the receiver,
+	 * directly or indirectly.
+	 * 
+	 * @return Number of children ThreadGroups
+	 */
+	public int activeGroupCount() {
+		int count = 0;
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				// One for this group & the subgroups
+				count += 1 + this.childrenGroups[i].activeGroupCount();
+		}
+		return count;
+	}
+
+	/**
+	 * Adds a Thread to the receiver. This should only be visible to class
+	 * java.lang.Thread, and should only be called when a new Thread is created
+	 * and initialized by the constructor.
+	 * 
+	 * @param thread
+	 *            Thread to add to the receiver
+	 * 
+	 * @throws IllegalThreadStateException
+	 *             if the receiver has been destroyed already
+	 * 
+	 * @see #remove(java.lang.Thread)
+	 */
+	final void add(Thread thread) throws IllegalThreadStateException {
+		synchronized (this.childrenThreadsLock) {
+			if (!isDestroyed) {
+				if (childrenThreads.length == numThreads) {
+					Thread[] newThreads = new Thread[childrenThreads.length * 2];
+					System.arraycopy(childrenThreads, 0, newThreads, 0,
+							numThreads);
+					newThreads[numThreads++] = thread;
+					childrenThreads = newThreads;
+				} else
+					childrenThreads[numThreads++] = thread;
+			} else
+				throw new IllegalThreadStateException();
+		}
+	}
+
+	/**
+	 * Adds a ThreadGroup to the receiver.
+	 * 
+	 * @param g
+	 *            ThreadGroup to add to the receiver
+	 * 
+	 * @throws IllegalThreadStateException
+	 *             if the receiver has been destroyed already
+	 */
+	private void add(ThreadGroup g) throws IllegalThreadStateException {
+		synchronized (this.childrenGroupsLock) {
+			if (!isDestroyed) {
+				if (childrenGroups.length == numGroups) {
+					ThreadGroup[] newGroups = new ThreadGroup[childrenGroups.length * 2];
+					System
+							.arraycopy(childrenGroups, 0, newGroups, 0,
+									numGroups);
+					newGroups[numGroups++] = g;
+					childrenGroups = newGroups;
+				} else
+					childrenGroups[numGroups++] = g;
+			} else
+				throw new IllegalThreadStateException();
+		}
+	}
+
+	/**
+	 * The definition of this method depends on the deprecated method
+	 * <code>suspend()</code>. The behavior of this call was never specified.
+	 * 
+	 * @param b
+	 *            Used to control low memory implicit suspension
+	 * 
+	 * @deprecated Required deprecated method suspend().
+	 */
+	public boolean allowThreadSuspension(boolean b) {
+		// Does not apply to this VM, no-op
+		return true;
+	}
+
+	/**
+	 * If there is a SecurityManager installed, call <code>checkAccess</code>
+	 * in it passing the receiver as parameter, otherwise do nothing.
+	 */
+	public final void checkAccess() {
+		// Forwards the message to the SecurityManager (if there's one) passing
+		// the receiver as parameter
+		SecurityManager currentManager = System.getSecurityManager();
+		if (currentManager != null)
+			currentManager.checkAccess(this);
+	}
+
+	/**
+	 * Destroys the receiver and recursively all its subgroups. It is only legal
+	 * to destroy a ThreadGroup that has no Threads. Any daemon ThreadGroup is
+	 * destroyed automatically when it becomes empty (no Threads and no
+	 * ThreadGroups in it).
+	 * 
+	 * @throws IllegalThreadStateException
+	 *             if the receiver or any of its subgroups has been destroyed
+	 *             already
+	 * @throws SecurityException
+	 *             if <code>this.checkAccess()</code> fails with a
+	 *             SecurityException
+	 */
+
+	public final void destroy() {
+		checkAccess();
+
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenThreadsLock) {
+			synchronized (this.childrenGroupsLock) {
+				int toDestroy = numGroups;
+				// Call recursively for subgroups
+				for (int i = 0; i < toDestroy; i++) {
+					// We always get the first element - remember, when the
+					// child dies it removes itself from our collection. See
+					// below.
+					this.childrenGroups[0].destroy();
+				}
+
+				if (parent != null)
+					parent.remove(this);
+
+				// Now that the ThreadGroup is really destroyed it can be tagged
+				// as so
+				this.isDestroyed = true;
+			}
+		}
+	}
+
+	/*
+	 * Auxiliary method that destroys the receiver and recursively all its
+	 * subgroups if the receiver is a daemon ThreadGroup.
+	 * 
+	 * @see #destroy
+	 * @see #setDaemon
+	 * @see #isDaemon
+	 */
+	private void destroyIfEmptyDaemon() {
+		// Has to be non-destroyed daemon to make sense
+		synchronized (this.childrenThreadsLock) {
+			if (isDaemon && !isDestroyed && numThreads == 0) {
+				synchronized (this.childrenGroupsLock) {
+					if (numGroups == 0)
+						destroy();
+				}
+			}
+		}
+	}
+
+	/**
+	 * Copies an array with all Threads which are children of the receiver
+	 * (directly or indirectly) into the array <code>threads</code> passed as
+	 * parameters. If the array passed as parameter is too small no exception is
+	 * thrown - the extra elements are simply not copied.
+	 * 
+	 * @param threads
+	 *            Thread array into which the Threads will be copied
+	 * @return How many Threads were copied over
+	 * 
+	 */
+	public int enumerate(Thread[] threads) {
+		return enumerate(threads, true);
+	}
+
+	/**
+	 * Copies an array with all Threads which are children of the receiver into
+	 * the array <code>threads</code> passed as parameter. Children Threads of
+	 * subgroups are recursively copied as well if parameter
+	 * <code>recurse</code> is <code>true</code>.
+	 * 
+	 * If the array passed as parameter is too small no exception is thrown -
+	 * the extra elements are simply not copied.
+	 * 
+	 * @param threads
+	 *            array into which the Threads will be copied
+	 * @param recurse
+	 *            Indicates whether Threads in subgroups should be recursively
+	 *            copied as well or not
+	 * @return How many Threads were copied over
+	 * 
+	 */
+	public int enumerate(Thread[] threads, boolean recurse) {
+		return enumerateGeneric(threads, recurse, 0, true);
+	}
+
+	/**
+	 * Copies an array with all ThreadGroups which are children of the receiver
+	 * (directly or indirectly) into the array <code>groups</code> passed as
+	 * parameters. If the array passed as parameter is too small no exception is
+	 * thrown - the extra elements are simply not copied.
+	 * 
+	 * @param groups
+	 *            array into which the ThreadGroups will be copied
+	 * @return How many ThreadGroups were copied over
+	 * 
+	 */
+	public int enumerate(ThreadGroup[] groups) {
+		return enumerate(groups, true);
+	}
+
+	/**
+	 * Copies an array with all ThreadGroups which are children of the receiver
+	 * into the array <code>groups</code> passed as parameter. Children
+	 * ThreadGroups of subgroups are recursively copied as well if parameter
+	 * <code>recurse</code> is <code>true</code>.
+	 * 
+	 * If the array passed as parameter is too small no exception is thrown -
+	 * the extra elements are simply not copied.
+	 * 
+	 * @param groups
+	 *            array into which the ThreadGroups will be copied
+	 * @param recurse
+	 *            Indicates whether ThreadGroups in subgroups should be
+	 *            recursively copied as well or not
+	 * @return How many ThreadGroups were copied over
+	 * 
+	 */
+	public int enumerate(ThreadGroup[] groups, boolean recurse) {
+		return enumerateGeneric(groups, recurse, 0, false);
+	}
+
+	/**
+	 * Copies into <param>enumeration</param> starting at
+	 * </param>enumerationIndex</param> all Threads or ThreadGroups in the
+	 * receiver. If </param>recurse</param> is true, recursively enumerate the
+	 * elements in subgroups.
+	 * 
+	 * If the array passed as parameter is too small no exception is thrown -
+	 * the extra elements are simply not copied.
+	 * 
+	 * @param enumeration
+	 *            array into which the elements will be copied
+	 * @param recurse
+	 *            Indicates whether </param>recurseCollection</param> should be
+	 *            enumerated or not
+	 * @param enumerationIndex
+	 *            Indicates in which position of the enumeration array we are
+	 * @param enumeratingThreads
+	 *            Indicates whether we are enumerating Threads or ThreadGroups
+	 * @return How many elements were enumerated/copied over
+	 */
+	private int enumerateGeneric(Object[] enumeration, boolean recurse,
+			int enumerationIndex, boolean enumeratingThreads) {
+		checkAccess();
+
+		Object[] immediateCollection = enumeratingThreads ? (Object[]) childrenThreads
+				: (Object[]) childrenGroups;
+		Object syncLock = enumeratingThreads ? childrenThreadsLock
+				: childrenGroupsLock;
+
+		synchronized (syncLock) { // Lock this subpart of the tree as we walk
+			for (int i = enumeratingThreads ? numThreads : numGroups; --i >= 0;) {
+				if (!enumeratingThreads
+						|| ((Thread) immediateCollection[i]).isAlive()) {
+					if (enumerationIndex >= enumeration.length)
+						return enumerationIndex;
+					enumeration[enumerationIndex++] = immediateCollection[i];
+				}
+			}
+		}
+
+		if (recurse) { // Lock this subpart of the tree as we walk
+			synchronized (this.childrenGroupsLock) {
+				for (int i = 0; i < numGroups; i++) {
+					if (enumerationIndex >= enumeration.length)
+						return enumerationIndex;
+					enumerationIndex = childrenGroups[i].enumerateGeneric(
+							enumeration, recurse, enumerationIndex,
+							enumeratingThreads);
+				}
+			}
+		}
+		return enumerationIndex;
+	}
+
+	/**
+	 * Answers the maximum allowed priority for a Thread in the receiver.
+	 * 
+	 * @return the maximum priority (an <code>int</code>)
+	 * 
+	 * @see #setMaxPriority
+	 */
+	public final int getMaxPriority() {
+		return maxPriority;
+	}
+
+	/**
+	 * Answers the name of the receiver.
+	 * 
+	 * @return the receiver's name (a java.lang.String)
+	 */
+	public final String getName() {
+		return name;
+	}
+
+	/**
+	 * Answers the receiver's parent ThreadGroup. It can be null if the receiver
+	 * is the the root ThreadGroup.
+	 * 
+	 * @return the parent ThreadGroup
+	 * 
+	 */
+	public final ThreadGroup getParent() {
+		if (parent != null)
+			parent.checkAccess();
+		return parent;
+	}
+
+	/**
+	 * Interrupts every Thread in the receiver and recursively in all its
+	 * subgroups.
+	 * 
+	 * @throws SecurityException
+	 *             if <code>this.checkAccess()</code> fails with a
+	 *             SecurityException
+	 * 
+	 * @see Thread#interrupt
+	 */
+	public final void interrupt() {
+		checkAccess();
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenThreadsLock) {
+			for (int i = 0; i < numThreads; i++)
+				this.childrenThreads[i].interrupt();
+		}
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				this.childrenGroups[i].interrupt();
+		}
+	}
+
+	/**
+	 * Answers true if the receiver is a daemon ThreadGroup, false otherwise.
+	 * 
+	 * @return if the receiver is a daemon ThreadGroup
+	 * 
+	 * @see #setDaemon
+	 * @see #destroy
+	 */
+	public final boolean isDaemon() {
+		return isDaemon;
+	}
+
+	/**
+	 * Answers true if the receiver has been destroyed already, false otherwise.
+	 * 
+	 * @return if the receiver has been destroyed already
+	 * 
+	 * @see #destroy
+	 */
+	public boolean isDestroyed() {
+		return isDestroyed;
+	}
+
+	/**
+	 * Outputs to <code>System.out</code> a text representation of the
+	 * hierarchy of Threads and ThreadGroups in the receiver (and recursively).
+	 * Proper identation is done to suggest the nesting of groups inside groups
+	 * and threads inside groups.
+	 */
+	public void list() {
+		// We start in a fresh line
+		System.out.println();
+		list(0);
+	}
+
+	/*
+	 * Outputs to <code>System.out</code>a text representation of the
+	 * hierarchy of Threads and ThreadGroups in the receiver (and recursively).
+	 * The identation will be four spaces per level of nesting.
+	 * 
+	 * @param levels How many levels of nesting, so that proper identetion can
+	 * be output.
+	 */
+	private void list(int levels) {
+		for (int i = 0; i < levels; i++)
+			System.out.print("    "); // 4 spaces for each level
+
+		// Print the receiver
+		System.out.println(this.toString());
+
+		// Print the children threads, with 1 extra identation
+		synchronized (this.childrenThreadsLock) {
+			for (int i = 0; i < numThreads; i++) {
+				// children get an extra identation, 4 spaces for each level
+				for (int j = 0; j <= levels; j++)
+					System.out.print("    ");
+				System.out.println(this.childrenThreads[i]);
+			}
+		}
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				this.childrenGroups[i].list(levels + 1);
+		}
+	}
+
+	/**
+	 * Answers true if the receiver is a direct or indirect parent group of
+	 * ThreadGroup <code>g</code>, false otherwise.
+	 * 
+	 * @param g
+	 *            ThreadGroup to test
+	 * 
+	 * @return if the receiver is parent of the ThreadGroup passed as parameter
+	 * 
+	 */
+	public final boolean parentOf(ThreadGroup g) {
+		while (g != null) {
+			if (this == g)
+				return true;
+			g = g.parent;
+		}
+		return false;
+	}
+
+	/**
+	 * Removes a Thread from the receiver. This should only be visible to class
+	 * java.lang.Thread, and should only be called when a Thread dies.
+	 * 
+	 * @param thread
+	 *            Thread to remove from the receiver
+	 * 
+	 * @see #add(Thread)
+	 */
+	final void remove(java.lang.Thread thread) {
+		synchronized (this.childrenThreadsLock) {
+			for (int i = 0; i < numThreads; i++) {
+				if (childrenThreads[i].equals(thread)) {
+					numThreads--;
+					System.arraycopy(childrenThreads, i + 1, childrenThreads,
+							i, numThreads - i);
+					childrenThreads[numThreads] = null;
+					break;
+				}
+			}
+		}
+		destroyIfEmptyDaemon();
+	}
+
+	/**
+	 * Removes an immediate subgroup from the receiver.
+	 * 
+	 * @param g
+	 *            Threadgroup to remove from the receiver
+	 * 
+	 * @see #add(Thread)
+	 * @see #add(ThreadGroup)
+	 */
+	private void remove(ThreadGroup g) {
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++) {
+				if (childrenGroups[i].equals(g)) {
+					numGroups--;
+					System.arraycopy(childrenGroups, i + 1, childrenGroups, i,
+							numGroups - i);
+					childrenGroups[numGroups] = null;
+					break;
+				}
+			}
+		}
+		destroyIfEmptyDaemon();
+	}
+
+	/**
+	 * Resumes every Thread in the receiver and recursively in all its
+	 * subgroups.
+	 * 
+	 * @throws SecurityException
+	 *             if <code>this.checkAccess()</code> fails with a
+	 *             SecurityException
+	 * 
+	 * @see Thread#resume
+	 * @see #suspend
+	 * 
+	 * @deprecated Requires deprecated method Thread.resume().
+	 */
+	public final void resume() {
+		checkAccess();
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenThreadsLock) {
+			for (int i = 0; i < numThreads; i++)
+				this.childrenThreads[i].resume();
+		}
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				this.childrenGroups[i].resume();
+		}
+	}
+
+	/**
+	 * Configures the receiver to be a daemon ThreadGroup or not. Daemon
+	 * ThreadGroups are automatically destroyed when they become empty.
+	 * 
+	 * @param isDaemon
+	 *            new value defining if receiver should be daemon or not
+	 * 
+	 * @throws SecurityException
+	 *             if <code>checkAccess()</code> for the parent group fails
+	 *             with a SecurityException
+	 * 
+	 * @see #isDaemon
+	 * @see #destroy
+	 */
+	public final void setDaemon(boolean isDaemon) {
+		checkAccess();
+		this.isDaemon = isDaemon;
+	}
+
+	/**
+	 * Configures the maximum allowed priority for a Thread in the receiver and
+	 * recursively in all its subgroups.
+	 * 
+	 * One can never change the maximum priority of a ThreadGroup to be higher
+	 * than it was. Such an attempt will not result in an exception, it will
+	 * simply leave the ThreadGroup with its current maximum priority.
+	 * 
+	 * @param newMax
+	 *            the new maximum priority to be set
+	 * 
+	 * @throws SecurityException
+	 *             if <code>checkAccess()</code> fails with a
+	 *             SecurityException
+	 * @throws IllegalArgumentException
+	 *             if the new priority is greater than Thread.MAX_PRIORITY or
+	 *             less than Thread.MIN_PRIORITY
+	 * 
+	 * @see #getMaxPriority
+	 */
+	public final void setMaxPriority(int newMax) {
+		checkAccess();
+
+		if (newMax <= this.maxPriority) {
+			if (newMax < Thread.MIN_PRIORITY)
+				newMax = Thread.MIN_PRIORITY;
+
+			int parentPriority = parent == null ? newMax : parent
+					.getMaxPriority();
+			this.maxPriority = parentPriority <= newMax ? parentPriority
+					: newMax;
+			// Lock this subpart of the tree as we walk
+			synchronized (this.childrenGroupsLock) {
+				// ??? why not maxPriority
+				for (int i = 0; i < numGroups; i++)
+					this.childrenGroups[i].setMaxPriority(newMax);
+			}
+		}
+	}
+
+	/**
+	 * Sets the parent ThreadGroup of the receiver, and adds the receiver to the
+	 * parent's collection of immediate children (if <code>parent</code> is
+	 * not <code>null</code>).
+	 * 
+	 * @param parent
+	 *            The parent ThreadGroup, or null if the receiver is to be the
+	 *            root ThreadGroup
+	 * 
+	 * @see #getParent
+	 * @see #parentOf
+	 */
+	private void setParent(ThreadGroup parent) {
+		if (parent != null)
+			parent.add(this);
+		this.parent = parent;
+	}
+
+	/**
+	 * Stops every Thread in the receiver and recursively in all its subgroups.
+	 * 
+	 * @throws SecurityException
+	 *             if <code>this.checkAccess()</code> fails with a
+	 *             SecurityException
+	 * 
+	 * @see Thread#stop()
+	 * @see Thread#stop(Throwable)
+	 * @see ThreadDeath
+	 * 
+	 * @deprecated Requires deprecated method Thread.stop().
+	 */
+	public final void stop() {
+		if (stopHelper())
+			Thread.currentThread().stop();
+	}
+
+	/**
+	 * @deprecated Requires deprecated method Thread.suspend().
+	 */
+	private final boolean stopHelper() {
+		checkAccess();
+
+		boolean stopCurrent = false;
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenThreadsLock) {
+			Thread current = Thread.currentThread();
+			for (int i = 0; i < numThreads; i++)
+				if (this.childrenThreads[i] == current) {
+					stopCurrent = true;
+				} else {
+					this.childrenThreads[i].stop();
+				}
+		}
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				stopCurrent |= this.childrenGroups[i].stopHelper();
+		}
+		return stopCurrent;
+	}
+
+	/**
+	 * Suspends every Thread in the receiver and recursively in all its
+	 * subgroups.
+	 * 
+	 * @throws SecurityException
+	 *             if <code>this.checkAccess()</code> fails with a
+	 *             SecurityException
+	 * 
+	 * @see Thread#suspend
+	 * @see #resume
+	 * 
+	 * @deprecated Requires deprecated method Thread.suspend().
+	 */
+	public final void suspend() {
+		if (suspendHelper())
+			Thread.currentThread().suspend();
+	}
+
+	/**
+	 * @deprecated Requires deprecated method Thread.suspend().
+	 */
+	private final boolean suspendHelper() {
+		checkAccess();
+
+		boolean suspendCurrent = false;
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenThreadsLock) {
+			Thread current = Thread.currentThread();
+			for (int i = 0; i < numThreads; i++)
+				if (this.childrenThreads[i] == current) {
+					suspendCurrent = true;
+				} else {
+					this.childrenThreads[i].suspend();
+				}
+		}
+		// Lock this subpart of the tree as we walk
+		synchronized (this.childrenGroupsLock) {
+			for (int i = 0; i < numGroups; i++)
+				suspendCurrent |= this.childrenGroups[i].suspendHelper();
+		}
+		return suspendCurrent;
+	}
+
+	/**
+	 * Answers a string containing a concise, human-readable description of the
+	 * receiver.
+	 * 
+	 * @return a printable representation for the receiver.
+	 */
+	public String toString() {
+		return getClass().getName() + "[name=" + this.getName() + ",maxpri="
+				+ this.getMaxPriority() + "]";
+	}
+
+	/**
+	 * Any uncaught exception in any Thread has to be forwarded (by the VM) to
+	 * the Thread's ThreadGroup by sending this message (uncaughtException).
+	 * This allows users to define custom ThreadGroup classes and custom
+	 * behavior for when a Thread has an uncaughtException or when it does
+	 * (ThreadDeath).
+	 * 
+	 * @param t
+	 *            Thread with an uncaught exception
+	 * @param e
+	 *            The uncaught exception itself
+	 * 
+	 * @see Thread#stop()
+	 * @see Thread#stop(Throwable)
+	 * @see ThreadDeath
+	 */
+	public void uncaughtException(Thread t, Throwable e) {
+		if (parent != null) {
+			parent.uncaughtException(t, e);
+		} else if (!(e instanceof ThreadDeath)) {
+			// No parent group, has to be 'system' Thread Group
+			e.printStackTrace(System.err);
+		}
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Throwable.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Throwable.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Throwable.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/Throwable.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,350 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+
+/**
+ * This class must be implemented by the vm vendor, or the reference
+ * implementation can be used if the documented natives are implemented.
+ * 
+ * This class is the superclass of all classes which can be thrown by the
+ * virtual machine. The two direct subclasses represent recoverable exceptions
+ * (Exception) and unrecoverable errors (Error). This class provides common
+ * methods for accessing a string message which provides extra information about
+ * the circumstances in which the throwable was created, and for filling in a
+ * walkback (i.e. a record of the call stack at a particular point in time)
+ * which can be printed later.
+ * 
+ * @see Error
+ * @see Exception
+ * @see RuntimeException
+ */
+public class Throwable implements java.io.Serializable {
+	static final long serialVersionUID = -3042686055658047285L;
+
+	/**
+	 * The message provided when the exception was created.
+	 */
+	private String detailMessage;
+
+	/**
+	 * An object which describes the walkback. This field is stored by the
+	 * fillInStackTrace() native, and used by the getStackTraceImpl() native.
+	 */
+	private transient Object walkback;
+
+	/**
+	 * The cause of this Throwable. Null when there is no cause.
+	 */
+	private Throwable cause = this;
+
+	private StackTraceElement[] stackTrace = null;
+
+	/**
+	 * Constructs a new instance of this class with its walkback filled in.
+	 */
+	public Throwable() {
+		super();
+		fillInStackTrace();
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback and message
+	 * filled in.
+	 * 
+	 * @param detailMessage
+	 *            String The detail message for the exception.
+	 */
+	public Throwable(String detailMessage) {
+		this();
+		this.detailMessage = detailMessage;
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback, message and
+	 * cause filled in.
+	 * 
+	 * @param detailMessage
+	 *            String The detail message for the exception.
+	 * @param throwable
+	 *            The cause of this Throwable
+	 */
+	public Throwable(String detailMessage, Throwable throwable) {
+		this();
+		this.detailMessage = detailMessage;
+		cause = throwable;
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback and cause
+	 * filled in.
+	 * 
+	 * @param throwable
+	 *            The cause of this Throwable
+	 */
+	public Throwable(Throwable throwable) {
+		this();
+		this.detailMessage = throwable == null ? null : throwable.toString();
+		cause = throwable;
+	}
+
+	/**
+	 * This native must be implemented to use the reference implementation of
+	 * this class.
+	 * 
+	 * Record in the receiver a walkback from the point where this message was
+	 * sent. The message is public so that code which catches a throwable and
+	 * then <em>re-throws</em> it can adjust the walkback to represent the
+	 * location where the exception was re-thrown.
+	 * 
+	 * @return the receiver
+	 */
+	public native Throwable fillInStackTrace();
+
+	/**
+	 * Answers the extra information message which was provided when the
+	 * throwable was created. If no message was provided at creation time, then
+	 * answer null.
+	 * 
+	 * @return String The receiver's message.
+	 */
+	public String getMessage() {
+		return detailMessage;
+	}
+
+	/**
+	 * Answers the extra information message which was provided when the
+	 * throwable was created. If no message was provided at creation time, then
+	 * answer null. Subclasses may override this method to answer localized text
+	 * for the message.
+	 * 
+	 * @return String The receiver's message.
+	 */
+	public String getLocalizedMessage() {
+		return getMessage();
+	}
+
+	/**
+	 * This native must be implemented to use the reference implementation of
+	 * this class. The result of this native is cloned, and returned from the
+	 * public API getStackTrace().
+	 * 
+	 * Answers an array of StackTraceElement. Each StackTraceElement represents
+	 * a entry on the stack.
+	 * 
+	 * @return an array of StackTraceElement representing the stack
+	 */
+	private native StackTraceElement[] getStackTraceImpl();
+
+	/**
+	 * Answers an array of StackTraceElement. Each StackTraceElement represents
+	 * a entry on the stack.
+	 * 
+	 * @return an array of StackTraceElement representing the stack
+	 */
+	public StackTraceElement[] getStackTrace() {
+		return (StackTraceElement[]) getInternalStackTrace().clone();
+	}
+
+	/**
+	 * Sets the array of StackTraceElements. Each StackTraceElement represents a
+	 * entry on the stack. A copy of this array will be returned by
+	 * getStackTrace() and printed by printStackTrace().
+	 * 
+	 * @param trace
+	 *            The array of StackTraceElement
+	 */
+	public void setStackTrace(StackTraceElement[] trace) {
+		StackTraceElement[] newTrace = (StackTraceElement[]) trace.clone();
+		for (int i = 0; i < newTrace.length; i++)
+			if (newTrace[i] == null)
+				throw new NullPointerException();
+		stackTrace = newTrace;
+	}
+
+	/**
+	 * Outputs a printable representation of the receiver's walkback on the
+	 * System.err stream.
+	 */
+	public void printStackTrace() {
+		printStackTrace(System.err);
+	}
+
+	/**
+	 * Count the number of duplicate stack frames, starting from
+	 * the end of the stack.
+	 * 
+	 * @param currentStack a stack to compare
+	 * @param parentStack a stack to compare
+	 *  
+	 * @return the number of duplicate stack frames.
+	 */
+	private static int countDuplicates(StackTraceElement[] currentStack,
+			StackTraceElement[] parentStack) {
+		int duplicates = 0;
+		int parentIndex = parentStack.length;
+		for (int i = currentStack.length; --i >= 0 && --parentIndex >= 0;) {
+			StackTraceElement parentFrame = parentStack[parentIndex];
+			if (parentFrame.equals(currentStack[i])) {
+				duplicates++;
+			} else {
+				break;
+			}
+		}
+		return duplicates;
+	}
+
+	/**
+	 * Answers an array of StackTraceElement. Each StackTraceElement represents
+	 * a entry on the stack. Cache the stack trace in the stackTrace field, returning
+	 * the cached field when it has already been initialized.
+	 *
+	 * @return an array of StackTraceElement representing the stack
+	 */
+	private StackTraceElement[] getInternalStackTrace() {
+		if (stackTrace == null)
+			stackTrace = getStackTraceImpl();
+		return stackTrace;
+	}
+
+	/**
+	 * Outputs a printable representation of the receiver's walkback on the
+	 * stream specified by the argument.
+	 * 
+	 * @param err
+	 *            PrintStream The stream to write the walkback on.
+	 */
+	public void printStackTrace(PrintStream err) {
+		err.println(toString());
+		// Don't use getStackTrace() as it calls clone()
+		// Get stackTrace, in case stackTrace is reassigned
+		StackTraceElement[] stack = getInternalStackTrace();
+		for (int i = 0; i < stack.length; i++)
+			err.println("\tat " + stack[i]);
+
+		StackTraceElement[] parentStack = stack;
+		Throwable throwable = getCause();
+		while (throwable != null) {
+			err.print("Caused by: ");
+			err.println(throwable);
+			StackTraceElement[] currentStack = throwable
+					.getInternalStackTrace();
+			int duplicates = countDuplicates(currentStack, parentStack);
+			for (int i = 0; i < currentStack.length - duplicates; i++)
+				err.println("\tat " + currentStack[i]);
+			if (duplicates > 0) {
+				err.println("\t... " + duplicates + " more");
+			}
+			parentStack = currentStack;
+			throwable = throwable.getCause();
+		}
+	}
+
+	/**
+	 * Outputs a printable representation of the receiver's walkback on the
+	 * writer specified by the argument.
+	 * 
+	 * @param err
+	 *            PrintWriter The writer to write the walkback on.
+	 */
+	public void printStackTrace(PrintWriter err) {
+		err.println(toString());
+		// Don't use getStackTrace() as it calls clone()
+		// Get stackTrace, in case stackTrace is reassigned
+		StackTraceElement[] stack = getInternalStackTrace();
+		for (int i = 0; i < stack.length; i++)
+			err.println("\tat " + stack[i]);
+
+		StackTraceElement[] parentStack = stack;
+		Throwable throwable = getCause();
+		while (throwable != null) {
+			err.print("Caused by: ");
+			err.println(throwable);
+			StackTraceElement[] currentStack = throwable
+					.getInternalStackTrace();
+			int duplicates = countDuplicates(currentStack, parentStack);
+			for (int i = 0; i < currentStack.length - duplicates; i++)
+				err.println("\tat " + currentStack[i]);
+			if (duplicates > 0) {
+				err.println("\t... " + duplicates + " more");
+			}
+			parentStack = currentStack;
+			throwable = throwable.getCause();
+		}
+	}
+
+	/**
+	 * Answers a string containing a concise, human-readable description of the
+	 * receiver.
+	 * 
+	 * @return String a printable representation for the receiver.
+	 */
+	public String toString() {
+		String msg = getLocalizedMessage();
+		String name = getClass().getName();
+		if (msg == null) {
+			return name;
+		}
+		return new StringBuffer(name.length() + 2 + msg.length()).append(name)
+				.append(": ").append(msg).toString();
+	}
+
+	/**
+	 * Initialize the cause of the receiver. The cause cannot be reassigned.
+	 * 
+	 * @param throwable
+	 *            The cause of this Throwable
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when the cause is the receiver
+	 * @exception IllegalStateException
+	 *                when the cause has already been initialized
+	 * 
+	 * @return the receiver.
+	 */
+	public synchronized Throwable initCause(Throwable throwable) {
+		if (cause == this) {
+			if (throwable != this) {
+				cause = throwable;
+				return this;
+			}
+			throw new IllegalArgumentException("Cause cannot be the receiver");
+		}
+		throw new IllegalStateException("Cause already initialized");
+	}
+
+	/**
+	 * Answers the cause of this Throwable, or null if there is no cause.
+	 * 
+	 * @return Throwable The receiver's cause.
+	 */
+	public Throwable getCause() {
+		if (cause == this)
+			return null;
+		return cause;
+	}
+
+	private void writeObject(ObjectOutputStream s) throws IOException {
+		// ensure the stackTrace field is initialized
+		getInternalStackTrace();
+		s.defaultWriteObject();
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/PhantomReference.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/PhantomReference.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/PhantomReference.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/PhantomReference.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,49 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.ref;
+
+/**
+ * PhantomReference objects are used to detect referents which are no longer
+ * visible and are eligible to have their storage reclaimed.
+ * 
+ * @since JDK1.2
+ */
+public class PhantomReference extends java.lang.ref.Reference {
+
+	/**
+	 * Return the referent of the reference object. Phantom reference objects
+	 * referents are inaccessible, and so null is returned.
+	 * 
+	 * 
+	 * @return Object Returns null.
+	 */
+	public Object get() {
+		return null;
+	}
+
+	/**
+	 * Constructs a new instance of this class.
+	 * 
+	 * 
+	 * @param r
+	 *            referent to track.
+	 * @param q
+	 *            queue to register to the reference object with.
+	 */
+	public PhantomReference(Object r, ReferenceQueue q) {
+		super();
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/Reference.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/Reference.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/Reference.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/Reference.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,120 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.ref;
+
+/**
+ * This class must be implemented by the vm vendor. The documented methods must
+ * be implemented to support the provided subclass implementations. As the
+ * provided subclass implementations are trivial and simply call
+ * initReference(Object) and initReference(Object, ReferenceQueue) from their
+ * constructors, the vm vendor may elect to implement the subclasses as well.
+ * Abstract class which describes behavior common to all reference objects.
+ * 
+ * @since JDK1.2
+ */
+public abstract class Reference extends Object {
+
+	/**
+	 * Make the referent null. This does not force the reference object to be
+	 * enqueued.
+	 * 
+	 */
+	public void clear() {
+		return;
+	}
+
+	/**
+	 * Force the reference object to be enqueued if it has been associated with
+	 * a queue.
+	 * 
+	 * @return boolean true if Reference is enqueued. false otherwise.
+	 */
+	public boolean enqueue() {
+		return false;
+	}
+
+	/**
+	 * Return the referent of the reference object.
+	 * 
+	 * @return Object Referent to which reference refers, or null if object has
+	 *         been cleared.
+	 */
+	public Object get() {
+		return null;
+	}
+
+	/**
+	 * Return whether the reference object has been enqueued.
+	 * 
+	 * @return boolean true if Reference has been enqueued. false otherwise.
+	 */
+	public boolean isEnqueued() {
+		return false;
+	}
+
+	/**
+	 * Enqueue the reference object on the associated queue.
+	 * 
+	 * @return boolean true if the Reference was successfully enqueued. false
+	 *         otherwise.
+	 */
+	boolean enqueueImpl() {
+		return false;
+	}
+
+	/**
+	 * Constructs a new instance of this class.
+	 * 
+	 */
+	Reference() {
+		super();
+	}
+
+	/**
+	 * Implement this method to support the provided subclass implementations.
+	 * Initialize a newly created reference object. Associate the reference
+	 * object with the referent.
+	 * 
+	 * @param r
+	 *            the referent
+	 */
+	void initReference(Object r) {
+		return;
+	}
+
+	/**
+	 * Implement this method to support the provided subclass implementations.
+	 * Initialize a newly created reference object. Associate the reference
+	 * object with the referent, and the specified ReferenceQueue.
+	 * 
+	 * @param r
+	 *            the referent
+	 * @param q
+	 *            the ReferenceQueue
+	 */
+	void initReference(Object r, ReferenceQueue q) {
+		return;
+	}
+
+	/**
+	 * Called when a Reference has been removed from its ReferenceQueue.
+	 * Set the enqueued field to false.
+	 */
+	void dequeue() {
+		return;
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/SoftReference.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/SoftReference.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/SoftReference.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/SoftReference.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,62 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.ref;
+
+/**
+ * SoftReference objects are used to detect referents which are no longer
+ * visible and who's memory is to be reclaimed.
+ * 
+ * @since JDK1.2
+ */
+public class SoftReference extends java.lang.ref.Reference {
+	private int age;
+
+	/**
+	 * Constructs a new instance of this class.
+	 * 
+	 * 
+	 * @param r
+	 *            referent to track.
+	 * @param q
+	 *            queue to register to the reference object with.
+	 */
+	public SoftReference(Object r, ReferenceQueue q) {
+		initReference(r, q);
+	}
+
+	/**
+	 * Constructs a new instance of this class.
+	 * 
+	 * 
+	 * @param r
+	 *            referent to track.
+	 */
+	public SoftReference(Object r) {
+		initReference(r);
+	}
+
+	/**
+	 * Return the referent of the reference object.
+	 * 
+	 * 
+	 * @return Object Referent to which reference refers, or null if object has
+	 *         been cleared.
+	 */
+	public Object get() {
+		return super.get();
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/WeakReference.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/WeakReference.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/WeakReference.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/ref/WeakReference.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,49 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.ref;
+
+/**
+ * WeakReference objects are used to detect referents which are no longer
+ * visible.
+ * 
+ * @since JDK1.2
+ */
+public class WeakReference extends java.lang.ref.Reference {
+
+	/**
+	 * Constructs a new instance of this class.
+	 * 
+	 * 
+	 * @param r
+	 *            referent to track.
+	 * @param q
+	 *            queue to register to the reference object with.
+	 */
+	public WeakReference(Object r, ReferenceQueue q) {
+		initReference(r, q);
+	}
+
+	/**
+	 * Constructs a new instance of this class.
+	 * 
+	 * 
+	 * @param r
+	 *            referent to track.
+	 */
+	public WeakReference(Object r) {
+		initReference(r);
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/reflect/AccessibleObject.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/reflect/AccessibleObject.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/reflect/AccessibleObject.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/kernel/src/java/lang/reflect/AccessibleObject.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,146 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+/**
+ * This class must be implemented by the vm vendor. This class is the superclass
+ * of all member reflect classes (Field, Constructor, Method). AccessibleObject
+ * provides the ability to toggle access checks for these objects. By default
+ * accessing a member (for example, setting a field or invoking a method) checks
+ * the validity of the access (for example, invoking a private method from
+ * outside the defining class is prohibited) and throws IllegalAccessException
+ * if the operation is not permitted. If the accessible flag is set to true,
+ * these checks are omitted. This allows privileged applications such as Java
+ * Object Serialization, inspectors, and debuggers to have complete access to
+ * objects.
+ * 
+ * @see Field
+ * @see Constructor
+ * @see Method
+ * @see ReflectPermission
+ */
+public class AccessibleObject {
+	static final Object[] emptyArgs = new Object[0];
+
+	/**
+	 * AccessibleObject constructor. AccessibleObjects can only be created by
+	 * the Virtual Machine.
+	 */
+	protected AccessibleObject() {
+		super();
+	}
+
+	/**
+	 * Returns the value of the accessible flag. This is false if access checks
+	 * are performed, true if they are skipped.
+	 * 
+	 * @return the value of the accessible flag
+	 */
+	public boolean isAccessible() {
+		return false;
+	}
+
+	/**
+	 * Attempts to set the value of the accessible flag for all the objects in
+	 * the array provided. Only one security check is performed. Setting this
+	 * flag to false will enable access checks, setting to true will disable
+	 * them. If there is a security manager, checkPermission is called with a
+	 * ReflectPermission("suppressAccessChecks").
+	 * 
+	 * @param objects
+	 *            the accessible objects
+	 * @param flag
+	 *            the new value for the accessible flag
+	 * @see #setAccessible(boolean)
+	 * @see ReflectPermission
+	 * @throws SecurityException
+	 *             if the request is denied
+	 */
+	public static void setAccessible(AccessibleObject[] objects, boolean flag)
+			throws SecurityException {
+		return;
+	}
+
+	/**
+	 * Attempts to set the value of the accessible flag. Setting this flag to
+	 * false will enable access checks, setting to true will disable them. If
+	 * there is a security manager, checkPermission is called with a
+	 * ReflectPermission("suppressAccessChecks").
+	 * 
+	 * @param flag
+	 *            the new value for the accessible flag
+	 * @see ReflectPermission
+	 * @throws SecurityException
+	 *             if the request is denied
+	 */
+	public void setAccessible(boolean flag) throws SecurityException {
+		return;
+	}
+
+	static Object[] marshallArguments(Class[] parameterTypes, Object[] args)
+			throws IllegalArgumentException {
+		return null;
+	}
+
+	void invokeV(Object receiver, Object args[])
+			throws InvocationTargetException {
+		return;
+	}
+
+	Object invokeL(Object receiver, Object args[])
+			throws InvocationTargetException {
+		return null;
+	}
+
+	int invokeI(Object receiver, Object args[])
+			throws InvocationTargetException {
+		return 0;
+	}
+
+	long invokeJ(Object receiver, Object args[])
+			throws InvocationTargetException {
+		return 0L;
+	}
+
+	float invokeF(Object receiver, Object args[])
+			throws InvocationTargetException {
+		return 0.0F;
+	}
+
+	double invokeD(Object receiver, Object args[])
+			throws InvocationTargetException {
+		return 0.0D;
+	}
+
+	native Class[] getParameterTypesImpl();
+
+	native int getModifiers();
+
+	native Class[] getExceptionTypesImpl();
+
+	native String getSignature();
+
+	native boolean checkAccessibility(Class senderClass, Object receiver);
+
+	static native void initializeClass(Class clazz);
+
+	/**
+	 * Answer the class at depth. Notes: 1) This method operates on the defining
+	 * classes of methods on stack. NOT the classes of receivers. 2) The item at
+	 * index zero describes the caller of this method.
+	 */
+	static final native Class getStackClass(int depth);
+}



Mime
View raw message