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!
JPA and React Plugins: From Buddies To Full Members of The JetBrains Family
We are excited to announce that JPA Buddy and React Buddy have joined the JetBrains family. Positioned as powerful plugins for working with JPA data and React applications, respectively, they will offer even more functionality for IntelliJ IDEA and WebStorm developers moving forward. With this ac…
New Livestream – Java 21: Focus on Virtual Threads and Pattern Matching
Join us for the new IntelliJ IDEA LiveStream episode with José Paumard to learn about the Java 21 release. Date: September 28, 2023. Time: 3:00 – 4:00 pm UTC.
Java Annotated Monthly – September 2023
The September edition of Java Annotated Monthly is here! With this month’s release of Java 21 approaching, we're excited to bring you a final sneak peek into its crucial features. But that's not all! This edition is packed with helpful articles about cutting-edge AI technologies, including update…