JAVA9 new Features

Source: Internet
Author: User
Tags stack trace java se

Reprint: http://blog.csdn.net/qq_32524177/article/details/77014757

Written in front of the words: Java9 came, search a lot of new features about JAVA9, but the literature is not much, special translation of this general relatively strong official articles for reference, my English proficiency is limited, although strive to each word accurate, but there will be some deviations, please haihan correct,, detailed update content please click the hyperlink.

What are some of the exciting new features that people are looking for in java9?

Do not pay attention to it because of the relative calm before java9 release! The core code submitter of the JDK is working hard to prepare for the release of the next release, which is expected to be widely used in September 2017.

Early access to project building (access builds) has been ubiquitous, and now we are using the "JAVA9 Countdown network" to get this version countdown.

    Now we can get a pretty clear picture of the new features that we can expect to appear in java9. If JAVA8 can be described primarily as a release version of lambda expressions, data streams, and API changes, JAVA9 is primarily jigsaw (the Primary goals of this Project is to:make the Java SE Platform, and the JDK, more easily scalable down to small computing Devices;improve the security and maintainability of Java SE Platform implementations in general, and the JDK in particular ; Enable improved application performance; and make it easier for developers to construct and maintain libraries and large applications, for both the Java SE and EE Platforms.to achieve these goals we propose to design and implement a standard module system for the Java SE Platform and To apply this system to the Platform itself, and to the Jdk. the module system should is powerful enough to Modulariz E The JDK and other large legacy code bases, yet still is approachable by all developers.), Jshell (we don't have to write the main method when we run simple code) and A range of advanced options and API updates. In this release we collected some of the most exciting features we thought would be Java9-in addition to the most common conjecture, the jigsaw project carries a split Java runtime environment and makes the core components of Java more modular.
Here are some of the features that you must know about JAVA9, some of which have already been released in the early stages to make you feel free to fix them.

1.java+repl=jshell (Ps:r (read), E (Evaluate), P (print), L (loop) as the name implies: Read, compute, print, loop-interactive interpreter environment)

Yes, we were still skeptical of Kulla (the purpose of this project is to investigate whether the product of the REPL tool in the Java programming language is as described in the Java optimization proposal) and whether the project can be completed in time for Java9 tasks (Jshell service for JAVA9) but now
It has received official approval. The next version of Java will focus on a command-line tool called Jshell, which allows Java to REPL native support and be more popularized. This means, for example, if you want to run some Java code in just a few lines,
You no longer have to package them as separate projects or methods. Oh, yes, there are semicolons, you can forget them:
2 + 2
| Expression value Is:4
| Assigned to temporary variable $ A type int
There are a lot of alternative options for REPL, such as the REPL plugin for some popular development tools or a solution like the Java REPL Web console, but so far there is no right and official way to handle it. Jshell is already available in a previously released version, and it is waiting for you to give him a test run.
2. Notable API updates: concurrency and Stack traversal
As part of this update, we hope to have an additional, broad range of features after this update is released.
The most important thing we want to mention here is that the JAVA9 concurrency API is based on Completablefuture (1.8 later interface, inherited from Java.util.concurrent.Future, no use, The idea is that when you don't need or want to get the results of a calculation right away, we use the future object to "placeholder" for the completion of the calculation, and the Java.util.concurrent.Flow class updates. Flow is the implementation of the responsive streaming API, and we are very happy that it came to Java. The response flow solves the pain of back pressure (in Rxjava, it is often the case that the observer sends the message too fast that its operator or subscriber cannot process the relevant message in time.) Then there is the way to deal with these unhandled messages. When the incoming task rate is higher than the processing power of the application itself to process the data, the data is built in, which produces a buffer for the unhandled data. As part of the concurrent update, the Completablefuture class is also updated, and this update resolves the complaints that have been made since JAVA8 introduced them. This update includes support for latency and timeouts, better support for subclasses, and added practical methods.
The second thing we want to mention here is the Stack traversal API. Yes, JAVA9 will change the way you traverse the stack trace (StackTrace). Fundamentally, this is a way for the Java official to handle stack traces, rather than just treating them as plain text. It sounds a bit like a vague "Star Wars" project reference, let's put it down.
3.G1 will become the new default GC
Java has only one garbage collector, which is the most common misconception that we often hear, but in fact it has 4 of them. Before J9, the default garbage collector was ' parallel/throughput Collector ', but now it's replaced by the G1 we introduced in Java7.
To learn about some of the differences between these GCs, please click here.
In general, G1 is designed to better support more than 4GB of heap memory and is known to reduce frequent GC pauses, but when there is a GC pause, the pause takes longer than before. At the same time we discussed everything about GC with the subjective Haim Yadid of next insurance, hoping to help you learn more about how to weigh the different GC.

4.http2.0 is the future development trend

The official HTTP2.0 request annotation based on the Google Spdy (Application layer protocol) algorithm was recently approved. Spdy has shown a greater speed boost compared to HTTP1.1, with a lift rate between 11.81% and 47.7%, and it has been implemented in most modern browsers.
J9 will fully support HTTP2.0 and form a new HTTP client for Java, which overrides HttpURLConnection for both HTTP2.0 and web sockets. Another cool thing about this API is that it will be used as a ' The first incubator module ' introduced to the public.
The incubator module is actually an experimental feature, and perhaps it will evolve to be used by the next version of Java, which means that Java10 may be removed. This is an unusual Java concept that promotes experimentation without disrupting backwards compatibility.

5. The Process Class API has been greatly advanced (class of processes, abstract classes, which provide methods to execute from process input, execute output to process, wait for process completion, check process exit status, and destroy (kill) processes)

To date, Java has limitations in its ability to control and manage operating system processes. For a chestnut, in earlier versions of Java in order to do something as simple as getting the PID of your process, you might need to access the local code or use some unusual way. In addition, it requires different implementations for different platforms to ensure that the results you get are correct.
In JAVA9, the expected code to get the Linux process ID looks like this:

[Java] View plainCopy
  1. public static void Main (string[] args) throws Exception {
  2. Process proc = Runtime.getruntime (). EXEC (new string[] {
  3. "/bin/sh",
  4. "-C",
  5. "Echo $PPID"
  6. });
  7. if (proc.waitfor () = = 0) {
  8. InputStream in = Proc.getinputstream ();
  9. int available = in.available ();
  10. byte[] outputbytes = new byte[available];
  11. In.read (outputbytes);
  12. String pid = new string (outputbytes);
  13. System.out.println ("Your pid is" + pid);
  14. }
  15. }



Now it becomes like this (this applies to all operating systems):

[Java] View plainCopy
    1. System.out.println ("Your pid is" + process.getcurrentpid ());


This update will extend Java's capabilities to interacting with the operating system:
Added methods for directly handling PIDs, process names and states, and the ability to enumerate JVMs and processes, among other things. This may not be particularly exciting for some people, but it may be widely used by us on overops, so
That's why we consider highlighting it in other features.

6. Product Commissioning

In addition to the JAVA9 itself, we think this conference is a chance to share some of the new progress we have made. Fixing bugs in the product has always been a hassle, looking for clues in a huge log file, and trying to identify each exception or error that caused the error state.
But what if you could completely avoid the log file? Here's how it's done.
Many Java developers who know about it have a lot of questions to ask about this tool, so we've created 1-to-1 sample tables to see and make a private work plan!
In addition, Java also removed some APIs, time is limited do not do translation and enumeration, please click to view.

JAVA9 new Features

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.