Skip to content

ClassCastException kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.List #581

Closed
@vtoupet

Description

@vtoupet

Current behavior

I am trying to access async storage from Java (i.e. Brownfield integration ->I implemented a widget in Java). I've followed the guide to read values

void readStorageValue(Context ctx, String key) {
    AsyncStorageAccess asyncStorage = StorageModule.getStorageInstance(ctx);

    BuildersKt.launch(GlobalScope.INSTANCE,
            Dispatchers.getIO(),
            CoroutineStart.DEFAULT,
            (scope, continuation) -> {
                List<String> keys = new ArrayList<>();
                keys.add(key);

                List<Entry> entries = (List<Entry>) asyncStorage.getValues(keys, (Continuation<? super List<? extends Entry>>) continuation);
                doSomethingWithValues(entries);

                return Unit.INSTANCE;
            });

}

When readStorageValue method gets called, my application crashes: ClassCastException kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.List

Expected behavior

The application should not crash

Repro steps

Environment

  • Platforms tested:
    • Android
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: 1.15.1
  • Environment:
    System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 66.86 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
    Binaries:
    Node: 15.11.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.6.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
    Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
    SDKs:
    iOS SDK:
    Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
    IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7199119
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
    Languages:
    Java: 15.0.2 - /usr/bin/javac
    npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.0 => 0.64.0
    react-native-macos: Not Found
    npmGlobalPackages:
    react-native: Not Found

Kotlin version 1.4.32

  • Logs/Errors that may be relevant:
java.lang.ClassCastException: kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.List
    at com.vtoupet.smartmixin.utils.Storage.lambda$readStorageValue$0(Storage.java:43)
    at com.vtoupet.smartmixin.utils.-$$Lambda$Storage$DXdrLrbhpt1sIvFEJaj9B7vmyWg.invoke
    at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$4.invokeSuspend(IntrinsicsJvm.kt:205)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions