Webinar Recording: What’s New in JDK 12
This week we hosted a webinar covering the most important features for developers from Java 12. The recording is now available for those of you who missed it, or want to go back over some of the details. Below the video you’ll find a list of the resources (links) from the video, and answers to the most relevant questions.
Using this link you can browse through the Java 12 API documentation and find out the modifications, additions or removals from Java SE 11. The left panel includes the statistics, which is interesting.
Q & A
Here are some of the most relevant questions from the session. Some of them have been re-phrased for clarity or to allow us to answer more than one instance of a similar question.
Q: Doesn’t "
break" mean jump to a label? How do we know if we are returning value of variable or jumping to the label?
IMPORTANT: Usage of
break-with to return a value from switch expressions changed after this webinar.
See the Switch Expression description for initial proposal on
break taking an argument. There was feedback from the community that this was confusing, so modifications to switch expression was suggested with JEP 354. This JEP initially included mention and usage of
break-with, a hyphenated keyword to return a value from a switch branch. Now it proposes usage of
yield to return a value from a branch of switch expressions.
Here’s the link to the Java Language Specification, which still includes
break-with. Note: this link may not be accessible in future.
Q: Can we join the default section with the other case section if the return values are the same?
In this case, the best approach is to remove the case section that duplicates the default section, as then this specific case will be covered by default. IntelliJ IDEA will actually suggest this to you.
You can’t include the keyword
default with the other case labels. That would be a compilation error.
Q: Is there a way to prohibit preview features in build configuration, e.g. by supplying arguments to compiler?
Q: Constable type was mentioned in the context of updates to the String API. What does this mean?
Q: In the context of Garbage Collection: What are mixed collections? And what’s the meaning of Abortable?
A mixed collection includes both young and old memory regions for G1 (Garbage First) to clean. An analysis system selects the set of regions, collectively called a collection set, for G1 GC to work on. Prior to JDK 12, G1 GC could exceed the maximum pause time when the collection set was too large, the collection set included too many old regions, or the collection set included regions with stale data.
Prior to Java 12, there wasn’t any mechanism to ‘abort’, or call-off a G1 GC’s collection cycle. This has changed now. When working with G1 GC in Java 12, you can abort mixed collections if they exceed your specified limit. Note that you can’t abort all categories of G1 GC pauses.
Q: Will Java 12 work with Spring Boot 2.* framework and with Spring 5+ framework?
Spring Boot 2.1 supports Java 11. According to this page, "The plan is to officially support Java 12 as of Spring Boot 2.2 ". Spring 5.1 supports "Warning-free support for JDK 11 on the classpath and the module path." I can’t find any reference to support for JDK 12 specifically.
Q: I cannot set the IntelliJ IDEA project language level to 12, I can just pick 10 or X, but cannot use Switch Expressions
Working with Switch Expressions is supported in IntelliJ IDEA 2019.1 or later versions. Please see this post on for further details on how to get started with Java 12 in IntelliJ IDEA.
Subscribe to Blog updates
Thanks, we've got you!
New Livestream – Enhance Code Safety: Unveiling IntelliJ IDEA’s New Exploitable Path Feature
Join us for the new IntelliJ IDEA LiveStream episode with Ori Bendet and Yaroslav Russkih to learn about secure coding within IntelliJ IDEA.
Java Annotated Monthly – December 2023
The December edition of Java Annotated Monthly is here! As usual, you’ll find all the latest Java and Kotlin updates as well as details of key industry events for networking and learning. This issue also features the latest release candidates and targeted JEPs alongside Java tutorials and articles a…
New Livestream: Harnessing the Power of AI Assistant in IntelliJ IDEA
Join us for the new IntelliJ IDEA LiveStream episode with Anton Arhipov to learn about the capabilities of AI Assistant in IntelliJ IDEA.
Java Annotated Monthly – November 2023
Welcome to the Java Annotated Monthly – November 2023! As the Java world keeps on spinning, we've gathered a treasure trove of articles, talks, and insights to warm your Java developers’ hearts. This month's edition features a delightful blend of the latest technological advancements and the ever…