2
mampf
6y

I really cannot see why there still isn't an API in Java where I can get an hashing algorithm without having to catch a checked exception.

Granted, Bouncy castle is a top library. But of you just have a small application with a single method wanting to hash a few values... It's so nuts and unnecessary.

So what do you do in the catch block? Either throw a checked exception (because without that hash your app won't work), or calculate a replacement. But if it were that easy, I wouldn't have needed a hash on the first place.

I really wonder what the java developers had in mind.

Same with IO exception. I'm beginning to like python more and more.
And, of course, kotlin.

Comments
  • 1
    If you just have a small application maybe dont use a language designed solely for enterprise use
  • 0
    Checked exceptions are one of the most hated features of Java. They can be really annoying, especially if you use lambda expressions.

    You can do something like this:

    } catch(IOException e) {

    throw new RuntimeException(e);

    }

    http://literatejava.com/exceptions/...
  • 0
    @sharktits it is for my company and we do not reply have anything other available besides python and perl without any 3rd party modules. So it's Java and Jackson.
  • 0
    @xonya that's what I said I do.
    But the more enterprise it's going to be, the more ugly code I see. We have colleagues who will just ignore those.
  • 0
    Java is a nice and powerful language.
    Sadly, checked exceptions are somewhat abused in many official parts (IOException in many places, SQLException in JDBC, to name the most notorious ones).
    Anyways rethrowing to unchecked one is the way to deal with it, if you don't have any alternative to act on it in the place where it is thrown.
Add Comment