jdk/src/share/classes/sun/misc/Unsafe.java
author alanb
Fri, 22 Feb 2013 14:04:06 +0000
changeset 16023 58ecc1b8327b
parent 14853 72f0bc58bb95
child 16906 44dfee24cb71
permissions -rw-r--r--
8008290: (profiles) Startup regression due to additional checking of JAR file manifests Reviewed-by: lancea, chegar, iris, mchung, sherman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 13591
diff changeset
     2
 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2707
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2707
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2707
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2707
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2707
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.misc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.reflect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A collection of methods for performing low-level, unsafe operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Although the class and all methods are public, use of this class is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * limited because only trusted code can obtain instances of it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @author John R. Rose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @see #getUnsafe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public final class Unsafe {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static native void registerNatives();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        registerNatives();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private Unsafe() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static final Unsafe theUnsafe = new Unsafe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Provides the caller with the capability of performing unsafe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * <p> The returned <code>Unsafe</code> object should be carefully guarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * by the caller, since it can be used to read and write data at arbitrary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * memory addresses.  It must never be passed to untrusted code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * <p> Most methods in this class are very low-level, and correspond to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * small number of hardware instructions (on typical machines).  Compilers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * are encouraged to optimize these methods accordingly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * <p> Here is a suggested idiom for using unsafe operations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * class MyTrustedClass {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *   private static final Unsafe unsafe = Unsafe.getUnsafe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *   ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *   private long myCountAddress = ...;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *   public int getCount() { return unsafe.getByte(myCountAddress); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * (It may assist compilers to make the local variable be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * <code>final</code>.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *             <code>checkPropertiesAccess</code> method doesn't allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *             access to the system properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public static Unsafe getUnsafe() {
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
    84
        Class<?> cc = sun.reflect.Reflection.getCallerClass(2);
