News on Java9 has been a bit muted lately, so don’t be fooled by it. JDK developers are working hard on the next release and plan to complete all features by December 2015. It will then undergo rigorous testing and bug fixes in preparation for its full launch, which is scheduled for September 2016.

Today we have a pretty clear picture of what to expect in Java 9. If Java 8 can be described primarily as lambdas, Streams, and API changes, then Java 9 is all about Jigsaw, additional utilities, and internal changes. In this article, we’ve collected what we think are the most anticipated features of Java 9 — the Jigsaw project, beyond the usual speculation, has taken on a mission to break the JRE and modularize Java’s core components.

Here are some features that are absolutely essential to know in Java 9, and some of them are already ready for you to tinker with in early releases.

1.Java + REPL = jshell

Yes. We were skeptical that the Kulla project would be released in time for Java 9, but now it’s officially confirmed. The next release of Java will have a new command-line tool called JShell that will add native support and java-style promotion of the REPL (interactive interpreter). This means that if you want to run only a few lines of Java code, you don’t have to wrap it in a single project or method.

Oh, you can forget the semicolons:

- > 2 + 2 | | the value of the expression is 4 will be temporarily set the type of the variable $1 to int

There are also alternatives like REPL add-ins that are added to popular ides and solutions, such as the Java REPL Web console. But so far, there is no official or proper way to do so. Jshell is available in early versions, waiting for you to give it a test run.

2. Microbenchmarks are coming

The Java Microbenchmarking Harness, developed by Alexey Shipilev, is in the next phase of its evolution and has added Java as the official benchmarking solution. We really like benchmarking in Takipi, so a standardized implementation is what we are looking forward to.

JHM is a suite for compiling, running, and analyzing Nano/Micro/Milli/Macro benchmarks. When it comes to accurate benchmarking, the ability to have a big impact on results, such as warm-up time and optimization, will be of great concern. This is especially true if you are timing in microseconds or nanoseconds. So, if you want more precise results to help track benchmarks and make the right decisions, JMH is your best bet — and it’s now synonymous with Java 9.

Will G1 be the new default garbage collector?

A common misconception we hear is that Java has only one garbage collector when in fact it has four. In Java 9, there is still a running proposal to replace the G1 default garbage collector (parallel/throughput collection) introduced by Java 7. For a brief overview of the differences between different collectors, see this article.

In general, G1 is designed to better support heaps larger than 4GB and does not cause frequent GC pauses, but tends to process longer when pauses occur. We recently talked with Outbrain’s performance expert Haim Yadid about all aspects of GC to help you understand more about the different trade-offs between collectors. Also, if you want to dive into the discussion, the hotspot-dev and jdk9-dev mailing groups are a good place to start.

The future is HTTP 2.0

The official HTTP 2.0 standard was approved a few months ago and is based on Google’s SPDY algorithm. SPDY has shown significant speed improvements over HTTP 1.1, ranging from 11.81% to 47.7%, and it already exists in most modern browsers. Java 9 will fully support HTTP 2.0, with a new HTTP client for Java to replace HttpURLConnection, as well as HTTP 2.0 and WebSockets.

5. Process apis got a big boost

Until now, the ability to control and manage operating system processes through Java has been limited. In earlier versions of Java, for example, to do simple things like get a process PID, either access native code or use some magical AD hoc solution. In addition, you may need a different implementation for each platform to ensure you get the right results.

In Java 9, except for the code to get Linux PID, it is now done like this:

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); }}

Switch to code like this (which also supports all operating systems) :

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

This update will extend Java’s ability to interact with the operating system: new ways to manipulate Pids, process names, and state directly, the ability to manipulate JVM threads and processes, and more.

What won’t you see in Java 9?

We thought two interesting features would be part of the upcoming Java release — but now we know they won’t be in this release.

1. A standard lightweight JSON API

In a survey of 350 developers we conducted, the JSON API was touted as much as Jigsaw, but it didn’t seem to be in the release, possibly due to funding issues. Mark Reinhold, lead architect for the Java platform, wrote in the JDK 9 mailing list:

“The JEP is a nice addition to the platform, but in the long run it’s not as important as other features given the funding and other features that Oracle funds. We’re considering releasing the JEP in JDK 10 or later.”

2. Money and currency apis

In news, it looks like the Money and currency API is also missing Oracle support. Here’s the answer we got from Anatole Tresch, the API’s product promoter:

@tkfxin Not at the moment. No support from Oracle. Instead, we will improve Java EE support and spring will support it 🙂

— Anatole Tresch (@Atsticks) June 16, 2015

Are we missing something? Let us know in the comment section below. No free time? Take a look at when and why code fails interrupts in production.

Original link:
takipiTranslation:
ImportNew.com –
eluq


Translation link:
www.importnew.com/16280.html


[
Please keep the source, translator and translation link for reprinting.]