Cannot use screenfragment from submodule in extending App

Hi,

I am trying to build for the first time and app based on submodules. For the sake of simplicity let’s assume I have a single submodule, and an App. The app extends screens from the submodule.

The extending app bases some of its screens on submodule screens, and I am getting issues when trying to reference screens and screenfragments, from both the extending app and the submodule.

For example I have a screen fragment from a submodule that has an onAttach listener, and depending on the FrameOwner class I execute different code paths. In one of the cases, the FrameOwner corresponds to a class from the App module, that derives from an A class in the submodule.

So when I try to execute:

if (fr instanceof A)

being fr the FrameOwner, the fr instance although being effectively derived from A won’t be recognized as such. However if debugging it will recognize it as an A derived class.

Another problem is that I have ScreenFragment class in the submodule, and when trying to operate on it in the extending app, I get messages such as

ClassCastException class B is in unnamed module of class loader … and class B is in unnamed module of class loader AppLoader

(or something like that, sorry if it is not a literal reproduction of the message)

Leaving the rest equal, I develop screens, entities and beans in the regular fashion. So I presume both errors have to do with class loaders, since instances although being of the same class file, since they come from different loaders, they won’t be able to interact, unless I use reflection.

But reflection looks as a dirty solution in this context where benefits of modularity are seeked.

I would greatly appreciate some help on this issue. Otherwhise I won’t be able to obtain the benefits promised by modularity and extension capabilities of the plattform.

One last suggestion, this looks as a basic and initial scenario to me when using modularity, but it is not reflected in any of the documentation entries. Have looked around and nothing seems to point to a solution. I kindly suggest to include this step or a mention to it in the Modularity and Extension documentation entry, if anything needs to be setup (app property?, gradle setting?) or ammended in order to clarify things to the user.

Thanks again and please help me solve this problem.

Regards,

Carlos.

Hi,

Could you please attach a small demo project that reproduces the problem?

Regards,
Gleb

Hi Gleb,

sorry for not answering sooner. I was rebuilding a full new project essaying to reproduce the issue, and I might have understood something wrong because in the sample project the problem went away. After checking that I approached a revisión of my app and suddenly in the next run the problem went away.

To be honest I have not identified the problem. But the problem is now gone.

Sorry and apologize for my first post since the mistake was clearly on my side.

Regards,

Carlos.