RuntimeException

RuntimeException ist eine unchecked Exception in Java.

Muss nicht im Methoden-Signatur deklariert werden — der Compiler zwingt dich nicht.

I. Beispiele


II. Verhalten bei CMT


In Jakarta EE mit CMT:

@Stateless
public class FooService {
    public void doIt() {
        throw new RuntimeException("oops");
        // → Container rollbackt die TX automatisch
    }
}

III. Unterschied zu Checked


RuntimeException Checked Exception
Compiler erzwingt try/catch?
throws im Signatur? optional Pflicht
Rollback bei CMT?