- Java 10 includes parallel full GC for G1 to improve performance of full garbage collections.
- It introduces an experimental Graal JIT compiler, though it is not recommended for production use.
- Application class-data sharing allows sharing of JDK classes to reduce startup times.
- Other improvements include thread-local handshakes, Docker awareness, planned removals for JDK 11, and local variable type inference using 'var'.
3. sbordet@webtide.com
Java 10 - Updates
● Parallel full GC for G1
● In Java 9, if G1 must perform a full GC it’s single threaded
○ Very slow
● In Java 10, it has been parallelized
[5.423s] GC(59) Pause Full 4028M->3286M(4096M) 513.026ms
[5.423s] GC(59) User=2.80s Sys=0.04s Real=0.52s
4. sbordet@webtide.com
Java 10 - Updates
● Experimental Graal JIT
○ https://www.graalvm.org/
● -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
● Not yet recommended in production
6. sbordet@webtide.com
Java 10 - Updates
● Thread-Local Handshakes
● Improves JVM performance
○ Reduces Time-To-SafePoint (TTSP)
● No need to have a global SafePoint to get stack traces
○ Great benefit to profilers for stack sampling
7. sbordet@webtide.com
Java 10 - Updates
● Docker awareness (Linux only)
○ https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/
○ It is on by default
● -XX:-UseContainerSupport
● -XX:ActiveProcessorCount=n
● -XX:MinRAMPercentage=p
● -XX:InitialRAMPercentage=p
● -XX:MaxRAMPercentage=p
9. sbordet@webtide.com
Java 10 - Updates
● Local variable type inference (a.k.a. var)
○ http://openjdk.java.net/projects/amber/LVTIstyle.html
var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
● var is not a keyword, it is a reserved type name
○ It’s a valid identifier, unless used in places where the compiler expects a type name
int var = 13;
10. sbordet@webtide.com
Java 10 - Updates
Object anon = new Object() {
int count = 0;
}
anon.count++; // Does not compile
var anon = new Object() {
int count = 0;
}
anon.count++; // Compiles
11. sbordet@webtide.com
Java 10 - Updates
● var comes with some controversy
var message = "warning, too many features"; // Good
● Consider:
List<String> list = new ArrayList<>();
list.trimToSize(); // Does not compile
var list = new ArrayList<String>();
list.trimToSize(); // Compiles
12. sbordet@webtide.com
Java 10 - Updates
● More controversy:
var result = processor.run(); // What type ?
var list = new <ctrl+space> // IDE cannot help you
13. sbordet@webtide.com
Java 10 - Updates
● And even more controversy for refactorings:
public void Runnable wrap(Task task);
var wrapped = wrap(task);
wrapped.run();
● After refactoring:
public void Wrapped wrap(Task task);
var wrapped = wrap(task);
wrapped.run(); // Same run() semantic as before ?