IntelliJ IDEA
IntelliJ IDEA – the Leading Java and Kotlin IDE, by JetBrains
Java 18 Features Support
Java 18 has now been released, and starting from version 2022.1, IntelliJ IDEA offers support for it.
Support for code snippets
The @snippet tag for JavaDoc’s Standard Doclet was introduced in JDK 18 to simplify the inclusion of example source code in API documentation.
Even without an explicit wrapper, the snippet fragment is still recognized as Java code. Any language can be specified, and the language injection features will work for the snippets as well. For example, navigable references will work for all the elements available through imports:
It is not necessary to write all of the code in the snippet with the binding from the class. The fragment will be recognized similarly to JShell fragments by IntelliJ IDEA.
Patterns for switch expressions: the second preview
The specification for pattern matching for switch expressions, introduced in JDK17, has now been updated with the two basic changes that are already supported in IntelliJ IDEA:
- Any type of pattern (including guarded patterns) dominates constant cases. Dominance for pattern and non-constant cases is unchanged.
- For sealed hierarchies, subtypes are occasionally not possible for, or not castable to, the selector type. You no longer need to handle these subtypes to make the switch statements exhaustive.
Other updates
Since Java 18, non-static inner classes (anonymous or not) don’t capture `this` if it’s not used, so the inspection Cleaner captures object reference has been updated accordingly. It will not trigger the following warning in code:
Additionally, in JDK18 the default charset is now UTF-8, instead of there being different default charsets depending on the platform. The Implicit platform default charset inspection, which reports the method and the constructor calls that implicitly use the platform’s default charset, has been updated accordingly.