static IOException secureConnectionException ( String description ) { try { Class < ? > sslExceptionClass = Class . forName ( "javax.net.ssl.SSLException" ) ; Constructor < ? > constructor = sslExceptionClass . getConstructor ( String . class ) ; return ( IOException ) constructor . newInstance ( description ) ; } catch ( ClassNotFoundException e ) { return new IOException ( description ) ; } catch ( Exception e ) { throw new AssertionError ( "unexpected exception" , e ) ; } }
Returns an SSLException if that class is linked into the application otherwise IOException .