Questions tagged [java-17]

JavaSE 17 is the latest java version which is also long term support. Use this tag for issues with JavaSE 17.

Java SE 17 is the latest java version which is also long term support. Use this tag for issues with Java SE 17.

841 questions
479
votes
11 answers

How do I install Java on Mac OSX allowing version switching?

I want to install OpenJDK Java on Mac OSX and have it work alongside other JDK's since it is a newer release. Currently, I downloaded the tar.gz and placed it in my path but that is hard to maintain. The only other install I found that do more…
Jayson Minard
  • 84,842
  • 38
  • 184
  • 227
160
votes
15 answers

IntelliJ - Invalid source release: 17

I've created a new Java project in IntelliJ with Gradle that uses Java 17. When running my app it has the error Cause: error: invalid source release: 17. My Settings I've installed openjdk-17 through IntelliJ and set it as my Project SDK. The…
Michael
  • 3,411
  • 4
  • 25
  • 56
78
votes
7 answers

OpenJDK Java 17 docker image

We are upgrading our microservices in docker to use Java 17 and previously we used the base image openjdk:11-jre-slim. What is the corresponding image for Java 17? There doesn't seem to be a openjdk:17-jre-slim? In fact there dont seem to be any…
David Geary
  • 1,756
  • 2
  • 14
  • 23
54
votes
7 answers

What are sealed classes in Java 17?

Today, I updated my Java version from 16 to 17, and I found that sealed classes is a new feature in it. I think it can be declared like this: public sealed class Main permits AClass, AnotherClass { } But, what is the use of sealed classes in…
user16411474
39
votes
2 answers

In Java 17 how do I avoid resorting to --add-opens?

As of Java 17 --illegal-access is effectively obsolete https://openjdk.java.net/jeps/403 Any use of this option, whether with permit, warn, debug, or deny, will have no effect other than to issue a warning message. We expect to remove the…
Robert Bain
  • 9,113
  • 8
  • 44
  • 63
37
votes
5 answers

Spring Boot 3.x upgrade. Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1

I recently wanted to upgrade my kotlin project from spring boot 2.7.x to 3.0.1. I use Java 17 temurin, gradle 7.6. In IntelliJ I got following error message on importing the project over gradle: A problem occurred configuring root project 'demo'. >…
Roman T
  • 1,400
  • 5
  • 18
  • 31
37
votes
7 answers

Apache Spark 3.3.0 breaks on Java 17 with "cannot access class sun.nio.ch.DirectBuffer"

A similar question was asked at Running unit tests with Spark 3.3.0 on Java 17 fails with IllegalAccessError: class StorageUtils cannot access class sun.nio.ch.DirectBuffer, but that question (and solution) was only about unit tests. For me Spark is…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
34
votes
1 answer

Java 17's parallelStream() causes critical performance issues with code that runs fine in Java 16. Why?

I work on a Jetty web app that was running on Java 16. I tried to upgrade it to Java 17 but there were critical performance issues caused entirely by one call to parallelStream(). The only changes are the Java version bump from 16 to 17, --add-opens…
Robert Bain
  • 9,113
  • 8
  • 44
  • 63
28
votes
2 answers

Why have nothing to override, but still can put @Override without syntax error?

I am using Java language level 17 on JDK 19. I have package ocp17.ch07; public record BeardedDragon(boolean fun) { @Override public boolean fun() { return false; } } Why have nothing to override, but still can put…
Vy Do
  • 46,709
  • 59
  • 215
  • 313
27
votes
2 answers

Why doesn't instanceof pattern matching work with else if in this particular case?

The following snippet does not compile on javac, version 17 (Temurin) class Instanceof { static void doesNotWork(Object o) { if (o == null) { throw new Error(); } else if (!(o instanceof String s)) { throw…
Fabian Kürten
  • 331
  • 2
  • 6
27
votes
2 answers

When and how to perform one to 0..n mapping Stream mapMulti over flatMap

I have been skimming through the news and the source code of the newest LTE Java 17 version and I have encountered with new Stream method called mapMulti. The early-access JavaDoc says it is similar to flatMap. Stream mapMulti(BiConsumer
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
25
votes
1 answer

Spring boot application fails to start after upgrading to 2.6.0 due to circular dependency[ unresolvable circular reference]

Spring boot upgrade Error Spring boot application fails to start after upgrading to 2.6.0 due to circular dependency Error creating bean with name 'securityConfig': Requested bean is currently in creation: Is there an unresolvable circular…
Thirumal
  • 8,280
  • 11
  • 53
  • 103
24
votes
4 answers

java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)

I am trying to update my SpringBoot maven project to Java 17. 17 17 I had working maven-jaxb2-plugin plugin defined which created java classes…
victorio
  • 6,224
  • 24
  • 77
  • 113
21
votes
1 answer

Gradle 7.2 Java 17 Build issue java.lang.NullPointerException: Cannot read field "bindingsWhenTrue" because "currentBindings" is null

Testing out upgrading some services to Java 17 now that it is GA and ran into the following issue compiling a Gradle 7.2 Spring Boot Application: > Task :compileJava Note: Some input files use or override a deprecated API. Note: Recompile with…
Patrick Bray
  • 552
  • 2
  • 7
  • 20
19
votes
3 answers

Java 17 Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass is null

I have small project in spring boot with oauth2, i want to run resource server settings: Java 17 spring-boot-starter-parent version 2.5.6 spring-cloud-dependencies version…
kgajda
  • 225
  • 1
  • 2
  • 5
1
2 3
56 57