Home / Class/ Zstd Class — netty Architecture

Zstd Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  f763e84e_7407_b0a4_1a72_45ba8e5b515d["Zstd"]
  27dd94d6_7b02_40cd_ad43_c80da7a0ced8["Zstd.java"]
  f763e84e_7407_b0a4_1a72_45ba8e5b515d -->|defined in| 27dd94d6_7b02_40cd_ad43_c80da7a0ced8
  288ca2bd_3429_1b22_382b_c61b66f4f4fd["isAvailable()"]
  f763e84e_7407_b0a4_1a72_45ba8e5b515d -->|method| 288ca2bd_3429_1b22_382b_c61b66f4f4fd
  8bb355e6_2a47_02ce_4918_92ba9de5a64c["ensureAvailability()"]
  f763e84e_7407_b0a4_1a72_45ba8e5b515d -->|method| 8bb355e6_2a47_02ce_4918_92ba9de5a64c
  7483d849_4aad_b442_5498_3c87cf541c1b["Throwable()"]
  f763e84e_7407_b0a4_1a72_45ba8e5b515d -->|method| 7483d849_4aad_b442_5498_3c87cf541c1b
  9ba9be07_2b85_2881_e8ea_71108da3c000["Zstd()"]
  f763e84e_7407_b0a4_1a72_45ba8e5b515d -->|method| 9ba9be07_2b85_2881_e8ea_71108da3c000

Relationship Graph

Source Code

codec-compression/src/main/java/io/netty/handler/codec/compression/Zstd.java lines 23–81

public final class Zstd {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(Zstd.class);
    private static final Throwable cause;

    static {
        Throwable t = null;

        try {
            Class.forName("com.github.luben.zstd.Zstd", false,
                PlatformDependent.getClassLoader(Zstd.class));
        } catch (ClassNotFoundException e) {
            t = e;
            logger.debug(
                "zstd-jni not in the classpath; Zstd support will be unavailable.");
        }

        // If in the classpath, try to load the native library and initialize zstd.
        if (t == null) {
            try {
                com.github.luben.zstd.util.Native.load();
            } catch (Throwable e) {
                t = e;
                logger.debug("Failed to load zstd-jni; Zstd support will be unavailable.", t);
            }
        }
        cause = t;
    }

    /**
     *
     * @return true when zstd-jni is in the classpath
     * and native library is available on this platform and could be loaded
     */
    public static boolean isAvailable() {
        return cause == null;
    }

    /**
     * Throws when zstd support is missing from the classpath or is unavailable on this platform
     * @throws Throwable a ClassNotFoundException if zstd-jni is missing
     * or a ExceptionInInitializerError if zstd native lib can't be loaded
     */
    public static void ensureAvailability() throws Throwable {
        if (cause != null) {
            throw cause;
        }
    }

    /**
     * Returns {@link Throwable} of unavailability cause
     */
    public static Throwable cause() {
        return cause;
    }

    private Zstd() {
    }
}

Frequently Asked Questions

What is the Zstd class?
Zstd is a class in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Zstd.java.
Where is Zstd defined?
Zstd is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Zstd.java at line 23.

Analyze Your Own Codebase

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

Try Supermodel Free