Class CRT


  • public final class CRT
    extends java.lang.Object
    This class is responsible for loading the aws-crt-jni shared lib for the current platform out of aws-crt-java.jar. One instance of this class has to be created somewhere to invoke the static initialization block which will load the shared lib
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CRT.UnknownPlatformException
      Exception thrown when we can't detect what platform we're running on and thus can't figure out the native library name/path to load.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int AWS_CRT_SUCCESS  
    • Constructor Summary

      Constructors 
      Constructor Description
      CRT()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void acquireShutdownRef()
      Public API that allows a user to indicate interest in controlling the CRT's time of shutdown.
      static java.lang.String awsErrorName​(int errorCode)
      Given an integer error code from an internal operation, get a corresponding string identifier for it.
      static java.lang.String awsErrorString​(int errorCode)
      Given an integer error code from an internal operation, get a corresponding description for it.
      static int awsLastError()
      Returns the last error on the current thread.
      static void checkJniExceptionContract​(boolean clearException)  
      static void dumpNativeMemory()
      Dump info to logs about all memory currently allocated by native resources.
      static java.lang.String getArchIdentifier()  
      static java.lang.String getCRuntime​(java.lang.String osIdentifier)  
      static java.lang.String getOSIdentifier()  
      static CrtPlatform getPlatformImpl()  
      static boolean isFIPS()  
      static long nativeMemory()  
      static void releaseShutdownRef()
      Public API to release a shutdown reference that blocks CRT shutdown from proceeding.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CRT

        public CRT()
    • Method Detail

      • getCRuntime

        public static java.lang.String getCRuntime​(java.lang.String osIdentifier)
      • getPlatformImpl

        public static CrtPlatform getPlatformImpl()
      • acquireShutdownRef

        public static void acquireShutdownRef()
        Public API that allows a user to indicate interest in controlling the CRT's time of shutdown. The shutdown process works via ref-counting, with a default starting count of 1 which is decremented by a JVM shutdown hook. Each external call to `acquireShutdownRef()` requires a corresponding call to `releaseShutdownRef()` when the caller is ready for the CRT to be shut down. Once all shutdown references have been released, the CRT will be shut down. If the ref count is not properly driven to zero (and thus leaving the CRT active), the JVM may crash if unmanaged native code in the CRT is still busy and attempts to call back into the JVM after the JVM cleans up JNI.
      • releaseShutdownRef

        public static void releaseShutdownRef()
        Public API to release a shutdown reference that blocks CRT shutdown from proceeding. Must be called once, and only once, for each call to `acquireShutdownRef()`. Once all shutdown references have been released (including the initial reference that is managed by a JVM shutdown hook), the CRT will begin its shutdown process which permanently severs all native-JVM interactions.
      • awsLastError

        public static int awsLastError()
        Returns the last error on the current thread.
        Returns:
        Last error code recorded in this thread
      • awsErrorString

        public static java.lang.String awsErrorString​(int errorCode)
        Given an integer error code from an internal operation, get a corresponding description for it.
        Parameters:
        errorCode - An error code returned from an exception or other native function call
        Returns:
        A user-friendly description of the error
      • awsErrorName

        public static java.lang.String awsErrorName​(int errorCode)
        Given an integer error code from an internal operation, get a corresponding string identifier for it.
        Parameters:
        errorCode - An error code returned from an exception or other native function call
        Returns:
        A string identifier for the error
      • nativeMemory

        public static long nativeMemory()
        Returns:
        The number of bytes allocated in native resources. If aws.crt.memory.tracing is 1 or 2, this will be a non-zero value. Otherwise, no tracing will be done, and the value will always be 0
      • dumpNativeMemory

        public static void dumpNativeMemory()
        Dump info to logs about all memory currently allocated by native resources. The following system properties must be set to see a dump: aws.crt.memory.tracing must be 1 or 2 aws.crt.log.level must be "Trace"
      • checkJniExceptionContract

        public static void checkJniExceptionContract​(boolean clearException)
      • isFIPS

        public static boolean isFIPS()