Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK 21 support #1396

Closed
johanjanssen opened this issue Jan 26, 2023 · 33 comments
Closed

JDK 21 support #1396

johanjanssen opened this issue Jan 26, 2023 · 33 comments
Assignees
Labels
Milestone

Comments

@johanjanssen
Copy link

Hi, I know I'm quite early :), but is support for JDK 21 already planned?

I ran the following example https://github.com/johanjanssen/JavaHiddenGems/tree/main/Examples/equalsverifier on an ea version of Java 21. It uses EqualsVerifier https://jqno.nl/equalsverifier/ which in turn uses Byte Buddy and produces the following error:

-> Java 21 (65) is not supported by the current version of Byte Buddy which officially supports Java 20 (64) - update Byte Buddy or set net.bytebuddy.experimental as a VM property

@raphw
Copy link
Owner

raphw commented Jan 26, 2023

For now, please set -Dnet.bytebuddy.experimental=true

Then it will work. Proper support is coning soon.

@raphw raphw self-assigned this Jan 26, 2023
@raphw raphw added the question label Jan 26, 2023
@raphw raphw added this to the 1.12.22 milestone Jan 26, 2023
@johanjanssen
Copy link
Author

Yes, I'm using that now indeed. Thanks a lot for working on supporting Java 21 and the great work on Byte Buddy in general!

@kennymacleod
Copy link

With the release of JDK 20 yesterday, 21 LTS is next up. Do you have an updated target release of byte-buddy?

@raphw
Copy link
Owner

raphw commented Mar 23, 2023

I'm waiting a bit on ASM here, unfortunately. The day they release support, I'll follow.

@kennymacleod
Copy link

ASM 9.5 is out in the wild. Aww yeah.

@raphw
Copy link
Owner

raphw commented Mar 28, 2023

Releasing as we speak.

@raphw raphw closed this as completed Apr 11, 2023
@ascopes
Copy link

ascopes commented May 6, 2023

@raphw random question, hope you don't mind me asking here.

Would specifying this flag enable JDK 21 build support for Mockito, given it uses ByteBuddy internally?

@raphw
Copy link
Owner

raphw commented May 8, 2023

It is supported in the latest Byte Buddy version. Mockito should have picked that up?

@bergerdenes
Copy link

Java 21 was out a few weeks ago, please give an update on when it will be officially supported. Thanks!

@raphw
Copy link
Owner

raphw commented Oct 3, 2023

It's been supported for a while, are you experiencing issues?

@OLibutzki
Copy link

@raphw The milestone assigned to this issue is misleading. As far as I can see it's not included in 1.12.22?

ASM has been updated with 1.14.3, so this is the version containg Java 21 support, right?

copybara-service bot pushed a commit to GoogleCloudPlatform/appengine-java-standard that referenced this issue Oct 9, 2023
trying to address raphw/byte-buddy#1396 as well.

PiperOrigin-RevId: 572035592
Change-Id: I9f6fe1ad19c78384ac5be7a4a147420aaf7363a5
@alphaho
Copy link

alphaho commented Oct 16, 2023

@OLibutzki Cross checking the release timeline and the discussion in this issue, I think the JDK 21 support is from version 1.14.3

@JavedAkramGit
Copy link

Hi, I have been facing an issue related to the upgraded version of Byte-Buddy(1.14.3) while hosting keycloak on my mac -> this was the issue when i tried to start it -> ERROR: java.util.concurrent.ExecutionException: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class org.keycloak.models.jpa.entities.ClientScopeAttributeEntity
ERROR: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class org.keycloak.models.jpa.entities.ClientScopeAttributeEntity
ERROR: Failed to enhance class org.keycloak.models.jpa.entities.ClientScopeAttributeEntity
ERROR: Java 21 (65) is not supported by the current version of Byte Buddy which officially supports Java 20 (64) - update Byte Buddy or set net.bytebuddy.experimental as a VM property
So i tried to upgrade the version of Byte buddy by downloading the latest version and moving it to the lib folder under keycloak but still facing the same issue.Please assist

@raphw
Copy link
Owner

raphw commented Nov 15, 2023

I assume you are still using an outdated version.

@JavedAkramGit
Copy link

I updated it to 1.14.3 but faced a similar issue. Please assist in updating it in another way compatible with KeyCloak

@ascopes
Copy link

ascopes commented Nov 15, 2023

The latest version of Mockito is 5.x, so if you are on 1.x then that is very outdated

@JavedAkramGit
Copy link

Not sure how am I gonna incorporate mockito while hosting keycloak on my local. The issue is that apparently keycloak requires an updated version of Byte-Buddy and the latest version from maven is 1.14 har file. Please assist with regards to that

@raphw
Copy link
Owner

raphw commented Nov 16, 2023

You should be able to just update Byte Buddy which is published to Maven Central.

@antemo
Copy link

