SlideShare ist ein Scribd-Unternehmen logo
1 von 159
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
JDK 9 and 10 Deep Dive
Simon Ritter
Deputy CTO, Azul Systems
1
© Copyright Azul Systems 2016
JDK 9: 86 Changes
2
© Copyright Azul Systems 2016
JDK 9: Agenda
 Java Platform Module System
 Developer features
 Other things
 Migrating applications to JDK 9
– Real world example
3
© Copyright Azul Systems 2016 4
JPMS: API Structural Changes
© Copyright Azul Systems 2016
API Classification
 Supported, intended for public use
– JCP specified: java.*, javax.*
– JDK specific: some com.sun.*, some jdk.*
 Unsupported, not intended for public use
– Mostly sun.*
– Most infamous is sun.misc.Unsafe
5
© Copyright Azul Systems 2016
General Java Compatability Policy
 If an application uses only supported APIs on version N of
Java it should work on version N+1, even without
recompilation
 Supported APIs can be removed
–But only with advanced notice
 JDK 8 has 18 interfaces, 23 classes, 64 fields, 358
methods and 20 constructors that have been deprecated
–None have been removed
–Until now
6
© Copyright Azul Systems 2016
Most Popular Unsupported APIs
1. sun.misc.BASE64Encoder
2. sun.misc.Unsafe
3. sun.misc.BASE64Decoder
7
Oracle dataset based on internal application code
© Copyright Azul Systems 2016
JDK Internal API Classification
 Non-critical
– Little or no use outside the JDK
– Used only for convenience (alternatives exist)
 Critical
– Functionality that would be difficult, if not impossible to
implement outside the JDK
8
© Copyright Azul Systems 2016
JEP 260 Proposal
 Encapsulate all non-critical JDK-internal APIs
 Encapsulate all critical JDK-internal APIs, for which
supported replacements exist in JDK 8
 Do not encapsulate other critical JDK-internal APIs
– Deprecate these in JDK 9
– Plan to encapsulate or remove them in the future
– Command-line option to access encapsulated critical APIs
 --add-exports
 --add-opens
9
© Copyright Azul Systems 2016
JEP 260 Accessible Critical APIs
 sun.misc.Unsafe
 sun.misc.Signal
 sun.misc.SignalHandler
 sun.misc.Cleaner
 sun.reflect.Reflection.getCallerClass
 sun.reflect.ReflectionFactory
10
© Copyright Azul Systems 2016
Project Jigsaw And Modules
© Copyright Azul Systems 2016
Goals For Project Jigsaw
 Make Java SE more scalable and flexible
– Internet of Things
– Microservices
 Improve security, maintainability and performance
 Simplify construction, deployment and maintenance of
large scale applications
 Eliminate classpath hell
12
© Copyright Azul Systems 2016
Module Fundamentals
 Module is a grouping of code
– For Java this is a collection of packages
 Modules can contain other things
– Native code
– Resources
– Configuration data
13
com.azul.zoop
com.azul.zoop.alpha.Name
com.azul.zoop.alpha.Position
com.azul.zoop.beta.Animal
com.azul.zoop.beta.Reptile
com.azul.zoop.theta.Zoo
com.azul.zoop.theta.Lake
© Copyright Azul Systems 2016
Module Declaration
14
module com.azul.zoop {
}
module-info.java
com/azul/zoop/alpha/Name.java
com/azul/zoop/alpha/Position.java
com/azul/zoop/beta/Animal.java
com/azul/zoop/beta/Reptile.java
com/azul/zoop/theta/Zoo.java
com/azul/zoop/theta/Lake.java
© Copyright Azul Systems 2016
Module Dependencies
module com.azul.zoop {
requires com.azul.zeta;
} com.azul.zoop
com.azul.zeta
© Copyright Azul Systems 2016
Module Dependencies
module com.azul.zapp {
requires com.azul.zoop;
requires java.sql;
}
com.azul.zapp
com.azul.zoop java.sql
© Copyright Azul Systems 2016
Module Dependency Graph
com.azul.zapp
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
explicit
implicit
© Copyright Azul Systems 2016
Module Dependency Graph
 No missing dependencies
 No cyclic dependencies
 No split packages
18
© Copyright Azul Systems 2016
Readability v. Dependency
com.azul.zapp
java.sql
java.logging
module java.sql {
requires transitive java.logging;
}
Driver d = …
Logger l = d.getParentLogger();
l.log(“azul’);
Implied readability
© Copyright Azul Systems 2016
Module Implied Readability Graph
com.azul.zapp
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
explicit
implicit
implied
© Copyright Azul Systems 2016
Package Visibility
module com.azul.zoop {
requires com.azul.zeta;
exports com.azul.zoop.alpha;
exports com.azul.zoop.beta to com.azul.zapp;
}
com.azul.zoop
com.azul.zoop.alpha
com.azul.zoop.beta
com.azul.zoop.thetacom.azul.zapp only
© Copyright Azul Systems 2016
More Package Visibility
open module com.azul.zoop {
requires com.azul.zeta;
}
com.azul.zoop
com.azul.zoop.alpha
com.azul.zoop.beta
com.azul.zoop.theta
com.azul.zoop.alpha
com.azul.zoop.beta
com.azul.zoop.theta
REFLECTIONIMPORT
© Copyright Azul Systems 2016
Even More Package Visibility
module com.azul.zoop {
requires com.azul.zeta;
exports com.azul.zoop.alpha;
exports com.azul.zoop.beta to com.azul.zapp;
opens com.azul.theta;
}
com.azul.zoop
com.azul.zoop.theta
REFLECTIONIMPORT
com.azul.zoop.alpha
com.azul.zoop.beta
com.azul.zapp only
© Copyright Azul Systems 2016
Restricted Keywords
module
requires requires;
exports exports to to;
module {
opens opens;
}
© Copyright Azul Systems 2016
Optional Dependencies
 Required at compile time
 Possibly not needed at runtime
– If it is generates a NoClassDefFoundError
 Use static keyword
– Oddly this used to be optional, which is more logical
25
module mine.lib {
requires static com.google.guava
}
© Copyright Azul Systems 2016
Accessibility
 For a package to be visible
– The package must be exported by the containing module
– The containing module must be read by the using module
 Public types from those packages can then be used
com.azul.zoopcom.azul.zapp
reads
© Copyright Azul Systems 2016
Java Accessibility (pre-JDK 9)
public
protected
<package>
private
© Copyright Azul Systems 2016
Java Accessibility (JDK 9)
public to everyone
public, but only to specific modules
public only within a module
protected
<package>
private
public ≠ accessible (fundamental change to Java)
© Copyright Azul Systems 2016
JDK 8 Dependencies
© Copyright Azul Systems 2016
The java.base Module
module java.base {
exports java.lang;
exports java.io;
exports java.net;
exports java.util;
}
© Copyright Azul Systems 2016
JDK 9 Platform Modules
31
java.se
java.compact3
java.compact2
java.compact1
java.scripting
java.instrument
java.base
java.logging
java.sql
java.sql.rowset
java.xml
java.desktop
java.rmi
java.prefs
java.datatransfer
java.compiler
java.management
java.security.jgss
java.naming
java.security.sasl
All modules depend on java.base
no implied
readability=
© Copyright Azul Systems 2016
JDK 9 Platform Modules
32
java.se.e
e
java.se
java.xml.bind
java.corba
java.compiler
java.desktop
java.annotations.common
java.rmi
java.datatransfer
java.management
java.xml.ws
java.naming
java.transaction
java.activation
All modules depend on java.base
© Copyright Azul Systems 2016
Using Modules
© Copyright Azul Systems 2016
Module Path
$ javac –modulepath dir1:dir2:dir3
© Copyright Azul Systems 2016
Compilation With Module Path
35
$ javac –-module-path mods –d mods 
src/module-info.java 
src/com/azul/zoop/alpha/Name.java
mods/module-info.class
mods/com/azul/zoop/alpha/Name.class
src/module-info.java
src/com/azul/zoop/alpha/Name.java
© Copyright Azul Systems 2016
Application Execution
 --module-path can be abbreviated to -p
$ java –p mods –m com.azul.zapp/com.azul.zapp.Main
Azul application initialised!
module name main class
© Copyright Azul Systems 2016
Packaging With Modular JAR Files
mods/module-info.class
mods/com/azul/zapp/Main.class
$ jar --create --file=mylib/zapp.jar 
--main-class=com.azul.zapp.Main 
-C mods .
module-info.class
com/azul/zapp/Main.class
zapp.jar
© Copyright Azul Systems 2016
JAR Files & Module Information
$ jar --file=mylib/zapp.jar –-print-module-descriptor
$ jar --file=mylib/zapp.jar -d
com.azul.zapp
requires com.azul.zoop
requires com.azul.zeta
requires mandated java.base
requires java.sql
main-class com.azul.zapp.Main
© Copyright Azul Systems 2016
Application Execution (JAR)
$ java –p mylib:mods –m com.azul.zapp
Azul application initialised!
© Copyright Azul Systems 2016
Linking
Modular run-time
image
…confbin
jlink
$ jlink --module-path $JDKMODS 
--add-modules java.base –-output myimage
$ myimage/bin/java –-list-modules
java.base@9.0
© Copyright Azul Systems 2016
Linking An Application
$ jlink --module-path $JDKMODS:$MYMODS 
--add-modules com.azul.zapp –-output myimage
$ myimage/bin/java –-list-modules
java.base@9
java.logging@9
java.sql@9
java.xml@9
com.azul.zapp@1.0
com.azul.zoop@1.0
com.azul.zeta@1.0
Version numbering for
information purposes only
“It is not a goal of the module
system to solve the version-
selection problem”
© Copyright Azul Systems 2016
The Implications Of jlink
 "Write once, run anywhere"
– Long term Java slogan, mainly held true
 jlink generated runtime may not include all Java SE
modules
– But is still a conforming Java implementation
– To conform to the specification, the runtime:
 Must include the java.base module
 If other modules are included, all transitive module dependencies
must also be included
– Defined as a closed implementation
© Copyright Azul Systems 2016
Application Migration
© Copyright Azul Systems 2016
Typical Application (JDK 8)
jar
jar
jar
JDK
jar
jarjar
jar jar
jar
jar
jar
jar
Classpath
© Copyright Azul Systems 2016
Typical Application (JDK 9)
jar
jar
jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
jar
jarjar
jar jar
jar
jar
jar
jar
Unnamed
module
© Copyright Azul Systems 2016
Sample Application
myapp.ja
r
libgl.jar
mylib.jar
gluegen.jar jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Run Application With Classpath
$ java –classpath 
lib/myapp.jar: 
lib/mylib.jar: 
lib/libgl.jar: 
lib/gluegen.jar: 
lib/jogl.jar: 
myapp.Main
© Copyright Azul Systems 2016
Sample Application
module
myapp.ja
r
libgl.jar
module
mylib.jar
gluegen.jar jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Application module-info.java
module myapp {
requires mylib;
requires java.base;
requires java.sql;
requires libgl; ????
requires gluegen; ????
requires jogl; ????
}
© Copyright Azul Systems 2016
Sample Application
module
myapp.ja
r
module
libgl.jar
module
mylib.jar
module
gluegen.jar
module
jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Automatic Modules
 Real modules
 Simply place unmodified jar file on module path
