Highlights from Java 10, 11 and 12
and Future of Java
Javaland 19.03.2019
by Vadym Kazulkin, ip.labs GmbH
Contact
Vadym Kazulkin, ip.labs GmbH
v.kazulkin@gmail.com
https://www.linkedin.com/in/vadymkazulkin
www.xing.com/profile/Vadym_Kazulkin
@VKazulkin, @ServerlessBonn (Meetup)
ip.labs GmbH
Agenda
● Highlights from Java 10
● Highlights from Java 11
● Highlights from Java 12
● Project Amber (Simplifying syntax)
● Project Valhalla (Value Types and Specialized Generics)
● Project Metropolis (Polyglot GraalVM)
● Project Loom (Fibers and Continuations)
Highlights from Java 10
JEP 286 (Project Amber)
Local-Variable Type Inference
URL url = new URL(„www.javaland.eu“);
URLConnection connection = url.openConnection();
Reader reader = new BufferedReader (
new InputStreamReader(connection.getInputStream()));
var url = new URL(„www.javaland.eu“);
var connection = url.openConnection();
var reader = new BufferedReader (
new InputStreamReader(connection.getInputStream()));
JEP 304
Garbage Collector Interface
Goals:
● Better modularity for HotSpot internal GC code
● Make it simpler to add a new GC to HotSpot without perturbing the current
code base
● Make it easier to exclude a GC from a JDK build
JEP 317
Experimental Java-Based JIT Compiler
Graal, a Java-based JIT compiler on the Linux/x64 platform, is the basis of the
experimental Ahead-of-Time (AOT) compiler introduced in JDK 9.
To Enable:
-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
Miscellaneous API Changes
Better container-awareness
● Before later versions of Java 8
– Runtime.getRuntime().availableProcessors() -> retrieves value from sysconf, means the total
number of processors for VM
– Runtime.getRuntime().maxMemory() -> gets the value for VM overall memory
● Java 9 is container-aware automatically detecting cpusets
JVM considers cgroups memory limits if the following flags are specified:
– -XX:+UseCGroupMemoryLimitForHeap
– -XX:+UnlockExperimentalVMOptions
– Max Heap space will be automatically set (if not overwritten) to the limit specified by the cgroup
Sources: „Improve docker container detection and resource configuration usage” https://bugs.openjdk.java.net/browse/JDK-8146115
„ Better containerized JVMs in JDK 10” https://jaxenter.com/better-containerized-jvms-jdk-10-140593.html
Miscellaneous API Changes
Better container-awareness
● For “fixing” CPU shares in Java 9 overwrite
– -XMX for memory
– -XX:ParallelGCThreads and -XX:ConcGCThreads for CPU
– -System property java.util.concurrent.ForkJoinPool.common.parallelism for ForkJoinPool
● Better container-awareness in Java 10 (CPU shares support is included)
– Runtime.getRuntime().availableProcessors()
– Runtime.getRuntime().maxMemory()
Sources: „Java SE 9 support for Docker CPU and memory limits“https://blogs.oracle.com/java-platform-group/java-se-support-for-
docker-cpu-and-memory-limits „ Nobody puts Java in a container” https://jaxenter.com/nobody-puts-java-container-139373.html
Miscellaneous API Changes
● java.util.List/Set/Map.copyOf(Collection)
● java.util.stream.Collectors.toUnmodifiableList/Set/Map(Stream)
● Optional.orElseThrow()
Highlights from Java 11
JEP 323 (Project Amber)
Local-Variable Syntax for Lambda Parameters
● (x, y) -> x.process(y) // implicitly typed lambda expression
● (var x, var y) -> x.process(y) // implicit typed lambda expression
● (@NonNull var x, @NonNull var y) -> x.process(y)
JEP 321
HTTP Client
Goals:
● Standardize the incubated HTTP Client API introduced in JDK 9, via JEP
110, and updated in JDK 10
● HTTP 2.0 Support
JEP 332
Transport Layer Security 1.3
Goal:
● Implement version 1.3 of the Transport Layer Security (TLS) Protocol
Miscellaneous API Changes
● File.isSameContents() in addition to File.isSameFile()
● New methods and behaviour on the Java String class
– String#trim method : uses the definition of space as any codepoint that is less than or equal to the
space character codepoint (u0040.)
– String#lines and String#strip also use this definition of String#trim method
– String#isBlank : true if the string is empty or contains only white space
– String#stripLeading, String#stripTrailing : removal of Unicode white space from the beginning/end
– String#repeat(int numberOfTimes) : repeat a string given number if times
Sources: https://bugs.openjdk.java.net/browse/JDK-8202285
https://www.javacodegeeks.com/2018/05/new-jdk-11-files-method-issamecontent.html
Highlights from Java 12
JEP 2
Preview Language and VM Features
Goals:
● A preview language or VM feature is a new feature of the Java SE
Platform that is fully specified, fully implemented, and yet impermanent. It
is available in a JDK feature release to provoke developer feedback based
on real world use
On JDK 12:
javac Foo.java // Do not enable any preview features
javac --release 12 --enable-preview Foo.java // Enable all preview features of Java SE 12
javac --release 11 --enable-preview Foo.java // DISALLOWED
On JDK 13:
javac Foo.java // Do not enable any preview features
javac --release 13 --enable-preview Foo.java // Enable all preview features of Java SE 13
javac --release 12 --enable-preview Foo.java // DISALLOWED
JEP 325
Switch Expressions (Preview)
int numberOfLetters;
switch(season) {
case FALL:
numberOfLetters=4;
break;
case WINTER:
case SPRING:
case SUMMER:
numberOfLetters=6;
break;
default:
throw new IllegalStateException(„unknown season “+season);
}
JEP 325
Switch Expressions (Preview)
int numberOfLetters =switch(season) {
case FALL -> 4;
case WINTER, SPRING, SUMMER -> 6;
};
JEP 230
Microbenchmark Suite
Goal:
● Add a basic suite of microbenchmarks based on the Java Microbenchmark
Harness (JMH) to the JDK source code, and make it easy for developers
to run existing microbenchmarks and create new ones.
JEP 189
Project Shenandoah: Low-Pause-Time GC (Experimental)
Goals :
● ultra-low pause time garbage collector that reduces GC pause times by
performing more garbage collection work concurrently with the running Java
program
● CMS and G1 both perform concurrent marking of live objects. Shenandoah adds
concurrent compaction
Sources: http://openjdk.java.net/projects/shenandoah
Talk by Alexey Shipilev: “Shenandoah: The Garbage Collector That Could” https://www.youtube.com/watch?v=VCeHkcwfF9Q
Miscellaneous API Changes
Double result = Stream.of(1, 2, 3, 4)
.collect(teeing(
summingDouble(i -> i),
counting(),
(sum, n) -> sum * n));
System.out.println(result); // 10*4=40
Future of Java
Beyond Java 12
Project Amber
Simplifying syntax (continuing)
Source: http://openjdk.java.net/projects/amber/
JEP 305
Pattern Matching
String formatted = "unknown";
if (obj instanceof Integer) {
int i = (Integer) obj;
formatted = String.format("int %d", i);
} else if (obj instanceof Byte) {
byte b = (Byte) obj;
formatted = String.format("byte %d", b);
} else if (obj instanceof Long) {
long l = (Long) obj;
formatted = String.format("long %d", l);
} else if (obj instanceof Double) {
double d = (Double) obj;
formatted = String.format(“double %f", d);
} else if (obj instanceof String) {
String s = (String) obj;
formatted = String.format("String %s", s); }
JEP 305
Pattern Matching
String formatted;
switch (obj) {
case Integer i: formatted = String.format("int %d", i);
break;
case Byte b: formatted = String.format("byte %d", b);
break;
case Long l: formatted = String.format("long %d", l);
break;
case Double d: formatted = String.format(“double %f", d);
break;
case String s: formatted = String.format("String %s", s);
break;
default: formatted = obj.toString();
}
Records
public class Point {
private final int x, y;
public Point (int x, int y) {
this.x=x;
this.y=y;
}
public int hashCode() { ... }
public boolean equals(Object obj) { ... }
public String toString() { ... }
}
Records
record Point (int x, int y) { }
Project Valhalla
Value types and specialised generics
Source: http://openjdk.java.net/projects/valhalla/
Project Valhalla
Goal:
● Reboot the layout of data in memory
Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
Project Valhalla
Motivation:
● Hardware has changed
– Multi-core
– The cost of cache misses has increased
Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
Project Valhalla
Motivation
Source: „Latency Numbers Every Programmer Should Know”
https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
Project Valhalla
Motivation
Source: „Latency Numbers Every Programmer Should Know”
https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
Project Valhalla
Value Object
Value Object is an immutable type that is distinguishable only
by the state of its properties
Project Valhalla
Benefits:
● Reduced memory usage
● Reduced indirection
● Increased locality
Codes like a class, works like a primitive (Brian Goetz)
Project Valhalla
Value Types
value class Point {long x, y ;}
Project Valhalla
Value Types
Can
● have method and field
● implement interfaces
● use encapsulation
● be generic
Can’t
● be mutated
● be sub-classed
Project Valhalla
Generics over Values and Specialized Generics
List<Long> points= new ArrayList<Long>();
List<Point> points= new ArrayList<Point>();
class Box<any T> { T value; }
class Box<T=Long>
class Box<T=Point>
Source: John Rose: http://cr.openjdk.java.net/~jrose/values/value-type-hygiene.html
Project Valhalla
Current Status:
● Released public prototype LW1
– VM support for „value types“ (as subtypes of Object)
– Only language support for „value types“ (no support for „generics over values“ and „specialized
generics“)
– No support for migrating existing classes to „value types“ yet
Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
Project Metropolis
Polyglot GraalVM for Java 8
(current version 1.0-RC14 as of 2019-03-18)
Source: http://openjdk.java.net/projects/metropolis
Project Metropolis
Goals:
● High performance for all languages
● Zero overhead interoperability between languages
● Language-level virtualization level for shared tooling
Source: Oleg Selajev : “Run Code in Any Language Anywhere with GraalVM” https://www.youtube.com/watch?v=JoDOo4FyYMU
GraalVM
Architecture
Sources: Practical Partial Evaluation for High-Performance Dynamic Language Runtimes
http://chrisseaton.com/rubytruffle/pldi17-truffle/pldi17-truffle.pdf
„The LLVM Compiler Infrastructure“ https://llvm.org/
Project Sulong
Source: Thomas Würthinger, Oracle : “One VM to Rule Them All” https://www.youtube.com/watch?v=mMmOntDWSgw
GraalVM
Architecture
Sources: Practical Partial Evaluation for High-Performance Dynamic Language Runtimes
http://chrisseaton.com/rubytruffle/pldi17-truffle/pldi17-truffle.pdf
„The LLVM Compiler Infrastructure“ https://llvm.org/
SubstrateVM
Source: Oleg Šelajev, Thomas Wuerthinger, Oracle: “Deep dive into using GraalVM for Java and JavaScript”
https://www.youtube.com/watch?v=a-XEZobXspo
GraalVM and SubstrateVM
Source: Oleg Selajev, Oracle : “Run Code in Any Language Anywhere with GraalVM” https://www.youtube.com/watch?v=JoDOo4FyYMU
Difference Between Substrate VM & JVM Models
Source: Kevin Menard : “Improving TruffleRuby’s Startup Time with the SubstrateVM” https://www.youtube.com/watch?v=hIMldcAzd5o
GraalVM on SubstrateVM
A game changer for Java & Serverless?
Cold Start :
Source: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
AWS Lambda cold start time
by supported language
Source: Yan Cui: https://read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
GraalVM on SubstrateVM
A game changer for Java & Serverless?
Java Function compiled into a native executable using GraalVM on
SubstrateVM reduces
● “cold start” times
● memory footprint
by order of magnitude compared to running on JVM.
Project Loom
Fibers and Continuations
Source: http://openjdk.java.net/projects/loom
Project Loom
Motivation:
● Developers currently have 2 choices
– use blocking/synchronous API, which is simple, but less scalable (number of threads, that OS
supports is far less that open and concurrent connections required)
– asynchronous API (Spring Project Reactor, RXJava 2), which is scalable, but complex, harder to
debug and profile and limited (no asynchronous JDBC standard in this area)
Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
Project Loom
Goals:
● explore and incubate Java VM features and APIs built on top of them for
the implementation of lightweight user-mode threads (fibers), delimited
continuations
Project Loom
Continuation
Continuation is a program object, representing a computation
that may be suspended and resumed
Continuation
package java.lang;
public class Continuation {
public Continuation (ContinuationScope scope, Runnable target)
public final void run()
public static void yield (ContinuationScope scope)
public boolean isDone()
}
http://hg.openjdk.java.net/loom/loom/file/d6496338e000/src/java.base/share/classes/java/lang/Continuation.java
Project Loom
Continuations
example () {
var scope = new ContinuationScope(„Example_Scope“);
var continuation = new Continuation (scope, () -> {
out.print(„1“);
Continuation.yield(scope);
out.print(„2“);
Continuation.yield(scope);
out.print(„3“);
Continuation.yield(scope);
});
while (! continuation.isDone()) {
out.print(„ run.. “);
continuation.run();
}
}
Output: run.. 1 run.. 2 run.. 3
Project Loom
Fibers
Fibre is a lightweight thread scheduled not by the OS, but by
the Java Runtime with low memory footprint and low task-
switching cost
Project Loom
Fibers
Strand (abstract thread)
Fiber Thread
Source: Talk „Project Loom: Fibers and Continuations for the Java Virtual Machine“ by Ron Pressler
https://www.youtube.com/watch?v=fpyub8fbrVE
Project Loom
Continuations
Fiber
=
Continuation + Schedular
Project Loom
Fibers
● java.lang.Fibre currently supports:
– scheduling
– parking/unparking
– waiting for a fibre to terminate
● java.util.concurrent can park/unpark fibres
● Socket and Pipe APIs park fibers rather than block threads
in syscalls
Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
Project Loom
Current Status:
● Implemented initial prototype with Continuation and Fiber support
● Current prototype of Continuations and Fibers can run existing code (with
some limitations)
● Current focus on
– Performance improvement
– Stable Fiber API
– Debugger support
Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
http://hg.openjdk.java.net/loom
Project Loom
Open Questions:
● Should the existing Thread API be completely re-examined?
● Can all existing code be run on top of Fibers?
Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
is still an interesting and great
programming language
Questions?
www.iplabs.de
Thank You!

Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vadym Kazulkin

  • 1.
    Highlights from Java10, 11 and 12 and Future of Java Javaland 19.03.2019 by Vadym Kazulkin, ip.labs GmbH
  • 2.
    Contact Vadym Kazulkin, ip.labsGmbH v.kazulkin@gmail.com https://www.linkedin.com/in/vadymkazulkin www.xing.com/profile/Vadym_Kazulkin @VKazulkin, @ServerlessBonn (Meetup)
  • 3.
  • 4.
    Agenda ● Highlights fromJava 10 ● Highlights from Java 11 ● Highlights from Java 12 ● Project Amber (Simplifying syntax) ● Project Valhalla (Value Types and Specialized Generics) ● Project Metropolis (Polyglot GraalVM) ● Project Loom (Fibers and Continuations)
  • 5.
  • 6.
    JEP 286 (ProjectAmber) Local-Variable Type Inference URL url = new URL(„www.javaland.eu“); URLConnection connection = url.openConnection(); Reader reader = new BufferedReader ( new InputStreamReader(connection.getInputStream())); var url = new URL(„www.javaland.eu“); var connection = url.openConnection(); var reader = new BufferedReader ( new InputStreamReader(connection.getInputStream()));
  • 7.
    JEP 304 Garbage CollectorInterface Goals: ● Better modularity for HotSpot internal GC code ● Make it simpler to add a new GC to HotSpot without perturbing the current code base ● Make it easier to exclude a GC from a JDK build
  • 8.
    JEP 317 Experimental Java-BasedJIT Compiler Graal, a Java-based JIT compiler on the Linux/x64 platform, is the basis of the experimental Ahead-of-Time (AOT) compiler introduced in JDK 9. To Enable: -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
  • 9.
    Miscellaneous API Changes Bettercontainer-awareness ● Before later versions of Java 8 – Runtime.getRuntime().availableProcessors() -> retrieves value from sysconf, means the total number of processors for VM – Runtime.getRuntime().maxMemory() -> gets the value for VM overall memory ● Java 9 is container-aware automatically detecting cpusets JVM considers cgroups memory limits if the following flags are specified: – -XX:+UseCGroupMemoryLimitForHeap – -XX:+UnlockExperimentalVMOptions – Max Heap space will be automatically set (if not overwritten) to the limit specified by the cgroup Sources: „Improve docker container detection and resource configuration usage” https://bugs.openjdk.java.net/browse/JDK-8146115 „ Better containerized JVMs in JDK 10” https://jaxenter.com/better-containerized-jvms-jdk-10-140593.html
  • 10.
    Miscellaneous API Changes Bettercontainer-awareness ● For “fixing” CPU shares in Java 9 overwrite – -XMX for memory – -XX:ParallelGCThreads and -XX:ConcGCThreads for CPU – -System property java.util.concurrent.ForkJoinPool.common.parallelism for ForkJoinPool ● Better container-awareness in Java 10 (CPU shares support is included) – Runtime.getRuntime().availableProcessors() – Runtime.getRuntime().maxMemory() Sources: „Java SE 9 support for Docker CPU and memory limits“https://blogs.oracle.com/java-platform-group/java-se-support-for- docker-cpu-and-memory-limits „ Nobody puts Java in a container” https://jaxenter.com/nobody-puts-java-container-139373.html
  • 11.
    Miscellaneous API Changes ●java.util.List/Set/Map.copyOf(Collection) ● java.util.stream.Collectors.toUnmodifiableList/Set/Map(Stream) ● Optional.orElseThrow()
  • 12.
  • 13.
    JEP 323 (ProjectAmber) Local-Variable Syntax for Lambda Parameters ● (x, y) -> x.process(y) // implicitly typed lambda expression ● (var x, var y) -> x.process(y) // implicit typed lambda expression ● (@NonNull var x, @NonNull var y) -> x.process(y)
  • 14.
    JEP 321 HTTP Client Goals: ●Standardize the incubated HTTP Client API introduced in JDK 9, via JEP 110, and updated in JDK 10 ● HTTP 2.0 Support
  • 15.
    JEP 332 Transport LayerSecurity 1.3 Goal: ● Implement version 1.3 of the Transport Layer Security (TLS) Protocol
  • 16.
    Miscellaneous API Changes ●File.isSameContents() in addition to File.isSameFile() ● New methods and behaviour on the Java String class – String#trim method : uses the definition of space as any codepoint that is less than or equal to the space character codepoint (u0040.) – String#lines and String#strip also use this definition of String#trim method – String#isBlank : true if the string is empty or contains only white space – String#stripLeading, String#stripTrailing : removal of Unicode white space from the beginning/end – String#repeat(int numberOfTimes) : repeat a string given number if times Sources: https://bugs.openjdk.java.net/browse/JDK-8202285 https://www.javacodegeeks.com/2018/05/new-jdk-11-files-method-issamecontent.html
  • 17.
  • 18.
    JEP 2 Preview Languageand VM Features Goals: ● A preview language or VM feature is a new feature of the Java SE Platform that is fully specified, fully implemented, and yet impermanent. It is available in a JDK feature release to provoke developer feedback based on real world use On JDK 12: javac Foo.java // Do not enable any preview features javac --release 12 --enable-preview Foo.java // Enable all preview features of Java SE 12 javac --release 11 --enable-preview Foo.java // DISALLOWED On JDK 13: javac Foo.java // Do not enable any preview features javac --release 13 --enable-preview Foo.java // Enable all preview features of Java SE 13 javac --release 12 --enable-preview Foo.java // DISALLOWED
  • 19.
    JEP 325 Switch Expressions(Preview) int numberOfLetters; switch(season) { case FALL: numberOfLetters=4; break; case WINTER: case SPRING: case SUMMER: numberOfLetters=6; break; default: throw new IllegalStateException(„unknown season “+season); }
  • 20.
    JEP 325 Switch Expressions(Preview) int numberOfLetters =switch(season) { case FALL -> 4; case WINTER, SPRING, SUMMER -> 6; };
  • 21.
    JEP 230 Microbenchmark Suite Goal: ●Add a basic suite of microbenchmarks based on the Java Microbenchmark Harness (JMH) to the JDK source code, and make it easy for developers to run existing microbenchmarks and create new ones.
  • 22.
    JEP 189 Project Shenandoah:Low-Pause-Time GC (Experimental) Goals : ● ultra-low pause time garbage collector that reduces GC pause times by performing more garbage collection work concurrently with the running Java program ● CMS and G1 both perform concurrent marking of live objects. Shenandoah adds concurrent compaction Sources: http://openjdk.java.net/projects/shenandoah Talk by Alexey Shipilev: “Shenandoah: The Garbage Collector That Could” https://www.youtube.com/watch?v=VCeHkcwfF9Q
  • 23.
    Miscellaneous API Changes Doubleresult = Stream.of(1, 2, 3, 4) .collect(teeing( summingDouble(i -> i), counting(), (sum, n) -> sum * n)); System.out.println(result); // 10*4=40
  • 24.
  • 25.
    Project Amber Simplifying syntax(continuing) Source: http://openjdk.java.net/projects/amber/
  • 26.
    JEP 305 Pattern Matching Stringformatted = "unknown"; if (obj instanceof Integer) { int i = (Integer) obj; formatted = String.format("int %d", i); } else if (obj instanceof Byte) { byte b = (Byte) obj; formatted = String.format("byte %d", b); } else if (obj instanceof Long) { long l = (Long) obj; formatted = String.format("long %d", l); } else if (obj instanceof Double) { double d = (Double) obj; formatted = String.format(“double %f", d); } else if (obj instanceof String) { String s = (String) obj; formatted = String.format("String %s", s); }
  • 27.
    JEP 305 Pattern Matching Stringformatted; switch (obj) { case Integer i: formatted = String.format("int %d", i); break; case Byte b: formatted = String.format("byte %d", b); break; case Long l: formatted = String.format("long %d", l); break; case Double d: formatted = String.format(“double %f", d); break; case String s: formatted = String.format("String %s", s); break; default: formatted = obj.toString(); }
  • 28.
    Records public class Point{ private final int x, y; public Point (int x, int y) { this.x=x; this.y=y; } public int hashCode() { ... } public boolean equals(Object obj) { ... } public String toString() { ... } }
  • 29.
  • 30.
    Project Valhalla Value typesand specialised generics Source: http://openjdk.java.net/projects/valhalla/
  • 31.
    Project Valhalla Goal: ● Rebootthe layout of data in memory Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
  • 32.
    Project Valhalla Motivation: ● Hardwarehas changed – Multi-core – The cost of cache misses has increased Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
  • 33.
    Project Valhalla Motivation Source: „LatencyNumbers Every Programmer Should Know” https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
  • 34.
    Project Valhalla Motivation Source: „LatencyNumbers Every Programmer Should Know” https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html
  • 35.
    Project Valhalla Value Object ValueObject is an immutable type that is distinguishable only by the state of its properties
  • 36.
    Project Valhalla Benefits: ● Reducedmemory usage ● Reduced indirection ● Increased locality Codes like a class, works like a primitive (Brian Goetz)
  • 37.
    Project Valhalla Value Types valueclass Point {long x, y ;}
  • 38.
    Project Valhalla Value Types Can ●have method and field ● implement interfaces ● use encapsulation ● be generic Can’t ● be mutated ● be sub-classed
  • 39.
    Project Valhalla Generics overValues and Specialized Generics List<Long> points= new ArrayList<Long>(); List<Point> points= new ArrayList<Point>(); class Box<any T> { T value; } class Box<T=Long> class Box<T=Point> Source: John Rose: http://cr.openjdk.java.net/~jrose/values/value-type-hygiene.html
  • 40.
    Project Valhalla Current Status: ●Released public prototype LW1 – VM support for „value types“ (as subtypes of Object) – Only language support for „value types“ (no support for „generics over values“ and „specialized generics“) – No support for migrating existing classes to „value types“ yet Source: Brian Goetz, Oracle „Evolving the Java Language” https://www.youtube.com/watch?v=A-mxj2vhVAA
  • 41.
    Project Metropolis Polyglot GraalVMfor Java 8 (current version 1.0-RC14 as of 2019-03-18) Source: http://openjdk.java.net/projects/metropolis
  • 42.
    Project Metropolis Goals: ● Highperformance for all languages ● Zero overhead interoperability between languages ● Language-level virtualization level for shared tooling Source: Oleg Selajev : “Run Code in Any Language Anywhere with GraalVM” https://www.youtube.com/watch?v=JoDOo4FyYMU
  • 43.
    GraalVM Architecture Sources: Practical PartialEvaluation for High-Performance Dynamic Language Runtimes http://chrisseaton.com/rubytruffle/pldi17-truffle/pldi17-truffle.pdf „The LLVM Compiler Infrastructure“ https://llvm.org/
  • 44.
    Project Sulong Source: ThomasWürthinger, Oracle : “One VM to Rule Them All” https://www.youtube.com/watch?v=mMmOntDWSgw
  • 45.
    GraalVM Architecture Sources: Practical PartialEvaluation for High-Performance Dynamic Language Runtimes http://chrisseaton.com/rubytruffle/pldi17-truffle/pldi17-truffle.pdf „The LLVM Compiler Infrastructure“ https://llvm.org/
  • 46.
    SubstrateVM Source: Oleg Šelajev,Thomas Wuerthinger, Oracle: “Deep dive into using GraalVM for Java and JavaScript” https://www.youtube.com/watch?v=a-XEZobXspo
  • 47.
    GraalVM and SubstrateVM Source:Oleg Selajev, Oracle : “Run Code in Any Language Anywhere with GraalVM” https://www.youtube.com/watch?v=JoDOo4FyYMU
  • 48.
    Difference Between SubstrateVM & JVM Models Source: Kevin Menard : “Improving TruffleRuby’s Startup Time with the SubstrateVM” https://www.youtube.com/watch?v=hIMldcAzd5o
  • 49.
    GraalVM on SubstrateVM Agame changer for Java & Serverless? Cold Start : Source: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
  • 50.
    AWS Lambda coldstart time by supported language Source: Yan Cui: https://read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
  • 51.
    GraalVM on SubstrateVM Agame changer for Java & Serverless? Java Function compiled into a native executable using GraalVM on SubstrateVM reduces ● “cold start” times ● memory footprint by order of magnitude compared to running on JVM.
  • 52.
    Project Loom Fibers andContinuations Source: http://openjdk.java.net/projects/loom
  • 53.
    Project Loom Motivation: ● Developerscurrently have 2 choices – use blocking/synchronous API, which is simple, but less scalable (number of threads, that OS supports is far less that open and concurrent connections required) – asynchronous API (Spring Project Reactor, RXJava 2), which is scalable, but complex, harder to debug and profile and limited (no asynchronous JDBC standard in this area) Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
  • 54.
    Project Loom Goals: ● exploreand incubate Java VM features and APIs built on top of them for the implementation of lightweight user-mode threads (fibers), delimited continuations
  • 55.
    Project Loom Continuation Continuation isa program object, representing a computation that may be suspended and resumed
  • 56.
    Continuation package java.lang; public classContinuation { public Continuation (ContinuationScope scope, Runnable target) public final void run() public static void yield (ContinuationScope scope) public boolean isDone() } http://hg.openjdk.java.net/loom/loom/file/d6496338e000/src/java.base/share/classes/java/lang/Continuation.java
  • 57.
    Project Loom Continuations example (){ var scope = new ContinuationScope(„Example_Scope“); var continuation = new Continuation (scope, () -> { out.print(„1“); Continuation.yield(scope); out.print(„2“); Continuation.yield(scope); out.print(„3“); Continuation.yield(scope); }); while (! continuation.isDone()) { out.print(„ run.. “); continuation.run(); } } Output: run.. 1 run.. 2 run.. 3
  • 58.
    Project Loom Fibers Fibre isa lightweight thread scheduled not by the OS, but by the Java Runtime with low memory footprint and low task- switching cost
  • 59.
    Project Loom Fibers Strand (abstractthread) Fiber Thread Source: Talk „Project Loom: Fibers and Continuations for the Java Virtual Machine“ by Ron Pressler https://www.youtube.com/watch?v=fpyub8fbrVE
  • 60.
  • 61.
    Project Loom Fibers ● java.lang.Fibrecurrently supports: – scheduling – parking/unparking – waiting for a fibre to terminate ● java.util.concurrent can park/unpark fibres ● Socket and Pipe APIs park fibers rather than block threads in syscalls Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
  • 62.
    Project Loom Current Status: ●Implemented initial prototype with Continuation and Fiber support ● Current prototype of Continuations and Fibers can run existing code (with some limitations) ● Current focus on – Performance improvement – Stable Fiber API – Debugger support Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ http://hg.openjdk.java.net/loom
  • 63.
    Project Loom Open Questions: ●Should the existing Thread API be completely re-examined? ● Can all existing code be run on top of Fibers? Source: Alan Bateman, Oracle „Project Loom: Fibers and Continuations for Java” https://www.youtube.com/watch?v=vbGbXUjlRyQ
  • 64.
    is still aninteresting and great programming language
  • 65.
  • 66.