private static void overrideExceptionValue ( ) { Field exceptionField = null ; Field modifiersField = null ; int originalModifiers = 0 ; boolean setModifiers = false ; try { exceptionField = OpenSsl . class . getDeclaredField ( "UNAVAILABILITY_CAUSE" ) ; exceptionField . setAccessible ( true ) ; modifiersField = exceptionField . getClass ( ) . getDeclaredField ( "modifiers" ) ; modifiersField . setAccessible ( true ) ; originalModifiers = modifiersField . getInt ( exceptionField ) ; modifiersField . setInt ( exceptionField , originalModifiers & ~ Modifier . FINAL ) ; setModifiers = true ; // Override the default value. This will trigger the static block to run which tries to load the libs, // however we know that will fail. exceptionField . set ( null , null ) ; } catch ( Throwable t ) { throw Throwables . propagate ( t ) ; } finally { // Restore the fields to their original values if ( exceptionField != null && modifiersField != null & setModifiers ) { try { modifiersField . setInt ( exceptionField , originalModifiers ) ; } catch ( IllegalAccessException e ) { // Allow the original exception to propagate instead. return ; } } } }
the library .