java.lang APIs
Categories
Composite Recipes
Recipes that include further recipes, often including the individual recipes below.
- A collection of
Stringrules - Find Virtual Thread opportunities
- Find non-virtual
ExecutorServicecreation - Use local variable type inference
- Use modernized
java.langAPIs
Recipes
- Add explicit import for
Recordclasses - Add null check to existing switch cases
- Convert assigning Switch statements to Switch expressions
- Convert switch cases where every case returns into a returned switch expression
- Convert switch expression yield to arrow
- If-else-if-else to switch
- Migrate
public static void main(String[] args)to instancevoid main() - Prefer
String.formatted(Object...) - Replace
0 < s.length()with!s.isEmpty() - Replace
String.indexOf(String, 0)withString.indexOf(String) - Replace
String.indexOf(char, 0)withString.indexOf(char) - Replace
Thread.resume(),Thread.stop(), andThread.suspend()withthrow new UnsupportedOperationException() - Replace lower and upper case
Stringcomparisons withString.equalsIgnoreCase(String) - Replace redundant
Stringmethod calls with self - Replace unused variables with underscore
- Use
Character#isJavaIdentifierPart(char) - Use
Character#isJavaIdentifierStart(char) - Use
Character#isWhitespace(char) - Use
Class#getDeclaredConstructor().newInstance() - Use
ClassLoader#defineClass(String, byte[], int, int) - Use
Process#waitFor(Duration) - Use
Runtime.Version#feature() - Use
Runtime.Version#interim() - Use
Runtime.Version#update() - Use
SecurityManager#checkMulticast(InetAddress) - Use switch cases labels for enums
- Use switch cases refinement when possible
- Use text blocks