how to multiple inheritence in ExpoKit create module

I’m put jar file in libs and making modules to use jar file in react-native.

I know that I must inherit ‘ReactContextBaseJavaModule’ to make a react module.

This has caused problems related to inheritance.

java file:

import io.realm.RealmObject;
...

public class let extends RealmObject {
...
}

As you can see, it inherits RealmObject.

But I mentioned it before.When creating a module, we had to inherit ReactContextBaseJavaModule, so we couldn’t inherit RealmObject

letmodule.java:

import com.facebook.react.bridge.ReactContextBaseJavaModule;
...

public class letmodule extends ReactContextBaseJavaModule {
...
}

othermodule.java:

import com.letmodule;
import io.realm.Realm;
...
public class othermodule extends ReactContextBaseJavaModule {
...
Realm realm = Realm.getDefaultInstance();
if (realm.where(letmodule.class).count() > 0) {...}
...

letmodule send = realm.createObject(letmodule.class, nextId);
...

for (letmodule send : realm.where(letmodule.class).findAll()) {

So the code at the top is an error in realm.

error: method where in class Realm cannot be applied to given types;
required: Class<E>
found: Class<letmodule>
reason: inferred type does not conform to upper bound(s)
inferred: letmodule
upper bound(s): RealmModel
where E is a type-variable:
E extends RealmModel declared in method <E>where(Class<E>)

How can I fix this error?

Please help me a lot.

I’ve been thinking about it since I mentioned the need to write a “composition”.

But the one thing I don’t understand is that the “letmodule” class has to inherit “RealmObject” so the error disappears. is it possible to solve it with “composition”?

The module cannot be applied from the JavaScript unless it inherits ReactContextBaseJavaModule from the class that creates the module. This is because the module.add part of the Package folder fails, the constructor fails in the ‘Module’ file and cannot write @OVERRIDE.

How can I get rid of that error if I have to inherit RealmObject?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.