Use this tag for questions specific to Java 19, which is version 19 of the Java platform, released on September 9, 2022. In most cases you should also specify the java tag.
Questions tagged [java-19]
67 questions
11
votes
3 answers
How can I run JDK 19 with Structured Concurrency?
I have edited this to bring things up-to-date wrt the original posting.
I want to try the new Project Loom feature defined in: JEP 428: Structured Concurrency (Incubator)
I have in my pom.xml
…

Eric Kolotyluk
- 1,958
- 2
- 21
- 30
8
votes
1 answer
OpenJDK 19 and compressed pointers
I have a hard time understanding how compressed pointers works in Java 19, help is appreciated.
In Java 11 the reference size is 4 for heaps below 32GiB (compressed pointers) and 8 for a larger heap. In Java 19 they seem to take 4 bytes even for…

Cornel Creanga
- 5,311
- 1
- 22
- 28
5
votes
5 answers
Idea Intellij: Error:java: error: release version 20 not supported, maven.compiler.target in pom.xml
I have a Idea Intellij project like this:
Test.java:
public class Test {
public static void main(String[] args) {
System.out.println("Test");
}
}
pom.xml:

parsecer
- 4,758
- 13
- 71
- 140
5
votes
4 answers
Java 19 compiler issues when trying record patterns in switch expressions
I downloaded the release candidate of JDK19 from here https://jdk.java.net/19/ to play a little bit with the new record patterns that were implemented there, but I'm encountering some issues. In my tests, I wrote a version of Optional based on…

MscG
- 366
- 2
- 15
4
votes
2 answers
Thread.currentThread().getName() returns empty string "" for Virtual Threads created via Executors.newVirtualThreadPerTaskExecutor()
I am working with Java 19. I have tried to use newly introduced virtual threads as follows:
public static void main(String[] args) {
System.out.println("Started with virutal threads");
try (ExecutorService virtualService =…

fascynacja
- 1,625
- 4
- 17
- 35
4
votes
1 answer
Currency difference between java 18 and java 19
I am trying to migrate to java 19 from java 18.
Here is the code I run:
NumberFormat currencyFormatter =…

Jakub Bręk
- 43
- 3
3
votes
1 answer
About project Lombok's future
I've been using Lombok and am pretty happy with it, enabling my laziness to avoid writing boilerplate code. But there have been some concerning information about Lombok like:
I read here that Lombok completely relies on a loophole, an illegal…

paratrooper
- 59
- 4
3
votes
2 answers
How can I know if a Java 19 Structured Concurrency StructuredTaskScope is shutdown ( canceled )?
A Java 19 ShutdownOnFailure scope also allows for explicit cancellation of all tasks using the shutdown method. How can I know if the scope has been shutdown? The API includes an isShutdown method, but it is private.
Here is some (incomplete) code…

Gonen I
- 5,576
- 1
- 29
- 60
3
votes
1 answer
How can I run JDK 19 with Structured Concurrency? (ERROR: java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope)
Note: this post somehow related with this question; however, the error is different. So I am posting as another question.
I want to try the new Project Loom feature defined in: JEP 428: Structured Concurrency (Incubator)
I created a library…

Tugalsan Karabacak
- 315
- 1
- 11
2
votes
0 answers
Method getDeclaredFields returning empty
Recently I upgraded to JDK19 and I am trying to list all the declared fields in the Method class. But it returns nothing.
import java.lang.reflect.Method;
import java.util.Arrays;
public class MethodFieldsDemo {
public static void…

Sai Dandem
- 8,229
- 11
- 26
2
votes
1 answer
Exe generated with Jpackage loads wrong jvm.dll
I'm trying to generate the Windows bundle of my JavaFX application using JPackage. I'm running on Liberica JDK 19 and my scripts first generate a runtime using JLink with a --vm=client argument and then they run jpackage with a --runtime-image…

Andrea Vacondio
- 888
- 9
- 19
2
votes
1 answer
SecurityManager deprecation and reflection with suppressAccessChecks
I'm an university lecturer and I'm revising my lecture on Java reflection.
Other years when teaching about the horrors of suppressAccessChecks I was showing
that you could set up a SecurityManager and do something like
if…

Marco Servetto
- 684
- 1
- 5
- 14
2
votes
1 answer
JDK 19 not being recognised in VSCode?
I have a grade project (7.6) that is also a LibGDX project and the latest java jdk (19.0.1) installed. I am on Mac OS Monterey btw.
The problem is that when opening the gradle project inside VSCode it throws a lot of errors.
It is however possible…

Rango
- 21
- 2
2
votes
1 answer
Java Switch Without Expression
In GoLang you can have a switch without an expression, where the cases replace a series of cascading ifs.
t := time.Now()
switch {
case t.Hour() < 12:
fmt.Println("It's before noon")
default:
fmt.Println("It's after noon")
}
In Java 19 I…

Gonen I
- 5,576
- 1
- 29
- 60
2
votes
1 answer
Java 19 preview, incubator features with Gradle
Java 19 has new features: virtual threads (as preview) and structured concurrency (as incubator). Gradle 7.6 will support Java 19. Given that 7.6-rc-1 is available, how can I try out these new features? I have working Bash scripts like the…

Michael Easter
- 23,733
- 7
- 76
- 107