Questions tagged [java-16]

Use this tag for questions specific to Java 16, which is version 16 of the Java platform, released on March 16, 2021. In most cases you should also specify the java tag.

This release is the Reference Implementation of version 16 of the Java SE Platform, as specified by JSR 391 in the Java Community Process.

124 questions
15
votes
2 answers

Java records and field comments

When we use classes in Java it's very simple to add JavaDoc/comment for each class field/method: class Product { //Product unique identifier private int id; } If we migrate these classes to Java records then it's unclear what is the the…
Sergiy
  • 1,854
  • 4
  • 22
  • 34
12
votes
1 answer

Record cannot get parameter names from constructors?

Looking to see how to use Records with reflection under Java 16 (and 15 same behavior) public record RecordTest2(int id, int something, double total, LocalDateTime createdOn) { public RecordTest2(int id, int something, double total) { …
sproketboy
  • 8,967
  • 18
  • 65
  • 95
11
votes
1 answer

Constructor annotation on java records

Is there a way to get an annotation like ConstructorProperties that has @Target(CONSTRUCTOR) to annotate the generated constructor of a java 16 record? E.g.: @ConstructorProperties({"id", "filename"}) public record Person(long id, String filename)…
pearcemerritt
  • 189
  • 1
  • 8
9
votes
1 answer

Why does Stream#toList's default implementation seem overcomplicated / suboptimal?

Looking at the implementation for Stream#toList, I just noticed how overcomplicated and suboptimal it seemed. Like mentioned in the javadoc just above, this default implementation is not used by most Stream implementation, however, it could have…
Yassin Hajaj
  • 21,337
  • 9
  • 51
  • 89
9
votes
3 answers

IntelliJ JDK 16 Early Access - Any Success? tools.jar

Has anyone had any success using JDK 16 (https://jdk.java.net/16/) early access build with IntelliJ? I am able to use JDK 15 early access builds, but when I try JDK 16 I get an error message: Error: Cannot determine path to 'tools.jar' library for…
NotArchon
  • 125
  • 1
  • 6
7
votes
2 answers

Paths.get() / Path.of() throws NullPointerException on upgrade to Java 16

When upgrading from Java 15 to Java 16, some of my unit tests began failing due to a null pointer exception. The issue was caused by a null value being passed to the Paths.get() api. What changed in Java 16 to make this an error? I am using OpenJDK…
NaderNader
  • 1,038
  • 1
  • 11
  • 16
7
votes
3 answers

Multiple records inside the same .java file

We can always have multiple classes inside a .java file. Considering encapsulation and that each class consists of multiple lines of code it always made sense to have 1 class (don't talk about nested classes) inside 1 .java file. Now that records…
Panagiotis Bougioukos
  • 15,955
  • 2
  • 30
  • 47
6
votes
1 answer

Why does mapMulti need type information in comparison to flatMap

I want to use mapMulti instead of flatMap and refactored the following code: // using flatMap (version 1) => returns Set var items = users.stream() .flatMap(u -> u.getItems().stream()) …
nimo23
  • 5,170
  • 10
  • 46
  • 75
6
votes
2 answers

Java 16 pattern matching problem with Switch in Intellij IDEA 2020.3.3 (Expression expected)

As we know Java 16 brings with a new features like Records, sealed interfaces and classes, and also pattern matching. Today I wanted use them in my training project. However, I ran into a problem, maybe I don't understand something. So situation…
K2mil J33
  • 167
  • 2
  • 14
5
votes
0 answers

JDK 16 Curve not supported: secp256r1 [NIST P-256,X9.62 prime256v1] (1.2.840.10045.3.1.7)

Currently working on upgrading from Java 13 to Java 16 and using the following updated dependencies for a cryptography library performing encryption/decryption: BouncyCastle 1.69 Google Tink 1.6.1 ================================= Crypto Library…
5
votes
1 answer

Install Java 16 on Raspberry Pi 4

I have tried multiple releases from here using : sudo -i cd /usr/lib/jvm wget [release link here] tar xzf [file name here] export PATH=$PWD/[dir here]/bin:$PATH java -version But after java -version I always get: /usr/lib/jvm/[dir here]/bin/java:…
resuther
  • 190
  • 1
  • 1
  • 9
5
votes
1 answer

Is it okay to make a record cloneable?

I couldn't find any material on Google saying about the use of Cloneable records. I was thinking of something like this: record Foo() implements Cloneable { public Foo clone() {...} } Is it a good thing? Should we avoid it in favor of the…
5
votes
2 answers

How can I solve a Netbeans 12.0 IllegalAccessError?

I just installed Netbeans 12.0. When I started my first project I got an unexpected error message just after creating a new java class. Any suggestions on how I can handle it? This is the message: java.lang.IllegalAccessError: superclass access…
user233923
  • 51
  • 1
  • 2
5
votes
1 answer

Talend Open Studio - an error (sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain))

For first launch Talend Open Studio have an error java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at…
Aleksandr
  • 51
  • 1
  • 4
4
votes
2 answers

Eclipse Plugin --add-exports Java 16+

Using the google-java-format eclipse plugin works great when running Eclipse under Java 11, but when running on Java 16+, it fails with the following error: Full error: A save participant caused problems. The save participant 'Code Clean Up' caused…
1
2
3
8 9