Post on 06-Jan-2016
description
transcript
Enabling the IBM Blue Stack with Java
October 18th 2010, Bangalore, India
© 2010 IBM CorporationConference materials may not be reproduced in whole or in
part without the prior written permission of IBM.
Java Language : New Features in a nutshell
Lakshmi Narasimhan
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation2 Bangalore, October 18th 2010
Agenda
Evolution of Java
Java eco-system
What’s driving the change
New Language Features in JDK7
Demo
Q&A
https://espresso.hursley.ibm.com/perl/secure/fetch/j9-60/Other/pxi32hs60/20090206_02/pxi32hs60-20090206_02-hsdk.jar
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation3 Bangalore, October 18th 2010
Disclaimer
Opinions/views expressed here are my own and should not be taken as IBM’s views.
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation4 Bangalore, October 18th 2010
Evolution of Java - Eras of Java Programming Language
1. Embedded System (1991-1994) Originally called Oak Aimed at electronic devices
2. Client Side System (1995-1997) Internet changed it all. Browsers and Applets gained popularity
3. Middle Tier System (1997-2007) Forms core of the 3-Tier Architecture Powers most of the Middleware systems.
4. Language for Languages (2007 onwards): Powering development of newer Programming Languages Clojure, Groovy, JRuby, Scala, Rhino, Jython…
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation5 Bangalore, October 18th 2010
Java eco-system
Relevance of “Java” brand name
– At least 15 known proprietary JVM implementations.
– >30 Free and open source implementations.
Image of Sun/Oracle in the Community
– More open participation through OpenJDK
– Multiple avenues available for contribution
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
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation6 Bangalore, October 18th 2010
What’s driving the changes Faster
– Invoke Dynamic– Concurrency and Collections update
Smaller– Modular Java (Moved to Java8)
Easier– Coin– NIO2– Method to close a URLClassLoader
Nicer– Locale Enhancements– Unicode 6.0– Translucent shaped windows– Swing : Nimbus L&F, JLayer components– XRender pipeline for Java 2D
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation7 Bangalore, October 18th 2010
JDK7 Features - Faster
InvokeDynamic
Implemented via JSR-292
Improves compatibility between Java and various dynamic languages, such as Ruby and Python, by providing better-than-native implementations of these languages on top of the Java Runtime Environment (JRE).
Eliminates need for “Glue-code” in the program interpreters.
Addition of new bytecode – “invokedynamic”
Read More : http://java.sun.com/developer/technicalArticles/DynTypeLang/
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation8 Bangalore, October 18th 2010
JDK7 Features - Faster
Concurrency and collections update Implemented via JSR 166y
Light-weight task framework called ForkJoin(FJ)
Introduces Parallel-Array (PA) concept to Java (simlar to Map-Reduce?)
Recursive Parallel De-composition of tasks
Suited for MMP Architectures.
Read More : http://artisans-serverintellect-com.si-eioswww6.com/default.asp?W9
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation9 Bangalore, October 18th 2010
JDK7 Features - Easier
Project Coin: Small language changes
New IO2 to define a true filesystem API
Method to close a URLClassLoader
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation10 Bangalore, October 18th 2010
JDK7 Features – Easier
Project Coin Strings in switch: A simple change that improves regularity in the language
Improved Type Inference for Generic Instance Creation (diamond)
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation11 Bangalore, October 18th 2010
JDK7 Features - Easier
Project Coin Simplified varargs method invocation
– Type information from generics gets erased at compile-time.– Current implementation generates unchecked warning at call time.– Proposal moves warnings from call site to Method declaration.
An omnibus proposal for better integral literals
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation12 Bangalore, October 18th 2010
JDK7 Features – Easier
Project Coin
Automatic Resource Management : Automatically close the resources using a new try clause.
Applies to Streams, Reader/Writers, Channels, Sockets, SQL operations and even Graphics.
When the statement completes, whether normally or abruptly, all of its resources are closed automatically.
Obviates the need for manual resource termination which is error prone and ugly.
Exception chaining masks true failures needing more verbose code (OR) more debugging time.
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation13 Bangalore, October 18th 2010
Project Coin – Automatic Resource Management Lets accept it, even good programmers get it wrong!!
The same code with ARM would look like this:
Makes the code vastly clear and concise.
Downside is you lose WYSIWYG (a lot happens under the hood now)
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation14 Bangalore, October 18th 2010
JDK7 Features - Easier
New I/O 2 JSR203
Need
– Java I/O File API buggy and not fully fail-safe.
– Inconsistent behavior across platforms (eg: rename function)
– Limited support for operating on Files.
What NIO2 provides:
– “Path” Class Operations
– Support for Directory manipulation
– Recursive File operations – FileVisitor class
– Full support for Symbolic links
– WatchService API
Read more : http://java.sun.com/developer/technicalArticles/javase/nio/
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation15 Bangalore, October 18th 2010
JDK7 Features - Easier
Method to close a URLClassLoader Custom URLClassLoaders are commonly written for loading classes and resources
from file-system directories, jar files or URLs.
Current implementation does not guarantee a “refresh” of updated implementations loaded from a particular codebase.
A new method close() introduced in URLClassLoader which:
– Invalidates the loader (so new classes can be loaded)
– Closes any resource opened by it (jar files)
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation16 Bangalore, October 18th 2010
Method to close URLClassLoader
Code snippet
Foo.jar now gets updated somehow
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation17 Bangalore, October 18th 2010
Java7 Features - Nicer
Swing Enhancements
Swing JLayer component
– Universal decorator for Swing components.
– easily decorate your compound components and catch all Mouse, Keyboard and FocusEvent for all its subcomponents
– Greatly eliminates verbose AWTEventListeners
Nimbus L & F :
– Cross platform L&F based on Synth LAF.
– Implemented in Java6 update10.
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation18 Bangalore, October 18th 2010
Java7 Features - Nicer
XRender pipeline for Java 2D
a new Java2D graphics pipeline based upon the X11 XRender extension.
Aim is to leverage hardware acceleration for most of Java2D’s functionality.
Locale Enhancements
Support for IETF BCP 47 and UTR 35 (CLDR/LDML)
Unicode 6.0
Support for Unicode 6.0 (changed from original goal of 5.1)
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation19 Bangalore, October 18th 2010
Want to get your hands dirty?
Participate in the IBM SDK for Java7 Beta program
Visit https://www.ibm.com/developerworks/java/jdk/beta/index.html to enroll.
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation20 Bangalore, October 18th 2010
Questions?
https://espresso.hursley.ibm.com/perl/secure/fetch/j9-60/Other/pxi32hs60/20090206_02/pxi32hs60-20090206_02-hsdk.jar
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation21 Bangalore, October 18th 2010
Useful links
List of JVM implementations : http://en.wikipedia.org/wiki/List_of_Java_virtual_machines
Java7 features overview : http://tech.puredanger.com/java7/
Project coin updates : http://www.baptiste-wicht.com/2010/04/java-7-updates-project-coin/
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation22 Bangalore, October 18th 2010
JDK7 Features overview
Modularity A large-scale effort to refactor, or break up, the Java SE platform into smaller, separate,
interdependent modules.
Implemented via JSR-294
Java Programming language was not designed with Modularity in mind.
Many module systems currently exist:
– Most mature implementation is OSGi.
– IntelliJ, Eclipse and Netbeans offer their own Plugin architecture.
JSR 294 aims at making Modules natively supported by the language.
Smaller download, start-up performance, smaller footprint.
Has taken various Avatars : JSR 291 (Dynamic Component Support for Java SE), JSR 277 (Java Module System)
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation23 Bangalore, October 18th 2010
Modularity So what’s changing:
– ClassLoader Architecture
– New java.lang.Module package
– New “module” keyword
– New packaging & distribution formats (one package per module??)
“module” keyword can be used by compilers to generate “meta” information. These can then be used for runtime validation for module dependencies, versioning etc.
Implemented in OpenJDK via Project Jigsaw
Aimed at making not just Java Modularized but also application classes.
Jigsaw modules aimed to be compatible with OSGi systems.
Enabling the IBM Blue Stack with Java
© 2010 IBM Corporation24 Bangalore, October 18th 2010
JDK7 Features overview – Developer Productivity
Type Annotations
JSR308
Java6 Annotation syntax useful but limited.
Type Annotations allow more expressive programming
Example : List<@NonNull Object>
Tools (annotation processors) can then validate the code for errors.