If I have understood the question correctly what you're looking forward to using are Services from the module system.
Java has long supported services via the java.util.ServiceLoader
class, which locates service providers at run time by searching the
classpath.
The module system could identify uses of services by scanning the class files in module artifacts for invocations of the ServiceLoader::load
method.
With your current project structure, you should define an abstract class
or an interface
that can be a extended of implemented in the guava
, core
module classes and is provided by them.
A module uses a particular service is an important aspect of that module’s definition, so for both efficiency and clarity its expressed in the module’s declaration with a uses
clause:
module com.foo.bar.sql {
uses com.foo.Verifiers;
}
A module provides an implementation of a particular service is equally fundamental, however, this is put in the module’s declaration with a provides
clause:
module guava {
provides com.foo.Verifiers with com.guava. GuavaVerifier;
}
module core {
provides com.foo.CoreVerifier with com.guava. GuavaVerifier;
}