Pearsonjava 9 To 211720732430043
Pearsonjava 9 To 211720732430043
Henri Tremblay
Managing Director, Head of TS Imagine Canada
TS Imagine
@henri_tremblay
Alumni
• More or less made possible class mocking and proxying
• Coined the term “partial mocking”
2
o l d s h i nny
G o o d New &
8 21
3
Source code
https://github.com/henri-tremblay/java91011beyond
4
POLL
6
Questions
?
7
Java Delivery Process
8
Delivery process
Support up to 2030
Support up to 2026
11
JXX
JCP: Java Community Process
Responsible of Java governance
JLS: Java Language Specification
This is a specification for the Java Language
JSR: Java Specification Request
Big piece of Java change submitted to JCP
JEP: Java Enhancement Proposal
Little pieces of Java change
https://openjdk.java.net/projects/jdk/ii/
12
Projects
https://openjdk.java.net/projects/
13
JEPs of projects
Amber:
JEP 361: Switch Expressions
JEP 389: Text Blocks
JEP 394: Pattern Matching for instanceof
JEP 395: Record
JEP 405: Record Patterns & Array Patterns (Preview)
JEP 406: Pattern matching for switch (Preview)
JEP 409: Sealed Classes
Valhalla:
JEP 374: Disable and Deprecate Biased Locking
JEP 390: Warnings for Value-Based Classes
JEP 401: Primitive Objects (Preview)
JEP 402: Unify the Basic Primitives with Objects (Preview)
Loom:
JEP 353: Reimplement the Legacy Socket API
JEP 373: Reimplement the Legacy DatagramSocket API
14
Trends
15
Trend #1
@Deprecated
is back
Stronger than ever
16
/**
* Counts the number of stack frames in this thread. The thread must
* be suspended.
*
* @return the number of stack frames in this thread.
* @throws IllegalThreadStateException if this thread is not
* suspended.
* @deprecated The definition of this call depends on {@link #suspend},
* which is deprecated. Further, the results of this call
* were never well-defined.
* This method is subject to removal in a future version of Java SE.
* @see StackWalker
*/
@Deprecated(since="1.2", forRemoval=true)
public native int countStackFrames();
17
Classes and methods removed
Unsafe.defineClass() Unsafe.defineClass()
removed
MethodHandles.defineClass()
18
Entire module removed
19
Trend #2
Encapsulation
The party is over
20
Trend #3
Garbage Collector
Java < 8 Java 11 Java 21
• Serial • Epsilon • Generational Z
• Parallel • Z (Experimental)
• ParallelOld
• CMS Java 12
• iCMS • Shenandoah (Experimental)
Java 8 Java 14
• G1 • Remove CMS
Java 9 Java 15
• Removed iCMS • Shenandoah
• G1 (Default GC) • Z
21
Trend #4
Developer efficiency
22
Trend #5
Performance
23
Legend
Deprecation
Garbage Collector
Encapsulation
Developer efficiency
Performance
24
Java 9
(September 2017)
25
Modules
102: Process API Updates 238: Multi-Release JAR Files 273: DRBG-Based SecureRandom Implementations
110: HTTP 2 Client 240: Remove the JVM TI hprof Agent 274: Enhanced Method Handles
143: Improve Contended Locking 241: Remove the jhat Tool 275: Modular Java Application Packaging
158: Unified JVM Logging 243: Java-Level JVM Compiler Interface 276: Dynamic Linking of Language-Defined Object Models
165: Compiler Control 244: TLS Application-Layer Protocol Negotiation Extension 277: Enhanced Deprecation
193: Variable Handles 245: Validate JVM Command-Line Flag Arguments 278: Additional Tests for Humongous Objects in G1
197: Segmented Code Cache 246: Leverage CPU Instructions for GHASH and RSA 279: Improve Test-Failure Troubleshooting
199: Smart Java Compilation, Phase Two 247: Compile for Older Platform Versions 280: Indify String Concatenation
200: The Modular JDK 248: Make G1 the Default Garbage Collector 281: HotSpot C++ Unit-Test Framework
201: Modular Source Code 249: OCSP Stapling for TLS 282: jlink: The Java Linker
211: Elide Deprecation Warnings on Import Statements 250: Store Interned Strings in CDS Archives 283: Enable GTK 3 on Linux
212: Resolve Lint and Doclint Warnings 251: Multi-Resolution Images 284: New HotSpot Build System
213: Milling Project Coin 252: Use CLDR Locale Data by Default 285: Spin-Wait Hints
214: Remove GC Combinations Deprecated in JDK 8 253: Prepare JavaFX UI Controls & CSS APIs for 287: SHA-3 Hash Algorithms
215: Tiered Attribution for javac Modularization 288: Disable SHA-1 Certificates
216: Process Import Statements Correctly 254: Compact Strings 289: Deprecate the Applet API
217: Annotations Pipeline 2.0 255: Merge Selected Xerces 2.11.0 Updates into JAXP 290: Filter Incoming Serialization Data
219: Datagram Transport Layer Security (DTLS) 256: BeanInfo Annotations 291: Deprecate the Concurrent Mark Sweep (CMS) Garbage
220: Modular Run-Time Images 257: Update JavaFX/Media to Newer Version of GStreamer Collector
221: Simplified Doclet API 258: HarfBuzz Font-Layout Engine 292: Implement Selected ECMAScript 6 Features in Nashorn
222: jshell: The Java Shell (Read-Eval-Print Loop) 259: Stack-Walking API 294: Linux/s390x Port
223: New Version-String Scheme 260: Encapsulate Most Internal APIs 295: Ahead-of-Time Compilation
224: HTML5 Javadoc 261: Module System 297: Unified arm32/arm64 Port
225: Javadoc Search 262: TIFF Image I/O 298: Remove Demos and Samples
226: UTF-8 Property Files 263: HiDPI Graphics on Windows and Linux 299: Reorganize Documentation
227: Unicode 7.0 264: Platform Logging API and Service Deprecation
228: Add More Diagnostic Commands 265: Marlin Graphics Renderer
229: Create PKCS12 Keystores by Default 266: More Concurrency Updates Garbage Collector
231: Remove Launch-Time JRE Version Selection 267: Unicode 8.0
232: Improve Secure Application Performance 268: XML Catalogs Encapsulation
233: Generate Run-Time Compiler Tests Automatically 269: Convenience Factory Methods for Collections
235: Test Class-File Attributes Generated by javac 270: Reserved Stack Areas for Critical Sections
Developer efficiency
236: Parser API for Nashorn 271: Unified GC Logging
237: Linux/AArch64 Port 272: Platform-Specific Desktop Features
Performance
26
Modern mustache instantiation
27
Immutable collections
28
Slightly longer map instantiation
29
Improved try-with-resource
try(in) {
Instead of
}
30
Interface private methods
31
Java SE Modules
Credits: Oracle
32
Modules
33
5 minutes break
34
Java 10
JSR 383 (March 2018)
35
Var!
JEP 286: Local-Variable Type Inference
JEP 296: Consolidate the JDK Forest into a Single Repository
JEP 304: Garbage-Collector Interface
JEP 307: Parallel Full GC for G1
JEP 310: Application Class-Data Sharing
JEP 312: Thread-Local Handshakes
JEP 313: Remove the Native-Header Generation Tool (javah)
JEP 314: Additional Unicode Language-Tag Extensions
JEP 316: Heap Allocation on Alternative Memory Devices
JEP 317: Experimental Java-Based JIT Compiler Deprecation
Garbage Collector
JEP 319: Root Certificates
Encapsulation
JEP 322: Time-Based Release Versioning Developer efficiency
Performance
36
Var inference 13
37
What is var?
Keywords
while, if, abstract, public, default,
class, enum (Java 5), _ (Java 9)
Restricted Keywords
open, module, to, with
Literals
true, false, null
Reserved identifier
var
38
Var inference 14
39
Java 11
JSR 384 (September 2018)
40
Cleanup!
41
HTTP Client 24
42
Single file program Java11
43
Var in a lambda, Var inference bis 14
44
Java 12
JSR 386 (March 2019)
45
Switch expressions!
Deprecation
Garbage Collector
Encapsulation
Developer efficiency
Performance
46
Switch expressions
private boolean isWeekDay(DayOfWeek day) {
boolean weekDay;
switch(day) {
case MONDAY:
case TUESDAY:
case WEDNESDAY:
case THURSDAY:
case FRIDAY:
weekDay = true;
break;
case SATURDAY:
case SUNDAY:
weekDay = false;
default:
throw new IllegalStateException("A new day was added in my week: " + day);
}
return weekDay;
}
47
Switch expressions
private boolean isWeekDay(DayOfWeek day) {
boolean weekDay;
switch(day) {
case MONDAY:
case TUESDAY:
case WEDNESDAY:
case THURSDAY:
case FRIDAY:
weekDay = true;
break;
case SATURDAY:
case SUNDAY:
weekDay = false;
break;
default:
throw new IllegalStateException("A new day was added in my week: " + day);
}
return weekDay;
}
48
Switch expressions
private boolean isWeekDay(DayOfWeek day) {
boolean weekDay;
switch(day) {
case MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY -> weekDay = true;
case SATURDAY, SUNDAY -> weekDay = false;
default -> throw new IllegalStateException("A new day was added in my week: " + day);
}
return weekDay;
}
49
Switch expressions
private boolean isWeekDay(DayOfWeek day) {
boolean weekDay = switch(day) {
case MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY -> true;
case SATURDAY, SUNDAY -> false;
default -> throw new IllegalStateException("A new day was added in my week: " + day);
};
return weekDay;
}
50
Switch expressions
private boolean isWeekDay(DayOfWeek day) {
return switch(day) {
case MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY -> true;
case SATURDAY, SUNDAY -> false;
default -> throw new IllegalStateException("A new day was added in my week: " + day);
};
}
51
Java 13
JSR 388 (September 2019)
52
Text Block!
Deprecation
Garbage Collector
Encapsulation
Developer efficiency
Performance
53
Switch expressions (still a preview)
54
Switch expressions, two syntaxes
55
Text Block (JEP 355)
hello();
""";
56
Text Block 16
57
5 minutes break
58
Java 14
JSR 389 (March 2020)
59
Big one
60
Helpful NPE 17
61
Pattern Matching for instanceof 18
62
Records 19
63
Packaging tools (package dir)
64
Java 15
JSR 390 (September 2020)
65
Previews
66
Sealed classes 21
67
Java 16
JSR 391 (March 2021)
68
Make the JDK developers life easier
69
Strongly encapsulate JDK internals by default
70
Value-based Classes 25
71
5 minutes break
72
Java 17
JSR 392 (September 2021)
73
LTS!!!!
74
Pattern Matching for switch 27
75
Java 18
JSR 393 (March 2022)
76
UTF-8 for all
Deprecation
Garbage Collector
Encapsulation
Developer efficiency
Performance
77
UTF-8 by default 30
78
Simple Web Server 31
79
Code Snippets in Java API Documentation 32
80
Java 19
JSR 394 (September 2022)
81
Virtual Threads
Deprecation
Garbage Collector
Encapsulation
Developer efficiency
Performance
82
Record Patterns 33
83
Virtual Threads 34
84
Structured Concurrency 35
85
Java 20
JSR 395 (March 2023)
86
Cool concurrency
Deprecation
Garbage Collector
Encapsulation
Developer efficiency
Performance
87
Scoped Values 36
88
Java 21
JSR 396 (September 2023)
89
LTS!!!!
90
String Templates 37
91
Unnamed Patterns and Variables 38
92
Unnamed Classes and Instance Main Methods - Java21
93
Sequenced Collections 36
94
Conclusion
95
Who has learned
something today?
?
96
Links
Java Champions – Java is still free
https://medium.com/@javachampions/java-is-still-free-3-0-0-ocrt-2021-bca75c88d23b
Inside Java
https://inside.java/
Dev Java
https://dev.java/
Virtual threads
https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html
Var styleguide
http://openjdk.java.net/projects/amber/LVTIstyle.html
Source code
https://github.com/henri-tremblay/java91011beyond
JDK
https://openjdk.java.net/projects/jdk/
https://docs.oracle.com/en/java/javase/
Sdkman
https://sdkman.io/
97
Other courses
Mailing list
https://javaspecialists.eu/courses/oreilly/
Courses by
• Cay Horstmann
• Eric Freeman and Elisabeth Robson
• Heinz Kabutz. Including self-paces ones like
• Learn reflection with Java https://www.oreilly.com/videos/learn-reflection-with/9780138314767/
• Ken Kousen
• Kirk Pepperdine (Memory Efficient Java on July 15)
• Maurice Naftalin (Java Threads Demystified on July 15)
98
http://objenesis.org
Questions? http://montreal-jug.org
Henri Tremblay
Blog: https://blog.tremblay.pro
GitHub: https://github.com/henri-tremblay
?
LinkedIn: https://www.linkedin.com/in/henritremblay/
X: https://twitter.com/henri_tremblay
Mastodon: https://mastodon.world/@henri http://easymock.org
99