Introduce JPMS module-info.java declarations to enforce architectural layer boundaries
#19
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The project has a well-defined three-layer architecture (
core→sdk→app),but this layering is currently enforced only by convention. Nothing in the build
prevents
app-layer code from importingzeroecho.core.alg.*orzeroecho.core.spi.*directly, bypassing thesdkabstraction entirely. As thecodebase grows and external contributors appear, this silent coupling will
inevitably occur.
Why this matters
Architectural boundaries that are not machine-enforced tend to erode. JPMS
module-info.javadeclarations make violations a compile-time error rather than areview-time catch. They also improve IDE tooling, enable strong encapsulation of
internal packages, and signal maturity to library consumers.
The project already targets Java 21 and uses Gradle 9.4, both of which support
JPMS without friction.
Proposed change
Introduce
module-info.javain each subproject:zeroecho.core— exportszeroecho.coreandzeroecho.core.contextpublicly;exports
zeroecho.core.alg,zeroecho.core.spi,zeroecho.core.marshal, andother internal packages only
to zeroecho.sdk; declaresuses zeroecho.core.CryptoAlgorithmforServiceLoader.zeroecho.sdk— exportszeroecho.sdk.builders,zeroecho.sdk.content.api,and
zeroecho.sdk.hybrid; keepszeroecho.sdk.content.builtinandzeroecho.sdk.integrationsinternal.zeroecho.app— no exports (application module).SPI providers must add
provides zeroecho.core.CryptoAlgorithm with ...in theirown
module-info.java.Acceptance criteria
lib,app,pki) has a validmodule-info.java.javacrejects any direct import ofzeroecho.core.alg.*fromapp-layercode.
ServiceLoaderdiscovery ofCryptoAlgorithmcontinues to work in both modularand classpath modes.
--module-pathcompilation.