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

MockitoMockTest doesn't run on jdk23 yet - Java 23 (67) is not supported by the current version of Byte Buddy #19354

Closed
pshipton opened this issue Apr 19, 2024 · 12 comments · Fixed by adoptium/aqa-tests#5715

Comments

@pshipton
Copy link
Member

https://openj9-jenkins.osuosl.org/job/Grinder_testList_0/294
amac jdk23 extended.functional testing on

16:24:21  OpenJDK Runtime Environment (build 23-internal-adhoc.jenkins.BuildJDKnextaarch64macOpenJDK)
16:24:21  Eclipse OpenJ9 VM (build master-7f82a7d9d55, JRE 23 Mac OS X aarch64-64-Bit 20240419_304 (JIT enabled, AOT enabled)
16:24:21  OpenJ9   - 7f82a7d9d55
16:24:21  OMR      - 9083c8237ac
16:24:21  JCL      - 835a7f8fa78 based on jdk-23+18)

MockitoMockTest_0

16:51:12  Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface java.util.List, class java.lang.Object, interface java.util.Collection, class java.util.ArrayList, interface java.util.SequencedCollection, interface java.util.RandomAccess, class java.util.AbstractCollection, interface java.lang.Iterable, interface java.io.Serializable, interface java.lang.Cloneable, class java.util.AbstractList]
16:51:12  	at test.java.MockitoMockTest.main(MockitoMockTest.java:22)
16:51:12  Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface java.util.List, class java.lang.Object, interface java.util.Collection, class java.util.ArrayList, interface java.util.SequencedCollection, interface java.util.RandomAccess, class java.util.AbstractCollection, interface java.lang.Iterable, interface java.io.Serializable, interface java.lang.Cloneable, class java.util.AbstractList]
16:51:12  	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
16:51:12  	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
16:51:12  	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
16:51:12  	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
16:51:12  	... 1 more
16:51:12  Caused by: java.lang.IllegalStateException: 
16:51:12  Byte Buddy could not instrument all classes within the mock's type hierarchy
16:51:12  
16:51:12  This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
16:51:12   - Compiled by older versions of scalac
16:51:12   - Classes that are part of the Android distribution
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:285)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.mockClass(InlineBytecodeGenerator.java:218)
16:51:12  	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:78)
16:51:12  	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
16:51:12  	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
16:51:12  	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
16:51:12  	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
16:51:12  	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:75)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMockType(InlineDelegateByteBuddyMockMaker.java:414)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.doCreateMock(InlineDelegateByteBuddyMockMaker.java:373)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMock(InlineDelegateByteBuddyMockMaker.java:352)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:56)
16:51:12  	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:99)
16:51:12  	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:84)
16:51:12  	at org.mockito.Mockito.mock(Mockito.java:2104)
16:51:12  	at org.mockito.Mockito.mock(Mockito.java:2019)
16:51:12  	... 1 more
16:51:12  Caused by: java.lang.IllegalArgumentException: Java 23 (67) is not supported by the current version of Byte Buddy which officially supports Java 22 (66) - update Byte Buddy or set net.bytebuddy.experimental as a VM property
16:51:12  	at net.bytebuddy.utility.OpenedClassReader.of(OpenedClassReader.java:100)
16:51:12  	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:4011)
16:51:12  	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:2224)
16:51:12  	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4055)
16:51:12  	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3739)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.transform(InlineBytecodeGenerator.java:402)
16:51:12  	at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:242)
16:51:12  	at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
16:51:12  	at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:610)
16:51:12  	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
16:51:12  	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:225)
16:51:12  	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:281)
16:51:12  	... 16 more
@pshipton
Copy link
Member Author

Excluding for jdk23+ via adoptium/aqa-tests#5252

@babsingh
Copy link
Contributor

babsingh commented May 14, 2024

@sophiaxu0424 @LongyuZhang @llxia

@llxia
Copy link
Contributor

llxia commented May 14, 2024

