Home / Class/ PlatformDependent Class — netty Architecture

PlatformDependent Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  2e66d079_807f_6785_864f_73ab09fbc515["PlatformDependent"]
  2a0673d5_1a45_ed74_0c46_7c4c3869c36d["PlatformDependent.java"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|defined in| 2a0673d5_1a45_ed74_0c46_7c4c3869c36d
  a0623413_f738_fef2_6101_d4b2ab01c570["initializeVarHandle()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| a0623413_f738_fef2_6101_d4b2ab01c570
  1c895ca2_fef1_2d9b_57c3_408b0d38cf3d["addFilesystemOsClassifiers()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| 1c895ca2_fef1_2d9b_57c3_408b0d38cf3d
  04af2971_ee46_5718_75c6_cb4b676d93ea["processOsReleaseFile()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| 04af2971_ee46_5718_75c6_cb4b676d93ea
  8d550031_ad67_8727_7ea7_dfb705fd8fb7["addPropertyOsClassifiers()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| 8d550031_ad67_8727_7ea7_dfb705fd8fb7
  a68b070d_016c_94fa_e049_521c627e73b6["byteArrayBaseOffset()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| a68b070d_016c_94fa_e049_521c627e73b6
  f2b6c96b_f0bc_42c1_81fd_e94d3a4d91a7["hasDirectBufferNoCleanerConstructor()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| f2b6c96b_f0bc_42c1_81fd_e94d3a4d91a7
  b5b1595a_81ae_ef62_8737_018138ea19a0["allocateUninitializedArray()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| b5b1595a_81ae_ef62_8737_018138ea19a0
  cd0f3e2f_a298_63fb_1f2c_ebcadecc3718["isAndroid()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| cd0f3e2f_a298_63fb_1f2c_ebcadecc3718
  f7450d1a_26c5_6254_a9c1_34426a5636a9["isWindows()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| f7450d1a_26c5_6254_a9c1_34426a5636a9
  83edde2e_7611_b57b_eafc_208e2112e6d7["isOsx()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| 83edde2e_7611_b57b_eafc_208e2112e6d7
  4c94489b_a7a2_f967_7904_4f43ca03cca3["maybeSuperUser()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| 4c94489b_a7a2_f967_7904_4f43ca03cca3
  faa8d681_9f8a_8e8e_1440_f5d53f9bd60c["javaVersion()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| faa8d681_9f8a_8e8e_1440_f5d53f9bd60c
  e61c9144_b6b1_83e7_f25c_d63294eff009["isVirtualThread()"]
  2e66d079_807f_6785_864f_73ab09fbc515 -->|method| e61c9144_b6b1_83e7_f25c_d63294eff009

Relationship Graph

Source Code

common/src/main/java/io/netty/util/internal/PlatformDependent.java lines 87–1910

public final class PlatformDependent {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(PlatformDependent.class);

    private static Pattern MAX_DIRECT_MEMORY_SIZE_ARG_PATTERN;
    private static final boolean MAYBE_SUPER_USER;

    private static final boolean CAN_ENABLE_TCP_NODELAY_BY_DEFAULT = !isAndroid();

    private static final Throwable UNSAFE_UNAVAILABILITY_CAUSE = unsafeUnavailabilityCause0();
    private static final boolean DIRECT_BUFFER_PREFERRED;
    private static final boolean EXPLICIT_NO_PREFER_DIRECT;
    private static final long MAX_DIRECT_MEMORY = estimateMaxDirectMemory();

    private static final int MPSC_CHUNK_SIZE =  1024;
    private static final int MIN_MAX_MPSC_CAPACITY =  MPSC_CHUNK_SIZE * 2;
    private static final int MAX_ALLOWED_MPSC_CAPACITY = Pow2.MAX_POW2;

    private static final long BYTE_ARRAY_BASE_OFFSET = byteArrayBaseOffset0();

    private static final File TMPDIR = tmpdir0();

    private static final int BIT_MODE = bitMode0();
    private static final String NORMALIZED_ARCH = normalizeArch(SystemPropertyUtil.get("os.arch", ""));
    private static final String NORMALIZED_OS = normalizeOs(SystemPropertyUtil.get("os.name", ""));

    private static final Set<String> LINUX_OS_CLASSIFIERS;

    private static final boolean IS_WINDOWS = isWindows0();
    private static final boolean IS_OSX = isOsx0();
    private static final boolean IS_J9_JVM = isJ9Jvm0();
    private static final boolean IS_IVKVM_DOT_NET = isIkvmDotNet0();

    private static final int ADDRESS_SIZE = addressSize0();
    private static final boolean USE_DIRECT_BUFFER_NO_CLEANER;
    private static final AtomicLong DIRECT_MEMORY_COUNTER;
    private static final long DIRECT_MEMORY_LIMIT;
    private static final Cleaner CLEANER;
    private static final Cleaner DIRECT_CLEANER;
    private static final Cleaner LEGACY_CLEANER;
    private static final boolean HAS_ALLOCATE_UNINIT_ARRAY;
    private static final String LINUX_ID_PREFIX = "ID=";
    private static final String LINUX_ID_LIKE_PREFIX = "ID_LIKE=";
    public static final boolean BIG_ENDIAN_NATIVE_ORDER = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;

    private static final boolean JFR;
    private static final boolean VAR_HANDLE;

    private static final Cleaner NOOP = new Cleaner() {
        @Override
        public CleanableDirectBuffer allocate(int capacity) {
            return new CleanableDirectBuffer() {
                private final ByteBuffer byteBuffer = ByteBuffer.allocateDirect(capacity);

                @Override
                public ByteBuffer buffer() {
                    return byteBuffer;
                }

                @Override
                public void clean() {
                    // NOOP
                }
            };
        }

        @Override
        public void freeDirectBuffer(ByteBuffer buffer) {
            // NOOP
        }
    };

    static {
        // Here is how the system property is used:
        //
        // * <  0  - Don't use cleaner, and inherit max direct memory from java. In this case the
        //           "practical max direct memory" would be 2 * max memory as defined by the JDK.
        // * == 0  - Use cleaner, Netty will not enforce max memory, and instead will defer to JDK.
        // * >  0  - Don't use cleaner. This will limit Netty's total direct memory
        //           (note: that JDK's direct memory limit is independent of this).
        long maxDirectMemory = SystemPropertyUtil.getLong("io.netty.maxDirectMemory", -1);

Frequently Asked Questions

What is the PlatformDependent class?
PlatformDependent is a class in the netty codebase, defined in common/src/main/java/io/netty/util/internal/PlatformDependent.java.
Where is PlatformDependent defined?
PlatformDependent is defined in common/src/main/java/io/netty/util/internal/PlatformDependent.java at line 87.

Analyze Your Own Codebase

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

Try Supermodel Free