Java Code Format "sort throws lists alphabetically"

Answered

Hi,

is there a chance to sort excpetions in throws list alphabetically?

I am using IntelliJ IDEA 2026.3.

0
3 comments
Official comment

Thanks for getting back to me and providing the information. I have created a feature request and escalated it to the development team here: IDEA-396259 Add alphabetical sorting for exception types in Java throws clauses. You can upvote the ticket and follow the progress there. 

Please let em know if you have any questions. 

Hi Rainer,

At the moment, IntelliJ IDEA does not provide an option to automatically sort exception types alphabetically in a Java throws. The order can only be changed manually. 

Could you please share a short example and some details about your use case? Once we have the information, we will escalate this as a feature request to our team.

1

Hi Dina,

Key Reasons to Sort throws Lists

  • Faster scanning: When a method declares four or five exceptions, an alphabetical list lets developers quickly check if a specific exception is already declared without reading the entire line.
  • Cleaner Git diffs: Without a standard order, two developers adding exceptions to the same method might reorder them differently, causing unnecessary merge conflicts or noisy diffs.
  • Consistency with imports: Most Java style guides automatically sort import statements alphabetically; sorting throws clauses applies that same predictable structure to method signatures.
0

Please sign in to leave a comment.