Scrivio Interview library
LeadershipAdvanced7 min read · updated 12 November 2026

You maintain internal libraries used by hundreds of services, most on the class path. Should libraries add module-info.java, Automatic-Module-Name only, or nothing? Make a recommendation and explain the risks.

I would recommend that every internal library sets at least Automatic-Module-Name, which is low risk and gives modular consumers a stable name, and that libraries with clear, stable APIs ship a full module-info. A full descriptor brings real encapsulation but forces explicit decisions on exports, and changing those exports later can break modular consumers. Class path consumers, which are most of our services, ignore module-info and see no change. Whatever we choose, we must avoid split packages across libraries, because they block modular use later.

Why this question is asked

Maintaining libraries for hundreds of services means every decision is multiplied. A small change in packaging can be invisible to 299 consumers and break the 300th in a confusing way, and a decision we skip today can become a migration project in three years. Interviewers ask this at a senior level to see whether we can weigh the three options with their risks, and give a recommendation that is cheap now and keeps future options open. In this answer, we will recap what each option means for consumers, look at the risks of each, deal with split packages, and finish with a recommendation and a rollout plan.

1A Quick Recap: What Consumers See in Each Case

Our consumers fall into two groups. Most run on the class path, where all jars live in the unnamed module and any module-info.class is ignored. A few, now or later, run on the module path, perhaps a small tool built with jlink or a service that adopts modules. What our library ships only matters to the second group.

With nothing, a modular consumer gets our jar as an automatic module whose name is derived from the file name, such as acme.billing.client from acme-billing-client-2.3.1.jar. With Automatic-Module-Name in the manifest, the jar is still an automatic module, exporting everything, but with a stable name we chose. With a full module-info, the jar is a named module with exactly the requires and exports we declared, and everything else encapsulated.

2Option 1: Automatic-Module-Name Only

This is a single manifest line, and its main value is the name. A consumer who writes requires com.acme.billing.client today will keep working when we later add a full descriptor with the same name, whereas a consumer who had to write the derived name acme.billing.client would break. The risk is close to zero: class path consumers ignore the manifest attribute, and modular consumers get exactly the behaviour they had before, with a better name.

XML
<!-- Maven: maven-jar-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.acme.billing.client</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
// Gradle (Kotlin DSL)
tasks.jar {
manifest { attributes("Automatic-Module-Name" to "com.acme.billing.client") }
}

The one decision to get right is the name itself, because it must never change. The convention is the reverse domain name of the library's main package, which is unique within the company and matches what a future module-info would use. The limitation is that nothing is encapsulated: as an automatic module, the library still exports every package, including internal ones.

3Option 2: A Full module-info

A full descriptor gives what the manifest entry cannot: only exported packages are visible to modular consumers, dependencies are declared and checked, and internal packages are protected. For a library with a clear API, that is valuable, because it stops consumers from depending on internals.

The risks are about change. A descriptor forces us to decide, today, exactly which packages are API. If we leave out a package some consumer needs, they get compile errors or IllegalAccessError until we release a fix; if we later stop exporting a package, that is a breaking change for every modular consumer, even if no class changed. Requires matter too: if our API exposes types from another library, we need requires transitive, and getting it wrong breaks consumers' compilation. And the build gets more involved: tests running on the module path, and, if any consumer is still on Java 8, packaging module-info.class as a multi-release jar entry so that old tools scanning the jar do not trip over it.

4Option 3: Nothing

Doing nothing costs nothing today and works for every class path consumer. The risk is deferred: any modular consumer must use a derived name that we never chose and may break when we change the file name or add a name later, and a future move to descriptors starts from scratch. For a library used by hundreds of services, there is no good reason to pick this over option 1, because option 1 costs one line.

Comparing the three options
OptionClass path consumersModular consumersMain risk
NothingNo changeUnstable derived nameName breaks later
Automatic-Module-NameNo changeStable name, no encapsulationChoosing a bad name
Full module-infoNo changeStable name, real encapsulationExport changes break consumers
Class path consumers ignore both the manifest entry and module-info.

5Split Packages Across Libraries

One issue can block every option later, and it is worth checking now: split packages. If acme-logging and acme-metrics both put classes into com.acme.common, every class path consumer works fine, because the class path merges packages silently. But on the module path, two modules may not contain the same package, so a consumer that puts both libraries on the module path fails at startup, whether they are automatic modules or named ones.

Fixing a split package means moving classes to a different package, which is a breaking change for every consumer, so the earlier it is found, the cheaper it is. A simple CI job that lists the packages of every internal library and fails on duplicates prevents new splits, and existing ones get fixed in each library's next major version, typically by giving each library its own package root such as com.acme.logging and com.acme.metrics.

6The Recommendation and Rollout

My recommendation has three parts. Every internal library sets Automatic-Module-Name now, with a name based on its root package; we can add it in the shared build configuration so it reaches all libraries in one release. Libraries with clear, stable APIs and modest reflection, such as clients and utility libraries, ship a full module-info, owned by the library team, with exports treated as public API under the same versioning rules as classes. And split packages are banned by a CI check, with existing ones scheduled for the next major versions.

Step throughChoosing per library
  1. Every library: set Automatic-Module-Nameone line, stable name
  2. Does it share a package with another library?
    YesFix in the next major versionNoNext question
  3. Clear, stable API and little reflection?
    YesShip a full module-infoNoKeep Automatic-Module-Name only
  4. Descriptors: test with a modular consumer in CI

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

Low-risk defaults now; encapsulation where the API is ready for it.

To keep the risk low, every library with a descriptor gets a small test consumer in its own build that compiles and runs on the module path, so a broken export is caught before release. And we track which consumers actually run on the module path, so we know who would be affected by an export change.

7Follow-up questions

Does adding module-info really have no effect on class path consumers?

On the class path the JVM ignores module-info.class, so behaviour does not change. The rare problems come from old tools that scan jars and do not understand the class file version of module-info.class; packaging it under META-INF/versions/9 in a multi-release jar avoids that if old tools are still in use.

Should the Automatic-Module-Name match the module-info name later?

Yes, always. The whole value of setting it early is that the name modular consumers write in their requires never changes, so the future descriptor must use exactly the same name.

What if a consumer needs a package our descriptor does not export?

First check whether they should be using the API instead. If they have a real need, we either add it to the API in a new release or, if it is a closely related internal module, add a qualified export to that module. Telling them to use --add-exports is only a temporary bridge.

8Conclusion

In this answer, we compared shipping nothing, Automatic-Module-Name only, and a full module-info for internal libraries. Class path consumers ignore both the manifest entry and the descriptor, so they see no change. Automatic-Module-Name is a one-line, low-risk way to give modular consumers a stable name, while a full descriptor adds real encapsulation but makes exports a contract whose changes can break modular consumers. We avoid split packages across libraries because they block modular use later, and recommend Automatic-Module-Name for all libraries and full descriptors for those with clear APIs.

What to say in the interviewAbout 90 seconds aloud

Open with

My recommendation is at least Automatic-Module-Name for every library, and a full module-info for the libraries with clear, stable APIs. The reasoning starts with who is affected. Most of our services run on the class path, and class path consumers ignore both the manifest entry and module-info, so they see no change either way.

Then, if they want more

Only modular consumers care. Automatic-Module-Name is one manifest line, and it gives those consumers a stable name instead of one derived from the jar's file name, which can change or even be invalid. Because it does not change behaviour, the risk is very low, and when we later add a full descriptor with the same name, nobody breaks.

A full module-info gives real encapsulation: only exported packages are visible and dependencies are checked. But it forces us to decide exactly what our API is, and changing exports later is a breaking change for modular consumers, and requires transitive must be right if our API exposes other libraries' types.

So I would only do it where the API is clear and the team owns it, and I would test each such library with a small modular consumer in CI.

Separately, I would ban split packages across our libraries with a CI check, because two libraries sharing a package work on the class path but block any consumer from using them on the module path, and fixing that later is a breaking change.

About this answer

Last updated
12 November 2026
Versions it names
Java 8
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 "You maintain internal libraries used by hundreds of services, most on the class path....": https://scrivio-interview-library.netlify.app/java/modules/ca1446da45/