< prev index next >

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

Print this page




 222     @HotSpotIntrinsicCandidate
 223     public native void putReference(Object o, long offset, Object x);
 224 
 225     /**
 226      * Fetches a value of type {@code <V>} from a given Java variable.
 227      * More specifically, fetches a field or array element within the given
 228      * {@code o} object at the given offset, or (if {@code o} is null)
 229      * from the memory address whose numerical value is the given offset.
 230      *
 231      * @param o Java heap object in which the variable resides, if any, else
 232      *        null
 233      * @param offset indication of where the variable resides in a Java heap
 234      *        object, if any, else a memory address locating the variable
 235      *        statically
 236      * @param vc value class
 237      * @param <V> the type of a value
 238      * @return the value fetched from the indicated Java variable
 239      * @throws RuntimeException No defined exceptions are thrown, not even
 240      *         {@link NullPointerException}
 241      */

 242     public native <V> V getValue(Object o, long offset, Class<?> vc);
 243 
 244     /**
 245      * Stores the given value into a given Java variable.
 246      *
 247      * Unless the reference {@code o} being stored is either null
 248      * or matches the field type, the results are undefined.
 249      *
 250      * @param o Java heap object in which the variable resides, if any, else
 251      *        null
 252      * @param offset indication of where the variable resides in a Java heap
 253      *        object, if any, else a memory address locating the variable
 254      *        statically
 255      * @param vc value class
 256      * @param v the value to store into the indicated Java variable
 257      * @param <V> the type of a value
 258      * @throws RuntimeException No defined exceptions are thrown, not even
 259      *         {@link NullPointerException}
 260      */

 261     public native <V> void putValue(Object o, long offset, Class<?> vc, V v);
 262 
 263     /**
 264      * Fetches a reference value of type {@code vc} from a given Java variable.
 265      * This method can return a reference to a value or a null reference
 266      * for a boxed value type.
 267      *
 268      * @param vc value class
 269      */
 270     public Object getReference(Object o, long offset, Class<?> vc) {
 271         Object ref = getReference(o, offset);
 272         if (ref == null && isValueType(vc)) {
 273             // If the type of the returned reference is a normal value type
 274             // return an uninitialized default value if null
 275             ref = uninitializedDefaultValue(vc);
 276         }
 277         return ref;
 278     }
 279 
 280     public Object getReferenceVolatile(Object o, long offset, Class<?> vc) {


 283             // If the type of the returned reference is a normal value type
 284             // return an uninitialized default value if null
 285             ref = uninitializedDefaultValue(vc);
 286         }
 287         return ref;
 288     }
 289 
 290     /**
 291      * Returns an uninitialized default value of the given value class.
 292      */
 293     public native <V> V uninitializedDefaultValue(Class<?> vc);
 294 
 295     /**
 296      * Returns an object instance with a private buffered value whose layout
 297      * and contents is exactly the given value instance.  The return object
 298      * is in the larval state that can be updated using the unsafe put operation.
 299      *
 300      * @param value a value instance
 301      * @param <V> the type of the given value instance
 302      */

 303     public native <V> V makePrivateBuffer(V value);
 304 
 305     /**
 306      * Exits the larval state and returns a value instance.
 307      *
 308      * @param value a value instance
 309      * @param <V> the type of the given value instance
 310      */

 311     public native <V> V finishPrivateBuffer(V value);
 312 
 313     /**
 314      * Returns the header size of the given value class
 315      *
 316      * @param vc Value class
 317      * @param <V> value clas
 318      * @return the header size of the value class
 319      */
 320     public native <V> long valueHeaderSize(Class<V> vc);
 321 
 322     /** @see #getInt(Object, long) */
 323     @HotSpotIntrinsicCandidate
 324     public native boolean getBoolean(Object o, long offset);
 325 
 326     /** @see #putInt(Object, long, int) */
 327     @HotSpotIntrinsicCandidate
 328     public native void    putBoolean(Object o, long offset, boolean x);
 329 
 330     /** @see #getInt(Object, long) */




 222     @HotSpotIntrinsicCandidate
 223     public native void putReference(Object o, long offset, Object x);
 224 
 225     /**
 226      * Fetches a value of type {@code <V>} from a given Java variable.
 227      * More specifically, fetches a field or array element within the given
 228      * {@code o} object at the given offset, or (if {@code o} is null)
 229      * from the memory address whose numerical value is the given offset.
 230      *
 231      * @param o Java heap object in which the variable resides, if any, else
 232      *        null
 233      * @param offset indication of where the variable resides in a Java heap
 234      *        object, if any, else a memory address locating the variable
 235      *        statically
 236      * @param vc value class
 237      * @param <V> the type of a value
 238      * @return the value fetched from the indicated Java variable
 239      * @throws RuntimeException No defined exceptions are thrown, not even
 240      *         {@link NullPointerException}
 241      */
 242     @HotSpotIntrinsicCandidate
 243     public native <V> V getValue(Object o, long offset, Class<?> vc);
 244 
 245     /**
 246      * Stores the given value into a given Java variable.
 247      *
 248      * Unless the reference {@code o} being stored is either null
 249      * or matches the field type, the results are undefined.
 250      *
 251      * @param o Java heap object in which the variable resides, if any, else
 252      *        null
 253      * @param offset indication of where the variable resides in a Java heap
 254      *        object, if any, else a memory address locating the variable
 255      *        statically
 256      * @param vc value class
 257      * @param v the value to store into the indicated Java variable
 258      * @param <V> the type of a value
 259      * @throws RuntimeException No defined exceptions are thrown, not even
 260      *         {@link NullPointerException}
 261      */
 262     @HotSpotIntrinsicCandidate
 263     public native <V> void putValue(Object o, long offset, Class<?> vc, V v);
 264 
 265     /**
 266      * Fetches a reference value of type {@code vc} from a given Java variable.
 267      * This method can return a reference to a value or a null reference
 268      * for a boxed value type.
 269      *
 270      * @param vc value class
 271      */
 272     public Object getReference(Object o, long offset, Class<?> vc) {
 273         Object ref = getReference(o, offset);
 274         if (ref == null && isValueType(vc)) {
 275             // If the type of the returned reference is a normal value type
 276             // return an uninitialized default value if null
 277             ref = uninitializedDefaultValue(vc);
 278         }
 279         return ref;
 280     }
 281 
 282     public Object getReferenceVolatile(Object o, long offset, Class<?> vc) {


 285             // If the type of the returned reference is a normal value type
 286             // return an uninitialized default value if null
 287             ref = uninitializedDefaultValue(vc);
 288         }
 289         return ref;
 290     }
 291 
 292     /**
 293      * Returns an uninitialized default value of the given value class.
 294      */
 295     public native <V> V uninitializedDefaultValue(Class<?> vc);
 296 
 297     /**
 298      * Returns an object instance with a private buffered value whose layout
 299      * and contents is exactly the given value instance.  The return object
 300      * is in the larval state that can be updated using the unsafe put operation.
 301      *
 302      * @param value a value instance
 303      * @param <V> the type of the given value instance
 304      */
 305     @HotSpotIntrinsicCandidate
 306     public native <V> V makePrivateBuffer(V value);
 307 
 308     /**
 309      * Exits the larval state and returns a value instance.
 310      *
 311      * @param value a value instance
 312      * @param <V> the type of the given value instance
 313      */
 314     @HotSpotIntrinsicCandidate
 315     public native <V> V finishPrivateBuffer(V value);
 316 
 317     /**
 318      * Returns the header size of the given value class
 319      *
 320      * @param vc Value class
 321      * @param <V> value clas
 322      * @return the header size of the value class
 323      */
 324     public native <V> long valueHeaderSize(Class<V> vc);
 325 
 326     /** @see #getInt(Object, long) */
 327     @HotSpotIntrinsicCandidate
 328     public native boolean getBoolean(Object o, long offset);
 329 
 330     /** @see #putInt(Object, long, int) */
 331     @HotSpotIntrinsicCandidate
 332     public native void    putBoolean(Object o, long offset, boolean x);
 333 
 334     /** @see #getInt(Object, long) */


< prev index next >