13589
da4cb574f4a6 7193339: Prepare system classes be defined by a non-null module loader
mchung
parents: 11117
diff changeset
    85
        if (!VM.isSystemDomainLoader(cc.getClassLoader()))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            throw new SecurityException("Unsafe");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        return theUnsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /// peek and poke operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /// (compilers should optimize these to memory ops)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // These work on object fields in the Java heap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    // They will not work on elements of packed arrays.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Fetches a value from a given Java variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * More specifically, fetches a field or array element within the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * object <code>o</code> at the given offset, or (if <code>o</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * null) from the memory address whose numerical value is the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * The results are undefined unless one of the following cases is true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <li>The offset was obtained from {@link #objectFieldOffset} on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * the {@link java.lang.reflect.Field} of some Java field and the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * referred to by <code>o</code> is of a class compatible with that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * field's class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <li>The offset and object reference <code>o</code> (either null or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * non-null) were both obtained via {@link #staticFieldOffset}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * and {@link #staticFieldBase} (respectively) from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * reflective {@link Field} representation of some Java field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * <li>The object referred to by <code>o</code> is an array, and the offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * is an integer of the form <code>B+N*S</code>, where <code>N</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * a valid index into the array, and <code>B</code> and <code>S</code> are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * the values obtained by {@link #arrayBaseOffset} and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * #arrayIndexScale} (respectively) from the array's class.  The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * referred to is the <code>N</code><em>th</em> element of the array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * If one of the above cases is true, the call references a specific Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * variable (field or array element).  However, the results are undefined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * if that variable is not in fact of the type returned by this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * This method refers to a variable by means of two parameters, and so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * it provides (in effect) a <em>double-register</em> addressing mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * for Java variables.  When the object reference is null, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * uses its offset as an absolute address.  This is similar in operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * to methods such as {@link #getInt(long)}, which provide (in effect) a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * <em>single-register</em> addressing mode for non-Java variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * However, because Java variables may have a different layout in memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * from non-Java variables, programmers should not assume that these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * two addressing modes are ever equivalent.  Also, programmers should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * remember that offsets from the double-register addressing mode cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * be portably confused with longs used in the single-register addressing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @param o Java heap object in which the variable resides, if any, else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *        null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param offset indication of where the variable resides in a Java heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *        object, if any, else a memory address locating the variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *        statically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @return the value fetched from the indicated Java variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @throws RuntimeException No defined exceptions are thrown, not even
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *         {@link NullPointerException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public native int getInt(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Stores a value into a given Java variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * The first two parameters are interpreted exactly as with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * {@link #getInt(Object, long)} to refer to a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Java variable (field or array element).  The given value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * is stored into that variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * The variable must be of the same type as the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * parameter <code>x</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param o Java heap object in which the variable resides, if any, else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *        null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param offset indication of where the variable resides in a Java heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *        object, if any, else a memory address locating the variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *        statically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param x the value to store into the indicated Java variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @throws RuntimeException No defined exceptions are thrown, not even
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *         {@link NullPointerException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public native void putInt(Object o, long offset, int x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Fetches a reference value from a given Java variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @see #getInt(Object, long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public native Object getObject(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Stores a reference value into a given Java variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Unless the reference <code>x</code> being stored is either null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * or matches the field type, the results are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * If the reference <code>o</code> is non-null, car marks or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * other store barriers for that object (if the VM requires them)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * are updated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @see #putInt(Object, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public native void putObject(Object o, long offset, Object x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public native boolean getBoolean(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public native void    putBoolean(Object o, long offset, boolean x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public native byte    getByte(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public native void    putByte(Object o, long offset, byte x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public native short   getShort(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public native void    putShort(Object o, long offset, short x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public native char    getChar(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public native void    putChar(Object o, long offset, char x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public native long    getLong(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public native void    putLong(Object o, long offset, long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public native float   getFloat(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public native void    putFloat(Object o, long offset, float x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /** @see #getInt(Object, long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public native double  getDouble(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /** @see #putInt(Object, int, int) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public native void    putDouble(Object o, long offset, double x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * This method, like all others with 32-bit offsets, was native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * in a previous release but is now a wrapper which simply casts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * the offset to a long value.  It provides backward compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * with bytecodes compiled against 1.4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public int getInt(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return getInt(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public void putInt(Object o, int offset, int x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        putInt(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public Object getObject(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return getObject(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public void putObject(Object o, int offset, Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        putObject(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public boolean getBoolean(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return getBoolean(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public void putBoolean(Object o, int offset, boolean x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        putBoolean(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public byte getByte(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        return getByte(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public void putByte(Object o, int offset, byte x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        putByte(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public short getShort(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        return getShort(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public void putShort(Object o, int offset, short x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        putShort(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public char getChar(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return getChar(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    public void putChar(Object o, int offset, char x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        putChar(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    public long getLong(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        return getLong(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public void putLong(Object o, int offset, long x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        putLong(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    public float getFloat(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        return getFloat(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public void putFloat(Object o, int offset, float x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        putFloat(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public double getDouble(Object o, int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        return getDouble(o, (long)offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * See {@link #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public void putDouble(Object o, int offset, double x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        putDouble(o, (long)offset, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    // These work on values in the C heap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * Fetches a value from a given memory address.  If the address is zero, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * does not point into a block obtained from {@link #allocateMemory}, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * results are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @see #allocateMemory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    public native byte    getByte(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Stores a value into a given memory address.  If the address is zero, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * does not point into a block obtained from {@link #allocateMemory}, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * results are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see #getByte(long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public native void    putByte(long address, byte x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    /** @see #getByte(long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    public native short   getShort(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /** @see #putByte(long, byte) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    public native void    putShort(long address, short x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /** @see #getByte(long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    public native char    getChar(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    /** @see #putByte(long, byte) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public native void    putChar(long address, char x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    /** @see #getByte(long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    public native int     getInt(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    /** @see #putByte(long, byte) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public native void    putInt(long address, int x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /** @see #getByte(long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public native long    getLong(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /** @see #putByte(long, byte) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public native void    putLong(long address, long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    /** @see #getByte(long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public native float   getFloat(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /** @see #putByte(long, byte) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    public native void    putFloat(long address, float x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /** @see #getByte(long) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    public native double  getDouble(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /** @see #putByte(long, byte) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    public native void    putDouble(long address, double x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * Fetches a native pointer from a given memory address.  If the address is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * zero, or does not point into a block obtained from {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * #allocateMemory}, the results are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * <p> If the native pointer is less than 64 bits wide, it is extended as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * an unsigned number to a Java long.  The pointer may be indexed by any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * given byte offset, simply by adding that offset (as a simple integer) to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * the long representing the pointer.  The number of bytes actually read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * from the target address maybe determined by consulting {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * #addressSize}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @see #allocateMemory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public native long getAddress(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * Stores a native pointer into a given memory address.  If the address is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * zero, or does not point into a block obtained from {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * #allocateMemory}, the results are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * <p> The number of bytes actually written at the target address maybe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * determined by consulting {@link #addressSize}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @see #getAddress(long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public native void putAddress(long address, long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /// wrappers for malloc, realloc, free:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Allocates a new block of native memory, of the given size in bytes.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * contents of the memory are uninitialized; they will generally be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * garbage.  The resulting native pointer will never be zero, and will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * aligned for all value types.  Dispose of this memory by calling {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * #freeMemory}, or resize it with {@link #reallocateMemory}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @throws IllegalArgumentException if the size is negative or too large
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *         for the native size_t type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @throws OutOfMemoryError if the allocation is refused by the system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @see #getByte(long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @see #putByte(long, byte)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    public native long allocateMemory(long bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * Resizes a new block of native memory, to the given size in bytes.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * contents of the new block past the size of the old block are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * uninitialized; they will generally be garbage.  The resulting native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * pointer will be zero if and only if the requested size is zero.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * resulting native pointer will be aligned for all value types.  Dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * of this memory by calling {@link #freeMemory}, or resize it with {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * #reallocateMemory}.  The address passed to this method may be null, in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * which case an allocation will be performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @throws IllegalArgumentException if the size is negative or too large
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *         for the native size_t type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @throws OutOfMemoryError if the allocation is refused by the system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see #allocateMemory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public native long reallocateMemory(long address, long bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * Sets all bytes in a given block of memory to a fixed value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * (usually zero).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * <p>This method determines a block's base address by means of two parameters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * and so it provides (in effect) a <em>double-register</em> addressing mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * as discussed in {@link #getInt(Object,long)}.  When the object reference is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * the offset supplies an absolute base address.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * <p>The stores are in coherent (atomic) units of a size determined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * by the address and length parameters.  If the effective address and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * length are all even modulo 8, the stores take place in 'long' units.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * If the effective address and length are (resp.) even modulo 4 or 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * the stores take place in units of 'int' or 'short'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    public native void setMemory(Object o, long offset, long bytes, byte value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * Sets all bytes in a given block of memory to a fixed value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * (usually zero).  This provides a <em>single-register</em> addressing mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * as discussed in {@link #getInt(Object,long)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * <p>Equivalent to <code>setMemory(null, address, bytes, value)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    public void setMemory(long address, long bytes, byte value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        setMemory(null, address, bytes, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * Sets all bytes in a given block of memory to a copy of another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * block.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * <p>This method determines each block's base address by means of two parameters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * and so it provides (in effect) a <em>double-register</em> addressing mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * as discussed in {@link #getInt(Object,long)}.  When the object reference is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * the offset supplies an absolute base address.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * <p>The transfers are in coherent (atomic) units of a size determined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * by the address and length parameters.  If the effective addresses and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * length are all even modulo 8, the transfer takes place in 'long' units.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * If the effective addresses and length are (resp.) even modulo 4 or 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * the transfer takes place in units of 'int' or 'short'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    public native void copyMemory(Object srcBase, long srcOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                                  Object destBase, long destOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                  long bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * Sets all bytes in a given block of memory to a copy of another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * block.  This provides a <em>single-register</em> addressing mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * as discussed in {@link #getInt(Object,long)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * Equivalent to <code>copyMemory(null, srcAddress, null, destAddress, bytes)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    public void copyMemory(long srcAddress, long destAddress, long bytes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        copyMemory(null, srcAddress, null, destAddress, bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Disposes of a block of native memory, as obtained from {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * this method may be null, in which case no action is taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * @see #allocateMemory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    public native void freeMemory(long address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /// random queries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * This constant differs from all results that will ever be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * {@link #staticFieldOffset}, {@link #objectFieldOffset},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * or {@link #arrayBaseOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    public static final int INVALID_FIELD_OFFSET   = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * Returns the offset of a field, truncated to 32 bits.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * This method is implemented as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * public int fieldOffset(Field f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *     if (Modifier.isStatic(f.getModifiers()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     *         return (int) staticFieldOffset(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *     else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     *         return (int) objectFieldOffset(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @deprecated As of 1.4.1, use {@link #staticFieldOffset} for static
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * fields and {@link #objectFieldOffset} for non-static fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    public int fieldOffset(Field f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        if (Modifier.isStatic(f.getModifiers()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            return (int) staticFieldOffset(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            return (int) objectFieldOffset(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * Returns the base address for accessing some static field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * in the given class.  This method is implemented as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * public Object staticFieldBase(Class c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *     Field[] fields = c.getDeclaredFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *     for (int i = 0; i < fields.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *         if (Modifier.isStatic(fields[i].getModifiers())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     *             return staticFieldBase(fields[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     *     return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * @deprecated As of 1.4.1, use {@link #staticFieldBase(Field)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * to obtain the base pertaining to a specific {@link Field}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * This method works only for JVMs which store all statics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * for a given class in one place.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    @Deprecated
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   619
    public Object staticFieldBase(Class<?> c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        Field[] fields = c.getDeclaredFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        for (int i = 0; i < fields.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            if (Modifier.isStatic(fields[i].getModifiers())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                return staticFieldBase(fields[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Report the location of a given field in the storage allocation of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * class.  Do not expect to perform any sort of arithmetic on this offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * it is just a cookie which is passed to the unsafe heap memory accessors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * <p>Any given field will always have the same offset and base, and no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * two distinct fields of the same class will ever have the same offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * and base.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * <p>As of 1.4.1, offsets for fields are represented as long values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * although the Sun JVM does not use the most significant 32 bits.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * However, JVM implementations which store static fields at absolute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * addresses can use long offsets and null base pointers to express
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * the field locations in a form usable by {@link #getInt(Object,long)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * Therefore, code which will be ported to such JVMs on 64-bit platforms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * must preserve all bits of static field offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @see #getInt(Object, long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    public native long staticFieldOffset(Field f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * Report the location of a given static field, in conjunction with {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * #staticFieldBase}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * <p>Do not expect to perform any sort of arithmetic on this offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * it is just a cookie which is passed to the unsafe heap memory accessors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * <p>Any given field will always have the same offset, and no two distinct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * fields of the same class will ever have the same offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * <p>As of 1.4.1, offsets for fields are represented as long values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * although the Sun JVM does not use the most significant 32 bits.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * It is hard to imagine a JVM technology which needs more than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * a few bits to encode an offset within a non-array object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * However, for consistency with other methods in this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * this method reports its result as a long value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * @see #getInt(Object, long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    public native long objectFieldOffset(Field f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * Report the location of a given static field, in conjunction with {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * #staticFieldOffset}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * <p>Fetch the base "Object", if any, with which static fields of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * given class can be accessed via methods like {@link #getInt(Object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * long)}.  This value may be null.  This value may refer to an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * which is a "cookie", not guaranteed to be a real Object, and it should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * not be used in any way except as argument to the get and put routines in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    public native Object staticFieldBase(Field f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    /**
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   681
     * Detect if the given class may need to be initialized. This is often
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   682
     * needed in conjunction with obtaining the static field base of a
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   683
     * class.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   684
     * @return false only if a call to {@code ensureClassInitialized} would have no effect
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   685
     */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   686
    public native boolean shouldBeInitialized(Class<?> c);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   687
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11117
diff changeset
   688
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * Ensure the given class has been initialized. This is often
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * needed in conjunction with obtaining the static field base of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   693
    public native void ensureClassInitialized(Class<?> c);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * Report the offset of the first element in the storage allocation of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * given array class.  If {@link #arrayIndexScale} returns a non-zero value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * for the same class, you may use that scale factor, together with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * base offset, to form new offsets to access elements of arrays of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * given class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @see #getInt(Object, long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * @see #putInt(Object, long, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   705
    public native int arrayBaseOffset(Class<?> arrayClass);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    /** The value of {@code arrayBaseOffset(boolean[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    public static final int ARRAY_BOOLEAN_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            = theUnsafe.arrayBaseOffset(boolean[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    /** The value of {@code arrayBaseOffset(byte[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    public static final int ARRAY_BYTE_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            = theUnsafe.arrayBaseOffset(byte[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    /** The value of {@code arrayBaseOffset(short[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    public static final int ARRAY_SHORT_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            = theUnsafe.arrayBaseOffset(short[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    /** The value of {@code arrayBaseOffset(char[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    public static final int ARRAY_CHAR_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            = theUnsafe.arrayBaseOffset(char[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    /** The value of {@code arrayBaseOffset(int[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    public static final int ARRAY_INT_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            = theUnsafe.arrayBaseOffset(int[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    /** The value of {@code arrayBaseOffset(long[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    public static final int ARRAY_LONG_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            = theUnsafe.arrayBaseOffset(long[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    /** The value of {@code arrayBaseOffset(float[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    public static final int ARRAY_FLOAT_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            = theUnsafe.arrayBaseOffset(float[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    /** The value of {@code arrayBaseOffset(double[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    public static final int ARRAY_DOUBLE_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            = theUnsafe.arrayBaseOffset(double[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    /** The value of {@code arrayBaseOffset(Object[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    public static final int ARRAY_OBJECT_BASE_OFFSET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            = theUnsafe.arrayBaseOffset(Object[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * Report the scale factor for addressing elements in the storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * allocation of a given array class.  However, arrays of "narrow" types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * will generally not work properly with accessors like {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * #getByte(Object, int)}, so the scale factor for such classes is reported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * as zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * @see #arrayBaseOffset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * @see #getInt(Object, long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * @see #putInt(Object, long, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   754
    public native int arrayIndexScale(Class<?> arrayClass);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    /** The value of {@code arrayIndexScale(boolean[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    public static final int ARRAY_BOOLEAN_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            = theUnsafe.arrayIndexScale(boolean[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    /** The value of {@code arrayIndexScale(byte[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    public static final int ARRAY_BYTE_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            = theUnsafe.arrayIndexScale(byte[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /** The value of {@code arrayIndexScale(short[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    public static final int ARRAY_SHORT_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            = theUnsafe.arrayIndexScale(short[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    /** The value of {@code arrayIndexScale(char[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    public static final int ARRAY_CHAR_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            = theUnsafe.arrayIndexScale(char[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    /** The value of {@code arrayIndexScale(int[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    public static final int ARRAY_INT_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            = theUnsafe.arrayIndexScale(int[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    /** The value of {@code arrayIndexScale(long[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    public static final int ARRAY_LONG_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            = theUnsafe.arrayIndexScale(long[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    /** The value of {@code arrayIndexScale(float[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    public static final int ARRAY_FLOAT_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            = theUnsafe.arrayIndexScale(float[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    /** The value of {@code arrayIndexScale(double[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    public static final int ARRAY_DOUBLE_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            = theUnsafe.arrayIndexScale(double[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    /** The value of {@code arrayIndexScale(Object[].class)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    public static final int ARRAY_OBJECT_INDEX_SCALE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            = theUnsafe.arrayIndexScale(Object[].class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * Report the size in bytes of a native pointer, as stored via {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * #putAddress}.  This value will be either 4 or 8.  Note that the sizes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * other primitive types (as stored in native memory blocks) is determined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * fully by their information content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    public native int addressSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    /** The value of {@code addressSize()} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    public static final int ADDRESS_SIZE = theUnsafe.addressSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * Report the size in bytes of a native memory page (whatever that is).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * This value will always be a power of two.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    public native int pageSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    /// random trusted operations from JNI:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     * Tell the VM to define a class, without security checks.  By default, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * class loader and protection domain come from the caller's class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   816
    public native Class<?> defineClass(String name, byte[] b, int off, int len,
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   817
                                       ClassLoader loader,
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   818
                                       ProtectionDomain protectionDomain);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   820
    public native Class<?> defineClass(String name, byte[] b, int off, int len);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   822
    /**
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   823
     * Define a class but do not make it known to the class loader or system dictionary.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   824
     * <p>
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   825
     * For each CP entry, the corresponding CP patch must either be null or have
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   826
     * the a format that matches its tag:
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   827
     * <ul>
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   828
     * <li>Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   829
     * <li>Utf8: a string (must have suitable syntax if used as signature or name)
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   830
     * <li>Class: any java.lang.Class object
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   831
     * <li>String: any object (not just a java.lang.String)
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   832
     * <li>InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   833
     * </ul>
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   834
     * @params hostClass context for linkage, access control, protection domain, and class loader
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   835
     * @params data      bytes of a class file
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   836
     * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   837
     */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   838
    public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   839
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents: 2
diff changeset
   840
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    /** Allocate an instance but do not run any constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        Initializes the class if it has not yet been. */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
   843
    public native Object allocateInstance(Class<?> cls)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        throws InstantiationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    public native void monitorEnter(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * Unlock the object.  It must have been locked via {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * #monitorEnter}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    public native void monitorExit(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * Tries to lock the object.  Returns true or false to indicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * whether the lock succeeded.  If it did, the object must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * unlocked via {@link #monitorExit}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    public native boolean tryMonitorEnter(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    /** Throw the exception without telling the verifier. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    public native void throwException(Throwable ee);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * Atomically update Java variable to <tt>x</tt> if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * holding <tt>expected</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * @return <tt>true</tt> if successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    public final native boolean compareAndSwapObject(Object o, long offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                                                     Object expected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                                                     Object x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * Atomically update Java variable to <tt>x</tt> if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * holding <tt>expected</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * @return <tt>true</tt> if successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    public final native boolean compareAndSwapInt(Object o, long offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                                                  int expected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                                                  int x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * Atomically update Java variable to <tt>x</tt> if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * holding <tt>expected</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * @return <tt>true</tt> if successful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    public final native boolean compareAndSwapLong(Object o, long offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                                                   long expected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                                                   long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * Fetches a reference value from a given Java variable, with volatile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * load semantics. Otherwise identical to {@link #getObject(Object, long)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    public native Object getObjectVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * Stores a reference value into a given Java variable, with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    public native void    putObjectVolatile(Object o, long offset, Object x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    /** Volatile version of {@link #getInt(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    public native int     getIntVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    /** Volatile version of {@link #putInt(Object, long, int)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    public native void    putIntVolatile(Object o, long offset, int x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    /** Volatile version of {@link #getBoolean(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    public native boolean getBooleanVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    /** Volatile version of {@link #putBoolean(Object, long, boolean)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    public native void    putBooleanVolatile(Object o, long offset, boolean x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    /** Volatile version of {@link #getByte(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    public native byte    getByteVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    /** Volatile version of {@link #putByte(Object, long, byte)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    public native void    putByteVolatile(Object o, long offset, byte x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    /** Volatile version of {@link #getShort(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    public native short   getShortVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    /** Volatile version of {@link #putShort(Object, long, short)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    public native void    putShortVolatile(Object o, long offset, short x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    /** Volatile version of {@link #getChar(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    public native char    getCharVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    /** Volatile version of {@link #putChar(Object, long, char)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    public native void    putCharVolatile(Object o, long offset, char x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    /** Volatile version of {@link #getLong(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    public native long    getLongVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    /** Volatile version of {@link #putLong(Object, long, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    public native void    putLongVolatile(Object o, long offset, long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    /** Volatile version of {@link #getFloat(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    public native float   getFloatVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    /** Volatile version of {@link #putFloat(Object, long, float)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    public native void    putFloatVolatile(Object o, long offset, float x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    /** Volatile version of {@link #getDouble(Object, long)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    public native double  getDoubleVolatile(Object o, long offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    /** Volatile version of {@link #putDouble(Object, long, double)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    public native void    putDoubleVolatile(Object o, long offset, double x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * Version of {@link #putObjectVolatile(Object, long, Object)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * that does not guarantee immediate visibility of the store to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * other threads. This method is generally only useful if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * underlying field is a Java volatile (or if an array cell, one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * that is otherwise only accessed using volatile accesses).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    public native void    putOrderedObject(Object o, long offset, Object x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)}  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    public native void    putOrderedInt(Object o, long offset, int x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    public native void    putOrderedLong(Object o, long offset, long x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     * Unblock the given thread blocked on <tt>park</tt>, or, if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     * not blocked, cause the subsequent call to <tt>park</tt> not to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * block.  Note: this operation is "unsafe" solely because the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * caller must somehow ensure that the thread has not been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * destroyed. Nothing special is usually required to ensure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * when called from Java (in which there will ordinarily be a live
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * reference to the thread) but this is not nearly-automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * so when calling from native code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * @param thread the thread to unpark.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    public native void unpark(Object thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * Block current thread, returning when a balancing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * <tt>unpark</tt> occurs, or a balancing <tt>unpark</tt> has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * already occurred, or the thread is interrupted, or, if not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * absolute and time is not zero, the given time nanoseconds have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * elapsed, or if absolute, the given deadline in milliseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * since Epoch has passed, or spuriously (i.e., returning for no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * "reason"). Note: This operation is in the Unsafe class only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * because <tt>unpark</tt> is, so it would be strange to place it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * elsewhere.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
    public native void park(boolean isAbsolute, long time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * Gets the load average in the system run queue assigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * to the available processors averaged over various periods of time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * This method retrieves the given <tt>nelem</tt> samples and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * assigns to the elements of the given <tt>loadavg</tt> array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * The system imposes a maximum of 3 samples, representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * averages over the last 1,  5,  and  15 minutes, respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * @params loadavg an array of double of size nelems
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * @params nelems the number of samples to be retrieved and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     *         must be 1 to 3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @return the number of samples actually retrieved; or -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     *         if the load average is unobtainable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
    public native int getLoadAverage(double[] loadavg, int nelems);
14851
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1011
14853
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1012
    // The following contain CAS-based Java implementations used on
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1013
    // platforms not supporting native instructions
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1014
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1015
    /**
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1016
     * Atomically adds the given value to the current value of a field
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1017
     * or array element within the given object <code>o</code>
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1018
     * at the given <code>offset</code>.
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1019
     *
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1020
     * @param o object/array to update the field/element in
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1021
     * @param offset field/element offset
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1022
     * @param delta the value to add
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1023
     * @return the previous value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1024
     * @since 1.8
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1025
     */
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1026
    public final int getAndAddInt(Object o, long offset, int delta) {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1027
        int v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1028
        do {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1029
            v = getIntVolatile(o, offset);
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1030
        } while (!compareAndSwapInt(o, offset, v, v + delta));
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1031
        return v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1032
    }
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1033
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1034
    /**
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1035
     * Atomically adds the given value to the current value of a field
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1036
     * or array element within the given object <code>o</code>
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1037
     * at the given <code>offset</code>.
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1038
     *
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1039
     * @param o object/array to update the field/element in
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1040
     * @param offset field/element offset
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1041
     * @param delta the value to add
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1042
     * @return the previous value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1043
     * @since 1.8
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1044
     */
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1045
    public final long getAndAddLong(Object o, long offset, long delta) {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1046
        long v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1047
        do {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1048
            v = getLongVolatile(o, offset);
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1049
        } while (!compareAndSwapLong(o, offset, v, v + delta));
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1050
        return v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1051
    }
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1052
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1053
    /**
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1054
     * Atomically exchanges the given value with the current value of
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1055
     * a field or array element within the given object <code>o</code>
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1056
     * at the given <code>offset</code>.
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1057
     *
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1058
     * @param o object/array to update the field/element in
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1059
     * @param offset field/element offset
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1060
     * @param newValue new value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1061
     * @return the previous value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1062
     * @since 1.8
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1063
     */
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1064
    public final int getAndSetInt(Object o, long offset, int newValue) {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1065
        int v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1066
        do {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1067
            v = getIntVolatile(o, offset);
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1068
        } while (!compareAndSwapInt(o, offset, v, newValue));
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1069
        return v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1070
    }
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1071
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1072
    /**
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1073
     * Atomically exchanges the given value with the current value of
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1074
     * a field or array element within the given object <code>o</code>
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1075
     * at the given <code>offset</code>.
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1076
     *
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1077
     * @param o object/array to update the field/element in
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1078
     * @param offset field/element offset
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1079
     * @param newValue new value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1080
     * @return the previous value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1081
     * @since 1.8
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1082
     */
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1083
    public final long getAndSetLong(Object o, long offset, long newValue) {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1084
        long v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1085
        do {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1086
            v = getLongVolatile(o, offset);
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1087
        } while (!compareAndSwapLong(o, offset, v, newValue));
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1088
        return v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1089
    }
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1090
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1091
    /**
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1092
     * Atomically exchanges the given reference value with the current
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1093
     * reference value of a field or array element within the given
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1094
     * object <code>o</code> at the given <code>offset</code>.
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1095
     *
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1096
     * @param o object/array to update the field/element in
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1097
     * @param offset field/element offset
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1098
     * @param newValue new value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1099
     * @return the previous value
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1100
     * @since 1.8
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1101
     */
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1102
    public final Object getAndSetObject(Object o, long offset, Object newValue) {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1103
        Object v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1104
        do {
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1105
            v = getObjectVolatile(o, offset);
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1106
        } while (!compareAndSwapObject(o, offset, v, newValue));
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1107
        return v;
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1108
    }
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1109
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1110
14851
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1111
    /**
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1112
     * Ensures lack of reordering of loads before the fence
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1113
     * with loads or stores after the fence.
14853
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1114
     * @since 1.8
14851
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1115
     */
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1116
    public native void loadFence();
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1117
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1118
    /**
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1119
     * Ensures lack of reordering of stores before the fence
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1120
     * with loads or stores after the fence.
14853
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1121
     * @since 1.8
14851
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1122
     */
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1123
    public native void storeFence();
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1124
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1125
    /**
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1126
     * Ensures lack of reordering of loads or stores before the fence
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1127
     * with loads or stores after the fence.
14853
72f0bc58bb95 8004330: Add missing Unsafe entry points for addAndGet() family
dl
parents: 14851
diff changeset
  1128
     * @since 1.8
14851
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1129
     */
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1130
    public native void fullFence();
5d879715aab6 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 14342
diff changeset
  1131
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
}