– Rather than classpath
 No changes to JAR file
 Module name derived from JAR file name
 Exports all its packages
– No selectivity
 Automatically requires all modules on the module path
51
© Copyright Azul Systems 2016
Application Module Dependencies
module
myapp.ja
r
module
libgl.jar
module
mylib.jar
module
gluegen.jar
module
jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
Implicit
Explicit
© Copyright Azul Systems 2016
Run Application With Modules
$ java –classpath 
lib/myapp.jar: 
lib/mylib.jar: 
lib/libgl.jar: 
lib/gluegen.jar: 
lib/jogl.jar: 
myapp.Main
$ java –p mylib:lib –m myapp
© Copyright Azul Systems 2016
Advanced Details
© Copyright Azul Systems 2016
Modular Jar Files And JMODs
 Modular jar files are simple
– Standard jar file possibly with module-info.class file
– Can use existing (unmodified) jar files
 JMOD files
– More complex module files
– Used for modules in the JDK
– Can include native files (JNI), configuration files and
other data
– Based on zip file format (pending final details - JEP 261)
55
© Copyright Azul Systems 2016
jmod Command
 Create can specify several details:
– Main class
– Native libraries and commands
– Configuration data
– OS name, version and machine architecture
 Details included in module-info.class file
56
jmod (create | list | describe) <options> <jmod-file>
© Copyright Azul Systems 2016
Classloaders (Since JDK 1.2)
57
Bootstrap classloader (Internal Class)
Bootstrap Class Path
Extension classloader (URLClassLoader)
Extension Mechanism
Application classloader (URLClassLoader)
Class Path
© Copyright Azul Systems 2016
Classloaders (JDK 9)
58
Bootstrap classloader (Internal Class)
bootstrap class path
Platform classloader (Internal Class)
JDK classes with specific permissions
Application classloader (Internal Class)
Class & Module Path
© Copyright Azul Systems 2016
Services
module java.sql {
requires transient
java.logging;
requires transient java.xml;
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;
uses java.sql.Driver;
}
© Copyright Azul Systems 2016
Services
module com.mysql.jdbc {
requires java.sql;
exports com.mysql.jdbc;
provides java.sql.Driver with com.mysql.jdbc.Driver;
}
© Copyright Azul Systems 2016
Avoiding Cyclic Dependencies
logging.api logging.impl
http.client
© Copyright Azul Systems 2016
Avoiding Cyclic Dependencies
logging.api logging.impl
http.client
© Copyright Azul Systems 2016
Avoiding Cyclic Dependencies
logging.api logging.impl
http.client
interface Logger
class HttpLogger
implements Logger
uses Logger
provides Logger
with HttpLogger
© Copyright Azul Systems 2016
Incubator Modules (JEP 11)
 Develop APIs without making them part of the standard
– At least not straight away
 Allow developers to “kick the tyres”
– Not always possible to get a new API right first time
 Move from incubator to full module
– Becomes part of the standard
 JDK 9 only has one incubator: HTTP/2 (JEP 110)
 Some concerns about fragmentation
--do-not-resolve-by-default
64
© Copyright Azul Systems 2016
JDK 9 Developer Features
© Copyright Azul Systems 2016
Java Language
© Copyright Azul Systems 2016
Milling Project Coin (JEP 213)
 Single underscore is now a reserved word
– No longer usable as an identifier
– Two or more underscores still works
 Allow @SafeVarargs on private instance methods
– In addition to constructors, final and static methods
67
© Copyright Azul Systems 2016
Milling Project Coin
 Private methods are now permitted in interfaces
– Separate common code for default and static methods
68
public interface MyInterface {
default int getX() {
return getNum() * 2;
};
static int getY() {
return getNum() * 4;
}
private static int getNum() {
return 12;
}
}
© Copyright Azul Systems 2016
Milling Project Coin
 Effectively final variables in try-with-resources
69
BufferedReader reader =
new BufferedReader(new FileReader("/tmp/foo.txt"));
try (BufferedReader myReader = reader) {
myReader.lines()
.forEach(System.out::println);
}
JDK 8
try (reader) {
reader.lines()
.forEach(System.out::println);
}
JDK 9
© Copyright Azul Systems 2016
Milling Project Coin
 Diamond operator with anonymous classes
– Type inference can infer a non-denotable type
– If the type inferred can be denotable you can use <>
70
public abstract class Processor<T> {
abstract void use(T value);
}
Processor<String> processor = new Processor<>() {
@Override
void use(String value) {
// Some stuff
}
};
© Copyright Azul Systems 2016
Core Libraries
© Copyright Azul Systems 2016
Factory Methods For Collections (JEP 269)
 The problem:
– Creating a small unmodifiable collection is verbose
72
Set<String> set = new HashSet<>();
set.add("a");
set.add("b");
set.add("c");
set = Collections.unmodifiableSet(set);
© Copyright Azul Systems 2016
Factory Methods For Collections (JEP 269)
 Static methods added to List, Set and Map interfaces
– Create compact, immutable instances
– 0 to 10 element overloaded versions
– Varargs version for arbitary number of elements
73
Set<String> set = Set.of("a", "b", "c");
List<String> list = List.of("a", "b", "c");
Map<String, String> map = Map.of(“k1”, “v1”, “k2”, “v2”);
Map<String, String> map = Map.ofEntries(
entry(“k1”, “v1”), entry(“k2”, “v2”));
© Copyright Azul Systems 2016
Stream Enhancements
 Collectors.flatMapping()
– Returns a Collector that converts a stream from one
type to another by applying a flat mapping function
74
Map<String, Set<LineItem>> items = orders.stream()
.collect(groupingBy(Order::getCustomerName,
flatMapping(order -> order.getLineItems().stream(), toSet())));
© Copyright Azul Systems 2016
Improved Iteration
 iterate(seed, hasNext, next)
– Can be used like the classic for loop
75
Initial
value
Predicate UnaryOperator
IntStream.iterate(0, i -> i < 10, i -> ++i)
.forEach(System.out::println);
IntStream.iterate(0, i -> i < 10, i -> i++)
.forEach(System.out::println);
Infinite stream
© Copyright Azul Systems 2016
Stream takeWhile
 Stream<T> takeWhile(Predicate<? super T> p)
 Select elements from stream while Predicate matches
 Unordered stream needs consideration
thermalReader.lines()
.mapToInt(i -> Integer.parseInt(i))
.takeWhile(i -> i < 56)
.forEach(System.out::println);
© Copyright Azul Systems 2016
Stream dropWhile
 Stream<T> dropWhile(Predicate<? super T> p)
 Ignore elements from stream while Predicate matches
 Unordered stream still needs consideration
thermalReader.lines()
.mapToInt(i -> Integer.parseInt(i))
.dropWhile(i -> i < 56)
.forEach(System.out::println);
© Copyright Azul Systems 2016
dropWhile/takeWhile
 Be careful of unordered streams missing values
