Questions tagged [java-14]

Reference Implementation of version 14 of the Java SE Platform, as specified by JSR 389 in the Java Community Process. Use this tag for questions specific to Java 14, which is version 14 of the Java platform, released on 17 March 2020. In most cases you should also specify the java tag.

Version 14 of the Java programming language.

The reference implementation of Java 14 reached General Availability on 17 March 2020.

The JDK/14 production-ready binaries for Linux and Windows.

New features and improvements:

  • Pattern Matching for instanceof (Preview)
  • Packaging Tool (Incubator)
  • NUMA-Aware Memory Allocation for G1
  • JFR Event Streaming
  • Non-Volatile Mapped Byte Buffers
  • Helpful NullPointerExceptions
  • Records (Preview)
  • Switch Expressions (Standard)
  • Deprecate the Solaris and SPARC Ports
  • Remove the Concurrent Mark Sweep (CMS) Garbage Collector
  • ZGC on macOS
  • ZGC on Windows
  • Deprecate the ParallelScavenge + SerialOld GC Combination
  • Remove the Pack200 Tools and API
  • Text Blocks (Second Preview)
  • Foreign-Memory Access API (Incubator)

Specified by JSR 389 in the Java Community Process.

192 questions
72
votes
6 answers

Lombok getter/setter vs Java 14 record

I love project Lombok but in these days I'm reading and trying some of the new features of java 14. Inside the new capability, there is the record keyword that allows creating a class with already built-in the following functionality: constructor,…
gixlg
  • 1,193
  • 1
  • 9
  • 21
69
votes
3 answers

Are Java records intended to eventually become value types?

The record preview feature (JEP 384) introduced in JDK 14 are a great innovation. They make it much easier to create simple immutable classes that are a pure collection of values without the loss of context inherent in the generic tuple classes in…
sprinter
  • 27,148
  • 6
  • 47
  • 78
56
votes
2 answers

Why is Java 14 not LTS?

Java 14 is non-LTS. Given the new release train of 6 monthly releases and that 8 and 11 were LTS, should Java 14 not have been the next LTS release? Or is purely based on the Java architects to decide which they pick for LTS? I did search online but…
Andy Cribbens
  • 1,370
  • 2
  • 11
  • 22
56
votes
5 answers

Post Java-14 getter/setter naming convention

Java 14 introduced records feature. Record creates getter with the same name as field, so one would write print(person.name()) for example. But old Java bean convention dictates that one should name this method as getName(). Using both styles in the…
vbezhenar
  • 11,148
  • 9
  • 49
  • 63
51
votes
2 answers

Define default constructor for record

I have a record and want to add default constructor to it. public record Record(int recordId) { public Record { } } But it created constructor with int param. public final class Record extends java.lang.Record { private final int…
Vikas
  • 6,868
  • 4
  • 27
  • 41
49
votes
3 answers

Do you need to override hashCode() and equals() for records?

Assuming the following example: public record SomeRecord(int foo, byte bar, long baz) { } Do I need to override hashCode and equals if I were to add said object to a HashMap?
shavit
  • 842
  • 1
  • 7
  • 17
44
votes
2 answers

What is the use of @Serial annotation as of Java 14

Java 14 introduces a new annotation @Serial in the java.io package. Its brief description in the API docs: Indicates that an annotated field or method is part of the serialization mechanism defined by the Java Object Serialization…
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
38
votes
3 answers

How is NullPointerException in Java 14 different from its predecessor?

One of the important features that were introduced with Java SE 14 was the Helpful NullPointerExceptions which is related to the usability of the NullPointerException. What makes NullPointerException in Java SE 14 more usable than its predecessor?
Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
38
votes
2 answers

How to document Java Record parameters?

How is one supposed to document Java Record parameters? I am referring to the parameters that end up becoming constructor parameters, class fields. I tried: /** * @param name the name of the animal * @param age the age of the animal */ public…
Gili
  • 86,244
  • 97
  • 390
  • 689
35
votes
3 answers

How to have placeholder for variable value in Java Text Block?

How can I put a variable into Java Text Block? Like this: """ { "someKey": "someValue", "date": "${LocalDate.now()}", } """
Dennis Gloss
  • 2,307
  • 4
  • 21
  • 27
29
votes
4 answers

What are switch expressions and how are they different from switch statements?

As part of Java SE 12, switch expressions were introduced and since Java SE 14, they have been standardized. How are they different from switch statements?
Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
29
votes
2 answers

Meaning of "shallowly immutable" in the documentation of Record in Java 14

I am reading the documentation of Records and don't understand the term "shallowly immutable". What do we mean by shallowly immutable? And if it's immutable why we need a copy constructor? Why two "Hello Worlds!"? For all record classes, the…
Debapriya Biswas
  • 1,079
  • 11
  • 23
29
votes
5 answers

Slow application, frequent JVM hangs with single-CPU setups and Java 12+

We have a client application (with 10+ years of development). Its JDK was upgraded from OpenJDK 11 to OpenJDK 14 recently. On single-CPU (hyper-threading disabled) Windows 10 setups (and inside VirtualBox machines with only one available CPU) the…
palacsint
  • 28,416
  • 10
  • 82
  • 109
26
votes
5 answers

KeyCloak Server Caused by: java.lang.ClassNotFoundException: java.security.acl.Group

I'm running a KeyCloak server to authenticate users who would like to gain access to a Spring Boot/Spring Web REST API. However, an error occurs while trying to authenticate. The following works: When I access…
21
votes
3 answers

Java 14 records and arrays

Given the following code: public static void main(String[] args) { record Foo(int[] ints){} var ints = new int[]{1, 2}; var foo = new Foo(ints); System.out.println(foo); // Foo[ints=[I@6433a2] System.out.println(new Foo(new…
user140547
  • 7,750
  • 3
  • 28
  • 80
1
2 3
12 13