+ All Categories
Home > Education > What to expect from Java 9

What to expect from Java 9

Date post: 19-Mar-2017
Category:
Upload: ivan-krylov
View: 169 times
Download: 1 times
Share this document with a friend
71
What to expect from Java 9? Ivan Krylov Azul Systems
Transcript
Page 1: What to expect from Java 9

What to expect from Java 9?

Ivan Krylov Azul Systems

Page 2: What to expect from Java 9

2

Page 3: What to expect from Java 9

3Ivan Aivazovsky, 1850, The Ninth Wave, Russian Museum, St. Petersburg

Page 4: What to expect from Java 9

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,

MIPS4

Page 5: What to expect from Java 9

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

Page 6: What to expect from Java 9

6

Page 7: What to expect from Java 9

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

Page 8: What to expect from Java 9

7

http://wiki.netbeans.org/InternalAPIsUnavailableInJava9

Page 9: What to expect from Java 9

8

“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”

Bjarne Stroustrup

Page 10: What to expect from Java 9

Java Timeline

JDK 6Dec 2006

JDK 7July 2011

JDK 8March 2014

JDK 9exp. July 2017

JDK 6Nov 2012

JDK 7Apr

2015

JDK 8exp. July 2018

J2SE 1.4 Dec 2006

JDK 5Oct 2009

9

GA

EOL

Page 11: What to expect from Java 9

Java EOL & You?EOL datepassed

Security vulnerabilities

keep appearing&

Sign Support contact

Adopt OpenJDK (Zulu, IcedTea,

homebrew builds)Updated to latest

JDK

10

Updates needed

Page 12: What to expect from Java 9

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

Page 13: What to expect from Java 9

How new features become part of Java standard?

12

Page 14: What to expect from Java 9

JEP process

13

Source: http://cr.openjdk.java.net/~mr/jep/jep-2.0-02.html

Page 15: What to expect from Java 9

JSR

Source: https://groups.google.com/forum/#!topic/java-social/InafCPMLLaA14

Page 16: What to expect from Java 9

New APIs and features in Java 9

15

Page 17: What to expect from Java 9

Fabric methods for collectionsInstantiation 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");

Page 18: What to expect from Java 9

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));

Page 19: What to expect from Java 9

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

Page 20: What to expect from Java 9

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

Page 21: What to expect from Java 9

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*/ ; } }

Page 22: What to expect from Java 9

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) { } }

Page 23: What to expect from Java 9

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

Page 24: What to expect from Java 9

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

Page 25: What to expect from Java 9

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;}

Page 26: What to expect from Java 9

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());

Page 27: What to expect from Java 9

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

Page 28: What to expect from Java 9

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

Page 29: What to expect from Java 9

Producer/Consumer and SLH

26

Page 30: What to expect from Java 9

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

Page 31: What to expect from Java 9

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

Page 32: What to expect from Java 9

Jshell Demo

29

just kick ./bin/jshell and try yourself

Page 33: What to expect from Java 9

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

Page 34: What to expect from Java 9

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-collection31

Page 35: What to expect from Java 9

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

Page 36: What to expect from Java 9

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

Page 37: What to expect from Java 9

HTTP/2 today

34

Page 38: What to expect from Java 9

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/

Page 39: What to expect from Java 9

36https://speakerdeck.com/vietj/2-2

HTTP/2. Multiplexing

Page 40: What to expect from Java 9

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

Page 41: What to expect from Java 9

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

Page 42: What to expect from Java 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

Page 43: What to expect from Java 9

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

Page 44: What to expect from Java 9

Unicode in Java 9

• 227: Unicode 7.0…

• … & 267: Unicode 8.0

41

Page 45: What to expect from Java 9

Modules

42

Page 46: What to expect from Java 9

Modules

Packages

Classes

fields & methods

Interfaces

Abstract Classes

Code encapsulation

43

Page 47: What to expect from Java 9

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 default44

Page 48: What to expect from Java 9

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

Page 49: What to expect from Java 9

Jigsaw

JEP 162: Prepare for ModularizationJEP 200: The Modular JDKJEP 220: Modular Run-Time ImagesJEP 201: Modular Source CodeJEP 260: Encapsulate Most Internal APIsJEP 282: jlink: The Java Linker

JSR 376: Java Platform Module SystemJEP 261: Module System

ModularityJava Module

46

Page 50: What to expect from Java 9

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

Page 51: What to expect from Java 9

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 248

Page 52: What to expect from Java 9

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

Page 53: What to expect from Java 9

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

Page 54: What to expect from Java 9

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

Page 55: What to expect from Java 9

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

Page 56: What to expect from Java 9

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

Page 57: What to expect from Java 9

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.corbajava.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/26154

Page 58: What to expect from Java 9

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

Page 59: What to expect from Java 9

56

jdeps -jdkinternalsglassfish-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

Page 60: What to expect from Java 9

57

java --add-exportsjava --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-readsjava --add-reads:java.management=testng

Page 61: What to expect from Java 9

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

Page 62: What to expect from Java 9

Modularity

Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.htmlJDK 7 b65

59http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html

Page 63: What to expect from Java 9

Modularity

Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html

JDK 8 b48

60http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html

Page 64: What to expect from Java 9

Modularity

Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.html

JDK9 b157

61http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html

Page 65: What to expect from Java 9

Modularity

Source: http://openjdk.java.net/projects/jigsaw/doc/jdk-modularization.htmlJDK9 b15762http://cr.openjdk.java.net/~mr/jigsaw/ea/module-summary.html

Page 66: What to expect from Java 9

Jigsaw - Unresolved issueshttp://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 ✔

Page 67: What to expect from Java 9

Jigsaw - Unresolved issueshttp://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

Page 68: What to expect from Java 9

(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

Page 69: What to expect from Java 9

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

Page 70: What to expect from Java 9

is thiswhat wewanted?

(rhetorical)

67

Page 71: What to expect from Java 9

Ivan Krylov www.azul.com Azul Systems ivan @azul.com

@JohnWings


Recommended