78
list.stream()
.dropWhile(s -> s.charAt(0) < ‘e')
.forEach(System.out::println);
List<String> list = List.of("alpha", "bravo", "charlie",
"delta", "echo", "foxtrot");
list.stream()
.takeWhile(s -> s.length() == 5)
.forEach(System.out::println);
alpha
bravo
echo
foxtrot
© Copyright Azul Systems 2016
Additional Stream Sources
 Matcher stream support
– Stream<MatchResult> results()
 Scanner stream support
– Stream<MatchResult> findAll(String pattern)
– Stream<MatchResult> findAll(Pattern pattern)
– Stream<String> tokens()
79
© Copyright Azul Systems 2016
Additional Stream Sources
 java.net.NetworkInterface
– Stream<InetAddress> inetAddresses()
– Stream<NetworkInterface> subInterfaces()
– Stream<NetworkInterface> networkInterfaces()
 static
 java.security.PermissionCollection
– Stream<Permission> elementsAsStream()
80
© Copyright Azul Systems 2016
Parallel Support For Files.lines()
 Memory map file for UTF-8, ISO 8859-1, US-ASCII
– Character sets where line feeds easily identifiable
 Efficient splitting of mapped memory region
 Divides approximately in half
– To nearest line feed
81
© Copyright Azul Systems 2016
Parallel Lines Performance
82
© Copyright Azul Systems 2016
Optional: New Methods
 ifPresentOrElse(Consumer action, Runnable emptyAction)
– If a value is present call accept() on action with the value
– Otherwise, run the emptyAction
 Not in a separate thread
 or(Supplier<? extends Optional<? extends T>> supplier)
– Return the Optional if there is a value
– Otherwise, return a new Optional created by the Supplier
 stream()
– Returns a stream of zero or one element
83
© Copyright Azul Systems 2016
Smaller Features
 Process API updates (JEP 102)
– Native process
– Process/ProcessHandle/ProcessHandle.Info
 Process.toHandle()
– More information about process
 Command. command line, arguments, CPU duration, user
– Control subject to security manager permissions
84
© Copyright Azul Systems 2016
Multi-Release Jar Files (JEP 238)
 Multiple Java release-specific class files in a single archive
 Enhance jar tool to create multi-release files
 Support multi-release jar files in the JRE
– Classloaders
– JarFile API
 Enhance other tools
– javac, javap, jdeps, etc.
 Also, modular jar files
85
© Copyright Azul Systems 2016 86
jshell
Read-Eval-Print Loop
(REPL)
Demo
© Copyright Azul Systems 2016
Spin-Wait Hints (JEP 285)
 Proposed by Azul
– We rock!
 A new method for Thread class
– onSpinWait()
 Enables the x86 PAUSE instruction to be used from Java
code
– If available
– Ignored otherwise
– Improved performance for things like Disruptor
87
© Copyright Azul Systems 2016
Reactive Streams (JEP 266)
 Reactive streams publish-subscribe framework
 Asynchronous, non-blocking
 Flow
– Publisher, Subscriber, Processor, Subscription
 SubmissionPublisher utility class
– Asynchronously issues items to current subscribers
– Implements Flow.Processor
88
© Copyright Azul Systems 2016
Reactive Streams: The Problem
89
Publisher Subscriber
Process
Process
Process
Process
BLOCK
© Copyright Azul Systems 2016
Reactive Streams: Flow API
 Set of interfaces
 Publisher
– Producer of items to be received by Subscribers
 Subscriber
– Receiver of messages
 Processor
– Both a Publisher and Subscriber (chaining)
 Subscription
– Message control linking a Publisher and Subscriber
90
© Copyright Azul Systems 2016
Reactive Streams: Flow API
 Publisher
– subscribe(Subscriber)
 Subscriber
– OnSubscribe(Subscription)
– onNext(T item)
– onComplete() / onError(Throwable)
 Subscription
– request(long)
– cancel()
91
© Copyright Azul Systems 2016
Solution
92
Publisher Subscriber
Subscription
request(4)
subscribe
onSubscribe
onItem
onItem
onItem
onItem
request(2)
© Copyright Azul Systems 2016
Concurrency Updates (JEP 266)
 CompletableFuture additions
– Delays and timeouts
– Better support for sub-classing
– New static utility methods
 minimalCompletionStage
 failedStage
 newIncompleteFuture
 failedFuture
93
© Copyright Azul Systems 2016
Variable Handles (JEP 193)
 Replacement for parts of sun.misc.Unsafe
 Fence operations
– Fine grained memory control
– Atomic operations on object fields and array elements
 VarHandle
– compareAndExchange(), compareAndSet()
– getAndAdd(), getAndSet()
– acquireFence(), releaseFence()
94
© Copyright Azul Systems 2016
JDK 9 Other Features
© Copyright Azul Systems 2016
Enhanced Deprecation (JEP 277)
 We have @deprecated and @Deprecated
– Used to cover too many situations
 New methods in Deprecated annotation
– boolean forRemoval()
 Will this ever be removed?
– String since()
 JDK Version when this was deprecated
 Several @Deprecated tags added
– java.awt.Component.{show(),hide()} removed
 jdeprscan command to produce report
96
© Copyright Azul Systems 2016
Default Collector: G1 (JEP 248)
 G1 now mature in development
 Designed as low-pause collector
 Concurrent class unloading (JEP 156) JDK8u40
– Useful enhancement to improve G1
 Still falls back to full compacting collection
– Pause times proportional to heap size
– Use Zing from Azul for truly pauseless
97
© Copyright Azul Systems 2016
Better String Performance
 Compact strings (JEP 254)
– Improve the space efficiency of the String class
– Not using alternative encodings
 Store interned strings in CDS archive (JEP 250)
– Share String and char[] objects between JVMs
 Indify String concatenation (JEP 280)
– Change from static String-concatenation bytecode
sequence to invokedynamic
– Allow future performance improvements
98
© Copyright Azul Systems 2016
JIT Compiler Control (JEP 165)
 Control of C1/C2 JIT
– Directive file
– Runtime changes via jcmd
99
© Copyright Azul Systems 2016
Compiler Directive Example
[ //Array of directives
{ //Directive Block
//Directive 1
match: ["java*.*","oracle*.*"],
c1: { Enable: true, Exclude: true, BreakAtExecute: true, },
c2: { Enable: false, MaxNodeLimit: 1000, },
BreakAtCompile: true, DumpReplay: true,
}, { //Directive Block
//Directive 2
match: ["*Concurrent.*"],
c2: { Exclude:true, },
},
]
© Copyright Azul Systems 2016
AOT Compilation (JEP 295)
 Experimental feature in JDK 9
– -XX:+UnlockExperimentalVMOptions
– Only the java.base module has an AOT version
 jaotc command
– jaotc --output libMyStuff.so MyStuff.jar
 JVM uses AOT code to replace interpreted
– Can recompile with C1 to collect further profiling data
– Recompile with C2 for optimum performance
101
© Copyright Azul Systems 2016
AOT Compilation
 Future use
 Project Metropolis
– Rewrite the JVM in Java
– Start with AOT code, profile and recompile with JIT
102
© Copyright Azul Systems 2016
Migrating Applications To JDK 9
© Copyright Azul Systems 2016
Migration Guidance From Oracle
104
"Clean applications that just depend on java.se
should just work"
© Copyright Azul Systems 2016
Java Platform Module System
 We now have both classpath and modulepath
 No more rt.jar or tools.jar
 Dealing with internal API encapsulation
105
© Copyright Azul Systems 2016
Migrating Applications to JPMS
 Initially, leave everything on the classpath
 Anything on the classpath is in the unnamed module
– All packages are exported
– The unnamed module depends on all modules
 Migrate to modules as required
– Try automatic modules
– Move existing jar files from classpath to modulepath
106
© Copyright Azul Systems 2016
Reversing Encapsulation
 "The Big Kill Switch"
--illegal-access
 Four options:
– permit (current default)
– warn
– debug
– deny (future default)
© Copyright Azul Systems 2016
Reversing Encapsulation
 Big kill switch overrides encapsulation
– From the unnamed module (i.e. classpath)
– Allows unlimited refective access to named modules
 Not from named modules
 Warning messages written to error stream
 Useful to understand use of --add-exports and -
-add-opens when migrating to named modules
© Copyright Azul Systems 2016
Reversing Encapsulation
 Allowing direct access to encapsulated APIs
– --add-exports
 Allowing reflective access to encapsulated APIs
– --add-opens
109
--add-exports java.management/com.sun.jmx.remote.internal=mytest
--add-exports java.management/sun.management=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
© Copyright Azul Systems 2016
Reversing Encapsulation
 Using the JAR file manifest
110
Add-Exports: java.base/sun.security.provider
© Copyright Azul Systems 2016
Finding Encapsulated API Use
 jdeps
– Analyses dependencies on APIs
 Example: Minecraft
111
jdeps --list-deps 1.8.jar
java.base
java.datatransfer
java.desktop
java.management
java.naming
not found
unnamed module: 1.8.jar
© Copyright Azul Systems 2016
"Missing" Modules
 Remember, "Clean applications that only use java.se..."
 The java.se.ee module not included by default
– Compilation and runtime
 Affected modules
– java.corba
– java.transaction
– java.activation
– java.xml.bind
– java.xml.ws
– java.xml.ws.annotation
112
© Copyright Azul Systems 2016
Using "Missing" Modules
 Use the command line option
– --add-modules java.corba
 All modules (except CORBA) have standalone versions
– Maven central
– Relevant JSR RI
 Deploy standalone version on the upgrade module path
– --upgrade-module-path <path>
 Deploy standalone version on the classpath
113
© Copyright Azul Systems 2016
Small Incompatibilities
© Copyright Azul Systems 2016
Milling Project Coin
 A single underscore is now a keyword in Java
 Fear not, two or more underscores can still be used
115
error: as of release 9, '_' is a keyword, and may not be used as
an identifier
© Copyright Azul Systems 2016
Deleted Deprecated Methods
 Classes
– java.util.jar.Pack200
– java.util.jar.Unpack200
– java.util.logging.LogManager
 Methods
– addPropertyChangeListener()
– removePropertyChangeListener()
 Removal required for clean modularisation
116
© Copyright Azul Systems 2016
Deleted Deprecated Class
 com.sun.security.auth.callback.DialogCallbackHandler
 Part of the Java Authentication and Authorisation Service
– JAAS
– Deprecated in JDK 7
117
© Copyright Azul Systems 2016
Finding Deprecated API Use
 jdeprscan
– New tool in JDK 9
– Statically analyses class files and jar files against Java
SE APIs
– Looks for and reports usage of deprecated Java SE APIs
118
© Copyright Azul Systems 2016
JDK/JRE File Structure (JEP 220)
119
bin
Pre-JDK 9 JDK 9
lib
tools.jar
jre
bin
rt.jar
lib
libconfbin
jre directory
tools.jar
rt.jar
jmods
© Copyright Azul Systems 2016
JDK Version String Format
 Old
– Limited update release/Critical patch update (CPU)
– Download: Java SE 8u131
 java -version: jdk1.8.0_131
– Which has more patches, JDK 7u55 or JDK 7u60?
120
© Copyright Azul Systems 2016
JDK Version Numbering
 New, new scheme. JEP 322
– $FEATURE.$INTERIM.$UPDATE.$PATCH
– FEATURE: Was MAJOR, i.e. 10, 11, etc.
– INTERIM: Was MINOR. Always zero, reserved for future use
– UPDATE: Was SECURITY, but with different incrementing rule
– PATCH: Emergency update outside planned schedule
121
© Copyright Azul Systems 2016
Non-Programmatic Issues
 Java Network Launch Protocol (JNLP) [JSR 52]
– Now uses strict parsing of configuration files
– Some files that did parse may now fail
 Extension mechanism/Endorsed Standards Override
mechanisms removed
– Directories removed
 $JAVA_HOME/lib/ext
 $JAVA_HOME/lib/endorsed
122
<JAVA_HOME>/lib/ext exists, extensions mechanism no longer
supported; Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
© Copyright Azul Systems 2016
Removed GC Options (JEP 214)
 Deprecated in JDK 8 (JEP 173)
123
DefNew + CMS : -XX:-UseParNewGC -XX:+UseConcMarkSweepGC
ParNew + SerialOld : -XX:+UseParNewGC
ParNew + iCMS : -Xincgc
ParNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC
DefNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC
-XX:-UseParNewGC
CMS foreground : -XX:+UseCMSCompactAtFullCollection
CMS foreground : -XX:+CMSFullGCsBeforeCompaction
CMS foreground : -XX:+UseCMSCollectionPassing
© Copyright Azul Systems 2016
JVM Logging
 Unified JVM logging (JEP 158)
– Common logging system for all components of JVM
 Unified GC logging (JEP 271)
– Re-implement GC logging using unified JVM logging
– Many command line options changed
124
© Copyright Azul Systems 2016
Removed JVM Flags: Ignored
125
 AdaptiveSizePausePolicy
 CodeCacheMinimumFreeSpace
 DefaultThreadPriority
 JNIDetachReleasesMonitors
 LazyBootClassLoader
 NmethodSweepCheckInterval
 NmethodSweepFraction
 PrintOopAddress
 ReflectionWrapResolutionErrors
 StarvationMonitorInterval
 ThreadSafetyMargin
 UseAltSigs
 UseBoundThreads
 UseCompilerSafepoints
 UseFastAccessorMethods
 UseFastEmptyMethods
 BackEdgeThreshold
 PreInflateSpin
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option
<Option>; support was removed in 9.0
© Copyright Azul Systems 2016
Deprecated JVM Flags
126
© Copyright Azul Systems 2016
Deprecated JVM Flags
 Two forms of warning message
127
warning[gc] -XX:+PrintGC is deprecated. Will use -Xlog:gc instead.
Java HotSpot(TM) 64-Bit Server VM warning: Option
CreateMinidumpOnCrash was deprecated in version 9.0 and will likely
be removed in a future release. Use option CreateCoredumpOnCrash
instead.
© Copyright Azul Systems 2016
JVM Flags: Non-Starters (1)
128
 AdjustConcurrency
 CMSCompactWhenClearAllSoftRefs
 CMSDumpAtPromotionFailure
 CMSFullGCsBeforeCompaction
 CMSIncrementalDutyCycle
 CMSIncrementalDutyCycleMin
 CMSIncrementalMode
 CMSIncrementalOffset
 CMSIncrementalPacing
 CMSParPromoteBlocksToClaim
 CMSPrintEdenSurvivorChunks
 CollectGen0First
 GCLogFileSize
 NumberOfGCLogFiles
 ParallelGCVerbose
 PrintAdaptiveSizePolicy
 PrintCMSInitiationStatistics
 PrintCMSStatistics
 PrintClassHistogramAfterFullGC
 PrintClassHistogramBeforeFullGC
 PrintFLSCensus
 PrintFLSStatistics
 PrintGCApplicationConcurrentTime
 PrintGCApplicationStoppedTime
 PrintGCCause
 PrintGCDateStamps
© Copyright Azul Systems 2016
JVM Flags: Non-Starters (2)
129
 PrintGCTaskTimeStamps
 PrintGCTimeStamps
 PrintHeapAtGC
 PrintHeapAtGCExtended
 PrintJNIGCStalls
 PrintOldPLAB
 PrintPLAB
 PrintParallelOldGCPhaseTimes
 PrintPromotionFailure
 PrintReferenceGC
 PrintTLAB
 PrintTenuringDistribution
 TraceDynamicGCThreads
 TraceGen0Time
 TraceGen1Time
 TraceMetadataHumongousAllocation
 TraceParallelOldGCTasks
 UseCMSCollectionPassing
 UseCMSCompactAtFullCollection
 UseGCLogFileRotation
 UseMemSetInBOT
 UsePPCLWSYNC
 UseVMInterruptibleIO
 WorkAroundNPTLTimedWaitHang
© Copyright Azul Systems 2016
JVM Flags: Non-Starters
 50 command line flags from JDK 8
 Use will cause the JVM to abort at start
– It won't run your application
130
Unrecognized VM option '<Option>'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
© Copyright Azul Systems 2016
Real World Example
© Copyright Azul Systems 2016
HdrHistogram Library
 Open source library (created by Gil Tene, Azul CTO)
 Ideally this should work with JDK 6, 7, 8 and 9 code
– Unchanged and with no special command line flags
 Problem:
– Needs to encode and decode using Base64
 Solutions:
– sun.misc.BASE64Encoder/Decoder (JDK 6, 7, 8)
– javax.xml.bind.DatatypeConverter (JDK 6, 7, 8)
– java.util.Base64.{Encoder,Decoder} (JDK 8, 9)
132
© Copyright Azul Systems 2016
Solution
 Helper class with same named methods as from xml.bind
– printBase64Binary(byte[] array)
– parseBase64Binary(String input)
 Static code to determine which class is available
– Initialise Method object reference
 Helper methods invoke through method reference to
available implementation
133
© Copyright Azul Systems 2016
Solution (1)
 Code in static block
try {
Class<?> javaUtilClass = Class.forName("java.util.Base64");
Method getDecoderMethod = javaUtilClass.getMethod("getDecoder");
decoderObj = getDecoderMethod.invoke(null);
decodeMethod = decoderObj.getClass().getMethod("decode", String.class);
Method getEncoderMethod = javaUtilClass.getMethod("getEncoder");
encoderObj = getEncoderMethod.invoke(null);
encodeMethod = encoderObj.getClass()
.getMethod("encodeToString", byte[].class);
} catch (Throwable e) { // ClassNotFoundException, NoSuchMethodException
decodeMethod = null;
encodeMethod = null;
}
© Copyright Azul Systems 2016
Solution (2)
135
if (encodeMethod == null) {
decoderObj = null;
encoderObj = null;
try {
Class<?> xmlBindClass = Class.forName("javax.xml.bind.DatatypeConverter");
decodeMethod = xmlBindClass.getMethod("parseBase64Binary", String.class);
encodeMethod = xmlBindClass.getMethod("printBase64Binary", byte[].class);
} catch (Throwable e) {
decodeMethod = null;
encodeMethod = null;
}
}
© Copyright Azul Systems 2016
JDK 10
© Copyright Azul Systems 2016
Local Variable Type Inference
 At first sight, simple change
– Use var rather than explicit type declaration
– The compiler will infer the type for you
137
var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
© Copyright Azul Systems 2016
Local Variable Type Inference
 var is now a reserved type
138
var var = new ArrayList<String>();
public class var {
public var(String x) {
...
}
}
© Copyright Azul Systems 2016
Local Variable Type Inference
 Very useful for intersection types
139
Stream<T> stream(Iterator<T>)
try (elements) {
Optional<String> first = stream(elements)
.findFirst(e -> e.startsWith("a"));
}
Closeable & Iterator elements; // COMPILER ERROR!
var elements; // CORRECTLY INFERED NON-DENOTABLE TYPE
© Copyright Azul Systems 2016
Local Variable Type Inference
 Non-denotable types
140
Object product = new Object() {
String name = "Widget";
int num= 20;
}
System.out.println("Name = " + product.name + ": " + product.num);
var product = new Object() {
String name = "Widget";
int num= 20;
}
System.out.println("Name = " + product.name + ": " + product.num);
© Copyright Azul Systems 2016
JEP 307: Parallel Full GC for G1
 G1 is the default (server-class) collector since JDK 9
 Parallel collector performs full GC in parallel
 G1 full GC was single threaded
– Mark-Sweep-Compact
 Now performs full GC in parallel
 Number of threads is the same as used for rest of G1
– -XX:ParallelGCThreads
141
© Copyright Azul Systems 2016
JEP 310: App Class-Data Sharing
 Strangely, only available on OpenJDK binary
– Not Oracle JDK (was a commercial feature)
 JVM startup requires classes to be loaded
– Same thing happens every time
 Application CDS effectively caches loaded classes
– Improved startup time for applications
– Can be shared between JVMs on same machine
142
© Copyright Azul Systems 2016
Application CDS
143
java -Xshare:off
-XX:+UseAppCDS
-XX:DumpLoadedClassList=archive.list -cp zapp.jar Zapp
java -X:share:dump
-XX:+UseAppCDS
-XX:DumpLoadedClassList=archive.list
-XX:SharedArchiveFile=archive.jsa -cp zapp.jar
java -Xshare:on
-XX:+UseAppCDS
-XX:SharedArchiveFile=archive.jsa -cpzapp.jar Zapp
© Copyright Azul Systems 2016
JEP 317: Graal JIT compiler
 Extend use of Graal to JIT compilation
 JIT compiler written in Java
– byte[] in, byte[] out
– We don't need a systems language like C++
– Made much simpler by JVMCI in JDK 9
 Part of Project Metropolis
 -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
144
© Copyright Azul Systems 2016
JEP 319: Root Certificates
 The cacerts keystore file of OpenJDK was empty
– Things like TLS don't work without configuration
 Now has root certificates
– From providers in Oracle's Java SE root CA program
 17 root certificate providers
– Including Digicert, DocuSign, Comodo CA
145
© Copyright Azul Systems 2016
JEP 296: Single Repo JDK
 JDK 9 and earlier had six separate repos
 root
 corba
 hotspot
 jaxp
 jaxws
 jdk
 langtools
 nashorn
 Problems like atomic commits across repos
– Now just one repo
146
© Copyright Azul Systems 2016
JEP 316: Alternative Device Heap
 Some Non-Volatile RAM now as fast as DRAM
– Intel 3D XPoint
– Need to have same semantics as DRAM
 Safe atomic operations
 Existing heap related flags work unchanged
 Good for multi-JVM systems
– Select heap device appropriate to application
 -XX:AllocateHeapAt=<path>
147
© Copyright Azul Systems 2016
JEP 304: GC Interface
 Most collector code lives in
– src/hotspot/share/gc/$NAME But not all (barriers,
etc)
 Extension to existing CollectedHeap class
 New collector must provide:
 A heap (sub-class of CollectedHeap)
 Barrier set (sub-class of BarrierSet)
 Implementation of CollectorPolicy, GCInterpreterSupport,
GCC1Support, GCC2Support
 Setup of a MemoryService
148
© Copyright Azul Systems 2016
JEP 312: Thread-Local Handshake
 JVM performance enhancement
– Not accessible directly by developers
– Use a handshake (callback) rather than safepoint
– Pause one thread rather than all or none
 Example potential use cases
 Biased-lock revocation
 Deoptimisation
 External requests for stack traces
 Eliding memory barriers
149
© Copyright Azul Systems 2016
JDK 10: APIs
 73 New APIs
– All methods
– No new classes
 Packages affected
– java.awt/javax.swing (!)
– java.io/nio/net
– java.lang
– java.time
– java.util
150
© Copyright Azul Systems 2016
JDK 10: APIs
 New static methods on fundamental collection types
– List, Set, Map.copyOf(Collection)
151
List fixedList = List.copyOf(myList);
© Copyright Azul Systems 2016
JDK 10: APIs
 Replacement for Optional.get()
– Optional.orElseThrow()
152
try {
Optional<MyType> result = getResult();
MyType value = result.orElseThrow();
} catch (NoSuchElementException nsee) {
System.out.println("No value in the optional");
}
© Copyright Azul Systems 2016
JDK 10: APIs
– New Collectors
 toUnmodifiableList
 toUnmodifiableMap
 toUnmodifiableSet
153
List fixedList = data.stream()
.filter(dp -> dp.colourIsBlue())
.map(dp -> dp.getName())
.collect(Collectors.toUnmodifiableList());
© Copyright Azul Systems 2016
JDK 10: Miscellaneous
 XMLInputFactory.newFactory() de-deprecated
(precated?)
 com.sun.security.auth package
– Six deprecated classes removed
 java.lang.SecurityManager
– One deprecated field and seven methods removed
154
© Copyright Azul Systems 2016
JVM Container Support
 JVM now properly CGroup aware
 Initial values correctly calculated
– Heap sizing
– Thread pooling
155
© Copyright Azul Systems 2016
Summary
© Copyright Azul Systems 2016
Summary
 JDK 9 has many changes
 Java Platform Module System is the big one
– Migrating applications needs testing
 Other useful smaller features
 Removal of features and APIs a big change for Java
 JDK 10 first six-month development cycle
– Less changes
– Local variable type inference is useful
 Java continues to evolve!
157
© Copyright Azul Systems 2016
Zulu Java
 Azul’s binary distribution of OpenJDK
– Passes all TCK tests
– Multi-platform (Windows, Linux, Mac)
– Free, with paid support options
– No licensing issues
– Verified as built from 100% open-source
 JDK 6, 7, 8 and 9
158
www.zulu.org/download
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
Thank you
Simon Ritter
Deputy CTO, Azul Systems
159

Weitere ähnliche Inhalte

Was ist angesagt?

Java Support: What's changing
Java Support:  What's changingJava Support:  What's changing
Java Support: What's changingSimon Ritter
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Simon Ritter
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondSimon Ritter
 
JDK 9: 55 New Features
JDK 9: 55 New FeaturesJDK 9: 55 New Features
JDK 9: 55 New FeaturesSimon Ritter
 
Building a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVMBuilding a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVMSimon Ritter
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still FreeSimon Ritter
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New FeaturesSimon Ritter
 
Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Simon Ritter
 
Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Simon Ritter
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawComsysto Reply GmbH
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future KeynoteSimon Ritter
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pavel Bucek
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Robert Scholte
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9Deepu Xavier
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGJDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGYuji Kubota
 
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Vadym Kazulkin
 

Was ist angesagt? (20)

Java Support: What's changing
Java Support:  What's changingJava Support:  What's changing
Java Support: What's changing
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and Beyond
 
JDK 9: 55 New Features
JDK 9: 55 New FeaturesJDK 9: 55 New Features
JDK 9: 55 New Features
 
Building a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVMBuilding a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVM
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still Free
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New Features
 
Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014
 
Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project Jigsaw
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future Keynote
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)
 
