Back to Home

JAVA 9. What's new? / OTUS Blog. Online education

java 9 · programming · features

JAVA 9. What's new?

    Java is an amazingly versatile programming language. Today, there are about 6.5 million Java developers around the world. And all thanks to its utility, ease of use, security and platform independence (it works regardless of what equipment or operating system is used).

    Java was developed in 1995 by Sun Microsystems and was originally designed for interactive television and consumer electronics programming. However, the public release of Java 1.0 revealed a shift in focus to Internet usage, turning it into one of the most popular programming languages.

    Obviously, a lot has changed since 1.0, and finally, after many transfers, September 21, 2017, Java 9 was released.

    The features of the previous (8th) version, due to its versatility, provided developers with the opportunity to create solutions for a wide variety of business sectors, including fintech, healthcare and other industries. Among the key innovations of Java 8, lambda expressions, streams and changes to the API should be noted.

    In turn, Java 9 also abounds with a variety of updates “under the hood” and in the API. In addition to the obvious Jigsaw project, which is responsible for introducing modularity into the main components of Java, the new version boasts three more important features:

    1. Full HTTP 2.0 client support: The issue is speed, and HTTP 2.0 provides better results, ranging from 11.81% to 47.7% compared to the HTTP 1.1 client.
    2. Jshell: New command line tool. If a developer wants to run several Java lines autonomously, then this can be done without having to wrap everything in a separate method or project.
    3. Microbenchmark: Now the performance of individual small pieces of code can be measured in a standardized way. Nanosecond JMH analysis is unique to Java 9.



    We recommend that you read the full list on the Java community portal , as well as freely download the distribution kit for review.

    Further, we will take a closer look at several features that were not available in Java 8.

    HTTP / 2 client

    This is probably the most expected innovation - an HTTP client with support for both the HTTP / 2 protocol and WebSocket. After all, the SPDY protocol from Google, on the basis of which HTTP / 2 is based, already demonstrates improved performance along with Netty or Jetty, support for non-blocking mode (many threads per request / response), and also Push-server support, which allows sending resources to the client without an explicit request.

    The new API is presented as the first incubator module for Java - an experimental feature that, if properly developed, will officially appear in the next version (i.e. Java 10), or will be removed. Unusual concept for Java, which encourages experimentation, but does not violate backward compatibility.

    Jigsaw

    Project The Jigsaw project (translated as “puzzle”) aims to modularize Java. This means that the program code is divided into parts and organized into modules depending on the tasks that these modules perform. This allows you to reuse modules, simplifies their organization and debugging. Which leads to optimized and streamlined software development. This is the key difference between Java 9 and Java 8.

    The second big advantage is that the Java Platform is becoming lighter and more scalable. This allows Java applications to run even on low-performance devices (since less resources are required to run). This is a big change, especially in the context of the Internet of Things (IoT). A step forward for Java, and the chance to see more IoT applications written in this language.

    Jshell

    Jshell will add built-in support and popularize Java's approach to REPL (Read-Eval-Print-Loop). This is an interactive tool that lets you test small pieces of code without having to create new classes. It is equipped with history and autocomplete functions, as well as a number of other features, including saving and loading written expressions.
    Say, if you want to run several Java lines yourself, now you don’t have to wrap them in a separate project or method. As for semicolons, you can forget about them: There are various alternatives like REPL plugins for the popular IDE or Java REPL web console, but none of them are official.

    Unified JVM Logging

    A single logging system for all JVM components has been added. However, if we look at the pros and cons of Java 9, here is one of them. There are no logging calls for individual JVM components, as well as logging Java code in the Java Development Kit

    G1 - the default garbage collector

    Very often we are confronted with the misconception that in Java there is only one garbage collector, although in fact there are 4. Parallel / Throughput Collector was considered default in previous versions, but now it has been replaced by G1, which was introduced in Java 7 and was designed to better support heaps larger than 4GB. It causes fewer GC pauses, but if they do occur, then they last longer.

    Multi-resolution Images

    This API allows you to encapsulate a set of images with different resolutions into a single object. Thus, the developer can get an image with a certain resolution or all the options inside one.

    Notable API Updates: Concurrency and Stack Walking

    Java 9 received an update to CompletableFuture and java.util.concurrent.Flow. Flow is a Java implementation of the Reactive Streams API. Reactive Streams help solve the back-pressure problem - the accumulation of a large amount of data, which occurs when the speed of receiving incoming events is higher than the speed of their processing by the application, which leads to the appearance of raw data buffers. In addition, as part of the concurrency improvement, CompletableFuture received an update that resolved issues identified after its implementation in Java 8. It includes delay and timeout support, improved subclass support, and several useful methods.

    I also want to mention the Stack Walking API. That's right, Java 9 is changing the approach to working with stack traces, providing an official way to handle stack traces, instead of equating them with plain text.

    Immutable List, Set, Map, and Map.Entry API

    Creating multiple-element sets in Java 8 required a few lines of code. Now this can be done only by one. Thus, one of the most time-consuming drawbacks of Java 8 has been eliminated. This should make working with arrays easier and speed up some functions.

    Advantages of Java 9

    Details of the differences between Java 9 and Java 8 are of great interest to developers, and therefore to the business, which is in search of the best solutions. The innovations of the ninth version improve the following development aspects:

    • Faster with HTTP / 2 client support.
    • Applications become resource efficient because developers can use only the necessary modules, not the entire JRE.
    • Development is accelerated by a system of modules that allows their reuse, simplified debugging and management.
    • The ability to analyze the performance of very small parts of the code thanks to Microbenchmarks.
    • Many are created with one line of code.

    THE END

    Here is a squeeze of all the interesting changes that we noted after the release of the new version. True, now the main question is when will companies begin to implement it, given that there are those who still do not use the eighth version. As a result, so far they decided not to change the program of the course (apart from small cosmetics) and leave everything as it is, and next year to think about this.

    Read Next