< prev index next >

jdk/src/java.base/share/classes/sun/misc/Unsafe.java

Print this page
rev 11228 : 8054494: Remove sun.misc.Unsafe.monitorEnter, monitorExit and tryMonitorEnter
Reviewed-by: dholmes
   1 /*
   2  * Copyright (c) 2000, 2013, 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


 828      * the a format that matches its tag:
 829      * <ul>
 830      * <li>Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
 831      * <li>Utf8: a string (must have suitable syntax if used as signature or name)
 832      * <li>Class: any java.lang.Class object
 833      * <li>String: any object (not just a java.lang.String)
 834      * <li>InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
 835      * </ul>
 836      * @params hostClass context for linkage, access control, protection domain, and class loader
 837      * @params data      bytes of a class file
 838      * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data
 839      */
 840     public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
 841 
 842 
 843     /** Allocate an instance but do not run any constructor.
 844         Initializes the class if it has not yet been. */
 845     public native Object allocateInstance(Class<?> cls)
 846         throws InstantiationException;
 847 
 848     /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
 849     public native void monitorEnter(Object o);
 850 
 851     /**
 852      * Unlock the object.  It must have been locked via {@link
 853      * #monitorEnter}.
 854      */
 855     public native void monitorExit(Object o);
 856 
 857     /**
 858      * Tries to lock the object.  Returns true or false to indicate
 859      * whether the lock succeeded.  If it did, the object must be
 860      * unlocked via {@link #monitorExit}.
 861      */
 862     public native boolean tryMonitorEnter(Object o);
 863 
 864     /** Throw the exception without telling the verifier. */
 865     public native void throwException(Throwable ee);
 866 
 867 
 868     /**
 869      * Atomically update Java variable to <tt>x</tt> if it is currently
 870      * holding <tt>expected</tt>.
 871      * @return <tt>true</tt> if successful
 872      */
 873     public final native boolean compareAndSwapObject(Object o, long offset,
 874                                                      Object expected,
 875                                                      Object x);
 876 
 877     /**
 878      * Atomically update Java variable to <tt>x</tt> if it is currently
 879      * holding <tt>expected</tt>.
 880      * @return <tt>true</tt> if successful
 881      */
 882     public final native boolean compareAndSwapInt(Object o, long offset,
 883                                                   int expected,


   1 /*
   2  * Copyright (c) 2000, 2015, 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


 828      * the a format that matches its tag:
 829      * <ul>
 830      * <li>Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
 831      * <li>Utf8: a string (must have suitable syntax if used as signature or name)
 832      * <li>Class: any java.lang.Class object
 833      * <li>String: any object (not just a java.lang.String)
 834      * <li>InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
 835      * </ul>
 836      * @params hostClass context for linkage, access control, protection domain, and class loader
 837      * @params data      bytes of a class file
 838      * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data
 839      */
 840     public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
 841 
 842 
 843     /** Allocate an instance but do not run any constructor.
 844         Initializes the class if it has not yet been. */
 845     public native Object allocateInstance(Class<?> cls)
 846         throws InstantiationException;
 847 
















 848     /** Throw the exception without telling the verifier. */
 849     public native void throwException(Throwable ee);
 850 
 851 
 852     /**
 853      * Atomically update Java variable to <tt>x</tt> if it is currently
 854      * holding <tt>expected</tt>.
 855      * @return <tt>true</tt> if successful
 856      */
 857     public final native boolean compareAndSwapObject(Object o, long offset,
 858                                                      Object expected,
 859                                                      Object x);
 860 
 861     /**
 862      * Atomically update Java variable to <tt>x</tt> if it is currently
 863      * holding <tt>expected</tt>.
 864      * @return <tt>true</tt> if successful
 865      */
 866     public final native boolean compareAndSwapInt(Object o, long offset,
 867                                                   int expected,


< prev index next >