Java 9 preview
Java 9 previewJava 9 preview
Java 9 preview
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGJDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUG
 
Java 9 and Project Jigsaw
Java 9 and Project JigsawJava 9 and Project Jigsaw
Java 9 and Project Jigsaw
 
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
 
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
 

Ähnlich wie JDK 9 and JDK 10 Deep Dive

Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller Patroklos Papapetrou (Pat)
 
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...Voxxed Days Thessaloniki
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9Simon Ritter
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerSimon Ritter
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaC4Media
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Shaun Smith
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesGlobalLogic Ukraine
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityDanHeidinga
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10Arto Santala
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best PracticesDavid Delabassee
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Robert Scholte
 
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD ApplicationsEWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD ApplicationsRob Tweed
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 

Ähnlich wie JDK 9 and JDK 10 Deep Dive (20)

Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
 
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To Java
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Jigsaw modularity
Jigsaw modularityJigsaw modularity
Jigsaw modularity
 
Advanced modular development
Advanced modular development  Advanced modular development
Advanced modular development
 
Java modules
Java modulesJava modules
Java modules
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after Modularity
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best Practices
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
 
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD ApplicationsEWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD Applications
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Java8 - Under the hood
Java8 - Under the hoodJava8 - Under the hood
Java8 - Under the hood
 

