I have been in the software development industry since 2010, working on enterprise product development using ADF. I am usually keen on learning about software design and emerging technologies. You can find me hanging around in the JavaRanch Forums where I am one of the moderators. Apart from Java, I am fascinated by the ease of use and simplicity of Ruby and Rails. Mohamed is a DZone MVB and is not an employee of DZone and has posted 53 posts at DZone. You can read more from them at their website. View Full User Profile

Various API and Language Enhancements as Part of Java 7

07.17.2012
| 4489 views |
  • submit to reddit

I believe most of the Java Developers are aware of the latest Java release i.e Java 7. Lot of us are disappointed about quite a few important features being deferred to Java 8, but its really good to see the language evolving and lot of things happening in the Java community. You must have seen plethora of articles on try-with-resources, strings in switch statements and other minor language enhancements as part of Project Coin. These are just few of the enhancements added to the release. There are few other API enhancements which are good to know, for example new Files API in java.nio package, watching directory changes, Fork-Join framework.

I went through few of those topics and blogged about them and I thought it is best to aggregate them here for the benefit of the readers.

Fork-Join Framework:

In Java 5 java.util.concurrent package was added with lot of new classes for developing concurrent applications- Executor, ExecutorService, Callable, Futures among others. Fork-Join framework was added in Java 7 which builds on top of ExecutorService and adds task stealing algorithm in which the tasks queued in one thread can be picked by ideal threads and this facilitates creating multiple tasks and not worrying about tasks not getting executed.

  • A brief overview of Fork-Join framework can be found here.
  • Implementing mergesort algorithm using ForkJoin framework can be found here.
Enhancements to the File API:

A new package java.nio.file was added with support for representing file path, a static Files utility for reading, writing to a file and other file related tasks, working with symbolic links, api for implementing watch service and others.

There was another utility added to java.util package- Objects class with static utility methods for operating on object references. This is kind of unknown addition but has been used extensively in the Java 8 APIs. And I came across this while reading through the Java 8 code.

One other important feature added to the JVM- invokedynamic has been missed out here. And I think its quite important to explore this feature for there are languages like Groovy 2.0, JRuby making use of this feature.

Published at DZone with permission of Mohamed Sanaulla, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)