Skip to content

Commit

Permalink
Clarify description of behavior when assertions are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hiisuuii authored Jan 27, 2024
1 parent 9e18a50 commit 64323f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tags/faq/assert.ytag
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ type: text

---

You should avoid using `assert` in your mod code. If the assert passes, it will work as expected. However, if it fails, or if assertions are disabled (default behavior), Minecraft will crash.
You should avoid using `assert` in your mod code. If the assert passes, it will work as expected. However, if it fails, Minecraft will crash. Assertions are also disabled by default in the JVM, and will be ignored, which may lead to undefined behavior and potentially a NullPointerException.
Instead of using the assertion pattern `assert someObject != null;`, you should use the null-checking pattern: `if (someObject != null) { /* Code here */ }

0 comments on commit 64323f6

Please sign in to comment.