Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Would you mandate module descriptors for all new internal code in your company? Present the arguments both ways and your decision criteria.

I would not mandate module descriptors for all new internal code. They give explicit APIs, reliable configuration and enforced encapsulation of internal packages, but they cost real friction with Spring and other reflection-heavy frameworks, need opens for reflection, complicate builds and tests, and Spring Boot applications run on the class path anyway. Build-level module boundaries and ArchUnit or Spring Modulith give most of the encapsulation for applications. My criteria are the number of consumers, the need for jlink, framework compatibility and team skill, which usually leads to descriptors for shared libraries with clear APIs and no mandate for applications.

Why this question is asked

A mandate is a strong tool: it applies to every team, every new repository and every new hire, and it is hard to undo. The Java module system is a good example of a technology where the right answer depends on what the code is, and where a blanket rule can cost more than it saves. Interviewers ask this at the principal level to see whether we can present both sides honestly, separate libraries from applications, and turn the debate into criteria that teams can apply themselves. In this answer, we will recap what descriptors offer, go through the arguments for and against, look at the alternatives, set out the decision criteria, and finish with the decision and how to roll it out.

1A Quick Recap: What a Descriptor Gives Us

A module descriptor, module-info.java, turns a jar into a named module. It declares what the module requires and which packages it exports, and the JVM enforces it: unexported packages cannot be used from other modules even if their classes are public, missing dependencies are reported at startup instead of at the first call, and two modules containing the same package are refused. It also enables jlink with our own modules, creating a runtime image that contains exactly the modules an application needs.

That enforcement only happens on the module path. Code on the class path ignores module-info entirely and runs in the unnamed module, where everything can see everything. This one fact shapes most of the debate, because most Java applications today, including nearly all Spring Boot services, run on the class path.

2The Arguments For a Mandate

The strongest argument is explicit, enforced APIs. In a large codebase, internal packages leak: another team imports a helper from com.acme.billing.internal because it is public and convenient, and from then on the billing team cannot change it without breaking someone. A descriptor makes the boundary a compile error instead of a convention. Second, reliable configuration: a missing or duplicated dependency fails at startup with a clear message, rather than as NoClassDefFoundError hours later. Third, the descriptor is documentation that cannot go stale, since it is checked on every build. And fourth, descriptors are a prerequisite for some tools, such as jlink images built from our own modules and clean use of ServiceLoader-based plug-ins.

3The Arguments Against a Mandate

The costs fall mainly on applications. Spring, Hibernate and Jackson work by reflection on our classes, so every package with beans, entities, configuration properties or DTOs needs an opens directive to the right framework modules, and a missing one shows up as an InaccessibleObjectException at run time, often in a code path tests did not cover. Spring Boot's executable jar runs from the class path through its own launcher, so a descriptor in a Boot application adds work without being enforced in production unless the team changes how it packages and launches the service.

Builds and tests get harder too. Unit tests that live in the same package as the code must be patched into the module, which Maven and Gradle handle but with configuration that teams need to understand, and some plug-ins and tools still behave differently on the module path. Many third-party dependencies are automatic modules without descriptors or contain split packages, which blocks or complicates a fully modular build. Finally, there is the skill cost: most Java developers have never written a descriptor, and a mandate means every team learns it at once, often by copying descriptors they do not understand.

The case for and against
AreaFor descriptorsAgainst a mandate
EncapsulationInternal packages enforced by the JVMOnly enforced on the module path
ConfigurationMissing modules fail at startupAutomatic modules and split packages in deps
FrameworksClear list of what is openedopens needed for Spring, JPA, Jackson
Spring Boot appsDocuments the structureFat jar runs on the class path anyway
Builds and testsChecked on every buildTest patching, plug-in quirks
PeopleShared vocabulary for APIsNew skill for every team at once

4Alternatives That Give Similar Encapsulation

The goal behind the mandate, keeping internal code internal, can be reached in other ways. Build-level boundaries are the most common: split the code into separate Maven or Gradle modules, an api module and an impl module, and let consumers depend only on the api artifact; Gradle's api and implementation configurations make that precise. ArchUnit tests can check package rules inside a single artifact, for example that nothing outside billing depends on billing.internal, and fail the build when someone breaks them. For Spring Boot applications, Spring Modulith goes further: it treats top-level packages as application modules, verifies that other modules only use their public API, and documents the structure. None of these depend on the module path, so they work for Boot applications as they are deployed today.

5Decision Criteria

Rather than a yes or no for everyone, I would give teams criteria. The number of consumers matters most: a library used by 200 services gains a lot from an explicit, enforced API and a stable module name; an application used by nobody else gains little. The need for jlink with our own modules is a second criterion, relevant for small tools, CLIs and desktop applications. Framework compatibility is the third: a library with little reflection is easy to modularise, while a Spring Boot service with JPA entities is not. Team skill is the fourth: a team that maintains shared platform libraries can be expected to own descriptors; a product team shipping features weekly should not be slowed down by them.

Step throughShould this codebase have a module descriptor?
  1. Is it a library used by other teams?
    YesNext questionNoApplication: use build modules, ArchUnit or Modulith
  2. Heavy framework reflection or problem dependencies?
    YesAutomatic-Module-Name now, descriptor laterNoNext question
  3. Does the owning team have module system skills?
    YesFull descriptor with clear exportsNoAutomatic-Module-Name, train first

3 steps in order. Play them, or step through them one at a time.

Applications rarely need a descriptor; shared libraries usually benefit.

6The Decision and How to Roll It Out

My decision would be: no mandate for applications; every shared library sets at least an Automatic-Module-Name, a stable module name in its jar manifest, which costs one line; and libraries with clear, stable APIs and modest reflection ship a full descriptor. For applications, the standard is build-level module boundaries plus ArchUnit or Spring Modulith rules, which give enforced encapsulation without changing how services run.

The rollout is a short guide with examples, a template descriptor for libraries, a CI check that every library jar has a module name, and a review of the decision in a year with real data: how many encapsulation violations ArchUnit caught, how many consumers run on the module path, and whether any team needs jlink with its own modules. If those numbers grow, the policy can tighten. Starting narrow is cheap; withdrawing a mandate after a year of friction is not.

7Follow-up questions

Doesn't a descriptor in a library hurt class path consumers?

No. Class path consumers ignore module-info.class entirely, so they see no change. The descriptor only takes effect for consumers that put the library on the module path.

What if an application team wants to go fully modular anyway?

Let them, as an explicit choice with the costs understood, for example a small tool that benefits from a jlink image. The policy is a default and criteria, not a prohibition.

How do you keep library descriptors from breaking consumers?

Treat exports as public API: changes go through the same versioning rules as public classes, removing an export is a breaking change for modular consumers, and a test in the library's build compiles a small consumer module on the module path.

8Conclusion

In this answer, we weighed a mandate for module descriptors. They give explicit APIs, reliable configuration and enforced encapsulation, but bring friction with reflection-based frameworks, opens directives, build and test complexity, limited value in Spring Boot applications that run on the class path, and a skill cost. Build-level modules, ArchUnit and Spring Modulith give similar encapsulation for applications. Using criteria of consumers, jlink needs, framework compatibility and team skill, the decision is descriptors, or at least Automatic-Module-Name, for shared libraries and no mandate for applications.

What to say in the interviewAbout 80 seconds aloud

Open with

I would not mandate it for everything, and I would explain why with criteria rather than opinion. The arguments for are real: a descriptor makes the API explicit, the JVM enforces that internal packages stay internal, missing or duplicate dependencies fail at startup, and it enables jlink with our own modules.

Then, if they want more

The arguments against are mostly practical. Spring, Hibernate and Jackson reflect on our classes, so we need opens directives everywhere and get run-time errors when one is missing. Spring Boot executable jars run on the class path, where module-info is ignored, so for a Boot service the descriptor is mostly work without enforcement.

Tests and build tooling get more complex, many dependencies are automatic modules or have split packages, and most teams lack the skill. And there are alternatives: separate build modules with api and implementation artifacts, ArchUnit rules, or Spring Modulith give most of the encapsulation for applications.

So my criteria are how many consumers the code has, whether we need jlink, how much framework reflection is involved, and the team's skill. In practice that means every shared library sets at least an Automatic-Module-Name, libraries with clear APIs ship full descriptors, and applications use build modules and ArchUnit instead. I would review it after a year with data.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Would you mandate module descriptors for all new internal code in your company? Present...": https://scrivio-interview-library.netlify.app/java/modules/5f6b25e624/