The first important update of Java SE after December

Source: Internet
Author: User

 

Java 7 was available for download in July 28, the first release of the Java platform after Oracle acquired Sun. This version contains several language changes, although small but popular, as well as new file APIs and the Fork/Join framework, and improves JVM dynamic language support.

Java 7 was previously part of Project Coin (JSR 334) and is the successor of JSR 201, enhancing the Java language through small changes that can improve productivity. It is particularly worth mentioning that "try-with-resources" is introduced, which is similar to the using statement in C #, but is based on the try statement form. The using statement can only process a single resource, while try-with-resources can process multiple resources in one block.

There are two changes to exception handling. First, a catch block can handle multiple exceptions of the specified type. Java 7 extends the catch clause Syntax of try to accept a series of exception types. Separate them with the "or" Operator ("|") When declaring exception parameters. Second, if the exception parameter is not modified and is thrown out again in the catch block, you do not need to add the exception to the method signature: the description here is not accurate. In fact, if the exception is thrown again in the catch Block, there will be more detailed type checks. For details, see the official documentation ).

Other language changes include:

1. The switch statement supports strings.

2. To enhance readability, a binary representation and underline separator are added for the number-for example, long creditCardNumber = 1234_5678_9012_3456L.

3. The Varargs method is simplified: the compiler warning is adjusted. In the past, warnings were issued when the Varargs and non-specific array methods were combined, the warning is now moved from the caller to the method declaration.

4. Improved type inference for generic instance creation (<> or diamond): When a class object is created, a finite type inference is used. Although the parameter type needs to be explicitly declared, however, you can determine them from the context so that you can directly use the empty type parameter set. I used to write this statement:

  

You can write this statement as follows:

 

Two major new APIs are introduced. The first is JSR 203, which adds new APIs for file system access, scalable asynchronous I/O operations, multicast data packets, Socket channel binding and configuration. Enterprise developers are particularly interested in adding real asynchronous I/O APIs, which is especially important for high-end server applications that require low latency and high throughput across multiple connections. JSR 203 also adds a real file system API for Java, providing support for certain OS-specific functions. For example, you can create a symbolic link in a system that supports symbolic links. However, this feature is controversial. Although JSR 203 provides general APIs that can run on all platforms and support specific platform features, however, it is not strictly "A single write runs everywhere ".

 

The second new API is the Fork/Join framework (part of JSR 166), which was originally planned to be placed in Java 5. It provides developers with a mechanism to split the problem into multiple tasks and execute them in parallel on any number of processor cores.

In addition, the platform has new network and security features, and supports Unicode 6.0 for international expansion.

Finally, Java SE 7 uses the InvokeDynamic keyword to mark the first new bytecode instruction after the birth of Java. InvokeDynamic adds a new call mode and connection mode, which can be customized by programming. Especially in method calls without static type information, it supports efficient and flexible method execution, which greatly improves the performance of dynamic languages, such as JRuby and Jython running on JVM.

New features are welcomed, but the most important thing is that the new version has finally been released. The long-standing differences between Sun and Apache Software Foundation, as well as the leadership and resource issues in Sun's last days, are all the reasons for the long interval between the two versions. As Mark Reinhold said in a recent interview:

For commercial and political reasons, Java has entered a short-term sleep state. But now we are back and we are about to release Java 7. This is not a revolutionary version, but an evolutionary version with some good content.

Developers interested in how to get started with Java SE 7 may wish to use NetBeans IDE 7.0 or IntelliJ IDEA 10.5, which all support the latest features of the Java SE 7 platform. Eclipse Indigo also supports beta-level Java 7. Oracle JDeveloper is expected to have a version that supports JDK 7 in the second half of this year.

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.