Java 13 has just arrived. ZGC has begun sharing memory, CDS itself remembers classes, and other technical wonders







Today a new version of Java is released - Java / JDK 13. The race began with the spring release of JDK 12, which took place on March 19, and the fork from the main branch occurred on June 13. Someone we lost along the way like JEP 343: Packaging Tool , but in general, everything is normal, and it's time to reap the benefits.







You can download the new release here . Under the cut will be a small overview of the fresh JEPs included in this release.







JEP 351: ZGC: Uncommit Unused Memory



As you know, in JDK 11 we have a new brilliant GC - ZGC, scalable, fast and low-pause. Well, or at least that's the idea. A rather serious problem in him was that he behaved like a dog in the manger and did not give up the busy memory, even if it was not needed. Shenandoah and G1 started sharing a long time ago, and the ZGC's behavior looked criminally shaking hands. Well, now everything is fixed, right after the timeout in -XX:ZUncommitDelay



we get our bytes back.







JEP 350: Dynamic CDS Archives



The CDS feature itself allows you to add loadable classes to a common archive, thereby speeding up startup and reducing the amount of wasted RAM. Unfortunately, it used to be a bit stupid that you needed to restart the application yourself many times, forming a list of such classes, and then dumping the list with your hands. Now robots are working, not humans: when the -XX:ArchiveClassesAtExit



option -XX:ArchiveClassesAtExit



, classes are automatically dumped into the archive after a normal application shutdown.









Stuart Marks - Doctor Deprecator, Consulting Member Of Technical Staff at Oracle + olegchir on Oracle Code One, few minutes after the announcement of Java 13







JEP 353: Reimplement the Legacy Socket API



In all (now obsolete) javas, net.Socket



and java.net.ServerSocket



based on a hellish mixture of Java and C-code, from which even the most seasoned performance theorists cry. The problem was solved by writing a fresh implementation using the same internal infrastructure as NIO, so it almost does not need its own native code. Well and yet, this is not legacy, they wrote everything beautifully and suitable for moving to the fibers from the Loom project. If it is interesting under the hood, then you need to look at the NioSocketImpl



class.







JEP 354: Switch Expressions



We continue to prepare for the arrival of pattern matching. Switch Expressions is the first feature that allows you to write code of the form:







 int j = switch (day) { case MONDAY -> 0; case TUESDAY -> 1; default -> { int k = day.toString().length(); int result = f(k); yield result; } };
      
      





As we see in the example, since JDK 12 we have one cosmetic change: break



changed to yield



, now everything is like all normal people.







JEP 355: Text Blocks



JEP 326: Raw String Literals went under the knife, but his business lives on! "Tell Comrade Stalin - a terrible mistake has occurred . " Text blocks are a new preview feature that allows you to do without escaping, it formats the lines in a convenient way, brews coffee with foam and miraculously gives control over the format of the resulting string.







More mundane, now any hangman without the need to learn JSP can write something like:







 String html = """ <html> <body> <p>Hello, world</p> </body> </html> """;
      
      





A beginner DBA will be able to build a career by starting with the following code:







 String query = """ SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB` WHERE `CITY` = 'NEW DEHLI' ORDER BY `EMP_ID`, `LAST_NAME`; """;
      
      







Sounds a little menacing







Warning



A JEP overview is a small part of what you can and should tell about the new Java. This full review should also include a comprehensive review of interesting tactical innovations and an overview of bugs in the bugtracker. Perhaps someone ( lany , ay!) Will be able to continue this work. My team and I are now at Oracle Code One - unfortunately, sitting on reports or leaning on the Liberica JDK booth - it’s quite difficult to write something so long. In any case, this is a topic for a completely different hub site.









Brian Goetz - Architect for the Java Language at Oracle + olegchir on Oracle Code One







And we also have a Joker conference where we can discuss the need to switch to Java 13, the timing of the transition to ZGC, the amount of popcorn stock needed after the introduction of Text Blocks, and other relevant issues. Tickets, as always, can be purchased on the official website .



All Articles