The most expected features of Java 9

July 20, 20160

article_java9

  Three years after Oracle published Java 8, the next major update of the JDK is coming in March 2017. Originally planning for September 2016, the target date for Java 9 general availability is rescheduled due to some delays in Project Jigsaw, which is one of the most exciting features.

  Here are the most exciting features that the community has been requesting for many years and that are expected to be released:

  Jshell – In Java, you normally can’t run a single statement or a collection of statements without using third-party tools. Usually, you run a main class or a collection of classes. Typical Java development means writing a complete program, then compiling it, fixing the possible errors, then running it, figuring out what is wrong, editing, and repeating. With the Java REPL (Read-Eval-Print-Loop), you can enter program elements one at a time, immediately seeing the result and adjusting accordingly. The SDK will come with an official REPL named JShell and codenamed Kulla.

  After installing and configuring the necessary stuff for jshell (you can follow this tutorial) you can try to execute something:

% java -jar kulla.jar 
|  Welcome to the Java REPL -- Version 0.411
|  Type /help for help 
-> System.out.println("Hi"); // User input
Hi                           // Output
-> 

  When you declare a variable, you will get a descriptive information about it:

-> 
int abc = 111
| Added variable abc of type int with initial value 111 

  The result of any expression is stored into a temporary variable that can be referenced later:

-> 
1 + 9
| Expression value is: 10
| assigned to temporary variable $1 of type int

  Note that the semicolons will be added automatically if missing.

  There are very many commands for settings and to display information like /vars – to see all the variables, /methods – to see all the methods or /classes – I think you’ve figured out for what it is intended for. To see all available commands just type /help.

  Lightweight JSON API would be delivered in Java 9 SDK through the java.util package. The JSON effort aims to enable Java developers to parse and generate JSON data without external libraries like Jackson. It will also support the navigation over JSON tree like in DOM or SAX for XML and JSON tree transformation.

  Process API updates is aimed at making it easier and a platform independent task to efficiently communicate with the operating system. This new API provides features such as:
– getting the PID of the current JVM process or processes created by it;


– getting and setting the name of the JVM process or processes created by it;


– enumerating JVMs processes and processes on system;


– working with the process tree (for example, destroying the process tree);


– working with hundreds of subprocesses, (for example, one output stream and error stream for many processes, not one thread per subprocess).

  Smart Java Compilation, Phase 2 is intended to improve the Java programming language compiler tool (sjavac) enabling it to be used by default in the JDK build, providing a higher speed of the build because this compiler would take advantage of all the cores in the system. Also it will be able to execute incremental and parallel compilation.

  Project Jigsaw is the most highly anticipated change to Java 9, its goal is to make Java modular and break the JRE up into interoperable components. In previous JDK like 8 or 7, many of the classes (about 20,00) were included in runtime, whether they were required in the project or not. The motivation behind this is to make Java easily scalable to small computing devices, to improve security and performance, and mainly, to make it easier for developers to construct and maintain libraries. This will define the JDK into modules and will decide which modules should be included by defining module boundaries at runtime.

  HTTP 2 Client promises to improve Web page load time and API capabilities. “One major goal is to allow the use of a single connection from browsers to a website.” JEP 110 will define and implement a new HTTP client for Java that will replace HttpURLConnection and will also implement HTTP 2.0 and web sockets.

  Segmented Code Cache aims to divide code cache into segments (heaps) to improve performance and facilitate extensions. Each segment contains a particular type of compiled code that has a life and this is defined by how frequently certain areas of codes are executed. There are 3 kinds of segments:

short duration cache – profiled code, specific to a certain set of conditions;


long duration – a code will stay there for much longer;


infinitely long duration – code that will stay in cache forever (JVM internal code such as compiler buffers and bytecode interpreter).

  Improve contended locking – to increase performance between threads.

  Ahead-of-time compilation – Java 9 proposes to fix the relatively slower startup times by enabling ahead-of-time compilation, among other benefits.

  Money and Currency API – a new and official API to represent, transport and perform comprehensive calculations with Money and Currency.

// getting CurrencyUnits by currency code
CurrencyUnit euro = MonetaryCurrencies.getCurrency("EUR");

// getting CurrencyUnits by locale
CurrencyUnit usd = Monetary.getCurrency(Locale.US);

// getting MonetaryAmount from currency code
MonetaryAmount tenUsDollar = Money.of(10, "USD");

  Collections factories – provide static factory methods on the collection interfaces that will create compact, unmodifiable collection instances:

Set<String> set = Set.of("a", "b", "c");

List<Integer> list = List.of( 1, 2, 3);

Map<String,String> map = Map.of("a", "b", "c", "d");

Map<String,String> map = Map.ofEntries( Map.entry("a", "b"), Map.entry("c", "d"), Map.entry("f", "g"), Map.entry("h", "i");

  Unified JVM Logging introduce a common logging system for all components of the JVM in order to easily find the root cause of intermittent crashes or performance quirks in a production environment.

java9_2

Leave a Reply

Your email address will not be published.

https://isd-soft.com/wp-content/uploads/2022/08/whitelogo150.png
Connect with us
Bulgara Street 33/1, Chisinau MD-2001, Moldova
+ 373 22 996 170
info@isd-soft.com
De Amfoor 15, 5807 GW Venray-Oostrum, The Netherlands
+ 31 478 502944

Subscribe to our newsletter today to receive updates on the latest news, releases and special offers.

Copyright ©2022, ISD. All rights reserved | Cookies Policy | Privacy Policy