5 new JAVA9 features for changing software development

Source: Internet
Author: User
Tags benchmark http 2

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:

1

2

3-> 2 + 2

| The value of the expression is 4

| Set the temporary variable to the type 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:

1

2

3

4

5

6

7

8

9

10

11publicstaticvoidmain (string[] args) throwsexception {

Process proc = Runtime.getruntime (). EXEC (newstring[]{"/bin/sh", "-C", "Echo $PPID"});

if (Proc.waitfor () ==0) {

InputStream in = Proc.getinputstream ();

intavailable = In.available ();

Byte[] Outputbytes =newbyte[available];

In.read (outputbytes);

String pid =newstring (outputbytes);

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

}

}

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

1system.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.

Http://mt.sohu.com/20160906/n467734021.shtml

Http://mt.sohu.com/20160906/n467725557.shtml

Http://mt.sohu.com/20160906/n467729919.shtml

5 new JAVA9 features for changing 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.