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

AbstractMethodError at MastodonClient.build() #524

Open
McPringle opened this issue Feb 7, 2025 · 4 comments
Open

AbstractMethodError at MastodonClient.build() #524

McPringle opened this issue Feb 7, 2025 · 4 comments

Comments

@McPringle
Copy link
Contributor

McPringle commented Feb 7, 2025

My project apus was working fine for about a year but since today it broke with the following exception when it calls new MastodonClient.Builder("mastodon.social").build():

java.lang.AbstractMethodError: Receiver class social.bigbone.nodeinfo.entity.Server$$serializer does not define or inherit an implementation of the resolved method 'abstract kotlinx.serialization.KSerializer[] typeParametersSerializers()' of interface kotlinx.serialization.internal.GeneratedSerializer.
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$typeParameterDescriptors$2.invoke(PluginGeneratedSerialDescriptor.kt:40)
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$typeParameterDescriptors$2.invoke(PluginGeneratedSerialDescriptor.kt:39)
	at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.getTypeParameterDescriptors$kotlinx_serialization_core(PluginGeneratedSerialDescriptor.kt:39)
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$_hashCode$2.invoke(PluginGeneratedSerialDescriptor.kt:44)
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$_hashCode$2.invoke(PluginGeneratedSerialDescriptor.kt:44)
	at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.get_hashCode(PluginGeneratedSerialDescriptor.kt:44)
	at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.hashCode(PluginGeneratedSerialDescriptor.kt:97)
	at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:937)
	at kotlinx.serialization.json.internal.DescriptorSchemaCache.get(SchemaCache.kt:37)
	at kotlinx.serialization.json.internal.DescriptorSchemaCache.getOrPut(SchemaCache.kt:29)
	at kotlinx.serialization.json.internal.JsonNamesMapKt.deserializationNamesMap(JsonNamesMap.kt:54)
	at kotlinx.serialization.json.internal.JsonNamesMapKt.getJsonNameIndexSlowPath(JsonNamesMap.kt:73)
	at kotlinx.serialization.json.internal.JsonNamesMapKt.getJsonNameIndex(JsonNamesMap.kt:97)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeObjectIndex(StreamingJsonDecoder.kt:229)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeElementIndex(StreamingJsonDecoder.kt:178)
	at social.bigbone.nodeinfo.entity.Server$$serializer.deserialize(Server.kt:11)
	at social.bigbone.nodeinfo.entity.Server$$serializer.deserialize(Server.kt:11)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.internal.NullableSerializer.deserialize(NullableSerializer.kt:30)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
	at social.bigbone.nodeinfo.NodeInfoClient.retrieveServerInfo(NodeInfoClient.kt:90)
	at social.bigbone.MastodonClient$Builder.getInstanceVersion(MastodonClient.kt:971)
	at social.bigbone.MastodonClient$Builder.build(MastodonClient.kt:1038)
	at swiss.fihlon.apus.MastodonTest.showPosts(MastodonTest.java:17)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1460)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2036)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)

How to reproduce:

  1. git clone https://github.com/McPringle/apus.git
  2. cd apus
  3. git checkout 332f323f339a5c2125657a78c6b0244d39f8af0a
  4. ./mvnw test -Dtest=swiss.fihlon.apus.MastodonTest

I wrote the test MastodonTest just to reproduce this error with as less code as possible. This is how the test class looks like:

public class MastodonTest {

    @Test
    void showPosts() throws BigBoneRequestException {
        final MastodonClient client = new MastodonClient.Builder("mastodon.social").build(); // AbstractMethodError
        final Range range = new Range(null, null, null, 10);
        final List<Status> posts = client.timelines().getTagTimeline("java", LOCAL_AND_REMOTE, range).execute().getPart();
        System.out.println(posts);
    }

}

Here are the two relevant snippets from the pom.xml:

        <!-- Enable snapshots to use BigBone Mastodon client API -->
        <repository>
            <id>maven-central-snapshots</id>
            <name>Maven Central Snapshot Repository</name>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <dependency>
            <groupId>social.bigbone</groupId>
            <artifactId>bigbone</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>

This project requires Java 21 or newer.

Fun fact: Two days ago it was working fine and I have no idea why this error shows up... 😜

McPringle added a commit to McPringle/apus that referenced this issue Feb 7, 2025
Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>
@bocops
Copy link
Collaborator

bocops commented Feb 7, 2025

There has been a new 2.0.0-SNAPSHOT release with some changes to the NodeInfoClient, which is probably why that error shows up for you now. I can't reproduce the error using your example code while building the library from scratch, though - and the AbstractMethodError documentation claims that "this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled".

I believe changes to SNAPSHOT releases are sometimes not properly detected, so could this just be a problem with an outdated cache or partial incremental build on your end?

@McPringle
Copy link
Contributor Author

McPringle commented Feb 7, 2025

I did a clean on the build and deleted the complete ~/.m2 directory. After some research with friends we have the suspicion that has to do with transitive Kotlin dependencies.

Image

kotlin-stdlib-jdk8 as a transitive dependency via okhttp3 vs. kotlin-stdlib as a dependency of BigBone.

Have you tried to reproduce using my four steps mentioned in the issue? If I create a plain project with BigBone as the only dependency, it works. If I use it in my project, it does not work. If I change the version of BigBone to 2.0.0-20240518.212224-30 (the previous one) it works fine with my project.

@bocops
Copy link
Collaborator

bocops commented Feb 10, 2025

@McPringle I now reproduced with your project.

Comparing our two snapshot releases, among other things we updated our dependency on org.jetbrains.kotlinx:kotlinx-serialization-json from 1.6.3 in the last to 1.8.0 in the current snapshot - and I can get the same error, both using your example as a BigBone sample as well as via several tests failing during a build, by just lowering the version to anything below 1.8.0 (including the previous 1.7.3).

In every case, the AbstractMethodError points to a non-existing method typeParametersSerializers() for one of our entities. I currently don't quite know what to make of that.

@McPringle
Copy link
Contributor Author

Thank you very much for reproducing my problem. Actually it does not hurry. In my project I do only a call to get public posts of a specific hashtag to show them on screen (it is a social wall), so I replaced the call to the BigBone library with a direct call to the REST endpoint and parse the JSON myself.

I'm preparing the wall for the Voxxed Days Zürich conference on March 25th and JavaLand conference on April 1st to 3rd and don't want to take any risk. 😅

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