11---
22name : java-developer
3- description : Guide for developing in Java 17 LTS , including modern features, best practices, and integration with Groovy/Grails projects
3+ description : Guide for developing on the Java 21 baseline , including modern features, best practices, and integration with Groovy/Grails projects
44license : Apache-2.0
55---
66<!--
@@ -11,8 +11,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more contributor l
1111
1212## What I Do
1313
14- - Provide guidance on Java 17 LTS syntax, features, and APIs for use in Grails/Groovy projects.
15- - Assist with code generation, refactoring, and debugging using Java 17 enhancements like records, sealed classes, pattern matching, and text blocks.
14+ - Provide guidance on Java 21 syntax, features, and APIs for use in Grails/Groovy projects.
15+ - Assist with code generation, refactoring, and debugging using modern Java features like records, sealed classes, pattern matching, and text blocks.
1616- Recommend best practices for Java code that interoperates with Groovy in mixed-language projects.
1717- Guide on tooling: Gradle builds, JDK setup, testing with JUnit 5/Spock, and profiling.
1818
@@ -21,11 +21,11 @@ Licensed to the Apache Software Foundation (ASF) under one or more contributor l
2121Use this skill when working on Java code within this repository, especially for:
2222- Writing Java classes that will be used alongside Groovy code.
2323- Implementing features using records, sealed classes, or pattern matching for instanceof.
24- - Migrating older Java code (e.g., Java 8/11) to Java 17 idioms.
24+ - Migrating older Java code (e.g., Java 8/11/17 ) to Java 21 idioms.
2525- Performance optimization, security hardening, or module system (JPMS) questions.
2626- Understanding how Java code integrates with Groovy's dynamic features.
2727
28- ## Java 17 Key Features
28+ ## Java 21 Baseline Features
2929
3030### Records (JEP 395)
3131Immutable data carriers with auto-generated constructors, accessors, equals, hashCode, and toString:
@@ -61,13 +61,13 @@ public non-sealed class Rectangle implements Shape {
6161### Pattern Matching for instanceof (JEP 394)
6262Eliminate redundant casts:
6363``` java
64- // Before Java 17
64+ // Before pattern matching
6565if (obj instanceof String ) {
6666 String s = (String ) obj;
6767 System . out. println(s. length());
6868}
6969
70- // Java 17
70+ // Modern Java
7171if (obj instanceof String s) {
7272 System . out. println(s. length());
7373}
@@ -200,7 +200,7 @@ def "Java record should work in Spock tests"() {
200200
201201## Performance and Profiling
202202
203- ### JVM Options for Java 17
203+ ### JVM Options for Java 21
204204``` bash
205205# Recommended GC for most workloads
206206-XX:+UseG1GC
@@ -266,6 +266,6 @@ List<String> copy = List.copyOf(mutableList);
266266
267267## Resources
268268
269- - ** Java 17 Documentation** : https://docs.oracle.com/en/java/javase/17 /
270- - ** Java Language Updates** : https://docs.oracle.com/en/java/javase/17 /language/
269+ - ** Java 21 Documentation** : https://docs.oracle.com/en/java/javase/21 /
270+ - ** Java Language Updates** : https://docs.oracle.com/en/java/javase/21 /language/
271271- ** JEP Index** : https://openjdk.org/jeps/0
0 commit comments