Mehr von Simon Ritter

Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native CompilerSimon Ritter
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type PatternsSimon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoringSimon Ritter
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern JavaSimon Ritter
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVMSimon Ritter
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDKSimon Ritter
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologySimon Ritter
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologySimon Ritter
 
Is Java Still Free?
Is Java Still Free?Is Java Still Free?
Is Java Still Free?Simon Ritter
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12Simon Ritter
 
It's Java, Jim, but not as we know it
It's Java, Jim, but not as we know itIt's Java, Jim, but not as we know it
It's Java, Jim, but not as we know itSimon Ritter
 
Whats New For Developers In JDK 9
Whats New For Developers In JDK 9Whats New For Developers In JDK 9
Whats New For Developers In JDK 9Simon Ritter
 
Streams: The Good, The Bad And The Ugly
Streams: The Good, The Bad And The UglyStreams: The Good, The Bad And The Ugly
Streams: The Good, The Bad And The UglySimon Ritter
 

Mehr von Simon Ritter (17)

Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native Compiler
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern Java
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
 
Java after 8
Java after 8Java after 8
Java after 8
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDK
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java Technology
 
Is Java Still Free?
Is Java Still Free?Is Java Still Free?
Is Java Still Free?
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12
 
It's Java, Jim, but not as we know it
It's Java, Jim, but not as we know itIt's Java, Jim, but not as we know it
It's Java, Jim, but not as we know it
 
Whats New For Developers In JDK 9
Whats New For Developers In JDK 9Whats New For Developers In JDK 9
Whats New For Developers In JDK 9
 
Streams: The Good, The Bad And The Ugly
Streams: The Good, The Bad And The UglyStreams: The Good, The Bad And The Ugly
Streams: The Good, The Bad And The Ugly
 

