emul/src/main/java/java/lang/Object.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 04 Dec 2012 11:21:10 +0100
branchreflection
changeset 249 001389026dbf
parent 233 5e8f219d60ba
parent 239 8ceee38f5840
child 335 b8fd5ab83a20
permissions -rw-r--r--
Merging in JNI-like naming scheme from default branch
     1 /*
     2  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    25 
    26 package java.lang;
    27 
    28 import org.apidesign.bck2brwsr.core.JavaScriptBody;
    29 import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
    30 
    31 /**
    32  * Class {@code Object} is the root of the class hierarchy.
    33  * Every class has {@code Object} as a superclass. All objects,
    34  * including arrays, implement the methods of this class.
    35  *
    36  * @author  unascribed
    37  * @see     java.lang.Class
    38  * @since   JDK1.0
    39  */
    40 @JavaScriptPrototype(container = "Object.prototype", prototype = "new Object")
    41 public class Object {
    42 
    43     @JavaScriptBody(args = {}, body = "")
    44     private static native void registerNatives();
    45     static {
    46         registerNatives();
    47     }
    48 
    49     /**
    50      * Returns the runtime class of this {@code Object}. The returned
    51      * {@code Class} object is the object that is locked by {@code
    52      * static synchronized} methods of the represented class.
    53      *
    54      * <p><b>The actual result type is {@code Class<? extends |X|>}
    55      * where {@code |X|} is the erasure of the static type of the
    56      * expression on which {@code getClass} is called.</b> For
    57      * example, no cast is required in this code fragment:</p>
    58      *
    59      * <p>
    60      * {@code Number n = 0;                             }<br>
    61      * {@code Class<? extends Number> c = n.getClass(); }
    62      * </p>
    63      *
    64      * @return The {@code Class} object that represents the runtime
    65      *         class of this object.
    66      * @see    Class Literals, section 15.8.2 of
    67      *         <cite>The Java&trade; Language Specification</cite>.
    68      */
    69     @JavaScriptBody(args="self", body="return self.constructor.$class;")
    70     public final native Class<?> getClass();
    71 
    72     /**
    73      * Returns a hash code value for the object. This method is
    74      * supported for the benefit of hash tables such as those provided by
    75      * {@link java.util.HashMap}.
    76      * <p>
    77      * The general contract of {@code hashCode} is:
    78      * <ul>
    79      * <li>Whenever it is invoked on the same object more than once during
    80      *     an execution of a Java application, the {@code hashCode} method
    81      *     must consistently return the same integer, provided no information
    82      *     used in {@code equals} comparisons on the object is modified.
    83      *     This integer need not remain consistent from one execution of an
    84      *     application to another execution of the same application.
    85      * <li>If two objects are equal according to the {@code equals(Object)}
    86      *     method, then calling the {@code hashCode} method on each of
    87      *     the two objects must produce the same integer result.
    88      * <li>It is <em>not</em> required that if two objects are unequal
    89      *     according to the {@link java.lang.Object#equals(java.lang.Object)}
    90      *     method, then calling the {@code hashCode} method on each of the
    91      *     two objects must produce distinct integer results.  However, the
    92      *     programmer should be aware that producing distinct integer results
    93      *     for unequal objects may improve the performance of hash tables.
    94      * </ul>
    95      * <p>
    96      * As much as is reasonably practical, the hashCode method defined by
    97      * class {@code Object} does return distinct integers for distinct
    98      * objects. (This is typically implemented by converting the internal
    99      * address of the object into an integer, but this implementation
   100      * technique is not required by the
   101      * Java<font size="-2"><sup>TM</sup></font> programming language.)
   102      *
   103      * @return  a hash code value for this object.
   104      * @see     java.lang.Object#equals(java.lang.Object)
   105      * @see     java.lang.System#identityHashCode
   106      */
   107     public native int hashCode();
   108 
   109     /**
   110      * Indicates whether some other object is "equal to" this one.
   111      * <p>
   112      * The {@code equals} method implements an equivalence relation
   113      * on non-null object references:
   114      * <ul>
   115      * <li>It is <i>reflexive</i>: for any non-null reference value
   116      *     {@code x}, {@code x.equals(x)} should return
   117      *     {@code true}.
   118      * <li>It is <i>symmetric</i>: for any non-null reference values
   119      *     {@code x} and {@code y}, {@code x.equals(y)}
   120      *     should return {@code true} if and only if
   121      *     {@code y.equals(x)} returns {@code true}.
   122      * <li>It is <i>transitive</i>: for any non-null reference values
   123      *     {@code x}, {@code y}, and {@code z}, if
   124      *     {@code x.equals(y)} returns {@code true} and
   125      *     {@code y.equals(z)} returns {@code true}, then
   126      *     {@code x.equals(z)} should return {@code true}.
   127      * <li>It is <i>consistent</i>: for any non-null reference values
   128      *     {@code x} and {@code y}, multiple invocations of
   129      *     {@code x.equals(y)} consistently return {@code true}
   130      *     or consistently return {@code false}, provided no
   131      *     information used in {@code equals} comparisons on the
   132      *     objects is modified.
   133      * <li>For any non-null reference value {@code x},
   134      *     {@code x.equals(null)} should return {@code false}.
   135      * </ul>
   136      * <p>
   137      * The {@code equals} method for class {@code Object} implements
   138      * the most discriminating possible equivalence relation on objects;
   139      * that is, for any non-null reference values {@code x} and
   140      * {@code y}, this method returns {@code true} if and only
   141      * if {@code x} and {@code y} refer to the same object
   142      * ({@code x == y} has the value {@code true}).
   143      * <p>
   144      * Note that it is generally necessary to override the {@code hashCode}
   145      * method whenever this method is overridden, so as to maintain the
   146      * general contract for the {@code hashCode} method, which states
   147      * that equal objects must have equal hash codes.
   148      *
   149      * @param   obj   the reference object with which to compare.
   150      * @return  {@code true} if this object is the same as the obj
   151      *          argument; {@code false} otherwise.
   152      * @see     #hashCode()
   153      * @see     java.util.HashMap
   154      */
   155     public boolean equals(Object obj) {
   156         return (this == obj);
   157     }
   158 
   159     /**
   160      * Creates and returns a copy of this object.  The precise meaning
   161      * of "copy" may depend on the class of the object. The general
   162      * intent is that, for any object {@code x}, the expression:
   163      * <blockquote>
   164      * <pre>
   165      * x.clone() != x</pre></blockquote>
   166      * will be true, and that the expression:
   167      * <blockquote>
   168      * <pre>
   169      * x.clone().getClass() == x.getClass()</pre></blockquote>
   170      * will be {@code true}, but these are not absolute requirements.
   171      * While it is typically the case that:
   172      * <blockquote>
   173      * <pre>
   174      * x.clone().equals(x)</pre></blockquote>
   175      * will be {@code true}, this is not an absolute requirement.
   176      * <p>
   177      * By convention, the returned object should be obtained by calling
   178      * {@code super.clone}.  If a class and all of its superclasses (except
   179      * {@code Object}) obey this convention, it will be the case that
   180      * {@code x.clone().getClass() == x.getClass()}.
   181      * <p>
   182      * By convention, the object returned by this method should be independent
   183      * of this object (which is being cloned).  To achieve this independence,
   184      * it may be necessary to modify one or more fields of the object returned
   185      * by {@code super.clone} before returning it.  Typically, this means
   186      * copying any mutable objects that comprise the internal "deep structure"
   187      * of the object being cloned and replacing the references to these
   188      * objects with references to the copies.  If a class contains only
   189      * primitive fields or references to immutable objects, then it is usually
   190      * the case that no fields in the object returned by {@code super.clone}
   191      * need to be modified.
   192      * <p>
   193      * The method {@code clone} for class {@code Object} performs a
   194      * specific cloning operation. First, if the class of this object does
   195      * not implement the interface {@code Cloneable}, then a
   196      * {@code CloneNotSupportedException} is thrown. Note that all arrays
   197      * are considered to implement the interface {@code Cloneable} and that
   198      * the return type of the {@code clone} method of an array type {@code T[]}
   199      * is {@code T[]} where T is any reference or primitive type.
   200      * Otherwise, this method creates a new instance of the class of this
   201      * object and initializes all its fields with exactly the contents of
   202      * the corresponding fields of this object, as if by assignment; the
   203      * contents of the fields are not themselves cloned. Thus, this method
   204      * performs a "shallow copy" of this object, not a "deep copy" operation.
   205      * <p>
   206      * The class {@code Object} does not itself implement the interface
   207      * {@code Cloneable}, so calling the {@code clone} method on an object
   208      * whose class is {@code Object} will result in throwing an
   209      * exception at run time.
   210      *
   211      * @return     a clone of this instance.
   212      * @exception  CloneNotSupportedException  if the object's class does not
   213      *               support the {@code Cloneable} interface. Subclasses
   214      *               that override the {@code clone} method can also
   215      *               throw this exception to indicate that an instance cannot
   216      *               be cloned.
   217      * @see java.lang.Cloneable
   218      */
   219     protected native Object clone() throws CloneNotSupportedException;
   220 
   221     /**
   222      * Returns a string representation of the object. In general, the
   223      * {@code toString} method returns a string that
   224      * "textually represents" this object. The result should
   225      * be a concise but informative representation that is easy for a
   226      * person to read.
   227      * It is recommended that all subclasses override this method.
   228      * <p>
   229      * The {@code toString} method for class {@code Object}
   230      * returns a string consisting of the name of the class of which the
   231      * object is an instance, the at-sign character `{@code @}', and
   232      * the unsigned hexadecimal representation of the hash code of the
   233      * object. In other words, this method returns a string equal to the
   234      * value of:
   235      * <blockquote>
   236      * <pre>
   237      * getClass().getName() + '@' + Integer.toHexString(hashCode())
   238      * </pre></blockquote>
   239      *
   240      * @return  a string representation of the object.
   241      */
   242     public String toString() {
   243         return getClass().getName() + "@" + Integer.toHexString(hashCode());
   244     }
   245 
   246     /**
   247      * Wakes up a single thread that is waiting on this object's
   248      * monitor. If any threads are waiting on this object, one of them
   249      * is chosen to be awakened. The choice is arbitrary and occurs at
   250      * the discretion of the implementation. A thread waits on an object's
   251      * monitor by calling one of the {@code wait} methods.
   252      * <p>
   253      * The awakened thread will not be able to proceed until the current
   254      * thread relinquishes the lock on this object. The awakened thread will
   255      * compete in the usual manner with any other threads that might be
   256      * actively competing to synchronize on this object; for example, the
   257      * awakened thread enjoys no reliable privilege or disadvantage in being
   258      * the next thread to lock this object.
   259      * <p>
   260      * This method should only be called by a thread that is the owner
   261      * of this object's monitor. A thread becomes the owner of the
   262      * object's monitor in one of three ways:
   263      * <ul>
   264      * <li>By executing a synchronized instance method of that object.
   265      * <li>By executing the body of a {@code synchronized} statement
   266      *     that synchronizes on the object.
   267      * <li>For objects of type {@code Class,} by executing a
   268      *     synchronized static method of that class.
   269      * </ul>
   270      * <p>
   271      * Only one thread at a time can own an object's monitor.
   272      *
   273      * @exception  IllegalMonitorStateException  if the current thread is not
   274      *               the owner of this object's monitor.
   275      * @see        java.lang.Object#notifyAll()
   276      * @see        java.lang.Object#wait()
   277      */
   278     public final native void notify();
   279 
   280     /**
   281      * Wakes up all threads that are waiting on this object's monitor. A
   282      * thread waits on an object's monitor by calling one of the
   283      * {@code wait} methods.
   284      * <p>
   285      * The awakened threads will not be able to proceed until the current
   286      * thread relinquishes the lock on this object. The awakened threads
   287      * will compete in the usual manner with any other threads that might
   288      * be actively competing to synchronize on this object; for example,
   289      * the awakened threads enjoy no reliable privilege or disadvantage in
   290      * being the next thread to lock this object.
   291      * <p>
   292      * This method should only be called by a thread that is the owner
   293      * of this object's monitor. See the {@code notify} method for a
   294      * description of the ways in which a thread can become the owner of
   295      * a monitor.
   296      *
   297      * @exception  IllegalMonitorStateException  if the current thread is not
   298      *               the owner of this object's monitor.
   299      * @see        java.lang.Object#notify()
   300      * @see        java.lang.Object#wait()
   301      */
   302     public final native void notifyAll();
   303 
   304     /**
   305      * Causes the current thread to wait until either another thread invokes the
   306      * {@link java.lang.Object#notify()} method or the
   307      * {@link java.lang.Object#notifyAll()} method for this object, or a
   308      * specified amount of time has elapsed.
   309      * <p>
   310      * The current thread must own this object's monitor.
   311      * <p>
   312      * This method causes the current thread (call it <var>T</var>) to
   313      * place itself in the wait set for this object and then to relinquish
   314      * any and all synchronization claims on this object. Thread <var>T</var>
   315      * becomes disabled for thread scheduling purposes and lies dormant
   316      * until one of four things happens:
   317      * <ul>
   318      * <li>Some other thread invokes the {@code notify} method for this
   319      * object and thread <var>T</var> happens to be arbitrarily chosen as
   320      * the thread to be awakened.
   321      * <li>Some other thread invokes the {@code notifyAll} method for this
   322      * object.
   323      * <li>Some other thread {@linkplain Thread#interrupt() interrupts}
   324      * thread <var>T</var>.
   325      * <li>The specified amount of real time has elapsed, more or less.  If
   326      * {@code timeout} is zero, however, then real time is not taken into
   327      * consideration and the thread simply waits until notified.
   328      * </ul>
   329      * The thread <var>T</var> is then removed from the wait set for this
   330      * object and re-enabled for thread scheduling. It then competes in the
   331      * usual manner with other threads for the right to synchronize on the
   332      * object; once it has gained control of the object, all its
   333      * synchronization claims on the object are restored to the status quo
   334      * ante - that is, to the situation as of the time that the {@code wait}
   335      * method was invoked. Thread <var>T</var> then returns from the
   336      * invocation of the {@code wait} method. Thus, on return from the
   337      * {@code wait} method, the synchronization state of the object and of
   338      * thread {@code T} is exactly as it was when the {@code wait} method
   339      * was invoked.
   340      * <p>
   341      * A thread can also wake up without being notified, interrupted, or
   342      * timing out, a so-called <i>spurious wakeup</i>.  While this will rarely
   343      * occur in practice, applications must guard against it by testing for
   344      * the condition that should have caused the thread to be awakened, and
   345      * continuing to wait if the condition is not satisfied.  In other words,
   346      * waits should always occur in loops, like this one:
   347      * <pre>
   348      *     synchronized (obj) {
   349      *         while (&lt;condition does not hold&gt;)
   350      *             obj.wait(timeout);
   351      *         ... // Perform action appropriate to condition
   352      *     }
   353      * </pre>
   354      * (For more information on this topic, see Section 3.2.3 in Doug Lea's
   355      * "Concurrent Programming in Java (Second Edition)" (Addison-Wesley,
   356      * 2000), or Item 50 in Joshua Bloch's "Effective Java Programming
   357      * Language Guide" (Addison-Wesley, 2001).
   358      *
   359      * <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
   360      * interrupted} by any thread before or while it is waiting, then an
   361      * {@code InterruptedException} is thrown.  This exception is not
   362      * thrown until the lock status of this object has been restored as
   363      * described above.
   364      *
   365      * <p>
   366      * Note that the {@code wait} method, as it places the current thread
   367      * into the wait set for this object, unlocks only this object; any
   368      * other objects on which the current thread may be synchronized remain
   369      * locked while the thread waits.
   370      * <p>
   371      * This method should only be called by a thread that is the owner
   372      * of this object's monitor. See the {@code notify} method for a
   373      * description of the ways in which a thread can become the owner of
   374      * a monitor.
   375      *
   376      * @param      timeout   the maximum time to wait in milliseconds.
   377      * @exception  IllegalArgumentException      if the value of timeout is
   378      *               negative.
   379      * @exception  IllegalMonitorStateException  if the current thread is not
   380      *               the owner of the object's monitor.
   381      * @exception  InterruptedException if any thread interrupted the
   382      *             current thread before or while the current thread
   383      *             was waiting for a notification.  The <i>interrupted
   384      *             status</i> of the current thread is cleared when
   385      *             this exception is thrown.
   386      * @see        java.lang.Object#notify()
   387      * @see        java.lang.Object#notifyAll()
   388      */
   389     public final native void wait(long timeout) throws InterruptedException;
   390 
   391     /**
   392      * Causes the current thread to wait until another thread invokes the
   393      * {@link java.lang.Object#notify()} method or the
   394      * {@link java.lang.Object#notifyAll()} method for this object, or
   395      * some other thread interrupts the current thread, or a certain
   396      * amount of real time has elapsed.
   397      * <p>
   398      * This method is similar to the {@code wait} method of one
   399      * argument, but it allows finer control over the amount of time to
   400      * wait for a notification before giving up. The amount of real time,
   401      * measured in nanoseconds, is given by:
   402      * <blockquote>
   403      * <pre>
   404      * 1000000*timeout+nanos</pre></blockquote>
   405      * <p>
   406      * In all other respects, this method does the same thing as the
   407      * method {@link #wait(long)} of one argument. In particular,
   408      * {@code wait(0, 0)} means the same thing as {@code wait(0)}.
   409      * <p>
   410      * The current thread must own this object's monitor. The thread
   411      * releases ownership of this monitor and waits until either of the
   412      * following two conditions has occurred:
   413      * <ul>
   414      * <li>Another thread notifies threads waiting on this object's monitor
   415      *     to wake up either through a call to the {@code notify} method
   416      *     or the {@code notifyAll} method.
   417      * <li>The timeout period, specified by {@code timeout}
   418      *     milliseconds plus {@code nanos} nanoseconds arguments, has
   419      *     elapsed.
   420      * </ul>
   421      * <p>
   422      * The thread then waits until it can re-obtain ownership of the
   423      * monitor and resumes execution.
   424      * <p>
   425      * As in the one argument version, interrupts and spurious wakeups are
   426      * possible, and this method should always be used in a loop:
   427      * <pre>
   428      *     synchronized (obj) {
   429      *         while (&lt;condition does not hold&gt;)
   430      *             obj.wait(timeout, nanos);
   431      *         ... // Perform action appropriate to condition
   432      *     }
   433      * </pre>
   434      * This method should only be called by a thread that is the owner
   435      * of this object's monitor. See the {@code notify} method for a
   436      * description of the ways in which a thread can become the owner of
   437      * a monitor.
   438      *
   439      * @param      timeout   the maximum time to wait in milliseconds.
   440      * @param      nanos      additional time, in nanoseconds range
   441      *                       0-999999.
   442      * @exception  IllegalArgumentException      if the value of timeout is
   443      *                      negative or the value of nanos is
   444      *                      not in the range 0-999999.
   445      * @exception  IllegalMonitorStateException  if the current thread is not
   446      *               the owner of this object's monitor.
   447      * @exception  InterruptedException if any thread interrupted the
   448      *             current thread before or while the current thread
   449      *             was waiting for a notification.  The <i>interrupted
   450      *             status</i> of the current thread is cleared when
   451      *             this exception is thrown.
   452      */
   453     public final void wait(long timeout, int nanos) throws InterruptedException {
   454         if (timeout < 0) {
   455             throw new IllegalArgumentException("timeout value is negative");
   456         }
   457 
   458         if (nanos < 0 || nanos > 999999) {
   459             throw new IllegalArgumentException(
   460                                 "nanosecond timeout value out of range");
   461         }
   462 
   463         if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
   464             timeout++;
   465         }
   466 
   467         wait(timeout);
   468     }
   469 
   470     /**
   471      * Causes the current thread to wait until another thread invokes the
   472      * {@link java.lang.Object#notify()} method or the
   473      * {@link java.lang.Object#notifyAll()} method for this object.
   474      * In other words, this method behaves exactly as if it simply
   475      * performs the call {@code wait(0)}.
   476      * <p>
   477      * The current thread must own this object's monitor. The thread
   478      * releases ownership of this monitor and waits until another thread
   479      * notifies threads waiting on this object's monitor to wake up
   480      * either through a call to the {@code notify} method or the
   481      * {@code notifyAll} method. The thread then waits until it can
   482      * re-obtain ownership of the monitor and resumes execution.
   483      * <p>
   484      * As in the one argument version, interrupts and spurious wakeups are
   485      * possible, and this method should always be used in a loop:
   486      * <pre>
   487      *     synchronized (obj) {
   488      *         while (&lt;condition does not hold&gt;)
   489      *             obj.wait();
   490      *         ... // Perform action appropriate to condition
   491      *     }
   492      * </pre>
   493      * This method should only be called by a thread that is the owner
   494      * of this object's monitor. See the {@code notify} method for a
   495      * description of the ways in which a thread can become the owner of
   496      * a monitor.
   497      *
   498      * @exception  IllegalMonitorStateException  if the current thread is not
   499      *               the owner of the object's monitor.
   500      * @exception  InterruptedException if any thread interrupted the
   501      *             current thread before or while the current thread
   502      *             was waiting for a notification.  The <i>interrupted
   503      *             status</i> of the current thread is cleared when
   504      *             this exception is thrown.
   505      * @see        java.lang.Object#notify()
   506      * @see        java.lang.Object#notifyAll()
   507      */
   508     public final void wait() throws InterruptedException {
   509         wait(0);
   510     }
   511 
   512     /**
   513      * Called by the garbage collector on an object when garbage collection
   514      * determines that there are no more references to the object.
   515      * A subclass overrides the {@code finalize} method to dispose of
   516      * system resources or to perform other cleanup.
   517      * <p>
   518      * The general contract of {@code finalize} is that it is invoked
   519      * if and when the Java<font size="-2"><sup>TM</sup></font> virtual
   520      * machine has determined that there is no longer any
   521      * means by which this object can be accessed by any thread that has
   522      * not yet died, except as a result of an action taken by the
   523      * finalization of some other object or class which is ready to be
   524      * finalized. The {@code finalize} method may take any action, including
   525      * making this object available again to other threads; the usual purpose
   526      * of {@code finalize}, however, is to perform cleanup actions before
   527      * the object is irrevocably discarded. For example, the finalize method
   528      * for an object that represents an input/output connection might perform
   529      * explicit I/O transactions to break the connection before the object is
   530      * permanently discarded.
   531      * <p>
   532      * The {@code finalize} method of class {@code Object} performs no
   533      * special action; it simply returns normally. Subclasses of
   534      * {@code Object} may override this definition.
   535      * <p>
   536      * The Java programming language does not guarantee which thread will
   537      * invoke the {@code finalize} method for any given object. It is
   538      * guaranteed, however, that the thread that invokes finalize will not
   539      * be holding any user-visible synchronization locks when finalize is
   540      * invoked. If an uncaught exception is thrown by the finalize method,
   541      * the exception is ignored and finalization of that object terminates.
   542      * <p>
   543      * After the {@code finalize} method has been invoked for an object, no
   544      * further action is taken until the Java virtual machine has again
   545      * determined that there is no longer any means by which this object can
   546      * be accessed by any thread that has not yet died, including possible
   547      * actions by other objects or classes which are ready to be finalized,
   548      * at which point the object may be discarded.
   549      * <p>
   550      * The {@code finalize} method is never invoked more than once by a Java
   551      * virtual machine for any given object.
   552      * <p>
   553      * Any exception thrown by the {@code finalize} method causes
   554      * the finalization of this object to be halted, but is otherwise
   555      * ignored.
   556      *
   557      * @throws Throwable the {@code Exception} raised by this method
   558      */
   559     protected void finalize() throws Throwable { }
   560 }