What's the key differences between Java 8 vs Java 17?
GC — Java 8 defaults to Parallel GC (rare but long pauses). Java 9+ defaults to G1 (frequent but short pauses). Both do Full GC if memory leaks exist.
Strings — Java 8 stores every character as 2 bytes. Java 9+ stores Latin characters as 1 byte, falls back to 2 bytes for Cyrillic/Chinese. Automatic memory saving, zero code changes.
PermGen → Metaspace — Java 8 removed PermGen (fixed-size box for class metadata) and replaced it with Metaspace (grows dynamically using native memory). Old -XX:MaxPermSize flags silently ignored.
Reflection locked down — Java 9+ introduced the module system and restricted access to internal JDK classes like sun.misc.Unsafe. Java 9-15 showed warnings. Java 16+ throws hard errors. This broke Hibernate, Spring, and hundreds of libraries. Main reason companies stayed on Java 8 for years.
New language features — Records (one-line DTOs), sealed classes (controlled inheritance), pattern matching (no manual casting after instanceof), text blocks (multiline strings). None exist in Java 8.
JIT — Java 8 had C1 and C2 compilers separately. Java 9+ introduced tiered compilation by default — C1 compiles quickly first, C2 recompiles hot methods with deeper optimisations. Faster warm-up.
API additions — var for local variables (Java 10), new HttpClient (Java 11), helpful NullPointerException messages showing exactly which reference was null (Java 14), Stream.toList() shortcut (Java 16).
#java8 #java9+
GC — Java 8 defaults to Parallel GC (rare but long pauses). Java 9+ defaults to G1 (frequent but short pauses). Both do Full GC if memory leaks exist.
Strings — Java 8 stores every character as 2 bytes. Java 9+ stores Latin characters as 1 byte, falls back to 2 bytes for Cyrillic/Chinese. Automatic memory saving, zero code changes.
PermGen → Metaspace — Java 8 removed PermGen (fixed-size box for class metadata) and replaced it with Metaspace (grows dynamically using native memory). Old -XX:MaxPermSize flags silently ignored.
Reflection locked down — Java 9+ introduced the module system and restricted access to internal JDK classes like sun.misc.Unsafe. Java 9-15 showed warnings. Java 16+ throws hard errors. This broke Hibernate, Spring, and hundreds of libraries. Main reason companies stayed on Java 8 for years.
New language features — Records (one-line DTOs), sealed classes (controlled inheritance), pattern matching (no manual casting after instanceof), text blocks (multiline strings). None exist in Java 8.
JIT — Java 8 had C1 and C2 compilers separately. Java 9+ introduced tiered compilation by default — C1 compiles quickly first, C2 recompiles hot methods with deeper optimisations. Faster warm-up.
API additions — var for local variables (Java 10), new HttpClient (Java 11), helpful NullPointerException messages showing exactly which reference was null (Java 14), Stream.toList() shortcut (Java 16).
#java8 #java9+