List<String> foo = new ArrayList<>();
Map<Customer, List<Order>> orderMap = new HashMap<>();
Jason Lee, Sr. Principal Software Engineer
Oracle | NetSuite Inc.
Introduction
A quick look at Java 10
Java 11
The boring stuff
What’s gone
What you won’t see
What you care about
Links
Jason Lee
Sr. Principal Software Engineer for Oracle | NetSuite
Tribe (Team) Architect
Commerce Site Management Tools
WYSIWYG tool for managing content on SuiteCommerce sites
Author, Java 9 Programming Blueprints
6-month release cycle
New Long-time Support (LTS) every 3 years (?)
Parallel Full GC for G1
"Improve G1 worst-case latencies by making the full GC parallel."
Garbage Collector Interface
"Improve the source code isolation of different garbage collectors by introducing a clean garbage collector (GC) interface."
Thread-Local Handshakes
Avoid global VM safepoint
"A handshake operation is a callback that is executed for each JavaThread while that thread is in a safepoint safe state… The big difference between safepointing and handshaking is that the per thread operation will be performed on all threads as soon as possible and they will continue to execute as soon as its own operation is completed."
Graal, an experimental Java-based JIT compiler
"…the basis of the experimental Ahead-of-Time (AOT) compiler introduced in JDK 9."
Enhance the Java Language to extend type inference to declarations of local variables with initializers.
Java already had some type inference with the diamond operator
List<String> foo = new ArrayList<>();
Map<Customer, List<Order>> orderMap = new HashMap<>();
Expand that to include local variables
var foo = new ArrayList<String>();
var orderMap = new HashMap<Customer, List<Order>>;
var stream = list.stream(); // infers Stream<String>
Not applicable for lambdas (and method params, obviously)
Class-Data Sharing, introduced in JDK 5, allows a set of classes to be pre-processed into a shared archive file that can then be memory-mapped at runtime to reduce startup time. It can also reduce dynamic memory footprint when multiple JVMs share the same archive file."
Goals
Reduce footprint by sharing common class metadata across different Java processes.
Improve startup time.
# Determining the classes to archive
java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=hello.lst \
-cp hello.jar HelloWorld
# Creating the AppCDS archive
java -Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=hello.lst \
-XX:SharedArchiveFile=hello.jsa -cp hello.jar
# Using the AppCDS archive
java -Xshare:on -XX:+UseAppCDS -XX:SharedArchiveFile=hello.jsa \
-cp hello.jar HelloWorld
For illustrative purposes:
We can save about 340MB of RAM for a Java EE app server that includes 6 JVM processes consuming a total of 13GB of RAM (~2GB of that is for class meta data).
We can improve the startup time of the JEdit benchmark by 20-30%.
Oracle JDK now "costs". Kinda.
Requires license for production use.
"Free" updates for 6 months
Security updates for Java SE, directly from Oracle (for 8 years)
Access to My Oracle Support (MOS) 24x7, support in 27 languages,
Java SE 8 Desktop management, monitoring, and deployment features
THAT’S HORRIBLE! I’M SWITCHING TO JAVASCRIPT!!!
Now you have NaN
problems…
(Yes, it’s gratuitous, but I couldn’t resist :)
OpenJDK is the most important build. Should be the go-to source.
Oracle JDK built of OpenJDK
The two are basically identical
"Starting with JDK 11, the Oracle JDK and builds of Oracle OpenJDK will be interchangeable!"
Removal of the Java EE and CORBA Modules
ZGC: A Scalable Low-Latency Garbage Collector (Experimental, and Linux/x64 only ATM)
Dynamic Class-File Constants
More Deprecations
Nashorn
Will be removed in a future release
Only options are Rhino or perhaps Graal
Pack200 Tools and API
JavaFX has been decoupled
Garbage collector that…
… does nothing
Ideal for testing, shell scripts, other short-lived invocations
Allow var to be used when declaring the formal parameters of implicitly typed lambda expressions."
(var x, var y) -> x.process(y)
(x, y) -> x.process(y)
Introduced in Java 9 as an incubating feature in jdk.incubator.http
Promoted to java.net.http
in 11
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("http://openjdk.java.net/"))
.build();
client.sendAsync(request, asString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
Character.toString(int)
CharSequence.compare(java.lang.CharSequence, java.lang.CharSequence)
String.repeat(int)
String.isBlank()
String.strip()/stripTrailing()/stripLeading()
String.lines()
java.nio.file.Path.of()
Path path = FileSystems.getDefault().getPath("logs", "access.log");
// ...
var path2 = Path.of("logs/access.log")
var userHome = Path.of(System.getProperty("user.home"));
Provide a low-overhead data collection framework for troubleshooting Java applications and the HotSpot JVM.
@Label("Hello World")
@Description("Helps the programmer getting started")
class HelloWorld extends Event {
@Label("Message")
String message;
}
public static void main(String... args) throws IOException {
HelloWorld event = new HelloWorld();
event.message = "hello, world!";
event.commit();
}
java Factorial.java 3 4 5
is informally equivalent to
javac -d <memory> Factorial.java
java -cp <memory> Factorial 3 4 5
"Shebang" files supported:
#!/path/to/java
./factorial
Java 10 JEP: http://openjdk.java.net/projects/jdk/10
Java 11 JEP: http://openjdk.java.net/projects/jdk/11
Release/license discussion