9 Big Things about Java 9

September 15, 2017

According to the latest Tiobe index of programming language popularity, Java tops the list.  No wonder there is so much buzz around the new Java 9 release, set for September 21, 2017.  Take a walk through with our expert.

Many compiled languages include tools for statements interpretation. By using these REPL tools you can rapidly test code snippets without creating a project.

Take Scala, as an example. Compilation can be time consuming, but by using REPL, each statement is executed instantly! That’s great when you are getting started with the language. Each expression returns a value and type, which is valuable information to have.

On the other hand, in Java, we would need to create a test or main method that prints results and must be recompiled every time someone makes a change.


The added static factory methods help create collections in variety of small cases.

This come to life due to static interface methods. Thus collections are immutable.


Java 9 provides new and improved strings which, in most cases, will reduce String memory consumption by half.

Instead of having a char[] array, String is now represented as a byte[] array. Depending on which characters it contains, it will use either UTF-16 or Latin-1 to produce either one or two bytes per character.

There is a also new field inside the String class–coder that indicates which variant is used. Unlike Compressed Strings, this feature is enabled by default. If necessary, as in a case where mainly UTF-16 Strings are used, it can be disabled by  -XX:-CompactStrings.


At last, Java9 adds an or() method to Optional API, which allows for the return of different chained optionals without calling isPresent() each time.

In addition, Java9 can create Stream out of Optional with no more than 1 element inside, which is a real advantage when «lazy» mapping is needed.

And, as the cherry on the cake, Java9 will have an ifPresentOrElse() method in Optional API.


This class was polished and several methods were added, but most notable is copy(). This method returns immutable copy for CompletableFuture.

But the coolest thing is that stopping an ancestor will affect the child!

Timeouts were also added to the API. Now it is possible to define how CF should finish after time runs out.


With the excellent additions of dropWhile() and takeWhile() to Stream API, there is now option to skip loop and use the stream iterate() method instead.


When starting Java9, there is now a straight and simple access to process handling.8. JAVA LANGUAGE ENHANCEMENT

Just in case if someone still uses it, «_» is no longer a legitimate identifier. In this case you should use « __» instead (but you don’t 😉 )

Private methods inside Interfaces.

Now with Java9 we are able to use final variables inside try-with-resources effectively.


We can now use stack-trace without creating an Exception instance.  We consider this a big improvement.

Starting Java9 G1 will be our default GC. The “Garbage-first” garbage collector, aka G1, is a concurrent multi-threaded GC. It mostly works alongside the application threads much like the concurrent mark sweep GC, and is designed to offer shorter, more predictable pause times while still achieving high throughput. What makes G1 different is that instead of splitting the heap into 3 big regions, it splits it into a set of lots of equal-size. Certain subsets of regions are still assigned roles just like in the other GCs. The amount of live data in each region is tracked, and when a collection is triggered, the G1GC will clear the ones with the most “garbage” first, hence the name. By doing this, it attempts to free as much space as possible with each  collection.


Software Engineer, CoreValue




0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Articles

What are your customers telling you? Maximize the effectiveness of sentiment analysis by using simple tips

September 7, 2017 | Lily Smirnova

Sentiment analysis is one method to gather and process customer-supplied information, and then convert it to a quality customer experience. Gartner predicts that 85% of all businesses will compete in the area of customer experience by 2020. As sentiment analysis explodes onto the scene, what can technology actually do to enhance business efforts? Hints on […]

Great features developers might have missed in the Summer ’17 release

September 1, 2017 | George Arshakian

Apex Metadata API (generally available in Summer’17) Apex Metadata API is a must-have for every developer.  It empowers developers to update classes/pages/remote site settings/custom metadata and much more straight from Apex. Imagine creating an Apex Class instance from an Apex Class. It will handle dependency Injection in a way that will lower the coherence of […]