SlideShare une entreprise Scribd logo
1  sur  71
Télécharger pour lire hors ligne
What to expect from Java 9?
Ivan Krylov
Azul Systems
2
3Ivan Aivazovsky, 1850, The Ninth Wave, Russian Museum, St. Petersburg
4
• Zing: A better JVM for the enterprise
• Azul’s enterprise JVM focused on better metrics
• Consistent performance - not just fast, always fast
• Eliminate GC as a concern for enterprise apps
• Very wide operating range
• From human-sensitive app responsiveness to low-latency
trading
• From microservices to huge in-memory apps
• Eliminates an entire class of engineering workarounds common in
Java
•Zulu Embedded: When you need embedded Support
• 100% open source, based on OpenJDK
• Certified Java SE compliant and compatible
• Verified “non-contaminating” open source license
• Identical metrics to OpenJDK and Oracle Java SE
• World-class support offerings
• Support for Linux & Windows; x86, ARM32, ARM64, PPC32,
MIPS
4
Java 9 -Why talking about it now?
• Release scheduled for 2017

• Lots of breaking changes
• I am from Azul Systems - maker of compliant JDKs 

• Observing the process from aside, unbiased view on changes

• Not promoting nor diminishing
5
6
6
• Reflection is disallowed from operating on non-exported types,
even with the use of setAccessible
• Jigsaw has only limited support for the dynamic introduction and
alteration of modules
• Restrictions that make interoperability with alternative modular
systems difficult.
• Source: http://wildfly.org/news/2016/12/12/Jigsaws-Missing-Pieces
Java 9 - concerns
7
http://wiki.netbeans.org/InternalAPIsUnavailableInJava9
8
“There are only two kinds of languages: 

the ones people complain about and the ones nobody uses.”
Bjarne Stroustrup
Java Timeline
JDK 6

Dec 2006
JDK 7

July
2011
JDK 8

March
2014
JDK 9

exp.
July
2017
JDK 6

Nov 2012
JDK 7

Apr
2015
JDK 8

exp.
July
2018
J2SE 1.4

Dec 2006
JDK 5

Oct 2009
9
GA
EOL
Java EOL & You?
EOL date

passed

Security
vulnerabilities 

keep appearing
&
Sign Support
contact
Adopt OpenJDK
(Zulu, IcedTea,
homebrew builds)
Updated to latest
JDK
10
Updates needed
What (was) new in Java 8
• Lambdas
• Method references
• Type annotations
• Repeated annotations
• Interface a.k.a. default
methods
• Stream API
• Date Time API
• PermGen replacement (vendor
specific)
• Nashorn, JavaScript Engine
• New tools (jdeps,jjs,..)
11
http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
How new features become part of
Java standard?
12
JEP process
13
Source: http://cr.openjdk.java.net/~mr/jep/jep-2.0-02.html
JSR
Source: https://groups.google.com/forum/#!topic/java-social/InafCPMLLaA14
New APIs and features 

in Java 9
15
Fabric methods for collections
Instantiation of the immutable containers
16
Set<String> set = new HashSet<>();
set.add("a");
set.add("b");
set = Collections.unmodifiableSet(set);
Set<String> set = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList("a", "b")));
Set<String> set = Collections.unmodifiableSet(
new HashSet<String>() {{
add("a");
add("b");
}});
Set<String> set = Collections.unmodifiableSet(
Stream.of("a", “b").collect(toSet())
);
Set<String> set = Set.of("a", "b");
Fabric methods for collections
17
• Set.of(a, b);
• List.of(a, b);
• Map.of(k1, v1);
• Map.of(k1, v1, k2, v2);
• Map.of(k1, v1, k2, v2, k3, v3);
• Map.ofEntries(entry(k1, v1), entry(k2, v2), ….. entry (kn, vn));
Stream API changes
18
• Stream::takeWhile

• A replacement for the 

while (predicate_on_stream_element) { <keep processing this ordered stream>};
• Stream::dropWhile

• Some but start processing stream after the predicate
Stream API changes
18
• Stream::takeWhile

• A replacement for the 

while (predicate_on_stream_element) { <keep processing this ordered stream>};
• Stream::dropWhile

• Some but start processing stream after the predicate
• Iterator with a predicate
• Stream::ofNullable

• Factory for a single non-null element
Syntax changes - Milling Project Coin
• Private default methods

interface I {
void a() { /*Common code*/ ; /*a’s specific code*/ }
void b() { /*Common code*/ ; /*b’s specific code*/ }
?? - void c() { /*Common code*/ ; }
}
19
interface II {
private void foo_private(String s); // Error: private method must declare body.
private abstract void foo_abstract(int i, int j); // Error: private & abstract: bad combo
void foo_decl(int x); // OK.
private I foo_with_body() { return null; } // OK.
}
interface I {
void a() { с(); /*a’s specific code*/ }
void b() { с(); /*b’s specific code*/ }
private void c() { /*Common code*/ ; }
}
Syntax changes - Milling Project Coin
• Effectively-final variables in try-with-resources expressions

20
public static void main(String... args) throws …{
FileReader f = new FileReader(“test.txt”);
br =new BufferedReader(fr);
try (br) {
// do something
} catch (Exception ex) {
}
}
public static void main(String... args) throws …{
FileReader f = new FileReader(“test.txt");
try (br =new BufferedReader(fr)) {
// do something
} catch (Exception ex) {
}
}
Syntax changes - Milling Project Coin
• @SafeVarargs in private methods

• (In Java 8 it was only final and static)
class VarargsFinalOnly {
@SafeVarargs private void m(List<String>... args) { }
}
21
public class TypeInferrenceTest {
Map<String, String> map =
new HashMap<String, String>()
{
{
map.put("key", "value");
}
};
}
• Using diamond with anonymous classes when actual type may be
deduced

public class TypeInferrenceTest {
Map<String, String> map =
new HashMap<> ()
{
{
map.put("key", "value");
}
};
}
Syntax changes - Milling Project Coin
22
Prior to Java 9
./TypeInferrenceTest.java:7: error: cannot infer
type arguments for HashMap<K,V>
new HashMap<>()
^
reason: cannot use '<>' with anonymous inner classes
where K,V are type-variables:
K extends Object declared in class HashMap
V extends Object declared in class HashMap
1 error
http://c2.com/cgi/wiki?DoubleBraceInitialization
Syntax changes - Milling Project Coin
•
Can’t use single _as a name
23
// key: compiler.warn.underscore.as.identifier
// options: -source 8 -Xlint:-options
class UnderscoreAsIdentifierWarning {
String _ = null;
}
Process API Updates
• JEP 102: Process API Updates
• What’s new:
• Get pid for this JVM
• Get list of processes
• Operations on trees of processes
Source: http://blog.takipi.com/java-9-the-ultimate-feature-list/ 24
Process proc = Runtime.getRuntime()
.exec(new String[]{"/bin/sh",
"-c", "echo $PPID"});
if (proc.waitFor()==0) {
InputStream in = proc.getInputStream();
int available = in.available();
byte[] outputBytes = new byte[available];
in.read(outputBytes);
String pid = new String(outputBytes);
System.out.println("Your pid is " + pid)
}
System.out.println("Your pid is " + ProcessHandle.current().getPid());
Spin Loop Hint (JEP-285)
• Scope: latency (& performance)
• Features:

• New method j.l.Thread.onSpinWait()

• On x86 - translates into the ‘pause’ instruction
• Already used 9 times in JSR 166 for JDK9

• java/util/concurrent/locks/StampedLock.java

• java/util/concurrent/Phaser.java

• java/util/concurrent/SynchronousQueue.java
25
Spin Loop Hint (JEP-285)
• Scope: latency (& performance)
• Features:

• New method j.l.Thread.onSpinWait()

• On x86 - translates into the ‘pause’ instruction
• Already used 9 times in JSR 166 for JDK9

• java/util/concurrent/locks/StampedLock.java

• java/util/concurrent/Phaser.java

• java/util/concurrent/SynchronousQueue.java
class EventHandler {
volatile boolean eventNotificationNotReceived;
void waitForEventAndHandleIt() {
while ( eventNotificationNotReceived ) {
java.lang.Thread.onSpinWait();
}
readAndProcessEvent();
}
void readAndProcessEvent() {
// Read event from some source and process it
. . .
}
}
25
Producer/Consumer and SLH
26
Spin Loop Hint
• Cool. I have spin loops. Wait for 9?
• May be not

• Just include the agrona library

• or look at java/org/agrona/hints/ThreadHints.java 

• Works for older JDKs
27
https://github.com/real-logic/Agrona/blob/master/src/main/java/org/agrona/hints/ThreadHints.java
JShell
• Project Kulla http://openjdk.java.net/projects/kulla/

• In main trunk since JDK 9 EA build 90

• REPL as you know it for other languages

• Helps teaching Java class HelloWorld {
public static void main(String[] args) {
System.out.println(" ");
}
}
28
Jshell Demo
29
just kick ./bin/jshell and try yourself
Garbage First is on by default
• Pros

• State-of-the-art GC in HotSpot (albeit being 14+ years old)

• Regional parallel concurrent collector

• Targeting both low pause and high throughput

• Default => Great number of users => Bugs detecter sooner => G1 will become even more robust shortly

• Cons

• Due to different characteristics it may reveal synchronisation problems in the code

• In recent years many bugs with Cassandra, Elasticsearch, Lucene were fixed in both GC and libraries.
Perhaps, other ones are yet not discovered?

• source (dated July 2015): https://groups.google.com/forum/#!topic/mechanical-sympathy/
JxsuVtIIOaY
30
Surviving the change of default GC
• If you used no i.e. default GC settings 

• capture the ergonomics at your deployment sites

• consider explicitly setting GC flags in all deployment scripts

• If you already had selected and tuned GC flags

• No changes, old collectors not phasing out

• In any case - keep trying G1

• Understand how GC works

• Basic algorithms and associated metrics 

• More reading: http://www.infoq.com/minibooks/java-garbage-collection
31
New JEPs briefly. Performance
• 193: Variable Handles 

• 143: Improve Contended Locking

• 266: More Concurrency Updates

• 197: Segmented Code Cache

• 165: Compiler Control

• 243: Java-Level JVM Compiler
Interface

• 246: Leverage CPU Instructions
for GHASH and RSA

• 250: Store Interned Strings in
CDS Archives

• 254: Compact Strings

• 280: Indify String Concatenation

• 230: Microbenchmark Suite
32
33
Unified JVM Logging
• For better diagnostics, uniform across all components

• 6 levels of logging x dozens of tags 

• Output to stdout / stderr / file / rotating file 

• No more badly interleaved lines

• -Xlog:help

• 11 decorators
-Xlog:classinit
-Xlog:classloaderdata
-Xlog:defaultmethods
-Xlog:itables
-Xlog:monitormismatch
-Xlog:safepoint
-Xlog:startuptime
-Xlog:vmoperation
-Xlog:vtables
-Xlog:verification
-XX:+TraceClassInitialization
-XX:+TraceClassLoaderData
-XX:+TraceDefaultMethods
-XX:+TraceItables
-XX:+TraceMonitorMismatch
-XX:+TraceSafepoint
-XX:+TraceStartupTime
-XX:+TraceVMOperation
-XX:+PrintVtables
-XX:+VerboseVerification
java -Xlog:help
HTTP/2 today
34
HTTP -> TCP
35
• HTTP 0.9: The One-Line Protocol (1989)
• HTTP/1.0 (1996)
• HTTP/1.1: Internet Standard (1997)

• Keep alive; chunk encodings; byte-
range requests, additional caching
mechanisms, transfer encodings, and
request pipelining
• HTTP/2.0 (since 2012)
Ref: https://hpbn.co/brief-history-of-http/
36
https://speakerdeck.com/vietj/2-2
HTTP/2. Multiplexing
Stack walking API
• Before 9: Throwable::getStackTrace и Thread::getStackTrace

StackTraceElement[] stack = Thread.currentThread().getStackTrace();
• Since 9 also possible to:

StackFrame[] stack =new StackWalker().walk((s) ->
s.collect(Collectors.toArray()));
• New StackWalker class
37
38
JEP 223: New Version-String Scheme
• System Property Existing Proposed
• ------------------------------- ------------ --------
• Early Access
• java.version 1.9.0-ea 9-ea
• java.runtime.version 1.9.0-ea-b73 9-ea+73
• java.vm.version 1.9.0-ea-b73 9-ea+73
• java.specification.version 1.9 9
• java.vm.specification.version 1.9 9
• Major (GA)
• java.version 1.9.0 9
• java.runtime.version 1.9.0-b100 9+100
• java.vm.version 1.9.0-b100 9+100
• java.specification.version 1.9 9
• java.vm.specification.version 1.9 9
• Minor #1 (GA)
• java.version 1.9.0_20 9.1.2
• java.runtime.version 1.9.0_20-b62 9.1.2+62
• java.vm.version 1.9.0_20-b62 9.1.2+62
• java.specification.version 1.9 9
• java.vm.specification.version 1.9 9
• Security #1 (GA)
• java.version 1.9.0_5 9.0.1
• java.runtime.version 1.9.0_5-b20 9.0.1+20
• java.vm.version 1.9.0_5-b20 9.0.1+20
• java.specification.version 1.9 9
New JEPs briefly. Client/graphics
• 258: HarfBuzz Font-Layout Engine

• 263: HiDPI Graphics on Windows and Linux

• 265: Marlin Graphics Renderer

• 262: TIFF Image I/O

• 257: Update JavaFX/Media to Newer Version of GStreamer (1.4.4)

• 251: Multi-Resolution Images
39
New JEPs briefly. Security
• 219: Datagram Transport Layer Security (DTLS)

• 229: Create PKCS12 Keystores by Default

• 244: TLS Application-Layer Protocol Negotiation Extension

• 249: OCSP Stapling for TLS
40
Unicode in Java 9
• 227: Unicode 7.0…
• … & 267: Unicode 8.0
41
Modules
42


Modules
Packages
Classes
fields &
methods
Interfaces
…
Abstract
Classes
…
Code encapsulation
43
Problems being addressed
• Java Runtime keeps getting bigger and bigger
• Java 8 profiles 1, 2, 3 provide partial solutions
• Jar / Classpath Hell
• What depends on what ..
• Optional dependancies, transitive dependancies
• Lazy class loading and initialization -> NoClassDefFoundError
• For code that escapes packages the visibility mechanism is poor - only public
• Classes from different packages “see” each other, even from different class loaders
• SecurityManager helps to protect, but it is not on by default
44
Wikepedia оn Jar-hell
• Accidental presence of two different versions of a library installed on a system. This will not
be considered an error by the system. Rather, the system will load classes from one or the other
library. Adding the new library to the list of available libraries instead of replacing it may result in
the application still behaving as though the old library is in use, which it may well be.
• Multiple libraries or applications require different versions of library foo. If versions of library
foo use the same class names, there is no way to load the versions of library foo with the same
classloader.
• The most complex JAR hell problems arise in circumstances that take advantage of the full
complexity of the classloading system. A Java program is not required to use only a single
"flat" classloader, but instead may be composed of several (potentially very many) nested,
cooperating classloaders. Classes loaded by different classloaders may interact in complex ways
not fully comprehended by a developer, leading to errors or bugs that are difficult to analyze,
explain, and resolve.
45
Jigsaw
JEP 162: Prepare for Modularization

JEP 200: The Modular JDK

JEP 220: Modular Run-Time Images

JEP 201: Modular Source Code

JEP 260: Encapsulate Most Internal
APIs

JEP 282: jlink: The Java Linker

JSR 376: Java Platform Module System

JEP 261: Module System

ModularityJava Module
46
Examples
47
• 01 - Classpath hell
• 02 - The simplest example with
Modules
• 03 - jimage
• 04 - Error “2 modules export the
same package into module 3”
• 05 - Working with 2 “identical”
classes in different modules
Example 1
src/com.azul.modules.module1/module-
info.java
module com.azul.modules.module1 {


exports com.azul.testpackage1;
}
src/com.azul.modules.module2/module-info.java
module com.azul.modules.module2 {
requires com.azul.modules.module1;
}
com.azul.modules.module1/com/azul/testpackage1/A.java
package com.azul.testpackage1;
public class B {
public static void m()
{
System.out.println("-- I am in path1.com.azul.test.B.m() ");
}
}
com.azul.modules.module2/com/azul/testpackage2/A.java
package com.azul.testpackage2;
public class A {
public static void main(String[] args) {
System.out.println("Calling from com.azul.modules.module2.com.azul.testpackage2.A.main() ");
com.azul.testpackage1.B.m();
}
}
1 2
48
New params javac/java (1)
• # Compile
• >javac --module-source-path src -d target $(find
com.azul.modules.module1 -name “*.java”)
• >javac --module-path mlib -d target/
com.azul.modules.module2 $(find
com.azul.modules.module2 -name “*.java”)# Run
• >java -p target -m mlib/com.azul.modules.module2
49
New parameters for javac/java (2)
50
• # Packaging
• jar --create --file=mlib/module2.jar --main-
class=com.azul.testpackage2.A -C target/
com.azul.modules.module2 .
• # Run
• $j/bin/java -p target -m com.azul.modules.module2
Reference: http://openjdk.java.net/projects/jigsaw/quick-start
Example 2
./nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java
module jdk.scripting.nashorn {
requires java.logging;
requires public java.scripting;
uses jdk.internal.dynalink.linker.GuardingDynamicLinker;
uses jdk.nashorn.internal.runtime.CodeStore;
provides javax.script.ScriptEngineFactory with
jdk.nashorn.api.scripting.NashornScriptEngineFactory;
exports jdk.nashorn.api.scripting;
exports jdk.nashorn.api.tree;
exports jdk.nashorn.internal.runtime to
jdk.scripting.nashorn.shell;
exports jdk.nashorn.internal.objects to
jdk.scripting.nashorn.shell;
exports jdk.nashorn.tools to
jdk.scripting.nashorn.shell;
}
META-INF/services
51
Types of modules
• Named
• Those containing module-info.class
• Automatic
• jar files placed to the module path
• Unnamed
• Contains all types in the classpath
52
Can modularised & non-modularised

code co-exist?
• Whatever is in classpath - going into unnamed modules
• Unnamed modules can access all named modules (requires *) /See next slide for a
special note/
• The reverse isn’t true - must specify requires unnamed or …
• jar file in --module-path is being automatically converted to a module with a name
matching the name of the jar file
• Therefore referred as automodules
• Provide transition path to jigsaw modules design
• Unnamed modules are being searched for types as a last option
53
Unnamed modules can access all
named modules
• Not so true since JDK9 build 118

• These modules are not accessible from unnamed modules:

java.activation - java.annotations.common - java.corba

java.transaction - java.xml.bind - java.xml.ws
• One can still add visibility with a flag like `-addmods
java.corba`
• Source: May 17th letter from Alan Bateman: http://mail.openjdk.java.net/
pipermail/jdk9-dev/2016-May/004309.html

• More info: http://openjdk.java.net/jeps/261
54
55
jdeps 

-genmoduleinfo
cat /Users/ivan/test/modules/generated/glassfish.corba.omgapi/module-info.java
module glassfish.corba.omgapi {
requires public java.corba;
requires public java.desktop;
requires public java.rmi;
exports com.sun.corba.ee.org.omg.CORBA;
exports javax.rmi.CORBA;
exports org.omg.CORBA;
exports org.omg.CORBA.DynAnyPackage;
exports org.omg.CORBA.ORBPackage;
exports org.omg.CORBA.TSIdentificationPackage;
exports org.omg.CORBA.TypeCodePackage;
exports org.omg.CORBA.portable;
exports org.omg.CORBA_2_3;
exports org.omg.CORBA_2_3.portable;
exports org.omg.CosNaming;
exports org.omg.CosNaming.NamingContextExtPackage;
exports org.omg.CosNaming.NamingContextPackage;
exports org.omg.CosTSInteroperation;
exports org.omg.CosTSPortability;
exports org.omg.CosTransactions;
exports org.omg.Dynamic;
exports org.omg.DynamicAny;
exports org.omg.DynamicAny.DynAnyFactoryPackage;
exports org.omg.DynamicAny.DynAnyPackage;
exports org.omg.IOP;
exports org.omg.IOP.CodecFactoryPackage;
exports org.omg.IOP.CodecPackage;
exports org.omg.Messaging;
exports org.omg.PortableInterceptor;
exports org.omg.PortableInterceptor.ORBInitInfoPackage;
exports org.omg.PortableServer;
exports org.omg.PortableServer.CurrentPackage;
exports org.omg.PortableServer.POAManagerPackage;
exports org.omg.PortableServer.POAPackage;
exports org.omg.SendingContext;
exports org.omg.stub.java.rmi;
}
jdeps
-genmoduleinfo
~/test/modules/generated/ 

glassfish-4.1.1/glassfish/modules/
glassfish-corba-omgapi.jar
56
jdeps -jdkinternals
glassfish-corba-orb.jar -> java.corba
com.sun.corba.ee.impl.copyobject.OldReflectObjectCopierImpl (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.copyobject.OldReflectObjectCopierImpl$1 (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.encoding.BufferManagerWriteStream (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.IIOPInputStream (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.IIOPInputStream$1 (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.IIOPOutputStream (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.IIOPOutputStream$1 (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.ObjectStreamClass (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.ObjectStreamClass$1 (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.ObjectStreamField (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.io.ObjectStreamField$1 (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl$1 (glassfish-corba-orb.jar)
-> com.sun.jndi.cosnaming.CNCtx JDK internal API (java.corba)
com.sun.corba.ee.impl.util.JDKClassLoader (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
com.sun.corba.ee.impl.util.JDKClassLoader$1 (glassfish-corba-orb.jar)
-> sun.corba.Bridge JDK internal API (java.corba)
jdeps
-jdkinternals
glassfish/
modules/
glassfish-corba-orb.jar
57
java --add-exports
java --add-exports
:java.base/sun.security.provider=ALL-UNNAMED,
java.base/sun.security.pkcs=ALL-UNNAMED,
java.base/sun.security.util=ALL-UNNAMED,
java.base/sun.security.x509=ALL-UNNAMED,
:
java --add-reads
java --add-reads:java.management=testng
58
• Consider an app with extensions
• The extension might require a different version of a module than loaded before
• The extension might require service providers
• Layer of modules encapsulates
• a module graph
• mapping from each module in that graph to a class loader
• Boot layer - created by VM at start time and suitable for most apps
• App can create a new layer - new universe of modules
• Stackable - package resolution starts with the app layer and goes down to the boot layer
Layers
Modularity
Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html
JDK 7 b65
59
http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html
Modularity
Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html
JDK 8 b48
60
http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html
Modularity
Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html
JDK9 b157
61
http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html
Modularity
Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html
JDK9 b15762
http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html
Jigsaw - Unresolved issues

http://openjdk.java.net/projects/jigsaw/spec/issues/
63
• Module declarations

• #ModuleNameSyntax · #ModuleNameCharacters ? ·
#CompileTimeDependences ✔ · #ModuleAnnotations ✔ ·
#ModuleDeprecation ✔ · #ExportAnnotation

• Module artifacts

• #MultiModuleExecutableJARs · #MultiModuleJARs ·
#ReifiedModuleGraphs · #ModuleNameInManifest ·
#AddExportsInManifest ✔

• Module descriptors

• #ClassFileModuleName ? · #ClassFileAccPublic ✔ ·
#ClassFileAccModule ? · #StandardModuleAttributes

• Module graphs

• #CyclicDependences · #MutableConfigurations ·
#LazyConfigurationAndInstantiation ·
#CustomizableAutomaticModuleNameMapping ✔

• Services

• #ServiceLoaderEnhancements ✔

• Reflection

• #ClassFilesAsResources ✔ · #ResourceEncapsulation ✔ ·
#ResourceExistenceAndSize ·
#ReflectiveAccessToNonExportedTypes ? ·
#AwkwardStrongEncapsulation ? · #ReflectionWithoutReadability ✔ ·
#ReadabilityAddedByLayerCreator ? ·
#IndirectQualifiedReflectiveAccess ?

• Class loaders

• #AvoidConcealedPackageConflicts · #PlatformClassLoader ✔ ·
#ClassLoaderNames ✔

• Versioning

• #StaticLayerConfiguration · #MultipleModuleVersions ·
#VersionsInModuleNames ✔ · #VersionedDependences ? ·
#VersionSyntax

• Layers

• #NonHierarchicalLayers ? · #DiscardableModules

• Tooling

• #BootstrapClassLoaderSearchInJVMTI ✔ ·
#ReflectiveAccessByInstrumentationAgents ✔
Jigsaw - Unresolved issues

http://openjdk.java.net/projects/jigsaw/spec/issues/
• Module declarations

• #ModuleNameSyntax · #ModuleNameCharacters ? ·
#CompileTimeDependences ✔ · #ModuleAnnotations ✔ ·
#ModuleDeprecation ✔ · #ExportAnnotation

• Module artifacts

• #MultiModuleExecutableJARs · #MultiModuleJARs ·
#ReifiedModuleGraphs · #ModuleNameInManifest ·
#AddExportsInManifest ✔

• Module descriptors

• #ClassFileModuleName ? · #ClassFileAccPublic ✔ ·
#ClassFileAccModule ? · #StandardModuleAttributes

• Module graphs

• #CyclicDependences · #MutableConfigurations ·
#LazyConfigurationAndInstantiation ·
#CustomizableAutomaticModuleNameMapping ✔

• Services

• #ServiceLoaderEnhancements ✔

• Reflection

• #ClassFilesAsResources ✔ · #ResourceEncapsulation ✔ ·
#ResourceExistenceAndSize ·
#ReflectiveAccessToNonExportedTypes ? ·
#AwkwardStrongEncapsulation ? · #ReflectionWithoutReadability ✔ ·
#ReadabilityAddedByLayerCreator ? ·
#IndirectQualifiedReflectiveAccess ?

• Class loaders

• #AvoidConcealedPackageConflicts · #PlatformClassLoader ✔ ·
#ClassLoaderNames ✔

• Versioning

• #StaticLayerConfiguration · #MultipleModuleVersions ·
#VersionsInModuleNames ✔ · #VersionedDependences ? ·
#VersionSyntax

• Layers

• #NonHierarchicalLayers ? · #DiscardableModules

• Tooling

• #BootstrapClassLoaderSearchInJVMTI ✔ ·
#ReflectiveAccessByInstrumentationAgents ✔
64
(My) takeaways on Java 9 modules
• Purpose - explicit listing of dependancies
• Will provide new optimization paths
• Compatible with jar/cp
• OSGi compatibility and reflection are a concern
• Jigsaw - rough flight all way along, loosing features 

• Lost ability to match versions
65
Jigsaw - links
• If you google it - discard all posts before 2014, probably even before 2015 too
• State of Jigsaw (March 8 2015)

• http://openjdk.java.net/projects/jigsaw/spec/sotms/
• JavaOne 2016 (also Devoxx BE 2017)

• http://openjdk.java.net/projects/jigsaw/talks/#j1-2016
• Code was integrated in JDK9 EA build 111
• See also: http://blog.codefx.org/java/dev/features-project-jigsaw-java-9/
• http://blog.codefx.org/java/dev/javaone-2015-under-the-hood-of-project-jigsaw/
66
is this
what we
wanted?
(rhetorical)
67
Ivan Krylov www.azul.com

Azul Systems ivan @azul.com

@JohnWings

Contenu connexe

Tendances

JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMMin-Yih Hsu
 
java8-patterns
java8-patternsjava8-patterns
java8-patternsJustin Lin
 
Lambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive CodeLambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive CodeIan Robertson
 
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Anton Arhipov
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programmingEric Polerecky
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...Nikita Lipsky
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMashleypuls
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsLeonardo Borges
 
OrientDB - The 2nd generation of (multi-model) NoSQL
OrientDB - The 2nd generation of  (multi-model) NoSQLOrientDB - The 2nd generation of  (multi-model) NoSQL
OrientDB - The 2nd generation of (multi-model) NoSQLRoberto Franchini
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
The Road To Reactive with RxJava JEEConf 2016
The Road To Reactive with RxJava JEEConf 2016The Road To Reactive with RxJava JEEConf 2016
The Road To Reactive with RxJava JEEConf 2016Frank Lyaruu
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Kenneth Geisshirt
 
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...confluent
 

Tendances (20)

JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVM
 
java8-patterns
java8-patternsjava8-patterns
java8-patterns
 
Lambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive CodeLambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive Code
 
JVM
JVMJVM
JVM
 
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming
 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASM
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
 
OrientDB - The 2nd generation of (multi-model) NoSQL
OrientDB - The 2nd generation of  (multi-model) NoSQLOrientDB - The 2nd generation of  (multi-model) NoSQL
OrientDB - The 2nd generation of (multi-model) NoSQL
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
RxJava Applied
RxJava AppliedRxJava Applied
RxJava Applied
 
Stacking Up Middleware
Stacking Up MiddlewareStacking Up Middleware
Stacking Up Middleware
 
The Road To Reactive with RxJava JEEConf 2016
The Road To Reactive with RxJava JEEConf 2016The Road To Reactive with RxJava JEEConf 2016
The Road To Reactive with RxJava JEEConf 2016
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
 
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
 

En vedette

Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Trisha Gee
 
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
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and ToolingTrisha Gee
 
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
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9Simon Ritter
 
Garbage Collection en el JVM
Garbage Collection en el JVMGarbage Collection en el JVM
Garbage Collection en el JVMsuperserch
 
Beyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessonsBeyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessonsSander Hoogendoorn
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9Deepu Xavier
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Robert Scholte
 
Discuss about java 9 with latest features
Discuss about java 9 with latest featuresDiscuss about java 9 with latest features
Discuss about java 9 with latest featuresNexSoftsys
 
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...Mary Ana Betancourt
 
Apresentação campanha 25 anos
Apresentação campanha 25 anosApresentação campanha 25 anos
Apresentação campanha 25 anosFabiano Dutra
 
Camera shots and sound
Camera shots and sound Camera shots and sound
Camera shots and sound banana81101
 

En vedette (20)

Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project Jigsaw
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 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)
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9
 
Garbage Collection en el JVM
Garbage Collection en el JVMGarbage Collection en el JVM
Garbage Collection en el JVM
 
Les applications-web-avec-javafx
Les applications-web-avec-javafxLes applications-web-avec-javafx
Les applications-web-avec-javafx
 
Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
 
Beyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessonsBeyond breaking bad. The current state of agile in ten easy lessons
Beyond breaking bad. The current state of agile in ten easy lessons
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
 
Git
GitGit
Git
 
Discuss about java 9 with latest features
Discuss about java 9 with latest featuresDiscuss about java 9 with latest features
Discuss about java 9 with latest features
 
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
Taller práctico 10 claves para la implementación de tendencias y enfoques inn...
 
benny cv
benny cvbenny cv
benny cv
 
Apresentação campanha 25 anos
Apresentação campanha 25 anosApresentação campanha 25 anos
Apresentação campanha 25 anos
 
Maltrato animal.
Maltrato animal.Maltrato animal.
Maltrato animal.
 
Camera shots and sound
Camera shots and sound Camera shots and sound
Camera shots and sound
 

Similaire à What to expect from Java 9

Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Martijn Verburg
 
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPInria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPStéphanie Roger
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Rittercatherinewall
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres..."The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...Edge AI and Vision Alliance
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherencearagozin
 
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010Arun Gupta
 
Docker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline ExecutionDocker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline ExecutionBrennan Saeta
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesAlexandra Masterson
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the CloudJim Driscoll
 
Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Felix Geisendörfer
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang YoonJesang Yoon
 

Similaire à What to expect from Java 9 (20)

Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
 
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPInria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14De Java 8 a Java 11 y 14
De Java 8 a Java 11 y 14
 
PostgreSQL and PL/Java
PostgreSQL and PL/JavaPostgreSQL and PL/Java
PostgreSQL and PL/Java
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
De Java 8 ate Java 14
De Java 8 ate Java 14De Java 8 ate Java 14
De Java 8 ate Java 14
 
Java >= 9
Java >= 9Java >= 9
Java >= 9
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres..."The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
 
Java 9 sneak peek
Java 9 sneak peekJava 9 sneak peek
Java 9 sneak peek
 
Docker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline ExecutionDocker & ECS: Secure Nearline Execution
Docker & ECS: Secure Nearline Execution
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the Cloud
 
Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 

Dernier

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 

Dernier (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 

What to expect from Java 9

  • 1. What to expect from Java 9? Ivan Krylov Azul Systems
  • 2. 2
  • 3. 3Ivan Aivazovsky, 1850, The Ninth Wave, Russian Museum, St. Petersburg
  • 4. 4 • Zing: A better JVM for the enterprise • Azul’s enterprise JVM focused on better metrics • Consistent performance - not just fast, always fast • Eliminate GC as a concern for enterprise apps • Very wide operating range • From human-sensitive app responsiveness to low-latency trading • From microservices to huge in-memory apps • Eliminates an entire class of engineering workarounds common in Java •Zulu Embedded: When you need embedded Support • 100% open source, based on OpenJDK • Certified Java SE compliant and compatible • Verified “non-contaminating” open source license • Identical metrics to OpenJDK and Oracle Java SE • World-class support offerings • Support for Linux & Windows; x86, ARM32, ARM64, PPC32, MIPS 4
  • 5. Java 9 -Why talking about it now? • Release scheduled for 2017 • Lots of breaking changes • I am from Azul Systems - maker of compliant JDKs • Observing the process from aside, unbiased view on changes • Not promoting nor diminishing 5
  • 6. 6
  • 7. 6 • Reflection is disallowed from operating on non-exported types, even with the use of setAccessible • Jigsaw has only limited support for the dynamic introduction and alteration of modules • Restrictions that make interoperability with alternative modular systems difficult. • Source: http://wildfly.org/news/2016/12/12/Jigsaws-Missing-Pieces Java 9 - concerns
  • 9. 8 “There are only two kinds of languages: 
 the ones people complain about and the ones nobody uses.” Bjarne Stroustrup
  • 10. Java Timeline JDK 6
 Dec 2006 JDK 7
 July 2011 JDK 8
 March 2014 JDK 9
 exp. July 2017 JDK 6
 Nov 2012 JDK 7
 Apr 2015 JDK 8
 exp. July 2018 J2SE 1.4
 Dec 2006 JDK 5
 Oct 2009 9 GA EOL
  • 11. Java EOL & You? EOL date passed Security vulnerabilities keep appearing & Sign Support contact Adopt OpenJDK (Zulu, IcedTea, homebrew builds) Updated to latest JDK 10 Updates needed
  • 12. What (was) new in Java 8 • Lambdas • Method references • Type annotations • Repeated annotations • Interface a.k.a. default methods • Stream API • Date Time API • PermGen replacement (vendor specific) • Nashorn, JavaScript Engine • New tools (jdeps,jjs,..) 11 http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
  • 13. How new features become part of Java standard? 12
  • 16. New APIs and features 
 in Java 9 15
  • 17. Fabric methods for collections Instantiation of the immutable containers 16 Set<String> set = new HashSet<>(); set.add("a"); set.add("b"); set = Collections.unmodifiableSet(set); Set<String> set = Collections.unmodifiableSet( new HashSet<>(Arrays.asList("a", "b"))); Set<String> set = Collections.unmodifiableSet( new HashSet<String>() {{ add("a"); add("b"); }}); Set<String> set = Collections.unmodifiableSet( Stream.of("a", “b").collect(toSet()) ); Set<String> set = Set.of("a", "b");
  • 18. Fabric methods for collections 17 • Set.of(a, b); • List.of(a, b); • Map.of(k1, v1); • Map.of(k1, v1, k2, v2); • Map.of(k1, v1, k2, v2, k3, v3); • Map.ofEntries(entry(k1, v1), entry(k2, v2), ….. entry (kn, vn));
  • 19. Stream API changes 18 • Stream::takeWhile • A replacement for the 
 while (predicate_on_stream_element) { <keep processing this ordered stream>}; • Stream::dropWhile • Some but start processing stream after the predicate
  • 20. Stream API changes 18 • Stream::takeWhile • A replacement for the 
 while (predicate_on_stream_element) { <keep processing this ordered stream>}; • Stream::dropWhile • Some but start processing stream after the predicate • Iterator with a predicate • Stream::ofNullable • Factory for a single non-null element
  • 21. Syntax changes - Milling Project Coin • Private default methods interface I { void a() { /*Common code*/ ; /*a’s specific code*/ } void b() { /*Common code*/ ; /*b’s specific code*/ } ?? - void c() { /*Common code*/ ; } } 19 interface II { private void foo_private(String s); // Error: private method must declare body. private abstract void foo_abstract(int i, int j); // Error: private & abstract: bad combo void foo_decl(int x); // OK. private I foo_with_body() { return null; } // OK. } interface I { void a() { с(); /*a’s specific code*/ } void b() { с(); /*b’s specific code*/ } private void c() { /*Common code*/ ; } }
  • 22. Syntax changes - Milling Project Coin • Effectively-final variables in try-with-resources expressions 20 public static void main(String... args) throws …{ FileReader f = new FileReader(“test.txt”); br =new BufferedReader(fr); try (br) { // do something } catch (Exception ex) { } } public static void main(String... args) throws …{ FileReader f = new FileReader(“test.txt"); try (br =new BufferedReader(fr)) { // do something } catch (Exception ex) { } }
  • 23. Syntax changes - Milling Project Coin • @SafeVarargs in private methods • (In Java 8 it was only final and static) class VarargsFinalOnly { @SafeVarargs private void m(List<String>... args) { } } 21
  • 24. public class TypeInferrenceTest { Map<String, String> map = new HashMap<String, String>() { { map.put("key", "value"); } }; } • Using diamond with anonymous classes when actual type may be deduced public class TypeInferrenceTest { Map<String, String> map = new HashMap<> () { { map.put("key", "value"); } }; } Syntax changes - Milling Project Coin 22 Prior to Java 9 ./TypeInferrenceTest.java:7: error: cannot infer type arguments for HashMap<K,V> new HashMap<>() ^ reason: cannot use '<>' with anonymous inner classes where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap 1 error http://c2.com/cgi/wiki?DoubleBraceInitialization
  • 25. Syntax changes - Milling Project Coin • Can’t use single _as a name 23 // key: compiler.warn.underscore.as.identifier // options: -source 8 -Xlint:-options class UnderscoreAsIdentifierWarning { String _ = null; }
  • 26. Process API Updates • JEP 102: Process API Updates • What’s new: • Get pid for this JVM • Get list of processes • Operations on trees of processes Source: http://blog.takipi.com/java-9-the-ultimate-feature-list/ 24 Process proc = Runtime.getRuntime() .exec(new String[]{"/bin/sh", "-c", "echo $PPID"}); if (proc.waitFor()==0) { InputStream in = proc.getInputStream(); int available = in.available(); byte[] outputBytes = new byte[available]; in.read(outputBytes); String pid = new String(outputBytes); System.out.println("Your pid is " + pid) } System.out.println("Your pid is " + ProcessHandle.current().getPid());
  • 27. Spin Loop Hint (JEP-285) • Scope: latency (& performance) • Features: • New method j.l.Thread.onSpinWait() • On x86 - translates into the ‘pause’ instruction • Already used 9 times in JSR 166 for JDK9 • java/util/concurrent/locks/StampedLock.java • java/util/concurrent/Phaser.java • java/util/concurrent/SynchronousQueue.java 25
  • 28. Spin Loop Hint (JEP-285) • Scope: latency (& performance) • Features: • New method j.l.Thread.onSpinWait() • On x86 - translates into the ‘pause’ instruction • Already used 9 times in JSR 166 for JDK9 • java/util/concurrent/locks/StampedLock.java • java/util/concurrent/Phaser.java • java/util/concurrent/SynchronousQueue.java class EventHandler { volatile boolean eventNotificationNotReceived; void waitForEventAndHandleIt() { while ( eventNotificationNotReceived ) { java.lang.Thread.onSpinWait(); } readAndProcessEvent(); } void readAndProcessEvent() { // Read event from some source and process it . . . } } 25
  • 30. Spin Loop Hint • Cool. I have spin loops. Wait for 9? • May be not • Just include the agrona library • or look at java/org/agrona/hints/ThreadHints.java • Works for older JDKs 27 https://github.com/real-logic/Agrona/blob/master/src/main/java/org/agrona/hints/ThreadHints.java
  • 31. JShell • Project Kulla http://openjdk.java.net/projects/kulla/ • In main trunk since JDK 9 EA build 90 • REPL as you know it for other languages • Helps teaching Java class HelloWorld { public static void main(String[] args) { System.out.println(" "); } } 28
  • 32. Jshell Demo 29 just kick ./bin/jshell and try yourself
  • 33. Garbage First is on by default • Pros • State-of-the-art GC in HotSpot (albeit being 14+ years old) • Regional parallel concurrent collector • Targeting both low pause and high throughput • Default => Great number of users => Bugs detecter sooner => G1 will become even more robust shortly • Cons • Due to different characteristics it may reveal synchronisation problems in the code • In recent years many bugs with Cassandra, Elasticsearch, Lucene were fixed in both GC and libraries. Perhaps, other ones are yet not discovered? • source (dated July 2015): https://groups.google.com/forum/#!topic/mechanical-sympathy/ JxsuVtIIOaY 30
  • 34. Surviving the change of default GC • If you used no i.e. default GC settings • capture the ergonomics at your deployment sites • consider explicitly setting GC flags in all deployment scripts • If you already had selected and tuned GC flags • No changes, old collectors not phasing out • In any case - keep trying G1 • Understand how GC works • Basic algorithms and associated metrics • More reading: http://www.infoq.com/minibooks/java-garbage-collection 31
  • 35. New JEPs briefly. Performance • 193: Variable Handles • 143: Improve Contended Locking • 266: More Concurrency Updates • 197: Segmented Code Cache • 165: Compiler Control • 243: Java-Level JVM Compiler Interface • 246: Leverage CPU Instructions for GHASH and RSA • 250: Store Interned Strings in CDS Archives • 254: Compact Strings • 280: Indify String Concatenation • 230: Microbenchmark Suite 32
  • 36. 33 Unified JVM Logging • For better diagnostics, uniform across all components • 6 levels of logging x dozens of tags • Output to stdout / stderr / file / rotating file • No more badly interleaved lines • -Xlog:help • 11 decorators -Xlog:classinit -Xlog:classloaderdata -Xlog:defaultmethods -Xlog:itables -Xlog:monitormismatch -Xlog:safepoint -Xlog:startuptime -Xlog:vmoperation -Xlog:vtables -Xlog:verification -XX:+TraceClassInitialization -XX:+TraceClassLoaderData -XX:+TraceDefaultMethods -XX:+TraceItables -XX:+TraceMonitorMismatch -XX:+TraceSafepoint -XX:+TraceStartupTime -XX:+TraceVMOperation -XX:+PrintVtables -XX:+VerboseVerification java -Xlog:help
  • 38. HTTP -> TCP 35 • HTTP 0.9: The One-Line Protocol (1989) • HTTP/1.0 (1996) • HTTP/1.1: Internet Standard (1997) • Keep alive; chunk encodings; byte- range requests, additional caching mechanisms, transfer encodings, and request pipelining • HTTP/2.0 (since 2012) Ref: https://hpbn.co/brief-history-of-http/
  • 40. Stack walking API • Before 9: Throwable::getStackTrace и Thread::getStackTrace StackTraceElement[] stack = Thread.currentThread().getStackTrace(); • Since 9 also possible to: StackFrame[] stack =new StackWalker().walk((s) -> s.collect(Collectors.toArray())); • New StackWalker class 37
  • 41. 38 JEP 223: New Version-String Scheme • System Property Existing Proposed • ------------------------------- ------------ -------- • Early Access • java.version 1.9.0-ea 9-ea • java.runtime.version 1.9.0-ea-b73 9-ea+73 • java.vm.version 1.9.0-ea-b73 9-ea+73 • java.specification.version 1.9 9 • java.vm.specification.version 1.9 9 • Major (GA) • java.version 1.9.0 9 • java.runtime.version 1.9.0-b100 9+100 • java.vm.version 1.9.0-b100 9+100 • java.specification.version 1.9 9 • java.vm.specification.version 1.9 9 • Minor #1 (GA) • java.version 1.9.0_20 9.1.2 • java.runtime.version 1.9.0_20-b62 9.1.2+62 • java.vm.version 1.9.0_20-b62 9.1.2+62 • java.specification.version 1.9 9 • java.vm.specification.version 1.9 9 • Security #1 (GA) • java.version 1.9.0_5 9.0.1 • java.runtime.version 1.9.0_5-b20 9.0.1+20 • java.vm.version 1.9.0_5-b20 9.0.1+20 • java.specification.version 1.9 9
  • 42. New JEPs briefly. Client/graphics • 258: HarfBuzz Font-Layout Engine • 263: HiDPI Graphics on Windows and Linux • 265: Marlin Graphics Renderer • 262: TIFF Image I/O • 257: Update JavaFX/Media to Newer Version of GStreamer (1.4.4) • 251: Multi-Resolution Images 39
  • 43. New JEPs briefly. Security • 219: Datagram Transport Layer Security (DTLS) • 229: Create PKCS12 Keystores by Default • 244: TLS Application-Layer Protocol Negotiation Extension • 249: OCSP Stapling for TLS 40
  • 44. Unicode in Java 9 • 227: Unicode 7.0… • … & 267: Unicode 8.0 41
  • 47. Problems being addressed • Java Runtime keeps getting bigger and bigger • Java 8 profiles 1, 2, 3 provide partial solutions • Jar / Classpath Hell • What depends on what .. • Optional dependancies, transitive dependancies • Lazy class loading and initialization -> NoClassDefFoundError • For code that escapes packages the visibility mechanism is poor - only public • Classes from different packages “see” each other, even from different class loaders • SecurityManager helps to protect, but it is not on by default 44
  • 48. Wikepedia оn Jar-hell • Accidental presence of two different versions of a library installed on a system. This will not be considered an error by the system. Rather, the system will load classes from one or the other library. Adding the new library to the list of available libraries instead of replacing it may result in the application still behaving as though the old library is in use, which it may well be. • Multiple libraries or applications require different versions of library foo. If versions of library foo use the same class names, there is no way to load the versions of library foo with the same classloader. • The most complex JAR hell problems arise in circumstances that take advantage of the full complexity of the classloading system. A Java program is not required to use only a single "flat" classloader, but instead may be composed of several (potentially very many) nested, cooperating classloaders. Classes loaded by different classloaders may interact in complex ways not fully comprehended by a developer, leading to errors or bugs that are difficult to analyze, explain, and resolve. 45
  • 49. Jigsaw JEP 162: Prepare for Modularization JEP 200: The Modular JDK
 JEP 220: Modular Run-Time Images JEP 201: Modular Source Code JEP 260: Encapsulate Most Internal APIs JEP 282: jlink: The Java Linker
 JSR 376: Java Platform Module System JEP 261: Module System
 ModularityJava Module 46
  • 50. Examples 47 • 01 - Classpath hell • 02 - The simplest example with Modules • 03 - jimage • 04 - Error “2 modules export the same package into module 3” • 05 - Working with 2 “identical” classes in different modules
  • 51. Example 1 src/com.azul.modules.module1/module- info.java module com.azul.modules.module1 { 
 exports com.azul.testpackage1; } src/com.azul.modules.module2/module-info.java module com.azul.modules.module2 { requires com.azul.modules.module1; } com.azul.modules.module1/com/azul/testpackage1/A.java package com.azul.testpackage1; public class B { public static void m() { System.out.println("-- I am in path1.com.azul.test.B.m() "); } } com.azul.modules.module2/com/azul/testpackage2/A.java package com.azul.testpackage2; public class A { public static void main(String[] args) { System.out.println("Calling from com.azul.modules.module2.com.azul.testpackage2.A.main() "); com.azul.testpackage1.B.m(); } } 1 2 48
  • 52. New params javac/java (1) • # Compile • >javac --module-source-path src -d target $(find com.azul.modules.module1 -name “*.java”) • >javac --module-path mlib -d target/ com.azul.modules.module2 $(find com.azul.modules.module2 -name “*.java”)# Run • >java -p target -m mlib/com.azul.modules.module2 49
  • 53. New parameters for javac/java (2) 50 • # Packaging • jar --create --file=mlib/module2.jar --main- class=com.azul.testpackage2.A -C target/ com.azul.modules.module2 . • # Run • $j/bin/java -p target -m com.azul.modules.module2 Reference: http://openjdk.java.net/projects/jigsaw/quick-start
  • 54. Example 2 ./nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java module jdk.scripting.nashorn { requires java.logging; requires public java.scripting; uses jdk.internal.dynalink.linker.GuardingDynamicLinker; uses jdk.nashorn.internal.runtime.CodeStore; provides javax.script.ScriptEngineFactory with jdk.nashorn.api.scripting.NashornScriptEngineFactory; exports jdk.nashorn.api.scripting; exports jdk.nashorn.api.tree; exports jdk.nashorn.internal.runtime to jdk.scripting.nashorn.shell; exports jdk.nashorn.internal.objects to jdk.scripting.nashorn.shell; exports jdk.nashorn.tools to jdk.scripting.nashorn.shell; } META-INF/services 51
  • 55. Types of modules • Named • Those containing module-info.class • Automatic • jar files placed to the module path • Unnamed • Contains all types in the classpath 52
  • 56. Can modularised & non-modularised
 code co-exist? • Whatever is in classpath - going into unnamed modules • Unnamed modules can access all named modules (requires *) /See next slide for a special note/ • The reverse isn’t true - must specify requires unnamed or … • jar file in --module-path is being automatically converted to a module with a name matching the name of the jar file • Therefore referred as automodules • Provide transition path to jigsaw modules design • Unnamed modules are being searched for types as a last option 53
  • 57. Unnamed modules can access all named modules • Not so true since JDK9 build 118 • These modules are not accessible from unnamed modules:
 java.activation - java.annotations.common - java.corba
 java.transaction - java.xml.bind - java.xml.ws • One can still add visibility with a flag like `-addmods java.corba` • Source: May 17th letter from Alan Bateman: http://mail.openjdk.java.net/ pipermail/jdk9-dev/2016-May/004309.html • More info: http://openjdk.java.net/jeps/261 54
  • 58. 55 jdeps -genmoduleinfo cat /Users/ivan/test/modules/generated/glassfish.corba.omgapi/module-info.java module glassfish.corba.omgapi { requires public java.corba; requires public java.desktop; requires public java.rmi; exports com.sun.corba.ee.org.omg.CORBA; exports javax.rmi.CORBA; exports org.omg.CORBA; exports org.omg.CORBA.DynAnyPackage; exports org.omg.CORBA.ORBPackage; exports org.omg.CORBA.TSIdentificationPackage; exports org.omg.CORBA.TypeCodePackage; exports org.omg.CORBA.portable; exports org.omg.CORBA_2_3; exports org.omg.CORBA_2_3.portable; exports org.omg.CosNaming; exports org.omg.CosNaming.NamingContextExtPackage; exports org.omg.CosNaming.NamingContextPackage; exports org.omg.CosTSInteroperation; exports org.omg.CosTSPortability; exports org.omg.CosTransactions; exports org.omg.Dynamic; exports org.omg.DynamicAny; exports org.omg.DynamicAny.DynAnyFactoryPackage; exports org.omg.DynamicAny.DynAnyPackage; exports org.omg.IOP; exports org.omg.IOP.CodecFactoryPackage; exports org.omg.IOP.CodecPackage; exports org.omg.Messaging; exports org.omg.PortableInterceptor; exports org.omg.PortableInterceptor.ORBInitInfoPackage; exports org.omg.PortableServer; exports org.omg.PortableServer.CurrentPackage; exports org.omg.PortableServer.POAManagerPackage; exports org.omg.PortableServer.POAPackage; exports org.omg.SendingContext; exports org.omg.stub.java.rmi; } jdeps -genmoduleinfo ~/test/modules/generated/ 
 glassfish-4.1.1/glassfish/modules/ glassfish-corba-omgapi.jar
  • 59. 56 jdeps -jdkinternals glassfish-corba-orb.jar -> java.corba com.sun.corba.ee.impl.copyobject.OldReflectObjectCopierImpl (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.copyobject.OldReflectObjectCopierImpl$1 (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.encoding.BufferManagerWriteStream (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.IIOPInputStream (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.IIOPInputStream$1 (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.IIOPOutputStream (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.IIOPOutputStream$1 (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.ObjectStreamClass (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.ObjectStreamClass$1 (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.ObjectStreamField (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.io.ObjectStreamField$1 (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl$1 (glassfish-corba-orb.jar) -> com.sun.jndi.cosnaming.CNCtx JDK internal API (java.corba) com.sun.corba.ee.impl.util.JDKClassLoader (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) com.sun.corba.ee.impl.util.JDKClassLoader$1 (glassfish-corba-orb.jar) -> sun.corba.Bridge JDK internal API (java.corba) jdeps -jdkinternals glassfish/ modules/ glassfish-corba-orb.jar
  • 61. 58 • Consider an app with extensions • The extension might require a different version of a module than loaded before • The extension might require service providers • Layer of modules encapsulates • a module graph • mapping from each module in that graph to a class loader • Boot layer - created by VM at start time and suitable for most apps • App can create a new layer - new universe of modules • Stackable - package resolution starts with the app layer and goes down to the boot layer Layers
  • 62. Modularity Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html JDK 7 b65 59 http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html
  • 63. Modularity Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html JDK 8 b48 60 http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html
  • 66. Jigsaw - Unresolved issues http://openjdk.java.net/projects/jigsaw/spec/issues/ 63 • Module declarations • #ModuleNameSyntax · #ModuleNameCharacters ? · #CompileTimeDependences ✔ · #ModuleAnnotations ✔ · #ModuleDeprecation ✔ · #ExportAnnotation • Module artifacts • #MultiModuleExecutableJARs · #MultiModuleJARs · #ReifiedModuleGraphs · #ModuleNameInManifest · #AddExportsInManifest ✔ • Module descriptors • #ClassFileModuleName ? · #ClassFileAccPublic ✔ · #ClassFileAccModule ? · #StandardModuleAttributes • Module graphs • #CyclicDependences · #MutableConfigurations · #LazyConfigurationAndInstantiation · #CustomizableAutomaticModuleNameMapping ✔ • Services • #ServiceLoaderEnhancements ✔
 • Reflection • #ClassFilesAsResources ✔ · #ResourceEncapsulation ✔ · #ResourceExistenceAndSize · #ReflectiveAccessToNonExportedTypes ? · #AwkwardStrongEncapsulation ? · #ReflectionWithoutReadability ✔ · #ReadabilityAddedByLayerCreator ? · #IndirectQualifiedReflectiveAccess ? • Class loaders • #AvoidConcealedPackageConflicts · #PlatformClassLoader ✔ · #ClassLoaderNames ✔ • Versioning • #StaticLayerConfiguration · #MultipleModuleVersions · #VersionsInModuleNames ✔ · #VersionedDependences ? · #VersionSyntax • Layers • #NonHierarchicalLayers ? · #DiscardableModules • Tooling • #BootstrapClassLoaderSearchInJVMTI ✔ · #ReflectiveAccessByInstrumentationAgents ✔
  • 67. Jigsaw - Unresolved issues http://openjdk.java.net/projects/jigsaw/spec/issues/ • Module declarations • #ModuleNameSyntax · #ModuleNameCharacters ? · #CompileTimeDependences ✔ · #ModuleAnnotations ✔ · #ModuleDeprecation ✔ · #ExportAnnotation • Module artifacts • #MultiModuleExecutableJARs · #MultiModuleJARs · #ReifiedModuleGraphs · #ModuleNameInManifest · #AddExportsInManifest ✔ • Module descriptors • #ClassFileModuleName ? · #ClassFileAccPublic ✔ · #ClassFileAccModule ? · #StandardModuleAttributes • Module graphs • #CyclicDependences · #MutableConfigurations · #LazyConfigurationAndInstantiation · #CustomizableAutomaticModuleNameMapping ✔ • Services • #ServiceLoaderEnhancements ✔
 • Reflection • #ClassFilesAsResources ✔ · #ResourceEncapsulation ✔ · #ResourceExistenceAndSize · #ReflectiveAccessToNonExportedTypes ? · #AwkwardStrongEncapsulation ? · #ReflectionWithoutReadability ✔ · #ReadabilityAddedByLayerCreator ? · #IndirectQualifiedReflectiveAccess ? • Class loaders • #AvoidConcealedPackageConflicts · #PlatformClassLoader ✔ · #ClassLoaderNames ✔ • Versioning • #StaticLayerConfiguration · #MultipleModuleVersions · #VersionsInModuleNames ✔ · #VersionedDependences ? · #VersionSyntax • Layers • #NonHierarchicalLayers ? · #DiscardableModules • Tooling • #BootstrapClassLoaderSearchInJVMTI ✔ · #ReflectiveAccessByInstrumentationAgents ✔ 64
  • 68. (My) takeaways on Java 9 modules • Purpose - explicit listing of dependancies • Will provide new optimization paths • Compatible with jar/cp • OSGi compatibility and reflection are a concern • Jigsaw - rough flight all way along, loosing features • Lost ability to match versions 65
  • 69. Jigsaw - links • If you google it - discard all posts before 2014, probably even before 2015 too • State of Jigsaw (March 8 2015) • http://openjdk.java.net/projects/jigsaw/spec/sotms/ • JavaOne 2016 (also Devoxx BE 2017) • http://openjdk.java.net/projects/jigsaw/talks/#j1-2016 • Code was integrated in JDK9 EA build 111 • See also: http://blog.codefx.org/java/dev/features-project-jigsaw-java-9/ • http://blog.codefx.org/java/dev/javaone-2015-under-the-hood-of-project-jigsaw/ 66
  • 71. Ivan Krylov www.azul.com
 Azul Systems ivan @azul.com
 @JohnWings