5 new JAVA9 features that are about to change software development

Source: Internet
Author: User

What are the most exciting features of the expected release of Java 9?

The news about Java9 seems a bit quiet lately, don't be fooled by it. The JDK developer is working towards the next release and is planning to complete all feature development before December 2015. After that, it undergoes rigorous testing and bug fixes to prepare for its full listing, which is scheduled to be released in September 2016.

Today we have a very clear picture of the features we expect in Java 9. Java 9 is about jigsaw, additional utilities, and internal changes if Java 8 can be described primarily as lambdas expressions, streams, and API changes. In this article, we have collected some of the features we consider to be the most anticipated in Java 9-in addition to the usual guesswork, the jigsaw project assumes the mission of breaking the JRE and modularity of the Java core components.

Here are some of the features that are absolutely necessary to understand in Java 9, some of which have been prepared for you in the early release version.

1.Java + REPL = Jshell

Yes. Before we doubted if the Kulla project would be released on time in Java 9, it has now been officially confirmed. The next release of Java will have a new command-line tool called Jshell, which will add local support and Java REPL (Interactive interpreter) to promote. This means that if you want to run only a few lines of Java code, you don't have to wrap it in a separate project or method.

Oh, you can forget the semicolons:

123 -> 2 + 2| 表达式的值是4| 将临时变量$1的类型设为int

There are also alternatives like REPL add-ons that are added to popular Ides and solutions, like the Java REPL Web Console. But so far, there is no official or appropriate way to do so. Jshell is ready for use in earlier versions and is waiting for you to test it for a run.

2, the micro-benchmark test to come

Java microbenchmarking Harness, developed by Alexey Shipilev, is in the next phase of its evolution and joins Java as the official benchmark solution. We really like to benchmark in Takipi, so a standardized way of doing it is what we're looking for.

JHM is a set of packages used to compile, run, and analyze Nano/micro/milli/macro benchmarks. When it comes to accurate benchmarking, the ability to have a significant impact on results will be of interest, such as warm-up time and optimization. This is especially true when you are clocking in microseconds or nanoseconds. So, if you want more accurate results to help track benchmarks to make the right decisions, JMH is your best choice-and now it's a synonym for Java 9.

3. Will G1 become the new default garbage collector?

One misconception we often hear is that Java has only one garbage collector, and there are actually 4 of them. In Java 9, there is still a running proposal to replace the discussion of the G1 default garbage collector (parallel/throughput collection) introduced by Java 7. A summary of the differences between different collectors can be seen in this article.

Typically, G1 is designed to better support heaps larger than 4GB, and does not cause frequent GC pauses, but often takes longer to process when a pause occurs. Recently we have discussed all aspects of GC with Outbrain's performance expert Haim Yadid to help you learn more about the different tradeoffs between collectors. Similarly, if you want to learn more about the discussion, the Hotspot-dev and Jdk9-dev mailing groups are a great place to start learning.

4, the future is HTTP 2.0

The official HTTP 2.0 standard was approved a few months ago, built on Google's spdy algorithm. Spdy has shown a huge speed boost relative to HTTP 1.1, ranging from 11.81% to 47.7%, and it already exists in most modern browsers. Java 9 will have full support for HTTP 2.0 and a new HTTP client for Java to replace HttpURLConnection, with HTTP 2.0 and WebSockets implemented as well.

5, the process API has been greatly promoted

So far, the ability to control and manage operating system processes through Java is limited. In earlier versions of Java, for example, to do something simple, like getting a process PID, or accessing native code, or using some magical temporary workaround. In addition, there may be a need for a different implementation for each platform to ensure you get the right results.

In Java 9, in addition to the code that acquires the Linux PID, it is now available like this:

1234567891011 public static void main(String[] args) throws Exception {    Process proc = Runtime.getRuntime().exec(new String[]{ "/bin/sh", "-c", "echo $PPID" });    if (proc.waitFor() == 0) {        InputStream in = proc.getInputStream();        int available = in.available();        byte[] outputBytes = new byte[available];        in.read(outputBytes);        String pid = new String(outputBytes);        System.out.println("Your pid is " + pid);    }}

Turn to code like this (also supported for all operating systems):

1 System.out.println("Your pid is"+ Process.getCurrentPid());

This update will extend the ability of Java to interact with the operating system: a new way of directly manipulating PID, process name and state, manipulating JVM threads and processes, and so on.

What do you not see in Java 9?

We thought two interesting features would be part of the upcoming Java release-but now we know they will not appear in this release.

1. A standard lightweight JSON API

In a survey of 350 developers we conducted, the JSON API was hyped like Jigsaw, but it didn't seem to be in the release version, possibly because of a funding problem. The lead architect of the Mark Reinhold,java platform , written in the mailing list for JDK 9:

"This Jep is a useful addition to the platform, but in the long run it is not as important as other features, given the funding factors and other features Oracle has financed." We consider the possibility of releasing this Jep in JDK 10 or later. ”

2. Money and Currency API

There is a piece of news that seems to look like the money and currency API also lacks Oracle support. This is the answer we get from Anatole Tresch, the product promoter for this API:

@tkfxin not at the moment. There is no support from Oracle. Instead, we will improve Java EE support and Spring will support it:)

–anatole Tresch (@atsticks) June 16, 2015

Have we missed anything? Please let us know in the comments section below. No free time? To see when and why the code in the product fails to break.

5 new JAVA9 features that are about to change software development

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.