169 * @param offset indication of where the variable resides in a Java heap
170 * object, if any, else a memory address locating the variable
171 * statically
172 * @param x the value to store into the indicated Java variable
173 * @throws RuntimeException No defined exceptions are thrown, not even
174 * {@link NullPointerException}
175 */
176 public native void putInt(Object o, long offset, int x);
177
178 /**
179 * Fetches a reference value from a given Java variable.
180 * @see #getInt(Object, long)
181 */
182 public native Object getObject(Object o, long offset);
183
184 /**
185 * Stores a reference value into a given Java variable.
186 * <p>
187 * Unless the reference <code>x</code> being stored is either null
188 * or matches the field type, the results are undefined.
189 * If the reference <code>o</code> is non-null, car marks or
190 * other store barriers for that object (if the VM requires them)
191 * are updated.
192 * @see #putInt(Object, int, int)
193 */
194 public native void putObject(Object o, long offset, Object x);
195
196 /** @see #getInt(Object, long) */
197 public native boolean getBoolean(Object o, long offset);
198 /** @see #putInt(Object, int, int) */
199 public native void putBoolean(Object o, long offset, boolean x);
200 /** @see #getInt(Object, long) */
201 public native byte getByte(Object o, long offset);
202 /** @see #putInt(Object, int, int) */
203 public native void putByte(Object o, long offset, byte x);
204 /** @see #getInt(Object, long) */
205 public native short getShort(Object o, long offset);
206 /** @see #putInt(Object, int, int) */
207 public native void putShort(Object o, long offset, short x);
208 /** @see #getInt(Object, long) */
209 public native char getChar(Object o, long offset);
417 /** @see #putByte(long, byte) */
418 public native void putChar(long address, char x);
419 /** @see #getByte(long) */
420 public native int getInt(long address);
421 /** @see #putByte(long, byte) */
422 public native void putInt(long address, int x);
423 /** @see #getByte(long) */
424 public native long getLong(long address);
425 /** @see #putByte(long, byte) */
426 public native void putLong(long address, long x);
427 /** @see #getByte(long) */
428 public native float getFloat(long address);
429 /** @see #putByte(long, byte) */
430 public native void putFloat(long address, float x);
431 /** @see #getByte(long) */
432 public native double getDouble(long address);
433 /** @see #putByte(long, byte) */
434 public native void putDouble(long address, double x);
435
436 /**
437 * Fetches a native pointer from a given memory address. If the address is
438 * zero, or does not point into a block obtained from {@link
439 * #allocateMemory}, the results are undefined.
440 *
441 * <p> If the native pointer is less than 64 bits wide, it is extended as
442 * an unsigned number to a Java long. The pointer may be indexed by any
443 * given byte offset, simply by adding that offset (as a simple integer) to
444 * the long representing the pointer. The number of bytes actually read
445 * from the target address maybe determined by consulting {@link
446 * #addressSize}.
447 *
448 * @see #allocateMemory
449 */
450 public native long getAddress(long address);
451
452 /**
453 * Stores a native pointer into a given memory address. If the address is
454 * zero, or does not point into a block obtained from {@link
455 * #allocateMemory}, the results are undefined.
456 *
|
169 * @param offset indication of where the variable resides in a Java heap
170 * object, if any, else a memory address locating the variable
171 * statically
172 * @param x the value to store into the indicated Java variable
173 * @throws RuntimeException No defined exceptions are thrown, not even
174 * {@link NullPointerException}
175 */
176 public native void putInt(Object o, long offset, int x);
177
178 /**
179 * Fetches a reference value from a given Java variable.
180 * @see #getInt(Object, long)
181 */
182 public native Object getObject(Object o, long offset);
183
184 /**
185 * Stores a reference value into a given Java variable.
186 * <p>
187 * Unless the reference <code>x</code> being stored is either null
188 * or matches the field type, the results are undefined.
189 * If the reference <code>o</code> is non-null, card marks or
190 * other store barriers for that object (if the VM requires them)
191 * are updated.
192 * @see #putInt(Object, int, int)
193 */
194 public native void putObject(Object o, long offset, Object x);
195
196 /** @see #getInt(Object, long) */
197 public native boolean getBoolean(Object o, long offset);
198 /** @see #putInt(Object, int, int) */
199 public native void putBoolean(Object o, long offset, boolean x);
200 /** @see #getInt(Object, long) */
201 public native byte getByte(Object o, long offset);
202 /** @see #putInt(Object, int, int) */
203 public native void putByte(Object o, long offset, byte x);
204 /** @see #getInt(Object, long) */
205 public native short getShort(Object o, long offset);
206 /** @see #putInt(Object, int, int) */
207 public native void putShort(Object o, long offset, short x);
208 /** @see #getInt(Object, long) */
209 public native char getChar(Object o, long offset);
417 /** @see #putByte(long, byte) */
418 public native void putChar(long address, char x);
419 /** @see #getByte(long) */
420 public native int getInt(long address);
421 /** @see #putByte(long, byte) */
422 public native void putInt(long address, int x);
423 /** @see #getByte(long) */
424 public native long getLong(long address);
425 /** @see #putByte(long, byte) */
426 public native void putLong(long address, long x);
427 /** @see #getByte(long) */
428 public native float getFloat(long address);
429 /** @see #putByte(long, byte) */
430 public native void putFloat(long address, float x);
431 /** @see #getByte(long) */
432 public native double getDouble(long address);
433 /** @see #putByte(long, byte) */
434 public native void putDouble(long address, double x);
435
436 /**
437 * Possible storage modes for references.
438 *
439 * The {@link StorageMode#DEFAULT} storage mode uses the JVM's setting for the respective
440 * storage class.
441 */
442 public enum StorageMode {
443 DEFAULT,
444 UNCOMPRESSED_OOP,
445 COMPRESSED_OOP,
446 UNCOMPRESSED_KLASS,
447 COMPRESSED_KLASS;
448
449 static {
450 for (StorageMode mode : StorageMode.values()) {
451 setStorageModeConstant(mode.name(), mode.ordinal());
452 }
453 };
454 }
455
456 /**
457 * Tell the JVM about the storage mode values.
458 */
459 private static native void setStorageModeConstant(String name, int ordinal);
460
461 /**
462 * Fetches a reference value from a given Java variable using the given storage mode.
463 * @see #getInt(Object, long)
464 * @since 1.8
465 */
466 public native Object getObject(Object o, long offset, StorageMode mode);
467
468 /**
469 * Stores a reference value into a given Java variable using the given storage mode.
470 * <p>
471 * Unless the reference <code>x</code> being stored is either null
472 * or matches the field type, the results are undefined.
473 * If the reference <code>o</code> is non-null, card marks or
474 * other store barriers for that object (if the VM requires them)
475 * are updated.
476 * @see #putInt(Object, int, int)
477 * @since 1.8
478 */
479 public native void putObject(Object o, long offset, Object x, StorageMode mode);
480
481 /**
482 * Fetches a meta data reference value from a given Java variable using the given storage mode.
483 * @see #getInt(Object, long)
484 * @since 1.8
485 */
486 public native long getMetadata(Object o, long offset, StorageMode mode);
487
488 /**
489 * Stores a meta data reference value into a given Java variable using the given storage mode.
490 * <p>
491 * Unless the reference <code>x</code> being stored is either null
492 * or matches the field type, the results are undefined.
493 * @see #putInt(Object, int, int)
494 * @since 1.8
495 */
496 public native void putMetadata(Object o, long offset, long x, StorageMode mode);
497
498 /**
499 * Fetches a native pointer from a given memory address. If the address is
500 * zero, or does not point into a block obtained from {@link
501 * #allocateMemory}, the results are undefined.
502 *
503 * <p> If the native pointer is less than 64 bits wide, it is extended as
504 * an unsigned number to a Java long. The pointer may be indexed by any
505 * given byte offset, simply by adding that offset (as a simple integer) to
506 * the long representing the pointer. The number of bytes actually read
507 * from the target address maybe determined by consulting {@link
508 * #addressSize}.
509 *
510 * @see #allocateMemory
511 */
512 public native long getAddress(long address);
513
514 /**
515 * Stores a native pointer into a given memory address. If the address is
516 * zero, or does not point into a block obtained from {@link
517 * #allocateMemory}, the results are undefined.
518 *
|