We are using byte-buddy-1.14.12.jar https://github.com/adoptium/TKG/blob/master/scripts/getDependencies.pl#L78
We can try with the latest version 1.14.15 (https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy/1.14.15) to see if this version works with JDK23.

@sophiaxu0424
Copy link

Hi @llxia I am checking on using the latest version of byte-buddy for testing mockitoMockTest on JDK 23. wondering if you have a jdk url link that is working, the above Grinder link has expired and not able to find the jdk version. TIA!

@llxia
Copy link
Contributor

llxia commented May 22, 2024

wondering if you have a jdk url link that is working,

see CUSTOMIZED_SDK_URL in https://openj9-jenkins.osuosl.org/job/Test_openjdknext_j9_sanity.openjdk_x86-64_linux_Nightly/6/

@sophiaxu0424
Copy link

sophiaxu0424 commented May 22, 2024

Tried the latest byte-buddy version, and still mockito test failed,

13:57:05  Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.util.ArrayList, class java.lang.Object, class java.util.AbstractList, interface java.lang.Iterable, interface java.lang.Cloneable, class java.util.AbstractCollection, interface java.io.Serializable, interface java.util.List, interface java.util.Collection, interface java.util.RandomAccess, interface java.util.SequencedCollection]
13:57:05  	at test.java.MockitoMockTest.main(MockitoMockTest.java:22)
13:57:05  Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.util.ArrayList, class java.lang.Object, class java.util.AbstractList, interface java.lang.Iterable, interface java.lang.Cloneable, class java.util.AbstractCollection, interface java.io.Serializable, interface java.util.List, interface java.util.Collection, interface java.util.RandomAccess, interface java.util.SequencedCollection]
13:57:05  	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
13:57:05  	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
13:57:05  	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
13:57:05  	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
13:57:05  	... 1 more
13:57:05  Caused by: java.lang.IllegalStateException: 
13:57:05  Byte Buddy could not instrument all classes within the mock's type hierarchy

More error information could be found here in Grinder: https://hyc-runtimes-jenkins.swg-devops.com/job/Grinder/40765/console

JDK version

13:55:52  =JAVA VERSION OUTPUT BEGIN=
13:55:52  openjdk version "23-internal" 2024-09-17
13:55:52  OpenJDK Runtime Environment (build 23-internal-adhoc.jenkins.BuildJDKnextx86-64linuxPersonal)
13:55:52  Eclipse OpenJ9 VM (build master-6e1e36f06c9, JRE 23 Linux amd64-64-Bit Compressed References 20240502_1486 (JIT enabled, AOT enabled)
13:55:52  OpenJ9   - 6e1e36f06c9
13:55:52  OMR      - acd6f7e0b0c
13:55:52  JCL      - 604bc7a1731 based on jdk-23+20)

@tajila
Copy link
Contributor

tajila commented Jul 30, 2024

@sophiaxu0424 Do you know if there has been a recent update to bytebuddy

@sergey-morenets
Copy link

Still doesn't work even with ByteBuddy 1.15.3 which officially supports Java 23

@tajila tajila added the comp:vm label Oct 22, 2024
@tajila
Copy link
Contributor

tajila commented Oct 22, 2024

@theresa-m Please take a look at this

@theresa-m
Copy link
Contributor

I tried MockitoMockTest (enabled with https://github.com/theresa-m/openjdk-tests/tree/fix_19354) using ByteBuddy and byte-buddy-agent.jar 1.15.4 (https://github.com/theresa-m/TKG/tree/fix_19354). The test is passing for me.
Grinder: https://hyc-runtimes-jenkins.swg-devops.com/view/Test_grinder/job/Grinder/44308/

@theresa-m
Copy link
Contributor

adoptium/TKG#629 and adoptium/aqa-tests#5715 have been merged

Copy link

Issue Number: 19354
Status: Closed
Actual Components: comp:vm, test failure, test excluded, jdk23
Actual Assignees: No one :(
PR Assignees: pshipton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants