How to throw unexpected checked exceptions

Today I found that it is possible to throw checked exceptions even if they are not declared in throws section.
What did we do when we have need to throw some checked exception? We do:

public void doSomething() throws CannotDoSomethingException {
throw new CannotDoSomethingException();


public class CannotDoSomethingException extends Exception {

But we can to throw the checked exception without declaring it at throws section:

public void doSomething() {
Thread.currenThread().stop(new CannotDoSomethingException());

I think that this is veeeery bad code

No comments: