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

EasyMock HEAD build fails on JDK21 #442

Closed
toby1984 opened this issue Jun 15, 2023 · 5 comments
Closed

EasyMock HEAD build fails on JDK21 #442

toby1984 opened this issue Jun 15, 2023 · 5 comments
Assignees
Milestone

Comments

@toby1984
Copy link

Hi,

Since JDK21 just entered RampDown Phase One and we want to switch to JDK21 ASAP after release, I tried building our project with OpenJDK 21 EA and ran into some failing EasyMock-based unit tests (tests were mocking classes).

The exact Java version I'm using (on Linux) is

openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+26-2328)
OpenJDK 64-Bit Server VM (build 21-ea+26-2328, mixed mode, sharing)

The exception I got during test execution was something along the lines of

Caused by: java.lang.IllegalArgumentException: com.ourpackage.SomeClass$$$EasyMock$2 must be defined in the same     package as org.easymock.internal.ClassProxyFactory
	at org.easymock.bytebuddy.dynamic.loading.ClassInjector$UsingLookup.injectRaw(ClassInjector.java:1635)
	at org.easymock.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:118)
	at org.easymock.bytebuddy.dynamic.loading.ClassLoadingStrategy$UsingLookup.load(ClassLoadingStrategy.java:519)
	at org.easymock.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
	at org.easymock.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6317)
	at org.easymock.internal.ClassProxyFactory.lambda$createProxy$0(ClassProxyFactory.java:146)
	at org.easymock.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	... 75 more

Checking the 'easymock-5.1.0' tag on the GitHub bytebuddy repo I saw that easymock includes a shaded version of bytebuddy 1.12.20 while the latest available release of bytebuddy is 1.14.5.

I then checked out master/HEAD of EasyMock (which is using the latest bytebuddy version 1.14.5. ) and tried to build the project using OpenJDK 21 EA but unfortunately unit test execution fails on ./test-nodeps/src/test/java/org/itests/NoDepsTest.java with the following error

Caused by: java.lang.IncompatibleClassChangeError: class org.easymock.mocks.CharBuffer$$$EasyMock$1 cannot inherit from sealed class java.nio.CharBuffer
    at java.base/jdk.internal.misc.Unsafe.defineClass0(Native Method)
    at java.base/jdk.internal.misc.Unsafe.defineClass(Unsafe.java:1330)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.easymock.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Enabled.defineClass(ClassInjector.java:2049)
    ... 54 more
@toby1984
Copy link
Author

Missed to clearly point out that our project is on EasyMock 5.1.0

@toby1984
Copy link
Author

I just installed EasyMock 5.2.0-SNAPSHOT (master/HEAD) and re-ran our project's unit tests with this snapshot version and now all tests are passing - so the upgraded bytebuddy dependency seems to have fixed it.

@basil
Copy link

basil commented Aug 11, 2023

I confirmed that our EasyMock based tests fail on Java 21 with EasyMock 5.1.0 and pass with EasyMock 5.2.0-SNAPSHOT at current HEAD. @henri-tremblay can HEAD please be released to facilitate the upgrade to Java 21?

@henri-tremblay
Copy link
Contributor

Released!

@basil
Copy link

basil commented Aug 30, 2023

Thank you very much!

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

3 participants