Enabling the IBM Blue Stack with Java

Download Report

Transcript Enabling the IBM Blue Stack with Java

Enabling the IBM Blue Stack with Java
October 18th 2010, Bangalore, India
Java Language : New Features in a
nutshell
Lakshmi Narasimhan
© 2010 IBM Corporation
Conference materials may not be reproduced in whole or in
part without the prior written permission of IBM.
Enabling the IBM Blue Stack with Java
Agenda
 Evolution of Java
 Java eco-system
 What’s driving the change
https://espresso.hursley.ibm.com/perl/secure/fetch/j9-60/Other/pxi32hs60/20090206_02/pxi32hs60-20090206_02-hsdk.jar
 New Language Features in JDK7
 Demo
 Q&A
2
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
Disclaimer
Opinions/views expressed
here are my own and
should not be taken as
IBM’s views.
3
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.
4
Language for Languages (2007 onwards):

Powering development of newer Programming Languages

Clojure, Groovy, JRuby, Scala, Rhino, Jython…
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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
5
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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
–
–
–
–
–
6
Locale Enhancements
Unicode 6.0
Translucent shaped windows
Swing : Nimbus L&F, JLayer components
XRender pipeline for Java 2D
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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/
7
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.sieioswww6.com/default.asp?W9
8
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
JDK7 Features - Easier
 Project Coin: Small language changes
 New IO2 to define a true filesystem API
 Method to close a URLClassLoader
9
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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)
10
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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
11
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.
12
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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)
13
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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/
14
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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)
15
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
Method to close URLClassLoader
 Code snippet
 Foo.jar now gets updated somehow
16
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.
17
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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)
18
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.
19
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
Questions?
https://espresso.hursley.ibm.com/perl/secure/fetch/j9-60/Other/pxi32hs60/20090206_02/pxi32hs60-20090206_02-hsdk.jar
20
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
Useful links
 List of JVM implementations :
http://en.wikipedia.org/wiki/List_of_Java_virtual_machine
s
 Java7 features overview :
http://tech.puredanger.com/java7/
 Project coin updates : http://www.baptistewicht.com/2010/04/java-7-updates-project-coin/
21
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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)
22
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.
23
Bangalore, October 18th 2010
© 2010 IBM Corporation
Enabling the IBM Blue Stack with Java
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.
24
Bangalore, October 18th 2010
© 2010 IBM Corporation