antemo commented Dec 20, 2023

We are using Mockito 5.8.0 which brings in bytebuddy version 1.14.10
When trying to run tests on JDK 21 we get same error as mentioned before:

Caused by: java.lang.IllegalArgumentException: Java 21 (65) is not supported by the current version of Byte Buddy which officially supports Java 20 (64) - update Byte Buddy or set net.bytebuddy.experimental as a VM property

How can we fix or avoid this issue?

@ascopes
Copy link

ascopes commented Dec 20, 2023

@antemo in my builds, I specify that flag on the Maven argline as a JVM property for the test runner.

<properties>
  <argLine>-Dnet.bytebuddy.experimental=true</argLine>
</properties>

I have stuff building on JDK 21 and JDK 22 EA, and haven't come across this issue.

I was meaning to remove that flag as it was a workaround from a while back but might leave it in if it is keeping builds stable.

@raphw
Copy link
Owner

raphw commented Dec 20, 2023

Have you checked with your dependency manager if the version of Byte Buddy that is used is the right one? If another library then Mockito uses Byte Buddy, a different version might be resolved.

@listeningALF
Copy link

listeningALF commented Apr 23, 2024

What do I have to do exactly?
I am using an Macbook Pro and am working in IntelliJ.

For now, please set -Dnet.bytebuddy.experimental=true

Then it will work. Proper support is coning soon.

@ascopes
Copy link

ascopes commented Apr 23, 2024

@listeningALF the JVM arguments for your test runner.

No idea about Gradle. In Maven you can just set a property called argLine.

@maxim5

This comment was marked as outdated.

@listeningALF
Copy link

listeningALF commented Jun 7, 2024 via email

@ascopes
Copy link

ascopes commented Jun 7, 2024

@FelixMarxIBM Mockito 5 uses the inline agent by default, so you need to just include mockito-core. If you are not on Mockito 5 I'd consider updating first.

@listeningALF you need to set the JVM arguments for your test runner. I don't know what you are using so I can't provide further info, but you can most likely Google " set test JVM arguments" if you are not using Maven.

@rdwivedi
Copy link

For now, please set -Dnet.bytebuddy.experimental=true

Then it will work. Proper support is coning soon.

saved my day. thanks a ton!!

@koraypeker
Copy link

@raphw it is working when set -Dnet.bytebuddy.experimental=true. But how can we solve this problem ? We are using spring-boot-starter-test 2.7.18 and we want to upgrade to java 21

@raphw
Copy link
Owner

raphw commented Jul 4, 2024

I assume you have an old version of Byte Buddy on the class path. Newer versions support Java 21 without this flag.

@koraypeker
Copy link

I assume you have an old version of Byte Buddy on the class path. Newer versions support Java 21 without this flag.

@raphw org.mockito.mockito-core:4.5.1 is using in spring-boot-starter-test 2.7.18 and net.bytebuddy.byte-buddy:1.12.9 is using in org.mockito.mockito-core:4.5.1

@iSE-Timur-Ugurlu
Copy link

iSE-Timur-Ugurlu commented Jul 4, 2024

Hey guys I am using Java21 with mockito-inline (latest version)
The experimental Flag can be used in Gradle like that:

tasks.named('test', Test) {
   jvmArgs("-Dnet.bytebuddy.experimental=true")
}

But I would like to not use this flag and use the latest bytebuddy version in mockito-inline

I can use this for example (which works) but it looks somehow ugly:

implementation ('org.mockito:mockito-inline:5.2.0'){
    exclude group: 'net.bytebuddy', module: 'byte-buddy'
}
implementation 'net.bytebuddy:byte-buddy:1.14.17'

@ascopes
Copy link

ascopes commented Jul 5, 2024

@iSE-Timur-Ugurlu for now the best bet is to use the flag. I've had it set in my code for ages now.

On Java 22, you'll also want to set -XX:+EnableDynamicAgentLoading to remove a warning about the deprecated behaviour of bytebuddy implicitly loading itself at runtime, as OpenJDK have plans (at least last time I checked) to disable that ability without JVM flags by default in the future as well.

@raphw
Copy link
Owner

raphw commented Jul 8, 2024

The Byte Buddy version is up to date in Mockito at least: https://github.com/mockito/mockito/blob/a1cdede8ffdc1e62b20daf32f36ccc49d6cf75a7/gradle/dependencies.gradle#L7

The enable dynamic loading must be enabled, this cannot be worked around.

lbrayner added a commit to lbrayner/init.lua that referenced this issue Oct 2, 2024
srinjoyray pushed a commit to GoogleCloudPlatform/appengine-java-standard that referenced this issue Nov 12, 2024
trying to address raphw/byte-buddy#1396 as well.

PiperOrigin-RevId: 572035592
Change-Id: I9f6fe1ad19c78384ac5be7a4a147420aaf7363a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests