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

IllegalStateException when running with multi-release jars (i.e. since 1.15.5) #1748

Closed
lenggi opened this issue Jan 13, 2025 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@lenggi
Copy link

lenggi commented Jan 13, 2025

Hi
We are experiencing an issue since Byte Buddy is published with multi-release jars.

In some rare cases, we hit the following exception

Field with name invocationHandler$92met31 and type interface java.lang.reflect.InvocationHandler already declared by class net.bytebuddy.renamed.java.lang.Object$ByteBuddy$MaWbun1g
java.lang.IllegalStateException: Field with name invocationHandler$92met31 and type interface java.lang.reflect.InvocationHandler already declared by class net.bytebuddy.renamed.java.lang.Object$ByteBuddy$MaWbun1g
	at net.bytebuddy.implementation.InvocationHandlerAdapter$ForInstance.prepare(InvocationHandlerAdapter.java:363)
	at net.bytebuddy.dynamic.scaffold.MethodRegistry$Handler$ForImplementation.prepare(MethodRegistry.java:227)
	at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:460)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.toTypeWriter(SubclassDynamicTypeBuilder.java:222)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.toTypeWriter(SubclassDynamicTypeBuilder.java:213)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4085)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3769)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:4021)
	at com.airlock.poc.bytebuddy.ListProxyInvocationHandler.createWrapperType(ListInvocationHandler.java:111)

The exception consistently is thrown with Byte Buddy v1.15.5 and later, with v1.15.4 we do not have any problems.

When debugging the issue, it seems that the hashcode calculated on net.bytebuddy.dynamic.scaffold.MethodRegistry.Handler.ForImplementation and implicitly used at net.bytebuddy.dynamic.scaffold.MethodRegistry.Default#prepare:70 by the hash map handlers differs in some cases between the above mentioned versions. This then leads to duplicate preparations of the same handler.

An example to reproduce the issue is attached.
reproduce-illegalstate-exception.zip

@lenggi lenggi changed the title IllegalStateException when running mit multi-release jars (i.e. since 1.15.5) IllegalStateException when running with multi-release jars (i.e. since 1.15.5) Jan 13, 2025
@raphw
Copy link
Owner

raphw commented Jan 14, 2025

It seems like the hash code and equals methods were not added, and this makes total sense given the current build setup, so it does not recognize the duplication. Sorry for that, this went fully unnoticed.

@raphw raphw self-assigned this Jan 14, 2025
@raphw raphw added this to the 1.15.11 milestone Jan 14, 2025
@raphw
Copy link
Owner

raphw commented Jan 14, 2025

I fixed the build issue (Maven is certainly starting to reach its limit when it comes to building Byte Buddy...) and tested on your project and it now works. This will be released soon, or you can build the master branch.

@lenggi
Copy link
Author

lenggi commented Jan 14, 2025

Great! Thank you very much!

@raphw
Copy link
Owner

raphw commented Jan 19, 2025

Fixes in 1.16.1

@raphw raphw closed this as completed Jan 19, 2025
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

2 participants