Home / Class/ Buffer Class — netty Architecture

Buffer Class — netty Architecture

Architecture documentation for the Buffer class in Buffer.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  0c9afafd_d1d6_54ea_20a8_b2070b867959["Buffer"]
  0852d569_cf4c_4036_b28b_1e73f0f1118e["Buffer.java"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|defined in| 0852d569_cf4c_4036_b28b_1e73f0f1118e
  f59f1d2d_2862_1444_0563_823d11c2e3f9["Buffer()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| f59f1d2d_2862_1444_0563_823d11c2e3f9
  50cbd778_b6a7_8f4d_f9bb_5e9f35602109["free()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| 50cbd778_b6a7_8f4d_f9bb_5e9f35602109
  21713478_8d78_e1a4_a380_d9b76677ba97["ByteBuffer()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| 21713478_8d78_e1a4_a380_d9b76677ba97
  25a8bd1e_bd4f_0d34_d8c5_a707e55aecf9["CleanableDirectBuffer()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| 25a8bd1e_bd4f_0d34_d8c5_a707e55aecf9
  cc1400a2_12aa_f8ff_7705_2182cd3d19fa["memoryAddress()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| cc1400a2_12aa_f8ff_7705_2182cd3d19fa
  124290b0_c6fa_f812_2ee0_0d742fa9fd91["addressSize()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| 124290b0_c6fa_f812_2ee0_0d742fa9fd91
  74a23a3f_aabc_22ed_e363_dc29bc9b9302["addressSize0()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| 74a23a3f_aabc_22ed_e363_dc29bc9b9302
  f0c92919_cb5b_b12f_d5fd_786801f4928e["memoryAddress0()"]
  0c9afafd_d1d6_54ea_20a8_b2070b867959 -->|method| f0c92919_cb5b_b12f_d5fd_786801f4928e

Relationship Graph

Source Code

transport-native-unix-common/src/main/java/io/netty/channel/unix/Buffer.java lines 25–90

@UnstableApi
public final class Buffer {

    private Buffer() { }

    /**
     * Free the direct {@link ByteBuffer}.
     * @deprecated Use {@link #allocateDirectBufferWithNativeOrder(int)} instead.
     */
    @Deprecated
    public static void free(ByteBuffer buffer) {
        PlatformDependent.freeDirectBuffer(buffer);
    }

    /**
     * Returns a new {@link ByteBuffer} which has the same {@link ByteOrder} as the native order of the machine.
     * @deprecated Use {@link #allocateDirectBufferWithNativeOrder(int)} instead.
     */
    @Deprecated
    public static ByteBuffer allocateDirectWithNativeOrder(int capacity) {
        return ByteBuffer.allocateDirect(capacity).order(
                PlatformDependent.BIG_ENDIAN_NATIVE_ORDER ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
    }

    /**
     * Returns a new {@link CleanableDirectBuffer} which has the same {@link ByteOrder} as the native order of the
     * machine.
     */
    public static CleanableDirectBuffer allocateDirectBufferWithNativeOrder(int capacity) {
        CleanableDirectBuffer cleanableDirectBuffer = PlatformDependent.allocateDirect(capacity);
        cleanableDirectBuffer.buffer().order(
                PlatformDependent.BIG_ENDIAN_NATIVE_ORDER ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
        return cleanableDirectBuffer;
    }

    /**
     * Returns the memory address of the given direct {@link ByteBuffer}.
     */
    public static long memoryAddress(ByteBuffer buffer) {
        assert buffer.isDirect();
        if (PlatformDependent.hasUnsafe()) {
            return PlatformDependent.directBufferAddress(buffer);
        }
        return memoryAddress0(buffer);
    }

    /**
     * Returns the size of a pointer.
     */
    public static int addressSize() {
        if (PlatformDependent.hasUnsafe()) {
            return PlatformDependent.addressSize();
        }
        return addressSize0();
    }

    // If Unsafe can not be used we will need to do JNI calls.
    private static native int addressSize0();
    private static native long memoryAddress0(ByteBuffer buffer);

    public static ByteBuffer wrapMemoryAddressWithNativeOrder(long memoryAddress, int capacity) {
        return wrapMemoryAddress(memoryAddress, capacity).order(ByteOrder.nativeOrder());
    }

    public static native ByteBuffer wrapMemoryAddress(long memoryAddress, int capacity);
}

Frequently Asked Questions

What is the Buffer class?
Buffer is a class in the netty codebase, defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/Buffer.java.
Where is Buffer defined?
Buffer is defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/Buffer.java at line 25.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free