166 * 167 * @param o Java heap object in which the variable resides, if any, else 168 * null 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 @HotSpotIntrinsicCandidate 177 public native void putInt(Object o, long offset, int x); 178 179 /** 180 * Returns true if the given class is a regular value type. 181 */ 182 public boolean isValueType(Class<?> c) { 183 return c.isValue() && c == c.asValueType(); 184 } 185 186 /** 187 * Returns true if the given class is a flattened array. 188 */ 189 public native boolean isFlattenedArray(Class<?> arrayClass); 190 191 /** 192 * Fetches a reference value from a given Java variable. 193 * This method can return a reference to either an object or value 194 * or a null reference. 195 * 196 * @see #getInt(Object, long) 197 */ 198 @HotSpotIntrinsicCandidate 199 public native Object getReference(Object o, long offset); 200 201 /** 202 * Stores a reference value into a given Java variable. 203 * This method can store a reference to either an object or value 204 * or a null reference. 205 * <p> 219 * {@code o} object at the given offset, or (if {@code o} is null) 220 * from the memory address whose numerical value is the given offset. 221 * 222 * @param o Java heap object in which the variable resides, if any, else 223 * null 224 * @param offset indication of where the variable resides in a Java heap 225 * object, if any, else a memory address locating the variable 226 * statically 227 * @param vc value class 228 * @param <V> the type of a value 229 * @return the value fetched from the indicated Java variable 230 * @throws RuntimeException No defined exceptions are thrown, not even 231 * {@link NullPointerException} 232 */ 233 public native <V> V getValue(Object o, long offset, Class<?> vc); 234 235 /** 236 * Stores the given value into a given Java variable. 237 * 238 * Unless the reference {@code o} being stored is either null 239 * or matches the field type and not in a value container, 240 * the results are undefined. 241 * 242 * @param o Java heap object in which the variable resides, if any, else 243 * null 244 * @param offset indication of where the variable resides in a Java heap 245 * object, if any, else a memory address locating the variable 246 * statically 247 * @param vc value class 248 * @param v the value to store into the indicated Java variable 249 * @param <V> the type of a value 250 * @throws RuntimeException No defined exceptions are thrown, not even 251 * {@link NullPointerException} 252 */ 253 public native <V> void putValue(Object o, long offset, Class<?> vc, V v); 254 255 /** @see #getInt(Object, long) */ 256 @HotSpotIntrinsicCandidate 257 public native boolean getBoolean(Object o, long offset); 258 259 /** @see #putInt(Object, long, int) */ 260 @HotSpotIntrinsicCandidate 261 public native void putBoolean(Object o, long offset, boolean x); 262 263 /** @see #getInt(Object, long) */ 264 @HotSpotIntrinsicCandidate 265 public native byte getByte(Object o, long offset); 266 267 /** @see #putInt(Object, long, int) */ 268 @HotSpotIntrinsicCandidate 269 public native void putByte(Object o, long offset, byte x); 270 271 /** @see #getInt(Object, long) */ 272 @HotSpotIntrinsicCandidate 273 public native short getShort(Object o, long offset); 274 | 166 * 167 * @param o Java heap object in which the variable resides, if any, else 168 * null 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 @HotSpotIntrinsicCandidate 177 public native void putInt(Object o, long offset, int x); 178 179 /** 180 * Returns true if the given class is a regular value type. 181 */ 182 public boolean isValueType(Class<?> c) { 183 return c.isValue() && c == c.asValueType(); 184 } 185 186 private static final int JVM_ACC_FLATTENED = 0x00008000; // HotSpot-specific bit 187 188 /** 189 * Returns true if the given field is flattened. 190 */ 191 public boolean isFlattened(Field f) { 192 return (f.getModifiers() & JVM_ACC_FLATTENED) == JVM_ACC_FLATTENED; 193 } 194 195 /** 196 * Returns true if the given class is a flattened array. 197 */ 198 public native boolean isFlattenedArray(Class<?> arrayClass); 199 200 /** 201 * Fetches a reference value from a given Java variable. 202 * This method can return a reference to either an object or value 203 * or a null reference. 204 * 205 * @see #getInt(Object, long) 206 */ 207 @HotSpotIntrinsicCandidate 208 public native Object getReference(Object o, long offset); 209 210 /** 211 * Stores a reference value into a given Java variable. 212 * This method can store a reference to either an object or value 213 * or a null reference. 214 * <p> 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 * Returns an object instance with a private buffered value whose layout 265 * and contents is exactly the given value instance. The return object 266 * is in the larval state that can be updated using the unsafe put operation. 267 * 268 * @param value a value instance 269 * @param <V> the type of the given value instance 270 */ 271 public native <V> V makePrivateBuffer(V value); 272 273 /** 274 * Exits the larval state and returns a value instance. 275 * 276 * @param value a value instance 277 * @param <V> the type of the given value instance 278 */ 279 public native <V> V finishPrivateBuffer(V value); 280 281 /** 282 * Returns the header size of the given value class 283 * 284 * @param vc Value class 285 * @param <V> value clas 286 * @return the header size of the value class 287 */ 288 public native <V> long valueHeaderSize(Class<V> vc); 289 290 /** @see #getInt(Object, long) */ 291 @HotSpotIntrinsicCandidate 292 public native boolean getBoolean(Object o, long offset); 293 294 /** @see #putInt(Object, long, int) */ 295 @HotSpotIntrinsicCandidate 296 public native void putBoolean(Object o, long offset, boolean x); 297 298 /** @see #getInt(Object, long) */ 299 @HotSpotIntrinsicCandidate 300 public native byte getByte(Object o, long offset); 301 302 /** @see #putInt(Object, long, int) */ 303 @HotSpotIntrinsicCandidate 304 public native void putByte(Object o, long offset, byte x); 305 306 /** @see #getInt(Object, long) */ 307 @HotSpotIntrinsicCandidate 308 public native short getShort(Object o, long offset); 309 |