1.1 --- a/emul/mini/src/main/java/java/lang/Object.java Fri Mar 22 16:59:47 2013 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,595 +0,0 @@
1.4 -/*
1.5 - * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 - *
1.8 - * This code is free software; you can redistribute it and/or modify it
1.9 - * under the terms of the GNU General Public License version 2 only, as
1.10 - * published by the Free Software Foundation. Oracle designates this
1.11 - * particular file as subject to the "Classpath" exception as provided
1.12 - * by Oracle in the LICENSE file that accompanied this code.
1.13 - *
1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 - * version 2 for more details (a copy is included in the LICENSE file that
1.18 - * accompanied this code).
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License version
1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 - *
1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 - * or visit www.oracle.com if you need additional information or have any
1.26 - * questions.
1.27 - */
1.28 -
1.29 -package java.lang;
1.30 -
1.31 -import java.lang.reflect.Array;
1.32 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.33 -import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
1.34 -
1.35 -/**
1.36 - * Class {@code Object} is the root of the class hierarchy.
1.37 - * Every class has {@code Object} as a superclass. All objects,
1.38 - * including arrays, implement the methods of this class.
1.39 - *
1.40 - * @author unascribed
1.41 - * @see java.lang.Class
1.42 - * @since JDK1.0
1.43 - */
1.44 -@JavaScriptPrototype(container = "Object.prototype", prototype = "new Object")
1.45 -public class Object {
1.46 -
1.47 - private static void registerNatives() {
1.48 - try {
1.49 - Array.get(null, 0);
1.50 - } catch (Throwable ex) {
1.51 - // ignore
1.52 - }
1.53 - }
1.54 - static {
1.55 - registerNatives();
1.56 - }
1.57 -
1.58 - /**
1.59 - * Returns the runtime class of this {@code Object}. The returned
1.60 - * {@code Class} object is the object that is locked by {@code
1.61 - * static synchronized} methods of the represented class.
1.62 - *
1.63 - * <p><b>The actual result type is {@code Class<? extends |X|>}
1.64 - * where {@code |X|} is the erasure of the static type of the
1.65 - * expression on which {@code getClass} is called.</b> For
1.66 - * example, no cast is required in this code fragment:</p>
1.67 - *
1.68 - * <p>
1.69 - * {@code Number n = 0; }<br>
1.70 - * {@code Class<? extends Number> c = n.getClass(); }
1.71 - * </p>
1.72 - *
1.73 - * @return The {@code Class} object that represents the runtime
1.74 - * class of this object.
1.75 - * @see Class Literals, section 15.8.2 of
1.76 - * <cite>The Java™ Language Specification</cite>.
1.77 - */
1.78 - @JavaScriptBody(args={}, body="return this.constructor.$class;")
1.79 - public final native Class<?> getClass();
1.80 -
1.81 - /**
1.82 - * Returns a hash code value for the object. This method is
1.83 - * supported for the benefit of hash tables such as those provided by
1.84 - * {@link java.util.HashMap}.
1.85 - * <p>
1.86 - * The general contract of {@code hashCode} is:
1.87 - * <ul>
1.88 - * <li>Whenever it is invoked on the same object more than once during
1.89 - * an execution of a Java application, the {@code hashCode} method
1.90 - * must consistently return the same integer, provided no information
1.91 - * used in {@code equals} comparisons on the object is modified.
1.92 - * This integer need not remain consistent from one execution of an
1.93 - * application to another execution of the same application.
1.94 - * <li>If two objects are equal according to the {@code equals(Object)}
1.95 - * method, then calling the {@code hashCode} method on each of
1.96 - * the two objects must produce the same integer result.
1.97 - * <li>It is <em>not</em> required that if two objects are unequal
1.98 - * according to the {@link java.lang.Object#equals(java.lang.Object)}
1.99 - * method, then calling the {@code hashCode} method on each of the
1.100 - * two objects must produce distinct integer results. However, the
1.101 - * programmer should be aware that producing distinct integer results
1.102 - * for unequal objects may improve the performance of hash tables.
1.103 - * </ul>
1.104 - * <p>
1.105 - * As much as is reasonably practical, the hashCode method defined by
1.106 - * class {@code Object} does return distinct integers for distinct
1.107 - * objects. (This is typically implemented by converting the internal
1.108 - * address of the object into an integer, but this implementation
1.109 - * technique is not required by the
1.110 - * Java<font size="-2"><sup>TM</sup></font> programming language.)
1.111 - *
1.112 - * @return a hash code value for this object.
1.113 - * @see java.lang.Object#equals(java.lang.Object)
1.114 - * @see java.lang.System#identityHashCode
1.115 - */
1.116 - @JavaScriptBody(args = {}, body =
1.117 - "if (this.$hashCode) return this.$hashCode;\n"
1.118 - + "var h = this.computeHashCode__I();\n"
1.119 - + "return this.$hashCode = h & h;"
1.120 - )
1.121 - public native int hashCode();
1.122 -
1.123 - @JavaScriptBody(args = {}, body = "return Math.random() * Math.pow(2, 32);")
1.124 - native int computeHashCode();
1.125 -
1.126 - /**
1.127 - * Indicates whether some other object is "equal to" this one.
1.128 - * <p>
1.129 - * The {@code equals} method implements an equivalence relation
1.130 - * on non-null object references:
1.131 - * <ul>
1.132 - * <li>It is <i>reflexive</i>: for any non-null reference value
1.133 - * {@code x}, {@code x.equals(x)} should return
1.134 - * {@code true}.
1.135 - * <li>It is <i>symmetric</i>: for any non-null reference values
1.136 - * {@code x} and {@code y}, {@code x.equals(y)}
1.137 - * should return {@code true} if and only if
1.138 - * {@code y.equals(x)} returns {@code true}.
1.139 - * <li>It is <i>transitive</i>: for any non-null reference values
1.140 - * {@code x}, {@code y}, and {@code z}, if
1.141 - * {@code x.equals(y)} returns {@code true} and
1.142 - * {@code y.equals(z)} returns {@code true}, then
1.143 - * {@code x.equals(z)} should return {@code true}.
1.144 - * <li>It is <i>consistent</i>: for any non-null reference values
1.145 - * {@code x} and {@code y}, multiple invocations of
1.146 - * {@code x.equals(y)} consistently return {@code true}
1.147 - * or consistently return {@code false}, provided no
1.148 - * information used in {@code equals} comparisons on the
1.149 - * objects is modified.
1.150 - * <li>For any non-null reference value {@code x},
1.151 - * {@code x.equals(null)} should return {@code false}.
1.152 - * </ul>
1.153 - * <p>
1.154 - * The {@code equals} method for class {@code Object} implements
1.155 - * the most discriminating possible equivalence relation on objects;
1.156 - * that is, for any non-null reference values {@code x} and
1.157 - * {@code y}, this method returns {@code true} if and only
1.158 - * if {@code x} and {@code y} refer to the same object
1.159 - * ({@code x == y} has the value {@code true}).
1.160 - * <p>
1.161 - * Note that it is generally necessary to override the {@code hashCode}
1.162 - * method whenever this method is overridden, so as to maintain the
1.163 - * general contract for the {@code hashCode} method, which states
1.164 - * that equal objects must have equal hash codes.
1.165 - *
1.166 - * @param obj the reference object with which to compare.
1.167 - * @return {@code true} if this object is the same as the obj
1.168 - * argument; {@code false} otherwise.
1.169 - * @see #hashCode()
1.170 - * @see java.util.HashMap
1.171 - */
1.172 - public boolean equals(Object obj) {
1.173 - return (this == obj);
1.174 - }
1.175 -
1.176 - /**
1.177 - * Creates and returns a copy of this object. The precise meaning
1.178 - * of "copy" may depend on the class of the object. The general
1.179 - * intent is that, for any object {@code x}, the expression:
1.180 - * <blockquote>
1.181 - * <pre>
1.182 - * x.clone() != x</pre></blockquote>
1.183 - * will be true, and that the expression:
1.184 - * <blockquote>
1.185 - * <pre>
1.186 - * x.clone().getClass() == x.getClass()</pre></blockquote>
1.187 - * will be {@code true}, but these are not absolute requirements.
1.188 - * While it is typically the case that:
1.189 - * <blockquote>
1.190 - * <pre>
1.191 - * x.clone().equals(x)</pre></blockquote>
1.192 - * will be {@code true}, this is not an absolute requirement.
1.193 - * <p>
1.194 - * By convention, the returned object should be obtained by calling
1.195 - * {@code super.clone}. If a class and all of its superclasses (except
1.196 - * {@code Object}) obey this convention, it will be the case that
1.197 - * {@code x.clone().getClass() == x.getClass()}.
1.198 - * <p>
1.199 - * By convention, the object returned by this method should be independent
1.200 - * of this object (which is being cloned). To achieve this independence,
1.201 - * it may be necessary to modify one or more fields of the object returned
1.202 - * by {@code super.clone} before returning it. Typically, this means
1.203 - * copying any mutable objects that comprise the internal "deep structure"
1.204 - * of the object being cloned and replacing the references to these
1.205 - * objects with references to the copies. If a class contains only
1.206 - * primitive fields or references to immutable objects, then it is usually
1.207 - * the case that no fields in the object returned by {@code super.clone}
1.208 - * need to be modified.
1.209 - * <p>
1.210 - * The method {@code clone} for class {@code Object} performs a
1.211 - * specific cloning operation. First, if the class of this object does
1.212 - * not implement the interface {@code Cloneable}, then a
1.213 - * {@code CloneNotSupportedException} is thrown. Note that all arrays
1.214 - * are considered to implement the interface {@code Cloneable} and that
1.215 - * the return type of the {@code clone} method of an array type {@code T[]}
1.216 - * is {@code T[]} where T is any reference or primitive type.
1.217 - * Otherwise, this method creates a new instance of the class of this
1.218 - * object and initializes all its fields with exactly the contents of
1.219 - * the corresponding fields of this object, as if by assignment; the
1.220 - * contents of the fields are not themselves cloned. Thus, this method
1.221 - * performs a "shallow copy" of this object, not a "deep copy" operation.
1.222 - * <p>
1.223 - * The class {@code Object} does not itself implement the interface
1.224 - * {@code Cloneable}, so calling the {@code clone} method on an object
1.225 - * whose class is {@code Object} will result in throwing an
1.226 - * exception at run time.
1.227 - *
1.228 - * @return a clone of this instance.
1.229 - * @exception CloneNotSupportedException if the object's class does not
1.230 - * support the {@code Cloneable} interface. Subclasses
1.231 - * that override the {@code clone} method can also
1.232 - * throw this exception to indicate that an instance cannot
1.233 - * be cloned.
1.234 - * @see java.lang.Cloneable
1.235 - */
1.236 - protected Object clone() throws CloneNotSupportedException {
1.237 - Object ret = clone(this);
1.238 - if (ret == null) {
1.239 - throw new CloneNotSupportedException(getClass().getName());
1.240 - }
1.241 - return ret;
1.242 - }
1.243 -
1.244 - @JavaScriptBody(args = "self", body =
1.245 - "\nif (!self.$instOf_java_lang_Cloneable) {"
1.246 - + "\n return null;"
1.247 - + "\n} else {"
1.248 - + "\n var clone = self.constructor(true);"
1.249 - + "\n var props = Object.getOwnPropertyNames(self);"
1.250 - + "\n for (var i = 0; i < props.length; i++) {"
1.251 - + "\n var p = props[i];"
1.252 - + "\n clone[p] = self[p];"
1.253 - + "\n };"
1.254 - + "\n return clone;"
1.255 - + "\n}"
1.256 - )
1.257 - private static native Object clone(Object self) throws CloneNotSupportedException;
1.258 -
1.259 - /**
1.260 - * Returns a string representation of the object. In general, the
1.261 - * {@code toString} method returns a string that
1.262 - * "textually represents" this object. The result should
1.263 - * be a concise but informative representation that is easy for a
1.264 - * person to read.
1.265 - * It is recommended that all subclasses override this method.
1.266 - * <p>
1.267 - * The {@code toString} method for class {@code Object}
1.268 - * returns a string consisting of the name of the class of which the
1.269 - * object is an instance, the at-sign character `{@code @}', and
1.270 - * the unsigned hexadecimal representation of the hash code of the
1.271 - * object. In other words, this method returns a string equal to the
1.272 - * value of:
1.273 - * <blockquote>
1.274 - * <pre>
1.275 - * getClass().getName() + '@' + Integer.toHexString(hashCode())
1.276 - * </pre></blockquote>
1.277 - *
1.278 - * @return a string representation of the object.
1.279 - */
1.280 - public String toString() {
1.281 - return getClass().getName() + "@" + Integer.toHexString(hashCode());
1.282 - }
1.283 -
1.284 - /**
1.285 - * Wakes up a single thread that is waiting on this object's
1.286 - * monitor. If any threads are waiting on this object, one of them
1.287 - * is chosen to be awakened. The choice is arbitrary and occurs at
1.288 - * the discretion of the implementation. A thread waits on an object's
1.289 - * monitor by calling one of the {@code wait} methods.
1.290 - * <p>
1.291 - * The awakened thread will not be able to proceed until the current
1.292 - * thread relinquishes the lock on this object. The awakened thread will
1.293 - * compete in the usual manner with any other threads that might be
1.294 - * actively competing to synchronize on this object; for example, the
1.295 - * awakened thread enjoys no reliable privilege or disadvantage in being
1.296 - * the next thread to lock this object.
1.297 - * <p>
1.298 - * This method should only be called by a thread that is the owner
1.299 - * of this object's monitor. A thread becomes the owner of the
1.300 - * object's monitor in one of three ways:
1.301 - * <ul>
1.302 - * <li>By executing a synchronized instance method of that object.
1.303 - * <li>By executing the body of a {@code synchronized} statement
1.304 - * that synchronizes on the object.
1.305 - * <li>For objects of type {@code Class,} by executing a
1.306 - * synchronized static method of that class.
1.307 - * </ul>
1.308 - * <p>
1.309 - * Only one thread at a time can own an object's monitor.
1.310 - *
1.311 - * @exception IllegalMonitorStateException if the current thread is not
1.312 - * the owner of this object's monitor.
1.313 - * @see java.lang.Object#notifyAll()
1.314 - * @see java.lang.Object#wait()
1.315 - */
1.316 - public final native void notify();
1.317 -
1.318 - /**
1.319 - * Wakes up all threads that are waiting on this object's monitor. A
1.320 - * thread waits on an object's monitor by calling one of the
1.321 - * {@code wait} methods.
1.322 - * <p>
1.323 - * The awakened threads will not be able to proceed until the current
1.324 - * thread relinquishes the lock on this object. The awakened threads
1.325 - * will compete in the usual manner with any other threads that might
1.326 - * be actively competing to synchronize on this object; for example,
1.327 - * the awakened threads enjoy no reliable privilege or disadvantage in
1.328 - * being the next thread to lock this object.
1.329 - * <p>
1.330 - * This method should only be called by a thread that is the owner
1.331 - * of this object's monitor. See the {@code notify} method for a
1.332 - * description of the ways in which a thread can become the owner of
1.333 - * a monitor.
1.334 - *
1.335 - * @exception IllegalMonitorStateException if the current thread is not
1.336 - * the owner of this object's monitor.
1.337 - * @see java.lang.Object#notify()
1.338 - * @see java.lang.Object#wait()
1.339 - */
1.340 - public final native void notifyAll();
1.341 -
1.342 - /**
1.343 - * Causes the current thread to wait until either another thread invokes the
1.344 - * {@link java.lang.Object#notify()} method or the
1.345 - * {@link java.lang.Object#notifyAll()} method for this object, or a
1.346 - * specified amount of time has elapsed.
1.347 - * <p>
1.348 - * The current thread must own this object's monitor.
1.349 - * <p>
1.350 - * This method causes the current thread (call it <var>T</var>) to
1.351 - * place itself in the wait set for this object and then to relinquish
1.352 - * any and all synchronization claims on this object. Thread <var>T</var>
1.353 - * becomes disabled for thread scheduling purposes and lies dormant
1.354 - * until one of four things happens:
1.355 - * <ul>
1.356 - * <li>Some other thread invokes the {@code notify} method for this
1.357 - * object and thread <var>T</var> happens to be arbitrarily chosen as
1.358 - * the thread to be awakened.
1.359 - * <li>Some other thread invokes the {@code notifyAll} method for this
1.360 - * object.
1.361 - * <li>Some other thread {@linkplain Thread#interrupt() interrupts}
1.362 - * thread <var>T</var>.
1.363 - * <li>The specified amount of real time has elapsed, more or less. If
1.364 - * {@code timeout} is zero, however, then real time is not taken into
1.365 - * consideration and the thread simply waits until notified.
1.366 - * </ul>
1.367 - * The thread <var>T</var> is then removed from the wait set for this
1.368 - * object and re-enabled for thread scheduling. It then competes in the
1.369 - * usual manner with other threads for the right to synchronize on the
1.370 - * object; once it has gained control of the object, all its
1.371 - * synchronization claims on the object are restored to the status quo
1.372 - * ante - that is, to the situation as of the time that the {@code wait}
1.373 - * method was invoked. Thread <var>T</var> then returns from the
1.374 - * invocation of the {@code wait} method. Thus, on return from the
1.375 - * {@code wait} method, the synchronization state of the object and of
1.376 - * thread {@code T} is exactly as it was when the {@code wait} method
1.377 - * was invoked.
1.378 - * <p>
1.379 - * A thread can also wake up without being notified, interrupted, or
1.380 - * timing out, a so-called <i>spurious wakeup</i>. While this will rarely
1.381 - * occur in practice, applications must guard against it by testing for
1.382 - * the condition that should have caused the thread to be awakened, and
1.383 - * continuing to wait if the condition is not satisfied. In other words,
1.384 - * waits should always occur in loops, like this one:
1.385 - * <pre>
1.386 - * synchronized (obj) {
1.387 - * while (<condition does not hold>)
1.388 - * obj.wait(timeout);
1.389 - * ... // Perform action appropriate to condition
1.390 - * }
1.391 - * </pre>
1.392 - * (For more information on this topic, see Section 3.2.3 in Doug Lea's
1.393 - * "Concurrent Programming in Java (Second Edition)" (Addison-Wesley,
1.394 - * 2000), or Item 50 in Joshua Bloch's "Effective Java Programming
1.395 - * Language Guide" (Addison-Wesley, 2001).
1.396 - *
1.397 - * <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
1.398 - * interrupted} by any thread before or while it is waiting, then an
1.399 - * {@code InterruptedException} is thrown. This exception is not
1.400 - * thrown until the lock status of this object has been restored as
1.401 - * described above.
1.402 - *
1.403 - * <p>
1.404 - * Note that the {@code wait} method, as it places the current thread
1.405 - * into the wait set for this object, unlocks only this object; any
1.406 - * other objects on which the current thread may be synchronized remain
1.407 - * locked while the thread waits.
1.408 - * <p>
1.409 - * This method should only be called by a thread that is the owner
1.410 - * of this object's monitor. See the {@code notify} method for a
1.411 - * description of the ways in which a thread can become the owner of
1.412 - * a monitor.
1.413 - *
1.414 - * @param timeout the maximum time to wait in milliseconds.
1.415 - * @exception IllegalArgumentException if the value of timeout is
1.416 - * negative.
1.417 - * @exception IllegalMonitorStateException if the current thread is not
1.418 - * the owner of the object's monitor.
1.419 - * @exception InterruptedException if any thread interrupted the
1.420 - * current thread before or while the current thread
1.421 - * was waiting for a notification. The <i>interrupted
1.422 - * status</i> of the current thread is cleared when
1.423 - * this exception is thrown.
1.424 - * @see java.lang.Object#notify()
1.425 - * @see java.lang.Object#notifyAll()
1.426 - */
1.427 - public final native void wait(long timeout) throws InterruptedException;
1.428 -
1.429 - /**
1.430 - * Causes the current thread to wait until another thread invokes the
1.431 - * {@link java.lang.Object#notify()} method or the
1.432 - * {@link java.lang.Object#notifyAll()} method for this object, or
1.433 - * some other thread interrupts the current thread, or a certain
1.434 - * amount of real time has elapsed.
1.435 - * <p>
1.436 - * This method is similar to the {@code wait} method of one
1.437 - * argument, but it allows finer control over the amount of time to
1.438 - * wait for a notification before giving up. The amount of real time,
1.439 - * measured in nanoseconds, is given by:
1.440 - * <blockquote>
1.441 - * <pre>
1.442 - * 1000000*timeout+nanos</pre></blockquote>
1.443 - * <p>
1.444 - * In all other respects, this method does the same thing as the
1.445 - * method {@link #wait(long)} of one argument. In particular,
1.446 - * {@code wait(0, 0)} means the same thing as {@code wait(0)}.
1.447 - * <p>
1.448 - * The current thread must own this object's monitor. The thread
1.449 - * releases ownership of this monitor and waits until either of the
1.450 - * following two conditions has occurred:
1.451 - * <ul>
1.452 - * <li>Another thread notifies threads waiting on this object's monitor
1.453 - * to wake up either through a call to the {@code notify} method
1.454 - * or the {@code notifyAll} method.
1.455 - * <li>The timeout period, specified by {@code timeout}
1.456 - * milliseconds plus {@code nanos} nanoseconds arguments, has
1.457 - * elapsed.
1.458 - * </ul>
1.459 - * <p>
1.460 - * The thread then waits until it can re-obtain ownership of the
1.461 - * monitor and resumes execution.
1.462 - * <p>
1.463 - * As in the one argument version, interrupts and spurious wakeups are
1.464 - * possible, and this method should always be used in a loop:
1.465 - * <pre>
1.466 - * synchronized (obj) {
1.467 - * while (<condition does not hold>)
1.468 - * obj.wait(timeout, nanos);
1.469 - * ... // Perform action appropriate to condition
1.470 - * }
1.471 - * </pre>
1.472 - * This method should only be called by a thread that is the owner
1.473 - * of this object's monitor. See the {@code notify} method for a
1.474 - * description of the ways in which a thread can become the owner of
1.475 - * a monitor.
1.476 - *
1.477 - * @param timeout the maximum time to wait in milliseconds.
1.478 - * @param nanos additional time, in nanoseconds range
1.479 - * 0-999999.
1.480 - * @exception IllegalArgumentException if the value of timeout is
1.481 - * negative or the value of nanos is
1.482 - * not in the range 0-999999.
1.483 - * @exception IllegalMonitorStateException if the current thread is not
1.484 - * the owner of this object's monitor.
1.485 - * @exception InterruptedException if any thread interrupted the
1.486 - * current thread before or while the current thread
1.487 - * was waiting for a notification. The <i>interrupted
1.488 - * status</i> of the current thread is cleared when
1.489 - * this exception is thrown.
1.490 - */
1.491 - public final void wait(long timeout, int nanos) throws InterruptedException {
1.492 - if (timeout < 0) {
1.493 - throw new IllegalArgumentException("timeout value is negative");
1.494 - }
1.495 -
1.496 - if (nanos < 0 || nanos > 999999) {
1.497 - throw new IllegalArgumentException(
1.498 - "nanosecond timeout value out of range");
1.499 - }
1.500 -
1.501 - if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
1.502 - timeout++;
1.503 - }
1.504 -
1.505 - wait(timeout);
1.506 - }
1.507 -
1.508 - /**
1.509 - * Causes the current thread to wait until another thread invokes the
1.510 - * {@link java.lang.Object#notify()} method or the
1.511 - * {@link java.lang.Object#notifyAll()} method for this object.
1.512 - * In other words, this method behaves exactly as if it simply
1.513 - * performs the call {@code wait(0)}.
1.514 - * <p>
1.515 - * The current thread must own this object's monitor. The thread
1.516 - * releases ownership of this monitor and waits until another thread
1.517 - * notifies threads waiting on this object's monitor to wake up
1.518 - * either through a call to the {@code notify} method or the
1.519 - * {@code notifyAll} method. The thread then waits until it can
1.520 - * re-obtain ownership of the monitor and resumes execution.
1.521 - * <p>
1.522 - * As in the one argument version, interrupts and spurious wakeups are
1.523 - * possible, and this method should always be used in a loop:
1.524 - * <pre>
1.525 - * synchronized (obj) {
1.526 - * while (<condition does not hold>)
1.527 - * obj.wait();
1.528 - * ... // Perform action appropriate to condition
1.529 - * }
1.530 - * </pre>
1.531 - * This method should only be called by a thread that is the owner
1.532 - * of this object's monitor. See the {@code notify} method for a
1.533 - * description of the ways in which a thread can become the owner of
1.534 - * a monitor.
1.535 - *
1.536 - * @exception IllegalMonitorStateException if the current thread is not
1.537 - * the owner of the object's monitor.
1.538 - * @exception InterruptedException if any thread interrupted the
1.539 - * current thread before or while the current thread
1.540 - * was waiting for a notification. The <i>interrupted
1.541 - * status</i> of the current thread is cleared when
1.542 - * this exception is thrown.
1.543 - * @see java.lang.Object#notify()
1.544 - * @see java.lang.Object#notifyAll()
1.545 - */
1.546 - public final void wait() throws InterruptedException {
1.547 - wait(0);
1.548 - }
1.549 -
1.550 - /**
1.551 - * Called by the garbage collector on an object when garbage collection
1.552 - * determines that there are no more references to the object.
1.553 - * A subclass overrides the {@code finalize} method to dispose of
1.554 - * system resources or to perform other cleanup.
1.555 - * <p>
1.556 - * The general contract of {@code finalize} is that it is invoked
1.557 - * if and when the Java<font size="-2"><sup>TM</sup></font> virtual
1.558 - * machine has determined that there is no longer any
1.559 - * means by which this object can be accessed by any thread that has
1.560 - * not yet died, except as a result of an action taken by the
1.561 - * finalization of some other object or class which is ready to be
1.562 - * finalized. The {@code finalize} method may take any action, including
1.563 - * making this object available again to other threads; the usual purpose
1.564 - * of {@code finalize}, however, is to perform cleanup actions before
1.565 - * the object is irrevocably discarded. For example, the finalize method
1.566 - * for an object that represents an input/output connection might perform
1.567 - * explicit I/O transactions to break the connection before the object is
1.568 - * permanently discarded.
1.569 - * <p>
1.570 - * The {@code finalize} method of class {@code Object} performs no
1.571 - * special action; it simply returns normally. Subclasses of
1.572 - * {@code Object} may override this definition.
1.573 - * <p>
1.574 - * The Java programming language does not guarantee which thread will
1.575 - * invoke the {@code finalize} method for any given object. It is
1.576 - * guaranteed, however, that the thread that invokes finalize will not
1.577 - * be holding any user-visible synchronization locks when finalize is
1.578 - * invoked. If an uncaught exception is thrown by the finalize method,
1.579 - * the exception is ignored and finalization of that object terminates.
1.580 - * <p>
1.581 - * After the {@code finalize} method has been invoked for an object, no
1.582 - * further action is taken until the Java virtual machine has again
1.583 - * determined that there is no longer any means by which this object can
1.584 - * be accessed by any thread that has not yet died, including possible
1.585 - * actions by other objects or classes which are ready to be finalized,
1.586 - * at which point the object may be discarded.
1.587 - * <p>
1.588 - * The {@code finalize} method is never invoked more than once by a Java
1.589 - * virtual machine for any given object.
1.590 - * <p>
1.591 - * Any exception thrown by the {@code finalize} method causes
1.592 - * the finalization of this object to be halted, but is otherwise
1.593 - * ignored.
1.594 - *
1.595 - * @throws Throwable the {@code Exception} raised by this method
1.596 - */
1.597 - protected void finalize() throws Throwable { }
1.598 -}