240 likes | 376 Views
Java Language : New Features in a nutshell. Lakshmi Narasimhan. 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.
E N D
Java Language : New Features in a nutshell Lakshmi Narasimhan
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 Bangalore, October 18th 2010
Disclaimer Opinions/views expressed here are my own and should not be taken as IBM’s views. Bangalore, October 18th 2010
Evolution of Java - Eras of Java Programming Language • Embedded System (1991-1994) • Originally called Oak • Aimed at electronic devices • Client Side System (1995-1997) • Internet changed it all. • Browsers and Applets gained popularity • Middle Tier System (1997-2007) • Forms core of the 3-Tier Architecture • Powers most of the Middleware systems. • Language for Languages (2007 onwards): • Powering development of newer Programming Languages • Clojure, Groovy, JRuby, Scala, Rhino, Jython… 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 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 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/ 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 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 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) 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 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. 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) 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/ 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) Bangalore, October 18th 2010
Method to close URLClassLoader • Code snippet • Foo.jar now gets updated somehow 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. 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) 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. Bangalore, October 18th 2010
Questions? https://espresso.hursley.ibm.com/perl/secure/fetch/j9-60/Other/pxi32hs60/20090206_02/pxi32hs60-20090206_02-hsdk.jar 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/ 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) 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. 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. Bangalore, October 18th 2010