Over a million developers have joined DZone.

Various API and Language Enhancements as Part of Java 7

· Java Zone

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

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.

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

Published at DZone with permission of Mohamed Sanaulla, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}