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

1.16.0 and jdk 25-ea #1755

Open
hazendaz opened this issue Jan 18, 2025 · 1 comment
Open

1.16.0 and jdk 25-ea #1755

hazendaz opened this issue Jan 18, 2025 · 1 comment

Comments

@hazendaz
Copy link

Various products were working fine with 1.5.11 with jdk 25-ea on github actions. They are all now failing.

See https://github.com/Waffle/waffle/actions/workflows/ci.yaml

Note other libraries came in without issue.

org.mockito.exceptions.base.MockitoException: 

Mockito cannot mock this class: interface org.springframework.security.core.Authentication.

If you're not sure why you're getting this error, please open an issue on GitHub.


Java               : 25
JVM vendor name    : Eclipse Adoptium
JVM vendor version : 25-beta+5-ea
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 25-beta+5-ea
JVM info           : mixed mode, sharing
OS name            : Windows Server 2022
OS version         : 10.0


You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.

Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface java.security.Principal, interface org.springframework.security.core.Authentication, interface java.io.Serializable]
	at waffle.spring.DelegatingNegotiateSecurityFilterTest.testNegotiate_CustomAuth(DelegatingNegotiateSecurityFilterTest.java:154)
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface java.security.Principal, interface org.springframework.security.core.Authentication, interface java.io.Serializable]
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
	... 1 more
Caused by: java.lang.IllegalStateException: 
Byte Buddy could not instrument all classes within the mock's type hierarchy

This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
 - Compiled by older versions of scalac
 - Classes that are part of the Android distribution
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:289)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.mockClass(InlineBytecodeGenerator.java:218)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:78)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:75)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMockType(InlineDelegateByteBuddyMockMaker.java:406)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.doCreateMock(InlineDelegateByteBuddyMockMaker.java:365)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMock(InlineDelegateByteBuddyMockMaker.java:344)
	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:56)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:99)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:84)
	at org.mockito.Mockito.mock(Mockito.java:2185)
	at org.mockito.Mockito.mock(Mockito.java:2100)
	... 1 more
Caused by: java.lang.IllegalStateException: Could not invoke proxy: Method not available on current VM: net.bytebuddy.jar.asmjdkbridge.JdkClassReader.<init>([B)
	at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForUnresolvedMethod.invoke(JavaDispatcher.java:1086)
	at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1163)
	at net.bytebuddy.utility.AsmClassReader$Factory$Default$5.make(AsmClassReader.java:141)
	at net.bytebuddy.utility.AsmClassReader$Factory$Default.make(AsmClassReader.java:180)
	at net.bytebuddy.utility.AsmClassReader$Factory$Default$2.make(AsmClassReader.java:102)
	at net.bytebuddy.utility.AsmClassReader$Factory$Default$1.make(AsmClassReader.java:89)
	at net.bytebuddy.utility.AsmClassReader$Factory$Default.make(AsmClassReader.java:180)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:4031)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:2246)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4085)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3769)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.transform(InlineBytecodeGenerator.java:406)
	at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:257)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:285)
	... 16 more

I haven't looked into it any further yet but wanted to report the issue since 1.5.11 works fine, only change is this update to 1.16.0.

@raphw
Copy link
Owner

raphw commented Jan 18, 2025

Indeed. I made a last minute change and testing MR Jars with Maven is a pain, so I punched a hole. I know what's wrong and will release a fix tonight.

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

No branches or pull requests

2 participants