3261N/A * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 845N/A * Class {@code Object} is the root of the class hierarchy. 845N/A * Every class has {@code Object} as a superclass. All objects, 0N/A * including arrays, implement the methods of this class. 0N/A * @author unascribed 0N/A * @see java.lang.Class 0N/A * Returns the runtime class of this {@code Object}. The returned 0N/A * {@code Class} object is the object that is locked by {@code 0N/A * static synchronized} methods of the represented class. 0N/A * <p><b>The actual result type is {@code Class<? extends |X|>} 0N/A * where {@code |X|} is the erasure of the static type of the 0N/A * expression on which {@code getClass} is called.</b> For 0N/A * example, no cast is required in this code fragment:</p> 0N/A * {@code Number n = 0; }<br> 0N/A * {@code Class<? extends Number> c = n.getClass(); } 0N/A * @return The {@code Class} object that represents the runtime 0N/A * class of this object. 4008N/A * @see Class Literals, section 15.8.2 of 4008N/A * <cite>The Java™ Language Specification</cite>. 0N/A * Returns a hash code value for the object. This method is 845N/A * supported for the benefit of hash tables such as those provided by 845N/A * {@link java.util.HashMap}. 845N/A * The general contract of {@code hashCode} is: 0N/A * <li>Whenever it is invoked on the same object more than once during 845N/A * an execution of a Java application, the {@code hashCode} method 0N/A * must consistently return the same integer, provided no information 845N/A * used in {@code equals} comparisons on the object is modified. 0N/A * This integer need not remain consistent from one execution of an 0N/A * application to another execution of the same application. 845N/A * <li>If two objects are equal according to the {@code equals(Object)} 845N/A * method, then calling the {@code hashCode} method on each of 0N/A * the two objects must produce the same integer result. 0N/A * <li>It is <em>not</em> required that if two objects are unequal 0N/A * according to the {@link java.lang.Object#equals(java.lang.Object)} 845N/A * method, then calling the {@code hashCode} method on each of the 0N/A * two objects must produce distinct integer results. However, the 0N/A * programmer should be aware that producing distinct integer results 845N/A * for unequal objects may improve the performance of hash tables. 0N/A * As much as is reasonably practical, the hashCode method defined by 845N/A * class {@code Object} does return distinct integers for distinct 0N/A * objects. (This is typically implemented by converting the internal 0N/A * address of the object into an integer, but this implementation 0N/A * technique is not required by the 0N/A * Java<font size="-2"><sup>TM</sup></font> programming language.) 0N/A * @return a hash code value for this object. 0N/A * @see java.lang.Object#equals(java.lang.Object) 845N/A * @see java.lang.System#identityHashCode 0N/A * Indicates whether some other object is "equal to" this one. 845N/A * The {@code equals} method implements an equivalence relation 0N/A * on non-null object references: 0N/A * <li>It is <i>reflexive</i>: for any non-null reference value 845N/A * {@code x}, {@code x.equals(x)} should return 0N/A * <li>It is <i>symmetric</i>: for any non-null reference values 845N/A * {@code x} and {@code y}, {@code x.equals(y)} 845N/A * should return {@code true} if and only if 845N/A * {@code y.equals(x)} returns {@code true}. 0N/A * <li>It is <i>transitive</i>: for any non-null reference values 845N/A * {@code x}, {@code y}, and {@code z}, if 845N/A * {@code x.equals(y)} returns {@code true} and 845N/A * {@code y.equals(z)} returns {@code true}, then 845N/A * {@code x.equals(z)} should return {@code true}. 0N/A * <li>It is <i>consistent</i>: for any non-null reference values 845N/A * {@code x} and {@code y}, multiple invocations of 845N/A * {@code x.equals(y)} consistently return {@code true} 845N/A * or consistently return {@code false}, provided no 845N/A * information used in {@code equals} comparisons on the 0N/A * objects is modified. 845N/A * <li>For any non-null reference value {@code x}, 845N/A * {@code x.equals(null)} should return {@code false}. 845N/A * The {@code equals} method for class {@code Object} implements 0N/A * the most discriminating possible equivalence relation on objects; 845N/A * that is, for any non-null reference values {@code x} and 845N/A * {@code y}, this method returns {@code true} if and only 845N/A * if {@code x} and {@code y} refer to the same object 845N/A * ({@code x == y} has the value {@code true}). 845N/A * Note that it is generally necessary to override the {@code hashCode} 0N/A * method whenever this method is overridden, so as to maintain the 845N/A * general contract for the {@code hashCode} method, which states 0N/A * that equal objects must have equal hash codes. 0N/A * @param obj the reference object with which to compare. 845N/A * @return {@code true} if this object is the same as the obj 845N/A * argument; {@code false} otherwise. 845N/A * @see java.util.HashMap 0N/A * Creates and returns a copy of this object. The precise meaning 0N/A * of "copy" may depend on the class of the object. The general 845N/A * intent is that, for any object {@code x}, the expression: 0N/A * x.clone() != x</pre></blockquote> 0N/A * will be true, and that the expression: 0N/A * x.clone().getClass() == x.getClass()</pre></blockquote> 845N/A * will be {@code true}, but these are not absolute requirements. 0N/A * While it is typically the case that: 0N/A * x.clone().equals(x)</pre></blockquote> 845N/A * will be {@code true}, this is not an absolute requirement. 0N/A * By convention, the returned object should be obtained by calling 845N/A * {@code super.clone}. If a class and all of its superclasses (except 845N/A * {@code Object}) obey this convention, it will be the case that 845N/A * {@code x.clone().getClass() == x.getClass()}. 0N/A * By convention, the object returned by this method should be independent 0N/A * of this object (which is being cloned). To achieve this independence, 0N/A * it may be necessary to modify one or more fields of the object returned 845N/A * by {@code super.clone} before returning it. Typically, this means 0N/A * copying any mutable objects that comprise the internal "deep structure" 0N/A * of the object being cloned and replacing the references to these 0N/A * objects with references to the copies. If a class contains only 0N/A * primitive fields or references to immutable objects, then it is usually 845N/A * the case that no fields in the object returned by {@code super.clone} 0N/A * need to be modified. 845N/A * The method {@code clone} for class {@code Object} performs a 0N/A * specific cloning operation. First, if the class of this object does 845N/A * not implement the interface {@code Cloneable}, then a 845N/A * {@code CloneNotSupportedException} is thrown. Note that all arrays 2738N/A * are considered to implement the interface {@code Cloneable} and that 2738N/A * the return type of the {@code clone} method of an array type {@code T[]} 2738N/A * is {@code T[]} where T is any reference or primitive type. 0N/A * Otherwise, this method creates a new instance of the class of this 0N/A * object and initializes all its fields with exactly the contents of 0N/A * the corresponding fields of this object, as if by assignment; the 0N/A * contents of the fields are not themselves cloned. Thus, this method 0N/A * performs a "shallow copy" of this object, not a "deep copy" operation. 845N/A * The class {@code Object} does not itself implement the interface 845N/A * {@code Cloneable}, so calling the {@code clone} method on an object 845N/A * whose class is {@code Object} will result in throwing an 0N/A * exception at run time. 0N/A * @return a clone of this instance. 0N/A * @exception CloneNotSupportedException if the object's class does not 845N/A * support the {@code Cloneable} interface. Subclasses 845N/A * that override the {@code clone} method can also 0N/A * throw this exception to indicate that an instance cannot 0N/A * @see java.lang.Cloneable 0N/A * Returns a string representation of the object. In general, the 845N/A * {@code toString} method returns a string that 0N/A * "textually represents" this object. The result should 0N/A * be a concise but informative representation that is easy for a 0N/A * It is recommended that all subclasses override this method. 845N/A * The {@code toString} method for class {@code Object} 0N/A * returns a string consisting of the name of the class of which the 845N/A * object is an instance, the at-sign character `{@code @}', and 0N/A * the unsigned hexadecimal representation of the hash code of the 0N/A * object. In other words, this method returns a string equal to the 0N/A * getClass().getName() + '@' + Integer.toHexString(hashCode()) 0N/A * </pre></blockquote> 0N/A * @return a string representation of the object. 0N/A * Wakes up a single thread that is waiting on this object's 0N/A * monitor. If any threads are waiting on this object, one of them 0N/A * is chosen to be awakened. The choice is arbitrary and occurs at 0N/A * the discretion of the implementation. A thread waits on an object's 845N/A * monitor by calling one of the {@code wait} methods. 0N/A * The awakened thread will not be able to proceed until the current 0N/A * thread relinquishes the lock on this object. The awakened thread will 0N/A * compete in the usual manner with any other threads that might be 0N/A * actively competing to synchronize on this object; for example, the 0N/A * awakened thread enjoys no reliable privilege or disadvantage in being 0N/A * the next thread to lock this object. 0N/A * This method should only be called by a thread that is the owner 0N/A * of this object's monitor. A thread becomes the owner of the 0N/A * object's monitor in one of three ways: 0N/A * <li>By executing a synchronized instance method of that object. 845N/A * <li>By executing the body of a {@code synchronized} statement 0N/A * that synchronizes on the object. 845N/A * <li>For objects of type {@code Class,} by executing a 0N/A * synchronized static method of that class. 0N/A * Only one thread at a time can own an object's monitor. 0N/A * @exception IllegalMonitorStateException if the current thread is not 0N/A * the owner of this object's monitor. 0N/A * @see java.lang.Object#notifyAll() 0N/A * @see java.lang.Object#wait() 0N/A * Wakes up all threads that are waiting on this object's monitor. A 0N/A * thread waits on an object's monitor by calling one of the 845N/A * {@code wait} methods. 0N/A * The awakened threads will not be able to proceed until the current 0N/A * thread relinquishes the lock on this object. The awakened threads 0N/A * will compete in the usual manner with any other threads that might 0N/A * be actively competing to synchronize on this object; for example, 0N/A * the awakened threads enjoy no reliable privilege or disadvantage in 0N/A * being the next thread to lock this object. 0N/A * This method should only be called by a thread that is the owner 845N/A * of this object's monitor. See the {@code notify} method for a 0N/A * description of the ways in which a thread can become the owner of 0N/A * @exception IllegalMonitorStateException if the current thread is not 0N/A * the owner of this object's monitor. 0N/A * @see java.lang.Object#notify() 0N/A * @see java.lang.Object#wait() 0N/A * Causes the current thread to wait until either another thread invokes the 0N/A * {@link java.lang.Object#notify()} method or the 0N/A * {@link java.lang.Object#notifyAll()} method for this object, or a 0N/A * specified amount of time has elapsed. 0N/A * The current thread must own this object's monitor. 0N/A * This method causes the current thread (call it <var>T</var>) to 0N/A * place itself in the wait set for this object and then to relinquish 0N/A * any and all synchronization claims on this object. Thread <var>T</var> 0N/A * becomes disabled for thread scheduling purposes and lies dormant 0N/A * until one of four things happens: 845N/A * <li>Some other thread invokes the {@code notify} method for this 0N/A * object and thread <var>T</var> happens to be arbitrarily chosen as 0N/A * the thread to be awakened. 845N/A * <li>Some other thread invokes the {@code notifyAll} method for this 0N/A * <li>Some other thread {@linkplain Thread#interrupt() interrupts} 0N/A * thread <var>T</var>. 0N/A * <li>The specified amount of real time has elapsed, more or less. If 845N/A * {@code timeout} is zero, however, then real time is not taken into 0N/A * consideration and the thread simply waits until notified. 0N/A * The thread <var>T</var> is then removed from the wait set for this 0N/A * object and re-enabled for thread scheduling. It then competes in the 0N/A * usual manner with other threads for the right to synchronize on the 0N/A * object; once it has gained control of the object, all its 0N/A * synchronization claims on the object are restored to the status quo 845N/A * ante - that is, to the situation as of the time that the {@code wait} 0N/A * method was invoked. Thread <var>T</var> then returns from the 845N/A * invocation of the {@code wait} method. Thus, on return from the 845N/A * {@code wait} method, the synchronization state of the object and of 845N/A * thread {@code T} is exactly as it was when the {@code wait} method 0N/A * A thread can also wake up without being notified, interrupted, or 0N/A * timing out, a so-called <i>spurious wakeup</i>. While this will rarely 0N/A * occur in practice, applications must guard against it by testing for 0N/A * the condition that should have caused the thread to be awakened, and 0N/A * continuing to wait if the condition is not satisfied. In other words, 0N/A * waits should always occur in loops, like this one: 0N/A * synchronized (obj) { 0N/A * while (<condition does not hold>) 0N/A * obj.wait(timeout); 0N/A * ... // Perform action appropriate to condition 0N/A * (For more information on this topic, see Section 3.2.3 in Doug Lea's 0N/A * "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 0N/A * 2000), or Item 50 in Joshua Bloch's "Effective Java Programming 0N/A * Language Guide" (Addison-Wesley, 2001). 0N/A * <p>If the current thread is {@linkplain java.lang.Thread#interrupt() 0N/A * interrupted} by any thread before or while it is waiting, then an 845N/A * {@code InterruptedException} is thrown. This exception is not 0N/A * thrown until the lock status of this object has been restored as 845N/A * Note that the {@code wait} method, as it places the current thread 0N/A * into the wait set for this object, unlocks only this object; any 0N/A * other objects on which the current thread may be synchronized remain 0N/A * locked while the thread waits. 0N/A * This method should only be called by a thread that is the owner 845N/A * of this object's monitor. See the {@code notify} method for a 0N/A * description of the ways in which a thread can become the owner of 0N/A * @param timeout the maximum time to wait in milliseconds. 0N/A * @exception IllegalArgumentException if the value of timeout is 0N/A * @exception IllegalMonitorStateException if the current thread is not 0N/A * the owner of the object's monitor. 0N/A * @exception InterruptedException if any thread interrupted the 0N/A * current thread before or while the current thread 0N/A * was waiting for a notification. The <i>interrupted 0N/A * status</i> of the current thread is cleared when 0N/A * this exception is thrown. 0N/A * @see java.lang.Object#notify() 0N/A * @see java.lang.Object#notifyAll() 0N/A * Causes the current thread to wait until another thread invokes the 0N/A * {@link java.lang.Object#notify()} method or the 0N/A * {@link java.lang.Object#notifyAll()} method for this object, or 0N/A * some other thread interrupts the current thread, or a certain 0N/A * amount of real time has elapsed. 845N/A * This method is similar to the {@code wait} method of one 0N/A * argument, but it allows finer control over the amount of time to 0N/A * wait for a notification before giving up. The amount of real time, 0N/A * measured in nanoseconds, is given by: 0N/A * 1000000*timeout+nanos</pre></blockquote> 0N/A * In all other respects, this method does the same thing as the 0N/A * method {@link #wait(long)} of one argument. In particular, 845N/A * {@code wait(0, 0)} means the same thing as {@code wait(0)}. 0N/A * The current thread must own this object's monitor. The thread 0N/A * releases ownership of this monitor and waits until either of the 0N/A * following two conditions has occurred: 0N/A * <li>Another thread notifies threads waiting on this object's monitor 845N/A * to wake up either through a call to the {@code notify} method 845N/A * or the {@code notifyAll} method. 845N/A * <li>The timeout period, specified by {@code timeout} 845N/A * milliseconds plus {@code nanos} nanoseconds arguments, has 0N/A * The thread then waits until it can re-obtain ownership of the 0N/A * monitor and resumes execution. 0N/A * As in the one argument version, interrupts and spurious wakeups are 0N/A * possible, and this method should always be used in a loop: 0N/A * synchronized (obj) { 0N/A * while (<condition does not hold>) 0N/A * obj.wait(timeout, nanos); 0N/A * ... // Perform action appropriate to condition 0N/A * This method should only be called by a thread that is the owner 845N/A * of this object's monitor. See the {@code notify} method for a 0N/A * description of the ways in which a thread can become the owner of 0N/A * @param timeout the maximum time to wait in milliseconds. 0N/A * @param nanos additional time, in nanoseconds range 0N/A * @exception IllegalArgumentException if the value of timeout is 0N/A * negative or the value of nanos is 0N/A * not in the range 0-999999. 0N/A * @exception IllegalMonitorStateException if the current thread is not 0N/A * the owner of this object's monitor. 0N/A * @exception InterruptedException if any thread interrupted the 0N/A * current thread before or while the current thread 0N/A * was waiting for a notification. The <i>interrupted 0N/A * status</i> of the current thread is cleared when 0N/A * this exception is thrown. 0N/A "nanosecond timeout value out of range");
0N/A * Causes the current thread to wait until another thread invokes the 0N/A * {@link java.lang.Object#notify()} method or the 0N/A * {@link java.lang.Object#notifyAll()} method for this object. 0N/A * In other words, this method behaves exactly as if it simply 845N/A * performs the call {@code wait(0)}. 0N/A * The current thread must own this object's monitor. The thread 0N/A * releases ownership of this monitor and waits until another thread 0N/A * notifies threads waiting on this object's monitor to wake up 845N/A * either through a call to the {@code notify} method or the 845N/A * {@code notifyAll} method. The thread then waits until it can 0N/A * re-obtain ownership of the monitor and resumes execution. 0N/A * As in the one argument version, interrupts and spurious wakeups are 0N/A * possible, and this method should always be used in a loop: 0N/A * synchronized (obj) { 0N/A * while (<condition does not hold>) 0N/A * ... // Perform action appropriate to condition 0N/A * This method should only be called by a thread that is the owner 845N/A * of this object's monitor. See the {@code notify} method for a 0N/A * description of the ways in which a thread can become the owner of 0N/A * @exception IllegalMonitorStateException if the current thread is not 0N/A * the owner of the object's monitor. 0N/A * @exception InterruptedException if any thread interrupted the 0N/A * current thread before or while the current thread 0N/A * was waiting for a notification. The <i>interrupted 0N/A * status</i> of the current thread is cleared when 0N/A * this exception is thrown. 0N/A * @see java.lang.Object#notify() 0N/A * @see java.lang.Object#notifyAll() 0N/A * Called by the garbage collector on an object when garbage collection 0N/A * determines that there are no more references to the object. 845N/A * A subclass overrides the {@code finalize} method to dispose of 0N/A * system resources or to perform other cleanup. 845N/A * The general contract of {@code finalize} is that it is invoked 0N/A * if and when the Java<font size="-2"><sup>TM</sup></font> virtual 0N/A * machine has determined that there is no longer any 0N/A * means by which this object can be accessed by any thread that has 0N/A * not yet died, except as a result of an action taken by the 0N/A * finalization of some other object or class which is ready to be 845N/A * finalized. The {@code finalize} method may take any action, including 0N/A * making this object available again to other threads; the usual purpose 845N/A * of {@code finalize}, however, is to perform cleanup actions before 0N/A * the object is irrevocably discarded. For example, the finalize method 0N/A * for an object that represents an input/output connection might perform 0N/A * explicit I/O transactions to break the connection before the object is 0N/A * permanently discarded. 845N/A * The {@code finalize} method of class {@code Object} performs no 0N/A * special action; it simply returns normally. Subclasses of 845N/A * {@code Object} may override this definition. 0N/A * The Java programming language does not guarantee which thread will 845N/A * invoke the {@code finalize} method for any given object. It is 0N/A * guaranteed, however, that the thread that invokes finalize will not 0N/A * be holding any user-visible synchronization locks when finalize is 0N/A * invoked. If an uncaught exception is thrown by the finalize method, 0N/A * the exception is ignored and finalization of that object terminates. 845N/A * After the {@code finalize} method has been invoked for an object, no 0N/A * further action is taken until the Java virtual machine has again 0N/A * determined that there is no longer any means by which this object can 0N/A * be accessed by any thread that has not yet died, including possible 0N/A * actions by other objects or classes which are ready to be finalized, 0N/A * at which point the object may be discarded. 845N/A * The {@code finalize} method is never invoked more than once by a Java 0N/A * virtual machine for any given object. 845N/A * Any exception thrown by the {@code finalize} method causes 0N/A * the finalization of this object to be halted, but is otherwise 845N/A * @throws Throwable the {@code Exception} raised by this method