hotspot/test/compiler/dependencies/MonomorphicObjectCall/java/lang/Object.java
changeset 37380 55c2549714af
parent 37379 e9c85d2b1fcc
parent 37377 bd3b98a11a14
child 37385 76f08075c3ee
equal deleted inserted replaced
37379:e9c85d2b1fcc 37380:55c2549714af
     1 /*
       
     2  * Copyright (c) 1994, 2014, 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 jdk.internal.HotSpotIntrinsicCandidate;
       
    29 
       
    30 /**
       
    31  * Slightly modified version of java.lang.Object that replaces
       
    32  * finalize() by finalizeObject() to avoid overriding in subclasses.
       
    33  */
       
    34 public class Object {
       
    35 
       
    36     @HotSpotIntrinsicCandidate
       
    37     public Object() {}
       
    38 
       
    39     private static native void registerNatives();
       
    40     static {
       
    41         registerNatives();
       
    42     }
       
    43 
       
    44     @HotSpotIntrinsicCandidate
       
    45     public final native Class<?> getClass();
       
    46 
       
    47     @HotSpotIntrinsicCandidate
       
    48     public native int hashCode();
       
    49 
       
    50     public boolean equals(Object obj) {
       
    51         return (this == obj);
       
    52     }
       
    53 
       
    54     @HotSpotIntrinsicCandidate
       
    55     protected native Object clone() throws CloneNotSupportedException;
       
    56 
       
    57     public String toString() {
       
    58         return getClass().getName() + "@" + Integer.toHexString(hashCode());
       
    59     }
       
    60 
       
    61     @HotSpotIntrinsicCandidate
       
    62     public final native void notify();
       
    63 
       
    64     @HotSpotIntrinsicCandidate
       
    65     public final native void notifyAll();
       
    66 
       
    67     public final native void wait(long timeout) throws InterruptedException;
       
    68 
       
    69     public final void wait(long timeout, int nanos) throws InterruptedException {
       
    70         if (timeout < 0) {
       
    71             throw new IllegalArgumentException("timeout value is negative");
       
    72         }
       
    73 
       
    74         if (nanos < 0 || nanos > 999999) {
       
    75             throw new IllegalArgumentException(
       
    76                                 "nanosecond timeout value out of range");
       
    77         }
       
    78 
       
    79         if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
       
    80             timeout++;
       
    81         }
       
    82 
       
    83         wait(timeout);
       
    84     }
       
    85 
       
    86     public final void wait() throws InterruptedException {
       
    87         wait(0);
       
    88     }
       
    89 
       
    90     /**
       
    91      * Replaces original finalize() method and is therefore not
       
    92      * overridden by any subclasses of Object.
       
    93      * @throws Throwable
       
    94      */
       
    95     // protected void finalize() throws Throwable { }
       
    96     public void finalizeObject() throws Throwable { }
       
    97 }