📜 ⬆️ ⬇️

Java 10 General Availability


Download link

The last half of the year, we have discussed in detail here the innovations of Java 10 and know them by heart.

But it would be strange if the most important Java news in half a year would not have appeared in this hub.


As they say, just leave it here. Next to the adventure!


Really out on time?


Yes indeed. The release was made of 46 builds, and collected a day ago, look:


$ java -version openjdk version "10" 2018-03-20 OpenJDK Runtime Environment 18.3 (build 10+46) OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode) 

Does the IDE work, or is everything red crossed out?


Works in fresh IntelliJ IDEA. But you have to install a beta version (for example, ideaIU-181.4203.400 ), because this language level is not supported on a stable 2017.3.5 .




Long road to release


Not really. This is the fastest full release in history!


Previously, the plan was published on the project page , but we will not need it anymore. All stages successfully completed.






So what, all is well?


Basically, yes. In this release, the developers focused on fixing only those bugs that are absolutely critical to the success of Java 10. All tasks related to other Java releases, even with top priority, are postponed.


But what is the release without a good fakap? Tagir Valeev ( lany ) in a matter of hours published in his twitter news about the epic new bug in the compiler.



The bug is already being discussed in the mailing list and work is underway to fix it .


This code can be inserted and verified:


 public class Main { void m() { var s = java.util.List.of("a", 1); } } 

The problem manifests itself only when the -g flag is on, which indicates the need to generate debug information. In IDE, it is enabled by default, so you won't miss the error :-)


Changes that appeared in this release



JEP 286 : Local-Variable Type Inference .

Local type inference with var . Ambiguous feature. Regularly causing buzz in the ezine.


Code example:


 var list = new ArrayList<String>(); // infers ArrayList<String> var stream = list.stream(); // infers Stream<String> 

Bearded anecdote to the topic.
A javist comes into the dining room and says: please give Borsch borsch new Borsch!





JEP 296 : Consolidate the JDK source forest into a single repository.

The general public is usually not interested, except that you collect OpenJDK from source. The interesting thing is that the less chaos in the project, the better the product turns out.





JEP 304 : Garbage-Collector Interface .

Improving the isolation of the main source from the GC by creating a good clean interface for the GC. Recently, it has become very popular to write our own GCs: Shenandoah, ZGC, Epsilon are on the way. To support these good undertakings, the OpenJDK developers had to specifically dump the dump in the code in order not only to maximally simplify the creation of new GCs, but also to give the opportunity to quickly disconnect unnecessary GCs from the assembly. One of the main criteria for success is the absence of a drawdown in performance after all these refactorings.





JEP 307 : Parallel Full GC for G1 .

CMS was thrown out into the cold , and everything interesting in common (not low-pause) garbage collection now occurs in G1. We read "Release Note: JEP 307: Parallel Full GC for G1" : "The G1 collector was created to do without full GC, but when a parallel assembly cannot utilize memory quickly enough, it returns to full GC. The old full GC implementation in G1 used the mark-sweep-compact single-threaded algorithm. After the implementation of JEP-307, full GC was parallelized and began to use the same number of parallel thread-workers as in young and mixed. ” (I remind you that young GC processes only regions of young / survivor, mixed - also old, full - all hip, young / tenured).





JEP 310 : Application Class-Data Sharing .

In order to speed up the launch and reduce the amount of memory used, it is proposed to extend the existing feature called Class-Data Sharing (“CDS”) by packing classes into a common archive.


If it is very short, then this is how the archive is first created and then used at startup:


 java -Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=hello.lst -XX:SharedArchiveFile=hello.jsa -cp hello.jar java -Xshare:on -XX:+UseAppCDS -XX:SharedArchiveFile=hello.jsa -cp hello.jar HelloWorld 




JEP 312 : Thread-Local Handshakes .

Ability to perform callback on threads without making global safepoint for JVM. The feature allows you to cheaply stop single threads, not just “all or nothing”. This is a low-level system feature; you cannot use it manually, but you can rejoice at the automagically increased program performance.





JEP 313 : Remove the Native-Header Generation Tool.

The javah utility javah no longer needed, because the native headers can now do javac (starting with JDK8, in fact).


javah was a utility that generates the header files and source files needed to use native methods. The files generated by it are intended for use in C programs to access instances of java objects from unmanaged native code. The .h file defines a structure that looks something like a class that we are going to manage. Structure fields are instance variables of a class. However, in JNI, the use of such stubs is not mandatory.





JEP 314 : Additional Unicode Language Tag Extensions .

Support for new Unicode extensions: cu (currency type) , fw (first day of week) , rg (region override) , tz (time zone) .





JEP 316 : Heap Allocation on Alternative Memory Devices .

HotSpot VM can now allocate hipp memory on other devices, for example, on NV-DIMM. Some operating systems are already able to allocate non-DRAM memory, placing it on a file system, for example, NTFS DAX and ext4 DAX . The option `-XX: AllocateHeapAt = is added.




JEP 317 : Experimental Java-Based JIT Compiler .

Graal , can be used as the main JIT compiler. Explaining what Graal is is a very long time, so in brief. Under the Graal brand several directions are now united: Graal Compiler, SubstrateVM, Truffle, various languages ​​for it ("Graal polyglot runtime"). In this case, it means Compiler. On some tests, such as Scala DaCapo, the grail allows you to get almost twice the performance compared to C2! To get such wonderful results, you need to have very, very much dynamic code and obviously, the programmers for Scala, Groovy, JavaScript, etc., will most benefit from it. This miracle works so far only on 64-bit Linux and macOS.





JEP 319 : Root Certificates .

The JDK has a cacerts keystroke , which is needed to store root certificates. But in OpenJDK, it is still empty. Therefore, nishtyaki type TLS in OpenJDK by default do not work. Now this cacerts will be correctly configured and filled, and the nishtyaki will start working. In addition, it will smooth the difference between OpenJDK and Oracle JDK.





JEP 322 : Time-Based Release Versioning .

Feature releases will add new features. Update releases will only fix bugs.


And of course,


 $ java -version openjdk version "10" 2018-03-20 OpenJDK Runtime Environment 18.3 (build 10+46) OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode) 



Not everything is in JEP


In the bugtracker and mailing list you can see a large number of changes that have not received such wide publicity as the main JEP.


On this occasion, Tagir Valeev ( lany ) recently wrote a very good article . Duplicate its contents does not make sense, you need to follow the link and read.


What's next?


You need to take JDK 10 and start migrating your code onto it!


Download link .


Minute advertising. As you probably know, we do conferences. The upcoming Java conference is JPoint 2018 . It will be held April 6-7, 2018 in Moscow. The reports often mention issues of transition to new versions of Java. What reports are there - you can see in our archive on YouTube or read in the habroblog . In addition, it will be possible to chat live with speakers and the best experts on the Java platform in special discussion zones after each talk. In short, come in, we are waiting for you.

')

Source: https://habr.com/ru/post/351694/


All Articles