Skip to content

io microsphere misc UnsafeUtils

github-actions[bot] edited this page Jul 26, 2026 · 1 revision

UnsafeUtils

Type: Class | Module: microsphere-java-core | Package: io.microsphere.misc | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/misc/UnsafeUtils.java

Overview

sun.misc.Unsafe Utility class

Take case to use those utility methods in order to the stability fo JVM

Declaration

public abstract class UnsafeUtils extends BaseUtils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.3.16-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.misc.UnsafeUtils;

API Reference

Public Methods

Method Description
getLongFromArrayVolatile
getIntFromArrayVolatile Get the value of the target Index in the object Array field
getShortFromArrayVolatile Get the short value of the target Index in the Array field of the object
getByteFromArrayVolatile Get the byte value of the target Index in the object Array field
getBooleanFromArrayVolatile Get the boolean value of the target Index in the Array field of the object
getDoubleFromArrayVolatile Get the double value of the target Index in the Array field of the object
getFloatFromArrayVolatile Get the float value of the target Index in the object Array field
getCharFromArrayVolatile Get the char value of the target Index in the object Array field
getObjectFromArrayVolatile Get the java.lang.Object value of the target Index in the object Array field
putDouble Sets the given double value to the field of the specified object
putFloat Sets the given float value to the field of the specified object
putShort Sets the given short value to the field of the specified object
putByte Sets the given byte value to the field of the specified object
putBoolean Sets the given boolean value to the field of the specified object
putChar Sets the given char value to the field of the specified object
putObject Sets the given Object value to the field of the specified object
putLong Sets the given long value to the field of the specified object
putInt Sets the given int value to the field of the specified object
putOrderedInt Sets the given int value to the field of the specified object (ensures writing order)
putOrderedLong Sets the given long value to the field of the specified object (ensures writing order)

Method Details

getIntFromArrayVolatile

public static int getIntFromArrayVolatile(Object object, String fieldName, int index)

Get the value of the target Index in the object Array field

getShortFromArrayVolatile

public static short getShortFromArrayVolatile(Object object, String fieldName, int index)

Get the short value of the target Index in the Array field of the object

getByteFromArrayVolatile

public static byte getByteFromArrayVolatile(Object object, String fieldName, int index)

Get the byte value of the target Index in the object Array field

getBooleanFromArrayVolatile

public static boolean getBooleanFromArrayVolatile(Object object, String fieldName, int index)

Get the boolean value of the target Index in the Array field of the object

getDoubleFromArrayVolatile

public static double getDoubleFromArrayVolatile(Object object, String fieldName, int index)

Get the double value of the target Index in the Array field of the object

getFloatFromArrayVolatile

public static float getFloatFromArrayVolatile(Object object, String fieldName, int index)

Get the float value of the target Index in the object Array field

getCharFromArrayVolatile

public static char getCharFromArrayVolatile(Object object, String fieldName, int index)

Get the char value of the target Index in the object Array field

getObjectFromArrayVolatile

public static Object getObjectFromArrayVolatile(Object object, String fieldName, int index)

Get the java.lang.Object value of the target Index in the object Array field

putDouble

public static void putDouble(Object object, String fieldName, double value)

Sets the given double value to the field of the specified object

putFloat

public static void putFloat(Object object, String fieldName, float value)

Sets the given float value to the field of the specified object

putShort

public static void putShort(Object object, String fieldName, short value)

Sets the given short value to the field of the specified object

putByte

public static void putByte(Object object, String fieldName, byte value)

Sets the given byte value to the field of the specified object

putBoolean

public static void putBoolean(Object object, String fieldName, boolean value)

Sets the given boolean value to the field of the specified object

putChar

public static void putChar(Object object, String fieldName, char value)

Sets the given char value to the field of the specified object

putObject

public static void putObject(Object object, String fieldName, Object value)

Sets the given Object value to the field of the specified object

putLong

public static void putLong(Object object, String fieldName, long value)

Sets the given long value to the field of the specified object

putInt

public static void putInt(Object object, String fieldName, int value)

Sets the given int value to the field of the specified object

putOrderedInt

public static void putOrderedInt(Object object, String fieldName, int value)

Sets the given int value to the field of the specified object (ensures writing order)

putOrderedLong

public static void putOrderedLong(Object object, String fieldName, long value)

Sets the given long value to the field of the specified object (ensures writing order)

See Also

  • sun.misc.Unsafe

This documentation was auto-generated from the source code of microsphere-java.

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally