Not sure if this is the right channel to ask this ...
# android
c
Not sure if this is the right channel to ask this question, please tell where to post it if not: With Kotlin 1.9.10 the RxJava implementations cause crashes when deriving a Kotlin class from classes like
Observer<T>
. With Kotlin 1.8 one could write such a derived class like this:
Copy code
class ObservableObserver<T : Any?> : Observer<T> {

    override fun onNext(t: T) { ... }
    ...
}
Kotlin 1.9 requires (probably because of the @NonNull annotation in the interface) a non-nullable type:
Copy code
class ObservableObserver<T : Any?> : Observer<T> {

    override fun onNext(t: T & Any) { ... }
    ...
}
The RxJava implementation looks crappy, because they declare the data to be passend through Observers as non-nullable but themselves pass on
null
in classes like `DeferredScalarDisposable`:
Copy code
public final void complete(T value) {
        int state = get();
        if ((state & (FUSED_READY | FUSED_CONSUMED | TERMINATED | DISPOSED)) != 0) {
            return;
        }
        Observer<? super T> a = downstream;
        if (state == FUSED_EMPTY) {
            this.value = value;
            lazySet(FUSED_READY);
            a.onNext(null);
        } else {
            lazySet(TERMINATED);
            a.onNext(value);
        }
        if (get() != DISPOSED) {
            a.onComplete();
        }
    }
Is there a way to still use RxJava in derived Kotlin classes, or is it now required to implement RxJava classes in Java and use the interop features for any communication to Kotlin?