It's possible to end up with this exception in ssl handshake code : 
Exception in thread "main" java.lang.Error: BAD
        at sun.security.ssl.HandshakeHash.getFinishedHash(HandshakeHash.java:249)
        at sun.security.ssl.HandshakeMessage$Finished.getFinished(HandshakeMessage.java:1945)
        at sun.security.ssl.HandshakeMessage$Finished.<init>(HandshakeMessage.java:1892)
        at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1192)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1112)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
That's not too informative. We should set the cause of exception when throwing an Error.