Each version of Java brings with it a plethora of new features and improvements to the Java platform. In Java 10, we saw several new interesting features and capabilities for developers. Java 10’s new features were aligned with Java’s goal of rapid innovation without compromising compatibility and reliability. They went a long way in ensuring that java advanced faster and stayed competitive in the programming landscape.
Java 10 was known for its simplicity, faster programs and less garbage with its wide array of exciting features. Let’s take brief look into what was some of it’s exciting features:-
Looking Back At What Made Java 10 Unique
Local-Variable Type Inference
Earlier Java required the programmer to state explicitly the kind of data contained by a variable. This is so that every class that uses the variable reads the content in the same way. The principle behind this is ‘type safety’ which reduces runtime errors. But, there can be many more variables within a single module that are only used internally. Explicitly typing these variable can cause errors as and is time- consuming.
This new feature enabled the programmer to simply declare the variable using special syntax and the Java compiler then interprets the type from the context. It appealed to those programmers who were not on board with Java’s verbosity.There is less amount of writing required while at the same time ensuring static safety.
With local- variable type interface,the programmers can declare local variables using a new keyword called var. With var, the user need not have to specify the type of the variable.
var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
Garbage-Collector Interface (JEP 304)
This JEP enhanced the code isolation of various garbage collectors through the introduction of a common Garbage Collector Interface. This change had some advantages including better modularity to the internal GC Code, ease of adding new GC without having to
alter existing codebase and also in housekeeping the previous GC.
Thread-Local Handshakes (JEP 312)
This feature intended to improve VM performance. With this feature, it became possible to perform a callback on application threads without having to perform a global VM savepoint which means that JVM could not only curb all of them, but individual threads as well. As a part of this feature, there are several improvements done to enhance VM performance.
Experimental Java-Based JIT
This feature is called experimental as it is not completely ready for prime time. Just In Time(JIT) compiler is the program that translates java code into machine codes. They require customization for each platform in order to generate machine codes that are compatible with that platform’ operating systems and microprocessor. Java already has JIT compilers which are written in C++. The downside is that they are hard to maintain. However , Java 10’s Experimental Java-based JIT is written in java, an appealing feature to java community owing to its easy maintenance. It also uses Ahead-Of- Time(AOT) compilation, a function that compiles in advance methods and classes in Java and thus shortens the start up time.
Heap Allocation on Alternative Memory Devices (JEP 316)
This was a very interesting feature. It aids HotSpot VM to allocate the Java object heap on a another memory device that is specified by the user. For instance, with this feature it was possible to allot lower priority processes to utilise NV-DIMM memory and also to only assign higher priority processes to the DRAM ina multi- JVM environment.
Consolidate the JDK Forest Into a Single Repository (JEP 296)
This feature dealt exclusively with housekeeping. It combined the various repositories of the JDK forest into one.
Root Certificates (JEP 319)
Another important change brought by Java 10. This feature will make OpenJDK build more attractive to developers by providing a default set of Root Certification Authorities. With this, Java 10 aims to decrease the differences between OpenJDK and Oracle JDK builds. Important security components like TLS will by default will work by default now in OpenJDK builds.
As you can see, these features of Java were a testimony to its history of innovation and improvement. Though there are a plethora of programming languages today in the industry, Java continues to enjoy wide patronage. Those looking to reap the benefits of Java can check out the various java training and certification courses provided by SpringPeople.