Question looks easy, and probably has an easy solution, but I didn't find one.
Given module A that needs module B, which in turn needs module C.
Module A should not need to know about module C. I well guess this is one major point about using modules.
How to do that? (I have found many oversimplified examples for declaring A to require B, but B never required anything else.)
The question is general, but in my example case, I have a project "Tracker" (corresponding to module A) and a project "Poppy" (corresponding to module B) which in turn depends on modules from javafx.
"Poppy" pops up a popup, and when on its own, works fine. "Tracker" has no use of javafx, except indirectly via "Poppy", but Poppy might be changed to use Swing instead of javafx, or other graphics libraries.
module-info are
module Tracker {
    requires transitive Poppy;
    opens tracker to pop;
}
and
module Poppy {
    requires transitive javafx.graphics;
    requires transitive javafx.controls;
    requires transitive javafx.base;
    opens pop to javafx.graphics, javafx.fxml;
    exports pop;
    
}
Where pop is the package name for the main class pop.Poppy.
Tracker calls Poppy.popup()
with
public static void popup() {
    Scene scene;
    Stage st = new Stage();
    VBox r2 = createRoot(null);
    scene = new Scene(r2);
    st.setScene(scene);
    st.show();
}
The call (developing with eclipse) result in java.lang.module.FindException: Module javafx.controls not found, required by Poppy.
Other tries resulted in complaints about other javafx.thingy not found.
Eclipse does not show me any (compile) errors. Just to double-check, in Poppy I changed the method name popup() to xpopup() and got the expected error for Tracker that there is no Poppy.popup().
So Tracker is aware of Poppy (but not of javafx, or anything Poppy cares to depend on, and rightfully should not be).
Meanwhile, I suspected the imports as a possible cause, and moved them to a different class in a different package that is not exported, now the pop package is clean of any direct references to javafx but calls a static method of a different class in a different package.
No success.
Has anyone out there ever done that before, nesting three modules A, B and C such that A doesn't need to have to declare all the stuff needed by B, C and whatever C and its dependencies might be using?
What am I missing?
The answers were guessing right, it is a XYProblem, or, as I like to put it: I tried to fix the healthy leg instead of the broken one.


Poppyasrequires transitive, and not just plainrequires? Because by declaring ittransitive, your telling the module system thatTrackerwill also require on all modules thatPoppyrequires. That seems contradictory with your claim thatTrackerdoesn't need to know that.Tracker(assuming you removedtransitive) but about the fact that the initialization of a module layer requires all dependencies, including indirect ones, to be present right at the start. Which removes the problem of failing at a later time, when required classes are missing. So if you want to runTrackerwhich depends onPoppywhich depends on JavaFX, then, of course, JavaFX must be present. How else is it supposed to work?