Introduction to the new features of JDK 7

Source: Internet
Author: User
Tags file system join locale new features

Overview of one of the new feature series of JDK7

The JDK full name Java Development Kit is a set of software development tools for Java developers, including JRE (Java Runtime Environment), as well as Java, Jar, Javac, JAVAP, Javah, Ja Vaws and other tools. Since Sun company released on December 11, 2006 JDK6 to Oracle company released on July 28, 2011 JDK7, lasted as long as 5 years, during the period experienced many big and small events. So first of all, let's review the ups and downs of JDK7 development history.

January 2009, Sun began to develop JDK7 Milestone 1.

At the Devoxx 2009 conference in November 2009, Sun announced the inclusion of closure features in JDK7 and postponed the release date of JDK7 to the end of 2010.

Oracle acquires Sun in April 2010.

In September 2010, Mark Reinhold announced at the JavaOne convention that JDK7 would chop off the new features of the LAMBDA, Jigsaw and Coin, and release it in 2011, with the remainder of the new features being released with JDK8 at the end of 2012.

In October 2010, IBM announced that it would join OpenJDK to develop the JDK together with Oracle. Since then, Apple and SAP have joined the OpenJDK community.

July 28, 2011, Oracle officially released JDK7, and designated OpenJDK7 as a reference implementation.

September 19, 2011, IBM officially released IBM JDK7.

After a series of events such as the postponement of the release, Sun being acquired, the deletion of new features, and the postponement of the release, JDK7 finally came to the front of everyone, so what are the important new features of JDK7? This series of articles will be presented to the reader individually.

JSR292: Support for dynamic type language (invokedynamic)

Figure 1. Project icon--a helicopter designed by Leonardo da Vinci

The emergence of more and more dynamic languages based on JVMs in recent years has brought new requirements and challenges to the JVM. In fact, the scripting language on the Jsr223:java platform is already supported in JDK6, and scripting languages such as JavaScript are executed on the JVM via a scripting language engine. However, since the design of the JVM itself was originally intended for the static type language of Java, the scripting language, whether it was an interpretation execution, a virtual type at compile time, or the use of a reflection mechanism, would have a significant impact on the efficiency of execution.

The implementation of JSR292 adds a invokedynamic byte code instruction to support the dynamic type language, which makes it unnecessary to determine the signature of the method when compiling the source code into bytecode, that is, the type of the method parameter and the return type. When the runtime executes the invokedynamic instruction, the JVM uses the new dynamic link mechanism method Handles to find the real way.

With invokedynamic, the execution speed of the dynamic type language on the JVM has been greatly improved, and the detailed implementation details and examples will be described in detail in future series articles.

G1 garbage collector (Garbage-first Collector)

The G1 garbage collector is a server-side garbage collector that targets large memory multi-core CPUs and aims to reduce the number of pauses that the full GC brings, and increase throughput. In the long run, G1 will replace Concurrent mark-sweep Collector (CMS). Implementation, G1 allocates a series of contiguous regions of the same size on the heap, and then scans all the regions at the time of the recovery, sorting according to the size of the surviving objects in each area, prioritizing the small area of the surviving object, the area with the most garbage objects, which is the origin of the name Garbage first. G1 merges the surviving objects in the area to be collected and replicates them to other areas, thus avoiding the memory fragmentation problems encountered by the CMS. In addition, G1 uses a predictable pause time model to achieve soft real-time requirements.

JSR334: Small language improvements (Project Coin)

The Coin project offers a range of language improvements that provide more convenience to Java developers. This includes switch statements that support String, automatic shutdown of resources after a try (try-with-resources), simpler generics, a number that can be segmented with underscores, and improvements to multiple catch, and so on.

Core Class Library Improvement

ClassLoader New API

The Java.lang.ClassLoader class adds the following APIs to prevent deadlock problems resulting from custom multithreaded classload.

Protected Object Getclassloadinglock (String className)
Protected static Boolean registerasparallelcapable ()

Please refer to JDK7 's official documentation for more information.

URLClassLoader New API

URLClassLoader the new Close method closes the resource that the class loader opens.

Improvement of Concurrent Package

The Java.util.concurrent package introduces a lightweight, fork/join framework to support multiple-core multithreaded concurrency calculations. In addition, it implements the Phaser class, which resembles Cyclicbarrier and Countdownlatch but is more flexible. Finally, the Threadlocalrandom class provides a thread-safe pseudo random number generator.

Internationalization (i18n)

Supports Unicode 6.0. Improved Java.util.Locale to support IETF BCP 47 and UTR 35, and Get/set Locale into the Locale for display and Locale for formatting.

I/O and network

More new NIO 2 APIs for the Java platform (JSR 203)

The NIO2 mainly includes 3 improvements:

The new file system API supports access to a large number of file properties, file system monitoring services, platform-related APIs such as Dosfileattributes and Posixfileattributes, and an SPI for pluggable file systems.

Asynchronous IO for sockets and files.

Socket Channel function is perfect, support binding, multicast and so on.

Support for Zip/jar Filesystemprovider implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.