Upload
lakshmi-narasimhan
View
47
Download
2
Embed Size (px)
Citation preview
© 2011 IBM Corporation
Java8 – under the hood
Lakshmi Narasimhan ([email protected])
Java Technology Center
© 2011 IBM Corporation
2
Agenda
Java eco-systemFeatures at a GlanceModularity in JavaLambda ExpressionsQ&A
© 2011 IBM Corporation
3
Disclaimer
Opinions/views expressed here are my own and should not be taken as IBM’s views.
Java8 is still under development and so ….
© 2011 IBM Corporation
footer text
Important Disclaimers
THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLED ENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE OR INFRASTRUCTURE DIFFERENCES.ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE.IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE. IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF: - CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS OR THEIR SUPPLIERS AND/OR LICENSORS
© 2011 IBM Corporation
5
Java eco-system Proliferation of Java
– At least 15 known proprietary JVMs– >30 Free and open source implementations
OpenJDK– OpenJDK is the Reference Implementation of J2SE Spec– More open participation through OpenJDK– Lot of big weights behind OpenJDK (IBM, Twitter, RedHat, SAP ..)– Release Cadence
Newer/simpler programming paradigms– Combine the best of interpreted and compiled languages– Allow for rapid prototyping and development
MMP and Cloud scale architectures– Thousands of “Clustered” JVMs– “Cloud aware” Vms– Network and memory no longer the constraints – but Java's awareness
of it is
© 2011 IBM Corporation
6
Java8 – features at a glance *Performance
Parallel Array Sorting Concurrency updates (JSR 166e) Charset implementation improvements
Modularity and Manageability Java Platform Module System Java Platform Module System (aka jigsaw)(aka jigsaw)
Ease of use Lambda Expressions Lambda Expressions (aka “Closures”/anonymous inner classes)(aka “Closures”/anonymous inner classes) Bulk data operations for collections Generalized Target-Type Inference Repeating annotations Date and time API
UI and “currency” updates Javadoc support through javax.tools Adopt unicode CLDR Data Unicode 6.1 Launch JavaFX applications
* Bound to change – For detailed list see http://openjdk.java.net/jeps/0
© 2011 IBM Corporation
7
Java8 - What’s out
Mtoolkit– Only XtoolKit (*nix) and WtoolKit (Windows) supported– Impact - Minimal
IO code page converters– sun.io.* classes removed– Deprecated in JDK7– Switch to NIO for all code-page conversion– Impact – High
“apt” tool– Deprecated in JDK7– Tool, associated API and docs will be removed– Users to switch to JSR269 (Pluggable Annotation Processing API)– Impact - Moderate
Watch out for modularity
© 2011 IBM Corporation
8
JDK8 Features - PerformanceParallel Array Sorting: Current sorting algorithms (in Collections and Arrays) are sequential Modified internally to use Fork/Join framework Sorting will still be synchronous Adds a default ForkJoin Pool to be used by both internal classes and applications
Read More : – http://openjdk.java.net/jeps/103
© 2011 IBM Corporation
9
JDK8 Features - PerformanceConcurrency updates Scalable updatable variables Cache-oriented enhancements to the ConcurrentHashMap API
– Less footprint (comparable to HashMap)– Better performance under concurrent load
ForkJoinPool improvements Additional Lock and Future classes and better support for software transactional
memory (STM) frameworks. Read More :
– http://openjdk.java.net/jeps/103
Charset Improvements:• Decrease the size of installed charsets• Reduce maintenance cost by generating charset implementations at build time
from simple text-based mapping tables• Improve the performance of encoding/decoding
© 2011 IBM Corporation
10
Java Platform Module System
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation11
Modularity exists at App level (only) Work around inefficiencies in underlying
layer Application migration is a pain
Do you remember your class path sequencing? Has led to tools like Maven
The JVM knows everything about the
application and its usage“one-size fits all” doesn't scale
© 2011 IBM Corporation
12
JDK8 Features – Java Platform Module SystemMotivations
Jar Hell– Excellent distribution format– Poor versioning format– “jar” format is outdated– No way to reliably specify and manage dependencies– Currently worked around at deployment stage
Monolithic JDK– Delivered as one massive, indivisible artifact– Inter-dependencies between J2SE components– Increased start-up, footprint, download time
“Profile” based usage– A simple “Hello World” program internally loads > 300 classes– Load only those classes that are needed by application
• Why do I need to load a “javax.swing” for a OLTP app??– Merging J2SE and J2ME
Expose “modularity” to applications– Modularize the entire stack and not just application– Inter-op with existing modularity frameworks
© 2011 IBM Corporation
13
JDK8 Features – Java Platform Module SystemDesign Principles and Definitions
Modularity is a language construct Module boundaries are strictly enforced Static, single-version module resolution is usually sufficientDefinitions Module -Collection of Java types (i.e., classes and interfaces) with a name, an optional
version number and a formal description of its relationships to other modules. A module may be platform specific and embody native code.
Resolution - Process of locating additional modules, as required, and constructing a superset of that set in which every dependence is optimally satisfied.
Phases - – Compile time – A module’s dependences are resolved, its types are compiled from Java source files,
and its other content is compiled or constructed as appropriate. The results are then packaged up for publication and distribution.
– Install time – A module is inserted into a module library, i.e., a collection of previously-installed modules. If the module is invokable, i.e., it has an entry point, then it is made ready for use by resolving its dependences and storing the result of that computation in a persistent configuration.
– Run time – An invokable module is loaded into a running Java virtual machine and linked up to the other modules upon which it depends as recorded in its configuration during installation.
© 2011 IBM Corporation
14
JDK8 Features – Java Platform Module System
Anatomy of a Module
Source code for module-info.java
© 2011 IBM Corporation
15
JDK8 Features – Java Platform Module System
Module nameModule Version
Anatomy of a ModuleDependent Module
Dependent Module with specific version
What does this module provide to others
Main method in this module
© 2011 IBM Corporation
16
JDK8 Features – Java Platform Module SystemCompiling and installing modules
1) javac now understands “modulepath” keyword – use when compiling multiple modules
2) Create a repository deploy your modules
3) Install your module into the repository
4) Run your app
© 2011 IBM Corporation
17
JDK8 Features – Java Platform Module SystemDifferences between Jigsaw and OSGi
Static resolution – Module dependencies are resolved at module install time and not run-time
– More predictable– Faster class loading
Meta data– Jigsaw uses module-info.class– OSGi uses readable MANIFEST.MF
Dependency boundary– Modules for jigsaw– Packages for OSGi
Unit of sharing– Modules for jigsaw (packages can span modules)– Packages for OSGi
© 2011 IBM Corporation
18
JDK8 Features – Java Platform Module SystemWhat it means to you?
No more “non-standard” API access (sun.*)– Visibility might be enforced by module boundary
No more single “rt.jar” Faster start up time Easier dependency resolution
– At compiler, install time and not run-time– Quicker migration
Custom distributable formats??
To the JDK Developers?
© 2011 IBM Corporation
19
JDK8 Features – Java Platform Module SystemFrom this
© 2011 IBM Corporation
20
JDK8 Features – Java Platform Module SystemTo this...
© 2011 IBM Corporation
21
JDK8 Features – Lambda ExpressionsSupport for operating on an arbitrary "block of Java code", or body, which is either a
statement list, an expression, or a combination of both.Implementation of JSR 335
Background Consider the ActionListener Interface (an eg of functional interface a.k.a SAM)
http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-4.html
“Call-back” interfaces are not uncommon (remember Runnable, Comparator?) Too much boiler plate without adding value
© 2011 IBM Corporation
22
JDK8 Features – Lambda ExpressionsEnter Java8 style:
Lambda syntax & Examples
Argumentlist → body()
Examples:
© 2011 IBM Corporation
23
JSR 335 – Adding Lambda expressions to the Java Language
© 2011 IBM Corporation
24
JDK8 Features – Lambda Expressions – parting thoughts
http://jcp.org/aboutJava/communityprocess/ec-public/materials/2011-01-1112/2011-01_JCP_EC_ProjectLambda.pdf
© 2011 IBM Corporation
25
Where to go next?• Read the documentation
• Download the SDK
• Write/break the code
• Prepare for migration
• Give feedback
• Join the “Java Technology Community” - http://bit.ly/a7KpQj
© 2011 IBM Corporation
26
Questions?
https://espresso.hursley.ibm.com/perl/secure/fetch/j9-60/Other/pxi32hs60/20090206_02/pxi32hs60-20090206_02-hsdk.jar
© 2011 IBM Corporation
27
Reference
List of propsed enhancements to jdk8 : http://openjdk.java.net/jeps/0
Modularity:Massive monolithic JDK - http://mreinhold.org/blog/massive-monolithic-jdk
Project jigsaw: Big picture : http://cr.openjdk.java.net/~mr/jigsaw/notes/jigsaw-big-picture-01
What's cooking in jdk 8 : http://www.javacodegeeks.com/2012/05/whats-cooking-in-java-8-project-jigsaw.html
Jigsaw quick start : http://openjdk.java.net/projects/jigsaw/doc/quickstart.html
Lambda Expressions:Project lambda homepage: http://openjdk.java.net/projects/lambda/
Enhanced collection APIs : http://www.javabeat.net/2012/05/enhanced-collections-api-in-java-8-supports-lambda-expressions/
Project lambda - multicore and beyond : http://jcp.org/aboutJava/communityprocess/ec-public/materials/2011-01-1112/2011-01_JCP_EC_ProjectLambda.pdf