Home / File/ VarHandleByteBufferAccess.java — netty Source File

VarHandleByteBufferAccess.java — netty Source File

Architecture documentation for VarHandleByteBufferAccess.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2025 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.buffer;

import io.netty.util.internal.PlatformDependent;

import java.nio.ByteBuffer;

/**
 * Centralizes all ByteBuffer VarHandle get/set calls so classes like UnpooledDirectByteBuf
 * don't directly reference signature-polymorphic methods. This allows avoiding class verification
 * failures on older Android runtimes by not loading this class when VarHandle is disabled.
 *
 * Methods here must only be called when PlatformDependent.hasVarHandle() is true.
 */
final class VarHandleByteBufferAccess {

    private VarHandleByteBufferAccess() {
    }

    // short (big endian)
    static short getShortBE(ByteBuffer buffer, int index) {
        //noinspection DataFlowIssue
        return (short) PlatformDependent.shortBeByteBufferView().get(buffer, index);
    }

    static void setShortBE(ByteBuffer buffer, int index, int value) {
        //noinspection DataFlowIssue
        PlatformDependent.shortBeByteBufferView().set(buffer, index, (short) value);
    }

    // short (little endian)
    static short getShortLE(ByteBuffer buffer, int index) {
        //noinspection DataFlowIssue
        return (short) PlatformDependent.shortLeByteBufferView().get(buffer, index);
    }

    static void setShortLE(ByteBuffer buffer, int index, int value) {
        //noinspection DataFlowIssue
        PlatformDependent.shortLeByteBufferView().set(buffer, index, (short) value);
    }

    // int (big endian)
    static int getIntBE(ByteBuffer buffer, int index) {
        //noinspection DataFlowIssue
        return (int) PlatformDependent.intBeByteBufferView().get(buffer, index);
    }
// ... (114 more lines)

Domain

Subdomains

Frequently Asked Questions

What does VarHandleByteBufferAccess.java do?
VarHandleByteBufferAccess.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is VarHandleByteBufferAccess.java in the architecture?
VarHandleByteBufferAccess.java is located at buffer/src/main/java/io/netty/buffer/VarHandleByteBufferAccess.java (domain: Buffer, subdomain: Allocators, directory: buffer/src/main/java/io/netty/buffer).

Analyze Your Own Codebase

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

Try Supermodel Free