Java has sum types - they are fairly recent, called sealed records, and can be exhaustively pattern matched on.
(I do agree however, Java is a great target for LLMs)