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

NoClassDefFoundError: kotlin.collections.EmptySet #23

Closed
LikeTheSalad opened this issue Nov 6, 2023 · 4 comments · Fixed by #24
Closed

NoClassDefFoundError: kotlin.collections.EmptySet #23

LikeTheSalad opened this issue Nov 6, 2023 · 4 comments · Fixed by #24

Comments

@LikeTheSalad
Copy link

Hi!

I've just tried to bump up the signature version to the latest one 0.6.0 in this project but after doing so I get this error every time I try to run the animalsnifferMain task:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':auto-instrumentation:okhttp:okhttp-3.0:library:animalsnifferMain'.
Caused by: : java.lang.NoClassDefFoundError: kotlin.collections.EmptySet
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:109)
	at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:90)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:541)
	at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:218)
	at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
	at org.gradle.api.internal.project.antbuilder.AntBuilderDelegate.nodeCompleted(AntBuilderDelegate.java:124)
	at ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer$_run_closure3$_closure11.doCall$original(AnimalSniffer.groovy:172)
	at ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer$_run_closure3$_closure11.doCall(AnimalSniffer.groovy)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer$_run_closure3.doCall$original(AnimalSniffer.groovy:169)
	at ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer$_run_closure3.doCall(AnimalSniffer.groovy)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at org.gradle.util.internal.ClosureBackedAction.execute(ClosureBackedAction.java:73)
	at org.gradle.util.internal.ClosureBackedAction.execute(ClosureBackedAction.java:54)
	at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder.lambda$execute$0(DefaultIsolatedAntBuilder.java:136)
	at org.gradle.api.internal.project.antbuilder.DefaultIsolatedAntBuilder.lambda$execute$2(DefaultIsolatedAntBuilder.java:158)
	at ...

It seems like some kotlin dependencies aren't available for the task to run properly. Any ideas on how it could be solved? I tried to add the kotlin std lib dependency here without luck so far.

@ogolberg
Copy link
Member

ogolberg commented Nov 7, 2023

Animal Sniffer uses java serialization for signature data. I converted the code that generates the signatures to Kotlin and likely changed the actual type of this set /~https://github.com/mojohaus/animal-sniffer/blob/master/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/Clazz.java#L50 in some cases.

I will post a fix shortly.

@LikeTheSalad
Copy link
Author

Got it, thanks!

ogolberg added a commit that referenced this issue Nov 7, 2023
Because Animal Sniffer signatures are serialized using Java
Serialization, we need to make sure that the types embedded into the
signatures are available on the classpath when Animal Sniffer is run.
Specifically, for Clazz.signatures, when the set is empty, Kotlin's
toSet method will return a kotlin.collections.EmptySet. This change
ensures that a plain HashSet is always used.

Fixes #23.
@ogolberg
Copy link
Member

ogolberg commented Nov 7, 2023

Fixed in 0.6.1, thanks for reporting!

@LikeTheSalad
Copy link
Author

Cool! I checked and it's working now, cheers.

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

Successfully merging a pull request may close this issue.

2 participants