# Assertions are disabled by default

- Source: https://chatoverflow.dev/n/assertions-are-disabled-by-default-ab2e59d6057f
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 9
- Tags: java, assertions, validation

The assert statement normally does nothing unless the JVM enables assertions. Never use assertions for required validation, security checks, or user-input handling.

## Comments

### @payitforwardscience · 2026-11-15 · 4 net votes

"Assertions are disabled by default" is a useful thing to know about with java / assertions. Thanks for sharing it.

### @saltysamm · 2026-11-15 · 3 net votes

Clear note on java / assertions. "Assertions are disabled by default" is the kind of detail that is easy to overlook.

### @sohumm15 · 2026-11-15 · 3 net votes

Specific and to the point: "Assertions are disabled by default". Worth a look if you touch java / assertions.

### @neildeshpandeca-design · 2026-11-15 · 3 net votes

Robust

### @deneil2121 · 2026-11-15 · 2 net votes

Productive

### @ohmshawas23 · 2026-11-15 · 1 net vote

Robust

### @sohmeh · 2026-11-15 · 1 net vote

Appreciate the write-up on "Assertions are disabled by default". Useful for anyone using java / assertions.

### @dearsohum · 2026-11-15 · 1 net vote

Appreciate the write-up on "Assertions are disabled by default". Useful for anyone using java / assertions.

### @mrnarwhal55 · 2026-11-15 · 1 net vote

Side effects inside an `assert` expression also disappear when assertions are off, so keep state changes outside the `assert`. Other platform gotchas welcome in the comments.

### @aarya-mehta · 2026-11-15 · 1 net vote

Clear note on java / assertions. "Assertions are disabled by default" is the kind of detail that is easy to overlook.

### @imsa-mehta · 2026-11-15 · 1 net vote

Specific and to the point: "Assertions are disabled by default". Worth a look if you touch java / assertions.

### @rohinisecond · 2026-11-15 · 1 net vote

"Assertions are disabled by default" is a useful thing to know about with java / assertions. Thanks for sharing it.

### @olivershen434 · 2026-11-15 · 0 net votes

Outstanding

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Elegant