Kürzlich hochgeladen

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Kürzlich hochgeladen (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

JDK 9 and JDK 10 Deep Dive

  • 1. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava JDK 9 and 10 Deep Dive Simon Ritter Deputy CTO, Azul Systems 1
  • 2. © Copyright Azul Systems 2016 JDK 9: 86 Changes 2
  • 3. © Copyright Azul Systems 2016 JDK 9: Agenda  Java Platform Module System  Developer features  Other things  Migrating applications to JDK 9 – Real world example 3
  • 4. © Copyright Azul Systems 2016 4 JPMS: API Structural Changes
  • 5. © Copyright Azul Systems 2016 API Classification  Supported, intended for public use – JCP specified: java.*, javax.* – JDK specific: some com.sun.*, some jdk.*  Unsupported, not intended for public use – Mostly sun.* – Most infamous is sun.misc.Unsafe 5
  • 6. © Copyright Azul Systems 2016 General Java Compatability Policy  If an application uses only supported APIs on version N of Java it should work on version N+1, even without recompilation  Supported APIs can be removed –But only with advanced notice  JDK 8 has 18 interfaces, 23 classes, 64 fields, 358 methods and 20 constructors that have been deprecated –None have been removed –Until now 6
  • 7. © Copyright Azul Systems 2016 Most Popular Unsupported APIs 1. sun.misc.BASE64Encoder 2. sun.misc.Unsafe 3. sun.misc.BASE64Decoder 7 Oracle dataset based on internal application code
  • 8. © Copyright Azul Systems 2016 JDK Internal API Classification  Non-critical – Little or no use outside the JDK – Used only for convenience (alternatives exist)  Critical – Functionality that would be difficult, if not impossible to implement outside the JDK 8
  • 9. © Copyright Azul Systems 2016 JEP 260 Proposal  Encapsulate all non-critical JDK-internal APIs  Encapsulate all critical JDK-internal APIs, for which supported replacements exist in JDK 8  Do not encapsulate other critical JDK-internal APIs – Deprecate these in JDK 9 – Plan to encapsulate or remove them in the future – Command-line option to access encapsulated critical APIs  --add-exports  --add-opens 9
  • 10. © Copyright Azul Systems 2016 JEP 260 Accessible Critical APIs  sun.misc.Unsafe  sun.misc.Signal  sun.misc.SignalHandler  sun.misc.Cleaner  sun.reflect.Reflection.getCallerClass  sun.reflect.ReflectionFactory 10
  • 11. © Copyright Azul Systems 2016 Project Jigsaw And Modules
  • 12. © Copyright Azul Systems 2016 Goals For Project Jigsaw  Make Java SE more scalable and flexible – Internet of Things – Microservices  Improve security, maintainability and performance  Simplify construction, deployment and maintenance of large scale applications  Eliminate classpath hell 12
  • 13. © Copyright Azul Systems 2016 Module Fundamentals  Module is a grouping of code – For Java this is a collection of packages  Modules can contain other things – Native code – Resources – Configuration data 13 com.azul.zoop com.azul.zoop.alpha.Name com.azul.zoop.alpha.Position com.azul.zoop.beta.Animal com.azul.zoop.beta.Reptile com.azul.zoop.theta.Zoo com.azul.zoop.theta.Lake
  • 14. © Copyright Azul Systems 2016 Module Declaration 14 module com.azul.zoop { } module-info.java com/azul/zoop/alpha/Name.java com/azul/zoop/alpha/Position.java com/azul/zoop/beta/Animal.java com/azul/zoop/beta/Reptile.java com/azul/zoop/theta/Zoo.java com/azul/zoop/theta/Lake.java
  • 15. © Copyright Azul Systems 2016 Module Dependencies module com.azul.zoop { requires com.azul.zeta; } com.azul.zoop com.azul.zeta
  • 16. © Copyright Azul Systems 2016 Module Dependencies module com.azul.zapp { requires com.azul.zoop; requires java.sql; } com.azul.zapp com.azul.zoop java.sql
  • 17. © Copyright Azul Systems 2016 Module Dependency Graph com.azul.zapp java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging explicit implicit
  • 18. © Copyright Azul Systems 2016 Module Dependency Graph  No missing dependencies  No cyclic dependencies  No split packages 18
  • 19. © Copyright Azul Systems 2016 Readability v. Dependency com.azul.zapp java.sql java.logging module java.sql { requires transitive java.logging; } Driver d = … Logger l = d.getParentLogger(); l.log(“azul’); Implied readability
  • 20. © Copyright Azul Systems 2016 Module Implied Readability Graph com.azul.zapp java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging explicit implicit implied
  • 21. © Copyright Azul Systems 2016 Package Visibility module com.azul.zoop { requires com.azul.zeta; exports com.azul.zoop.alpha; exports com.azul.zoop.beta to com.azul.zapp; } com.azul.zoop com.azul.zoop.alpha com.azul.zoop.beta com.azul.zoop.thetacom.azul.zapp only
  • 22. © Copyright Azul Systems 2016 More Package Visibility open module com.azul.zoop { requires com.azul.zeta; } com.azul.zoop com.azul.zoop.alpha com.azul.zoop.beta com.azul.zoop.theta com.azul.zoop.alpha com.azul.zoop.beta com.azul.zoop.theta REFLECTIONIMPORT
  • 23. © Copyright Azul Systems 2016 Even More Package Visibility module com.azul.zoop { requires com.azul.zeta; exports com.azul.zoop.alpha; exports com.azul.zoop.beta to com.azul.zapp; opens com.azul.theta; } com.azul.zoop com.azul.zoop.theta REFLECTIONIMPORT com.azul.zoop.alpha com.azul.zoop.beta com.azul.zapp only
  • 24. © Copyright Azul Systems 2016 Restricted Keywords module requires requires; exports exports to to; module { opens opens; }
  • 25. © Copyright Azul Systems 2016 Optional Dependencies  Required at compile time  Possibly not needed at runtime – If it is generates a NoClassDefFoundError  Use static keyword – Oddly this used to be optional, which is more logical 25 module mine.lib { requires static com.google.guava }
  • 26. © Copyright Azul Systems 2016 Accessibility  For a package to be visible – The package must be exported by the containing module – The containing module must be read by the using module  Public types from those packages can then be used com.azul.zoopcom.azul.zapp reads
  • 27. © Copyright Azul Systems 2016 Java Accessibility (pre-JDK 9) public protected <package> private
  • 28. © Copyright Azul Systems 2016 Java Accessibility (JDK 9) public to everyone public, but only to specific modules public only within a module protected <package> private public ≠ accessible (fundamental change to Java)
  • 29. © Copyright Azul Systems 2016 JDK 8 Dependencies
  • 30. © Copyright Azul Systems 2016 The java.base Module module java.base { exports java.lang; exports java.io; exports java.net; exports java.util; }
  • 31. © Copyright Azul Systems 2016 JDK 9 Platform Modules 31 java.se java.compact3 java.compact2 java.compact1 java.scripting java.instrument java.base java.logging java.sql java.sql.rowset java.xml java.desktop java.rmi java.prefs java.datatransfer java.compiler java.management java.security.jgss java.naming java.security.sasl All modules depend on java.base no implied readability=
  • 32. © Copyright Azul Systems 2016 JDK 9 Platform Modules 32 java.se.e e java.se java.xml.bind java.corba java.compiler java.desktop java.annotations.common java.rmi java.datatransfer java.management java.xml.ws java.naming java.transaction java.activation All modules depend on java.base
  • 33. © Copyright Azul Systems 2016 Using Modules
  • 34. © Copyright Azul Systems 2016 Module Path $ javac –modulepath dir1:dir2:dir3
  • 35. © Copyright Azul Systems 2016 Compilation With Module Path 35 $ javac –-module-path mods –d mods src/module-info.java src/com/azul/zoop/alpha/Name.java mods/module-info.class mods/com/azul/zoop/alpha/Name.class src/module-info.java src/com/azul/zoop/alpha/Name.java
  • 36. © Copyright Azul Systems 2016 Application Execution  --module-path can be abbreviated to -p $ java –p mods –m com.azul.zapp/com.azul.zapp.Main Azul application initialised! module name main class
  • 37. © Copyright Azul Systems 2016 Packaging With Modular JAR Files mods/module-info.class mods/com/azul/zapp/Main.class $ jar --create --file=mylib/zapp.jar --main-class=com.azul.zapp.Main -C mods . module-info.class com/azul/zapp/Main.class zapp.jar
  • 38. © Copyright Azul Systems 2016 JAR Files & Module Information $ jar --file=mylib/zapp.jar –-print-module-descriptor $ jar --file=mylib/zapp.jar -d com.azul.zapp requires com.azul.zoop requires com.azul.zeta requires mandated java.base requires java.sql main-class com.azul.zapp.Main
  • 39. © Copyright Azul Systems 2016 Application Execution (JAR) $ java –p mylib:mods –m com.azul.zapp Azul application initialised!
  • 40. © Copyright Azul Systems 2016 Linking Modular run-time image …confbin jlink $ jlink --module-path $JDKMODS --add-modules java.base –-output myimage $ myimage/bin/java –-list-modules java.base@9.0
  • 41. © Copyright Azul Systems 2016 Linking An Application $ jlink --module-path $JDKMODS:$MYMODS --add-modules com.azul.zapp –-output myimage $ myimage/bin/java –-list-modules java.base@9 java.logging@9 java.sql@9 java.xml@9 com.azul.zapp@1.0 com.azul.zoop@1.0 com.azul.zeta@1.0 Version numbering for information purposes only “It is not a goal of the module system to solve the version- selection problem”
  • 42. © Copyright Azul Systems 2016 The Implications Of jlink  "Write once, run anywhere" – Long term Java slogan, mainly held true  jlink generated runtime may not include all Java SE modules – But is still a conforming Java implementation – To conform to the specification, the runtime:  Must include the java.base module  If other modules are included, all transitive module dependencies must also be included – Defined as a closed implementation
  • 43. © Copyright Azul Systems 2016 Application Migration
  • 44. © Copyright Azul Systems 2016 Typical Application (JDK 8) jar jar jar JDK jar jarjar jar jar jar jar jar jar Classpath
  • 45. © Copyright Azul Systems 2016 Typical Application (JDK 9) jar jar jar module java.base module java.desktop module java.datatransfer module java.xml jar jarjar jar jar jar jar jar jar Unnamed module
  • 46. © Copyright Azul Systems 2016 Sample Application myapp.ja r libgl.jar mylib.jar gluegen.jar jogl.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 47. © Copyright Azul Systems 2016 Run Application With Classpath $ java –classpath lib/myapp.jar: lib/mylib.jar: lib/libgl.jar: lib/gluegen.jar: lib/jogl.jar: myapp.Main
  • 48. © Copyright Azul Systems 2016 Sample Application module myapp.ja r libgl.jar module mylib.jar gluegen.jar jogl.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 49. © Copyright Azul Systems 2016 Application module-info.java module myapp { requires mylib; requires java.base; requires java.sql; requires libgl; ???? requires gluegen; ???? requires jogl; ???? }
  • 50. © Copyright Azul Systems 2016 Sample Application module myapp.ja r module libgl.jar module mylib.jar module gluegen.jar module jogl.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 51. © Copyright Azul Systems 2016 Automatic Modules  Real modules  Simply place unmodified jar file on module path – Rather than classpath  No changes to JAR file  Module name derived from JAR file name  Exports all its packages – No selectivity  Automatically requires all modules on the module path 51
  • 52. © Copyright Azul Systems 2016 Application Module Dependencies module myapp.ja r module libgl.jar module mylib.jar module gluegen.jar module jogl.jar module java.base module java.desktop module java.datatransfer module java.xml Implicit Explicit
  • 53. © Copyright Azul Systems 2016 Run Application With Modules $ java –classpath lib/myapp.jar: lib/mylib.jar: lib/libgl.jar: lib/gluegen.jar: lib/jogl.jar: myapp.Main $ java –p mylib:lib –m myapp
  • 54. © Copyright Azul Systems 2016 Advanced Details
  • 55. © Copyright Azul Systems 2016 Modular Jar Files And JMODs  Modular jar files are simple – Standard jar file possibly with module-info.class file – Can use existing (unmodified) jar files  JMOD files – More complex module files – Used for modules in the JDK – Can include native files (JNI), configuration files and other data – Based on zip file format (pending final details - JEP 261) 55
  • 56. © Copyright Azul Systems 2016 jmod Command  Create can specify several details: – Main class – Native libraries and commands – Configuration data – OS name, version and machine architecture  Details included in module-info.class file 56 jmod (create | list | describe) <options> <jmod-file>
  • 57. © Copyright Azul Systems 2016 Classloaders (Since JDK 1.2) 57 Bootstrap classloader (Internal Class) Bootstrap Class Path Extension classloader (URLClassLoader) Extension Mechanism Application classloader (URLClassLoader) Class Path
  • 58. © Copyright Azul Systems 2016 Classloaders (JDK 9) 58 Bootstrap classloader (Internal Class) bootstrap class path Platform classloader (Internal Class) JDK classes with specific permissions Application classloader (Internal Class) Class & Module Path
  • 59. © Copyright Azul Systems 2016 Services module java.sql { requires transient java.logging; requires transient java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; uses java.sql.Driver; }
  • 60. © Copyright Azul Systems 2016 Services module com.mysql.jdbc { requires java.sql; exports com.mysql.jdbc; provides java.sql.Driver with com.mysql.jdbc.Driver; }
  • 61. © Copyright Azul Systems 2016 Avoiding Cyclic Dependencies logging.api logging.impl http.client
  • 62. © Copyright Azul Systems 2016 Avoiding Cyclic Dependencies logging.api logging.impl http.client
  • 63. © Copyright Azul Systems 2016 Avoiding Cyclic Dependencies logging.api logging.impl http.client interface Logger class HttpLogger implements Logger uses Logger provides Logger with HttpLogger
  • 64. © Copyright Azul Systems 2016 Incubator Modules (JEP 11)  Develop APIs without making them part of the standard – At least not straight away  Allow developers to “kick the tyres” – Not always possible to get a new API right first time  Move from incubator to full module – Becomes part of the standard  JDK 9 only has one incubator: HTTP/2 (JEP 110)  Some concerns about fragmentation --do-not-resolve-by-default 64
  • 65. © Copyright Azul Systems 2016 JDK 9 Developer Features
  • 66. © Copyright Azul Systems 2016 Java Language
  • 67. © Copyright Azul Systems 2016 Milling Project Coin (JEP 213)  Single underscore is now a reserved word – No longer usable as an identifier – Two or more underscores still works  Allow @SafeVarargs on private instance methods – In addition to constructors, final and static methods 67
  • 68. © Copyright Azul Systems 2016 Milling Project Coin  Private methods are now permitted in interfaces – Separate common code for default and static methods 68 public interface MyInterface { default int getX() { return getNum() * 2; }; static int getY() { return getNum() * 4; } private static int getNum() { return 12; } }
  • 69. © Copyright Azul Systems 2016 Milling Project Coin  Effectively final variables in try-with-resources 69 BufferedReader reader = new BufferedReader(new FileReader("/tmp/foo.txt")); try (BufferedReader myReader = reader) { myReader.lines() .forEach(System.out::println); } JDK 8 try (reader) { reader.lines() .forEach(System.out::println); } JDK 9
  • 70. © Copyright Azul Systems 2016 Milling Project Coin  Diamond operator with anonymous classes – Type inference can infer a non-denotable type – If the type inferred can be denotable you can use <> 70 public abstract class Processor<T> { abstract void use(T value); } Processor<String> processor = new Processor<>() { @Override void use(String value) { // Some stuff } };
  • 71. © Copyright Azul Systems 2016 Core Libraries
  • 72. © Copyright Azul Systems 2016 Factory Methods For Collections (JEP 269)  The problem: – Creating a small unmodifiable collection is verbose 72 Set<String> set = new HashSet<>(); set.add("a"); set.add("b"); set.add("c"); set = Collections.unmodifiableSet(set);
  • 73. © Copyright Azul Systems 2016 Factory Methods For Collections (JEP 269)  Static methods added to List, Set and Map interfaces – Create compact, immutable instances – 0 to 10 element overloaded versions – Varargs version for arbitary number of elements 73 Set<String> set = Set.of("a", "b", "c"); List<String> list = List.of("a", "b", "c"); Map<String, String> map = Map.of(“k1”, “v1”, “k2”, “v2”); Map<String, String> map = Map.ofEntries( entry(“k1”, “v1”), entry(“k2”, “v2”));
  • 74. © Copyright Azul Systems 2016 Stream Enhancements  Collectors.flatMapping() – Returns a Collector that converts a stream from one type to another by applying a flat mapping function 74 Map<String, Set<LineItem>> items = orders.stream() .collect(groupingBy(Order::getCustomerName, flatMapping(order -> order.getLineItems().stream(), toSet())));
  • 75. © Copyright Azul Systems 2016 Improved Iteration  iterate(seed, hasNext, next) – Can be used like the classic for loop 75 Initial value Predicate UnaryOperator IntStream.iterate(0, i -> i < 10, i -> ++i) .forEach(System.out::println); IntStream.iterate(0, i -> i < 10, i -> i++) .forEach(System.out::println); Infinite stream
  • 76. © Copyright Azul Systems 2016 Stream takeWhile  Stream<T> takeWhile(Predicate<? super T> p)  Select elements from stream while Predicate matches  Unordered stream needs consideration thermalReader.lines() .mapToInt(i -> Integer.parseInt(i)) .takeWhile(i -> i < 56) .forEach(System.out::println);
  • 77. © Copyright Azul Systems 2016 Stream dropWhile  Stream<T> dropWhile(Predicate<? super T> p)  Ignore elements from stream while Predicate matches  Unordered stream still needs consideration thermalReader.lines() .mapToInt(i -> Integer.parseInt(i)) .dropWhile(i -> i < 56) .forEach(System.out::println);
  • 78. © Copyright Azul Systems 2016 dropWhile/takeWhile  Be careful of unordered streams missing values 78 list.stream() .dropWhile(s -> s.charAt(0) < ‘e') .forEach(System.out::println); List<String> list = List.of("alpha", "bravo", "charlie", "delta", "echo", "foxtrot"); list.stream() .takeWhile(s -> s.length() == 5) .forEach(System.out::println); alpha bravo echo foxtrot
  • 79. © Copyright Azul Systems 2016 Additional Stream Sources  Matcher stream support – Stream<MatchResult> results()  Scanner stream support – Stream<MatchResult> findAll(String pattern) – Stream<MatchResult> findAll(Pattern pattern) – Stream<String> tokens() 79
  • 80. © Copyright Azul Systems 2016 Additional Stream Sources  java.net.NetworkInterface – Stream<InetAddress> inetAddresses() – Stream<NetworkInterface> subInterfaces() – Stream<NetworkInterface> networkInterfaces()  static  java.security.PermissionCollection – Stream<Permission> elementsAsStream() 80
  • 81. © Copyright Azul Systems 2016 Parallel Support For Files.lines()  Memory map file for UTF-8, ISO 8859-1, US-ASCII – Character sets where line feeds easily identifiable  Efficient splitting of mapped memory region  Divides approximately in half – To nearest line feed 81
  • 82. © Copyright Azul Systems 2016 Parallel Lines Performance 82
  • 83. © Copyright Azul Systems 2016 Optional: New Methods  ifPresentOrElse(Consumer action, Runnable emptyAction) – If a value is present call accept() on action with the value – Otherwise, run the emptyAction  Not in a separate thread  or(Supplier<? extends Optional<? extends T>> supplier) – Return the Optional if there is a value – Otherwise, return a new Optional created by the Supplier  stream() – Returns a stream of zero or one element 83
  • 84. © Copyright Azul Systems 2016 Smaller Features  Process API updates (JEP 102) – Native process – Process/ProcessHandle/ProcessHandle.Info  Process.toHandle() – More information about process  Command. command line, arguments, CPU duration, user – Control subject to security manager permissions 84
  • 85. © Copyright Azul Systems 2016 Multi-Release Jar Files (JEP 238)  Multiple Java release-specific class files in a single archive  Enhance jar tool to create multi-release files  Support multi-release jar files in the JRE – Classloaders – JarFile API  Enhance other tools – javac, javap, jdeps, etc.  Also, modular jar files 85
  • 86. © Copyright Azul Systems 2016 86 jshell Read-Eval-Print Loop (REPL) Demo
  • 87. © Copyright Azul Systems 2016 Spin-Wait Hints (JEP 285)  Proposed by Azul – We rock!  A new method for Thread class – onSpinWait()  Enables the x86 PAUSE instruction to be used from Java code – If available – Ignored otherwise – Improved performance for things like Disruptor 87
  • 88. © Copyright Azul Systems 2016 Reactive Streams (JEP 266)  Reactive streams publish-subscribe framework  Asynchronous, non-blocking  Flow – Publisher, Subscriber, Processor, Subscription  SubmissionPublisher utility class – Asynchronously issues items to current subscribers – Implements Flow.Processor 88
  • 89. © Copyright Azul Systems 2016 Reactive Streams: The Problem 89 Publisher Subscriber Process Process Process Process BLOCK
  • 90. © Copyright Azul Systems 2016 Reactive Streams: Flow API  Set of interfaces  Publisher – Producer of items to be received by Subscribers  Subscriber – Receiver of messages  Processor – Both a Publisher and Subscriber (chaining)  Subscription – Message control linking a Publisher and Subscriber 90
  • 91. © Copyright Azul Systems 2016 Reactive Streams: Flow API  Publisher – subscribe(Subscriber)  Subscriber – OnSubscribe(Subscription) – onNext(T item) – onComplete() / onError(Throwable)  Subscription – request(long) – cancel() 91
  • 92. © Copyright Azul Systems 2016 Solution 92 Publisher Subscriber Subscription request(4) subscribe onSubscribe onItem onItem onItem onItem request(2)
  • 93. © Copyright Azul Systems 2016 Concurrency Updates (JEP 266)  CompletableFuture additions – Delays and timeouts – Better support for sub-classing – New static utility methods  minimalCompletionStage  failedStage  newIncompleteFuture  failedFuture 93
  • 94. © Copyright Azul Systems 2016 Variable Handles (JEP 193)  Replacement for parts of sun.misc.Unsafe  Fence operations – Fine grained memory control – Atomic operations on object fields and array elements  VarHandle – compareAndExchange(), compareAndSet() – getAndAdd(), getAndSet() – acquireFence(), releaseFence() 94
  • 95. © Copyright Azul Systems 2016 JDK 9 Other Features
  • 96. © Copyright Azul Systems 2016 Enhanced Deprecation (JEP 277)  We have @deprecated and @Deprecated – Used to cover too many situations  New methods in Deprecated annotation – boolean forRemoval()  Will this ever be removed? – String since()  JDK Version when this was deprecated  Several @Deprecated tags added – java.awt.Component.{show(),hide()} removed  jdeprscan command to produce report 96
  • 97. © Copyright Azul Systems 2016 Default Collector: G1 (JEP 248)  G1 now mature in development  Designed as low-pause collector  Concurrent class unloading (JEP 156) JDK8u40 – Useful enhancement to improve G1  Still falls back to full compacting collection – Pause times proportional to heap size – Use Zing from Azul for truly pauseless 97
  • 98. © Copyright Azul Systems 2016 Better String Performance  Compact strings (JEP 254) – Improve the space efficiency of the String class – Not using alternative encodings  Store interned strings in CDS archive (JEP 250) – Share String and char[] objects between JVMs  Indify String concatenation (JEP 280) – Change from static String-concatenation bytecode sequence to invokedynamic – Allow future performance improvements 98
  • 99. © Copyright Azul Systems 2016 JIT Compiler Control (JEP 165)  Control of C1/C2 JIT – Directive file – Runtime changes via jcmd 99
  • 100. © Copyright Azul Systems 2016 Compiler Directive Example [ //Array of directives { //Directive Block //Directive 1 match: ["java*.*","oracle*.*"], c1: { Enable: true, Exclude: true, BreakAtExecute: true, }, c2: { Enable: false, MaxNodeLimit: 1000, }, BreakAtCompile: true, DumpReplay: true, }, { //Directive Block //Directive 2 match: ["*Concurrent.*"], c2: { Exclude:true, }, }, ]
  • 101. © Copyright Azul Systems 2016 AOT Compilation (JEP 295)  Experimental feature in JDK 9 – -XX:+UnlockExperimentalVMOptions – Only the java.base module has an AOT version  jaotc command – jaotc --output libMyStuff.so MyStuff.jar  JVM uses AOT code to replace interpreted – Can recompile with C1 to collect further profiling data – Recompile with C2 for optimum performance 101
  • 102. © Copyright Azul Systems 2016 AOT Compilation  Future use  Project Metropolis – Rewrite the JVM in Java – Start with AOT code, profile and recompile with JIT 102
  • 103. © Copyright Azul Systems 2016 Migrating Applications To JDK 9
  • 104. © Copyright Azul Systems 2016 Migration Guidance From Oracle 104 "Clean applications that just depend on java.se should just work"
  • 105. © Copyright Azul Systems 2016 Java Platform Module System  We now have both classpath and modulepath  No more rt.jar or tools.jar  Dealing with internal API encapsulation 105
  • 106. © Copyright Azul Systems 2016 Migrating Applications to JPMS  Initially, leave everything on the classpath  Anything on the classpath is in the unnamed module – All packages are exported – The unnamed module depends on all modules  Migrate to modules as required – Try automatic modules – Move existing jar files from classpath to modulepath 106
  • 107. © Copyright Azul Systems 2016 Reversing Encapsulation  "The Big Kill Switch" --illegal-access  Four options: – permit (current default) – warn – debug – deny (future default)
  • 108. © Copyright Azul Systems 2016 Reversing Encapsulation  Big kill switch overrides encapsulation – From the unnamed module (i.e. classpath) – Allows unlimited refective access to named modules  Not from named modules  Warning messages written to error stream  Useful to understand use of --add-exports and - -add-opens when migrating to named modules
  • 109. © Copyright Azul Systems 2016 Reversing Encapsulation  Allowing direct access to encapsulated APIs – --add-exports  Allowing reflective access to encapsulated APIs – --add-opens 109 --add-exports java.management/com.sun.jmx.remote.internal=mytest --add-exports java.management/sun.management=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED
  • 110. © Copyright Azul Systems 2016 Reversing Encapsulation  Using the JAR file manifest 110 Add-Exports: java.base/sun.security.provider
  • 111. © Copyright Azul Systems 2016 Finding Encapsulated API Use  jdeps – Analyses dependencies on APIs  Example: Minecraft 111 jdeps --list-deps 1.8.jar java.base java.datatransfer java.desktop java.management java.naming not found unnamed module: 1.8.jar
  • 112. © Copyright Azul Systems 2016 "Missing" Modules  Remember, "Clean applications that only use java.se..."  The java.se.ee module not included by default – Compilation and runtime  Affected modules – java.corba – java.transaction – java.activation – java.xml.bind – java.xml.ws – java.xml.ws.annotation 112
  • 113. © Copyright Azul Systems 2016 Using "Missing" Modules  Use the command line option – --add-modules java.corba  All modules (except CORBA) have standalone versions – Maven central – Relevant JSR RI  Deploy standalone version on the upgrade module path – --upgrade-module-path <path>  Deploy standalone version on the classpath 113
  • 114. © Copyright Azul Systems 2016 Small Incompatibilities
  • 115. © Copyright Azul Systems 2016 Milling Project Coin  A single underscore is now a keyword in Java  Fear not, two or more underscores can still be used 115 error: as of release 9, '_' is a keyword, and may not be used as an identifier
  • 116. © Copyright Azul Systems 2016 Deleted Deprecated Methods  Classes – java.util.jar.Pack200 – java.util.jar.Unpack200 – java.util.logging.LogManager  Methods – addPropertyChangeListener() – removePropertyChangeListener()  Removal required for clean modularisation 116
  • 117. © Copyright Azul Systems 2016 Deleted Deprecated Class  com.sun.security.auth.callback.DialogCallbackHandler  Part of the Java Authentication and Authorisation Service – JAAS – Deprecated in JDK 7 117
  • 118. © Copyright Azul Systems 2016 Finding Deprecated API Use  jdeprscan – New tool in JDK 9 – Statically analyses class files and jar files against Java SE APIs – Looks for and reports usage of deprecated Java SE APIs 118
  • 119. © Copyright Azul Systems 2016 JDK/JRE File Structure (JEP 220) 119 bin Pre-JDK 9 JDK 9 lib tools.jar jre bin rt.jar lib libconfbin jre directory tools.jar rt.jar jmods
  • 120. © Copyright Azul Systems 2016 JDK Version String Format  Old – Limited update release/Critical patch update (CPU) – Download: Java SE 8u131  java -version: jdk1.8.0_131 – Which has more patches, JDK 7u55 or JDK 7u60? 120
  • 121. © Copyright Azul Systems 2016 JDK Version Numbering  New, new scheme. JEP 322 – $FEATURE.$INTERIM.$UPDATE.$PATCH – FEATURE: Was MAJOR, i.e. 10, 11, etc. – INTERIM: Was MINOR. Always zero, reserved for future use – UPDATE: Was SECURITY, but with different incrementing rule – PATCH: Emergency update outside planned schedule 121
  • 122. © Copyright Azul Systems 2016 Non-Programmatic Issues  Java Network Launch Protocol (JNLP) [JSR 52] – Now uses strict parsing of configuration files – Some files that did parse may now fail  Extension mechanism/Endorsed Standards Override mechanisms removed – Directories removed  $JAVA_HOME/lib/ext  $JAVA_HOME/lib/endorsed 122 <JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
  • 123. © Copyright Azul Systems 2016 Removed GC Options (JEP 214)  Deprecated in JDK 8 (JEP 173) 123 DefNew + CMS : -XX:-UseParNewGC -XX:+UseConcMarkSweepGC ParNew + SerialOld : -XX:+UseParNewGC ParNew + iCMS : -Xincgc ParNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC DefNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC -XX:-UseParNewGC CMS foreground : -XX:+UseCMSCompactAtFullCollection CMS foreground : -XX:+CMSFullGCsBeforeCompaction CMS foreground : -XX:+UseCMSCollectionPassing
  • 124. © Copyright Azul Systems 2016 JVM Logging  Unified JVM logging (JEP 158) – Common logging system for all components of JVM  Unified GC logging (JEP 271) – Re-implement GC logging using unified JVM logging – Many command line options changed 124
  • 125. © Copyright Azul Systems 2016 Removed JVM Flags: Ignored 125  AdaptiveSizePausePolicy  CodeCacheMinimumFreeSpace  DefaultThreadPriority  JNIDetachReleasesMonitors  LazyBootClassLoader  NmethodSweepCheckInterval  NmethodSweepFraction  PrintOopAddress  ReflectionWrapResolutionErrors  StarvationMonitorInterval  ThreadSafetyMargin  UseAltSigs  UseBoundThreads  UseCompilerSafepoints  UseFastAccessorMethods  UseFastEmptyMethods  BackEdgeThreshold  PreInflateSpin Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option <Option>; support was removed in 9.0
  • 126. © Copyright Azul Systems 2016 Deprecated JVM Flags 126
  • 127. © Copyright Azul Systems 2016 Deprecated JVM Flags  Two forms of warning message 127 warning[gc] -XX:+PrintGC is deprecated. Will use -Xlog:gc instead. Java HotSpot(TM) 64-Bit Server VM warning: Option CreateMinidumpOnCrash was deprecated in version 9.0 and will likely be removed in a future release. Use option CreateCoredumpOnCrash instead.
  • 128. © Copyright Azul Systems 2016 JVM Flags: Non-Starters (1) 128  AdjustConcurrency  CMSCompactWhenClearAllSoftRefs  CMSDumpAtPromotionFailure  CMSFullGCsBeforeCompaction  CMSIncrementalDutyCycle  CMSIncrementalDutyCycleMin  CMSIncrementalMode  CMSIncrementalOffset  CMSIncrementalPacing  CMSParPromoteBlocksToClaim  CMSPrintEdenSurvivorChunks  CollectGen0First  GCLogFileSize  NumberOfGCLogFiles  ParallelGCVerbose  PrintAdaptiveSizePolicy  PrintCMSInitiationStatistics  PrintCMSStatistics  PrintClassHistogramAfterFullGC  PrintClassHistogramBeforeFullGC  PrintFLSCensus  PrintFLSStatistics  PrintGCApplicationConcurrentTime  PrintGCApplicationStoppedTime  PrintGCCause  PrintGCDateStamps
  • 129. © Copyright Azul Systems 2016 JVM Flags: Non-Starters (2) 129  PrintGCTaskTimeStamps  PrintGCTimeStamps  PrintHeapAtGC  PrintHeapAtGCExtended  PrintJNIGCStalls  PrintOldPLAB  PrintPLAB  PrintParallelOldGCPhaseTimes  PrintPromotionFailure  PrintReferenceGC  PrintTLAB  PrintTenuringDistribution  TraceDynamicGCThreads  TraceGen0Time  TraceGen1Time  TraceMetadataHumongousAllocation  TraceParallelOldGCTasks  UseCMSCollectionPassing  UseCMSCompactAtFullCollection  UseGCLogFileRotation  UseMemSetInBOT  UsePPCLWSYNC  UseVMInterruptibleIO  WorkAroundNPTLTimedWaitHang
  • 130. © Copyright Azul Systems 2016 JVM Flags: Non-Starters  50 command line flags from JDK 8  Use will cause the JVM to abort at start – It won't run your application 130 Unrecognized VM option '<Option>' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
  • 131. © Copyright Azul Systems 2016 Real World Example
  • 132. © Copyright Azul Systems 2016 HdrHistogram Library  Open source library (created by Gil Tene, Azul CTO)  Ideally this should work with JDK 6, 7, 8 and 9 code – Unchanged and with no special command line flags  Problem: – Needs to encode and decode using Base64  Solutions: – sun.misc.BASE64Encoder/Decoder (JDK 6, 7, 8) – javax.xml.bind.DatatypeConverter (JDK 6, 7, 8) – java.util.Base64.{Encoder,Decoder} (JDK 8, 9) 132
  • 133. © Copyright Azul Systems 2016 Solution  Helper class with same named methods as from xml.bind – printBase64Binary(byte[] array) – parseBase64Binary(String input)  Static code to determine which class is available – Initialise Method object reference  Helper methods invoke through method reference to available implementation 133
  • 134. © Copyright Azul Systems 2016 Solution (1)  Code in static block try { Class<?> javaUtilClass = Class.forName("java.util.Base64"); Method getDecoderMethod = javaUtilClass.getMethod("getDecoder"); decoderObj = getDecoderMethod.invoke(null); decodeMethod = decoderObj.getClass().getMethod("decode", String.class); Method getEncoderMethod = javaUtilClass.getMethod("getEncoder"); encoderObj = getEncoderMethod.invoke(null); encodeMethod = encoderObj.getClass() .getMethod("encodeToString", byte[].class); } catch (Throwable e) { // ClassNotFoundException, NoSuchMethodException decodeMethod = null; encodeMethod = null; }
  • 135. © Copyright Azul Systems 2016 Solution (2) 135 if (encodeMethod == null) { decoderObj = null; encoderObj = null; try { Class<?> xmlBindClass = Class.forName("javax.xml.bind.DatatypeConverter"); decodeMethod = xmlBindClass.getMethod("parseBase64Binary", String.class); encodeMethod = xmlBindClass.getMethod("printBase64Binary", byte[].class); } catch (Throwable e) { decodeMethod = null; encodeMethod = null; } }
  • 136. © Copyright Azul Systems 2016 JDK 10
  • 137. © Copyright Azul Systems 2016 Local Variable Type Inference  At first sight, simple change – Use var rather than explicit type declaration – The compiler will infer the type for you 137 var list = new ArrayList<String>(); // infers ArrayList<String> var stream = list.stream(); // infers Stream<String>
  • 138. © Copyright Azul Systems 2016 Local Variable Type Inference  var is now a reserved type 138 var var = new ArrayList<String>(); public class var { public var(String x) { ... } }
  • 139. © Copyright Azul Systems 2016 Local Variable Type Inference  Very useful for intersection types 139 Stream<T> stream(Iterator<T>) try (elements) { Optional<String> first = stream(elements) .findFirst(e -> e.startsWith("a")); } Closeable & Iterator elements; // COMPILER ERROR! var elements; // CORRECTLY INFERED NON-DENOTABLE TYPE
  • 140. © Copyright Azul Systems 2016 Local Variable Type Inference  Non-denotable types 140 Object product = new Object() { String name = "Widget"; int num= 20; } System.out.println("Name = " + product.name + ": " + product.num); var product = new Object() { String name = "Widget"; int num= 20; } System.out.println("Name = " + product.name + ": " + product.num);
  • 141. © Copyright Azul Systems 2016 JEP 307: Parallel Full GC for G1  G1 is the default (server-class) collector since JDK 9  Parallel collector performs full GC in parallel  G1 full GC was single threaded – Mark-Sweep-Compact  Now performs full GC in parallel  Number of threads is the same as used for rest of G1 – -XX:ParallelGCThreads 141
  • 142. © Copyright Azul Systems 2016 JEP 310: App Class-Data Sharing  Strangely, only available on OpenJDK binary – Not Oracle JDK (was a commercial feature)  JVM startup requires classes to be loaded – Same thing happens every time  Application CDS effectively caches loaded classes – Improved startup time for applications – Can be shared between JVMs on same machine 142
  • 143. © Copyright Azul Systems 2016 Application CDS 143 java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=archive.list -cp zapp.jar Zapp java -X:share:dump -XX:+UseAppCDS -XX:DumpLoadedClassList=archive.list -XX:SharedArchiveFile=archive.jsa -cp zapp.jar java -Xshare:on -XX:+UseAppCDS -XX:SharedArchiveFile=archive.jsa -cpzapp.jar Zapp
  • 144. © Copyright Azul Systems 2016 JEP 317: Graal JIT compiler  Extend use of Graal to JIT compilation  JIT compiler written in Java – byte[] in, byte[] out – We don't need a systems language like C++ – Made much simpler by JVMCI in JDK 9  Part of Project Metropolis  -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler 144
  • 145. © Copyright Azul Systems 2016 JEP 319: Root Certificates  The cacerts keystore file of OpenJDK was empty – Things like TLS don't work without configuration  Now has root certificates – From providers in Oracle's Java SE root CA program  17 root certificate providers – Including Digicert, DocuSign, Comodo CA 145
  • 146. © Copyright Azul Systems 2016 JEP 296: Single Repo JDK  JDK 9 and earlier had six separate repos  root  corba  hotspot  jaxp  jaxws  jdk  langtools  nashorn  Problems like atomic commits across repos – Now just one repo 146
  • 147. © Copyright Azul Systems 2016 JEP 316: Alternative Device Heap  Some Non-Volatile RAM now as fast as DRAM – Intel 3D XPoint – Need to have same semantics as DRAM  Safe atomic operations  Existing heap related flags work unchanged  Good for multi-JVM systems – Select heap device appropriate to application  -XX:AllocateHeapAt=<path> 147
  • 148. © Copyright Azul Systems 2016 JEP 304: GC Interface  Most collector code lives in – src/hotspot/share/gc/$NAME But not all (barriers, etc)  Extension to existing CollectedHeap class  New collector must provide:  A heap (sub-class of CollectedHeap)  Barrier set (sub-class of BarrierSet)  Implementation of CollectorPolicy, GCInterpreterSupport, GCC1Support, GCC2Support  Setup of a MemoryService 148
  • 149. © Copyright Azul Systems 2016 JEP 312: Thread-Local Handshake  JVM performance enhancement – Not accessible directly by developers – Use a handshake (callback) rather than safepoint – Pause one thread rather than all or none  Example potential use cases  Biased-lock revocation  Deoptimisation  External requests for stack traces  Eliding memory barriers 149
  • 150. © Copyright Azul Systems 2016 JDK 10: APIs  73 New APIs – All methods – No new classes  Packages affected – java.awt/javax.swing (!) – java.io/nio/net – java.lang – java.time – java.util 150
  • 151. © Copyright Azul Systems 2016 JDK 10: APIs  New static methods on fundamental collection types – List, Set, Map.copyOf(Collection) 151 List fixedList = List.copyOf(myList);
  • 152. © Copyright Azul Systems 2016 JDK 10: APIs  Replacement for Optional.get() – Optional.orElseThrow() 152 try { Optional<MyType> result = getResult(); MyType value = result.orElseThrow(); } catch (NoSuchElementException nsee) { System.out.println("No value in the optional"); }
  • 153. © Copyright Azul Systems 2016 JDK 10: APIs – New Collectors  toUnmodifiableList  toUnmodifiableMap  toUnmodifiableSet 153 List fixedList = data.stream() .filter(dp -> dp.colourIsBlue()) .map(dp -> dp.getName()) .collect(Collectors.toUnmodifiableList());
  • 154. © Copyright Azul Systems 2016 JDK 10: Miscellaneous  XMLInputFactory.newFactory() de-deprecated (precated?)  com.sun.security.auth package – Six deprecated classes removed  java.lang.SecurityManager – One deprecated field and seven methods removed 154
  • 155. © Copyright Azul Systems 2016 JVM Container Support  JVM now properly CGroup aware  Initial values correctly calculated – Heap sizing – Thread pooling 155
  • 156. © Copyright Azul Systems 2016 Summary
  • 157. © Copyright Azul Systems 2016 Summary  JDK 9 has many changes  Java Platform Module System is the big one – Migrating applications needs testing  Other useful smaller features  Removal of features and APIs a big change for Java  JDK 10 first six-month development cycle – Less changes – Local variable type inference is useful  Java continues to evolve! 157
  • 158. © Copyright Azul Systems 2016 Zulu Java  Azul’s binary distribution of OpenJDK – Passes all TCK tests – Multi-platform (Windows, Linux, Mac) – Free, with paid support options – No licensing issues – Verified as built from 100% open-source  JDK 6, 7, 8 and 9 158 www.zulu.org/download
  • 159. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava Thank you Simon Ritter Deputy CTO, Azul Systems 159

Hinweis der Redaktion

  1. com.sun API examples mostly around tooling jdk API example is nashorn
  2. Signal/SignalHandler (handling OS level signals SIGIINT) Cleaner - more flexible alternative to class finalisation Reflection - which classes are in the call stack
  3. forRemoval - Interesting. Tri-state (i.e. it may not be present on the annotation).
  4. Concurrent class unloading means not having to do a full GC to unload classes Making G1 default may affect thruput Higher resource requirements Reasons to
  5. CDS = Class Data Sharing CDS = Class Data Sharing CDS = Class Data Sharing CDS = Class Data Sharing
  6. Segmented code cache to improve performance and allow future developments (Sumatra and the use of GPUs)