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

Multiple @RealmModules with same class name can cause erroneous schema definitions #7860

Closed
rorbech opened this issue Nov 29, 2023 · 4 comments
Labels

Comments

@rorbech
Copy link
Contributor

rorbech commented Nov 29, 2023

How frequently does the bug occur?

Sometimes

Description

Defining a library and an app module with an @RealmModule with a equal class name can cause configurations to pick up the wrong schema. Both @RealmModule-classes must have the same name (but needs to be in separate packages to avoid class name overlaps).

Library:

package io.realm.library
@RealmModule(library = true, allClasses = true)
class Module

App:

package io.realm.app
@RealmModule(allClasses = true)
class Module

Due to the layout of our mediators both of the above modules will generate a mediator class named io.realm.ModuleMediator. For some reason compilation of the final app will silently discard one of the classes instead of throwing a compilation error.

Note: Somehow the project setup can be dictating how the final app is build and which of the two modules that will end up in the final package. Thus, it is not guaranteed to fail.

Similar issue reported in #7855

Stacktrace & log output

No response

Can you reproduce the bug?

Sometimes

Reproduction Steps

No response

Version

1.17.0

What Atlas App Services are you using?

Both Atlas Device Sync and Atlas App Services

Are you using encryption?

No

Platform OS and version(s)

Android API 33

Build environment

Android Build Tools version: 8.1.4
Gradle version: 8.3

@rorbech
Copy link
Contributor Author

rorbech commented Dec 4, 2023

Since there is an immediate workaround by just avoiding name overlaps, we have no immediate plans of fixing this.

@rorbech rorbech closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
@andriy-svirskyy
Copy link

How about inability to avoid name overlaps in third party libraries provided without the source code?

@rorbech
Copy link
Contributor Author

rorbech commented Dec 4, 2023

Hi @andriy-svirskyy. It will of course be a problem if you don't control source code of external libraries. Do you have such use cases and with which libraries?

On this note, we are working on Realm Kotlin which does not have such issues. Have you consider migrating to that instead?

@andriy-svirskyy
Copy link

Hi @rorbech, afraid there are no migration plans to Kotlin.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants