Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

What are automatic modules and the unnamed module? How is an automatic module's name chosen?

An automatic module is what a jar without a module-info becomes when we put it on the module path. Its name comes from the Automatic-Module-Name entry in the jar's manifest, or, if there is none, is derived from the jar's file name. Automatic modules export and open all their packages and read every other module, including the unnamed module. The unnamed module is where all class path code lives: it reads every module, but named modules cannot require it because it has no name. File-name-derived names are unstable, so libraries should set Automatic-Module-Name.

Why this question is asked

When the module system arrived in Java 9, almost no library had a module descriptor, and most still do not today. If modular applications could only use fully modular libraries, nobody could have adopted modules at all. Automatic modules and the unnamed module are the two bridges that let old and new code work together. Interviewers ask about them because they explain most of the confusing behaviour in mixed applications, and because the naming rule causes real breakage for library consumers. In this answer, we will recap named modules, look at automatic modules and how their names are chosen, look at the unnamed module, see how the three kinds of module interact, and finish with why libraries should set Automatic-Module-Name.

1A Quick Recap: Named Modules

A named module is a jar or directory with a module-info.class. It has a name, such as com.acme.orders, a list of modules it requires and a list of packages it exports and opens. The module system enforces all of that: other modules can only use exported packages and only if they require the module. Named modules are the ideal, but they assume every dependency is also a module, which is rarely true. That gap is what the other two kinds fill.

2Automatic Modules: Old Jars on the Module Path

Put a plain jar, one without module-info, on the module path, and the module system turns it into an automatic module. Because the jar says nothing about its dependencies or its API, the module system makes generous assumptions: an automatic module exports and opens every package it contains, reads every other module in the configuration, including the unnamed module, and grants implied readability to all other automatic modules. Service providers listed in META-INF/services become provides declarations.

The point of these rules is that a named module can now write requires for an old library and use it as if it were modular. That makes migration possible from the top down: an application can modularise its own code before its dependencies have done so.

3How an Automatic Module's Name Is Chosen

An automatic module needs a name so that named modules can require it. The module system looks in two places. First, the Automatic-Module-Name attribute in the jar's META-INF/MANIFEST.MF: if it is present, that is the name. Otherwise, the name is derived from the file name: drop the .jar suffix, cut off everything from a hyphen followed by a digit, which is taken as the version, replace every character that is not a letter or digit with a dot, collapse repeated dots, and remove leading and trailing dots.

Properties
# Without Automatic-Module-Name
jar --describe-module --file acme-billing-client-2.3.1.jar
# No module descriptor found. Derived automatic module.
#
# acme.billing.client@2.3.1 automatic
# requires java.base mandated
# contains com.acme.billing.client
# contains com.acme.billing.client.internal
# With Automatic-Module-Name: com.acme.billing.client in the manifest
# com.acme.billing.client@2.3.1 automatic
# A derived name can even be invalid
java --module-path libs -m com.acme.app/com.acme.App
# FindException: Unable to derive module descriptor for libs/my-native-lib-1.0.jar
# Caused by: java.lang.IllegalArgumentException: my.native.lib: Invalid module name:
# 'native' is not a Java identifier
Deriving a name from the file name
Jar fileDerived module nameWhy
acme-billing-client-2.3.1.jaracme.billing.clientVersion cut at -2, hyphens become dots
commons-lang3-3.17.0.jarcommons.lang3Version starts at -3.; real name differs
foo_bar-SNAPSHOT.jarfoo.bar.SNAPSHOTNo digit after a hyphen: nothing cut
my-native-lib-1.0.jarmy.native.lib (invalid)native is a keyword: startup fails
commons-lang3 actually declares Automatic-Module-Name org.apache.commons.lang3, which takes precedence.

Notice the first two results. The same jar gets the name acme.billing.client from its file name, and com.acme.billing.client when the manifest sets it. A consumer who wrote requires acme.billing.client would break the day the library adds the manifest entry. That is the instability the question refers to: derived names depend on how the jar file happens to be named, which can differ between build tools, repositories and versions, and they can collide with Java keywords such as native, as the last example shows.

4The Unnamed Module: Everything on the Class Path

Every class loaded from the class path belongs to one unnamed module, one per class loader. It is what keeps old applications working unchanged on new JDKs. The unnamed module reads every other module, so class path code can use any exported package of any named module, and it exports all its own packages. When an application runs entirely from the class path, as most do, all of its code and all of its libraries are in the unnamed module, and the JDK's own modules are the only named modules around.

There is one restriction, and it is a big one: a named module cannot require the unnamed module, because requires needs a name and the unnamed module has none. So named modules cannot see class path code at all. This is deliberate. If modules could depend on the class path, their configuration could never be checked reliably, which was the whole point of modules.

5How the Three Kinds Work Together

Putting the rules together explains the bridge. A named module can read an automatic module, because the automatic module has a name. The automatic module reads the unnamed module, so it can use classes from the class path. The unnamed module reads everything. So in a mixed application, the usual layout is: our code as named modules, the old libraries it depends on directly as automatic modules on the module path, and anything else left on the class path.

Step throughWho can see whom
  1. Named modulesread only what they require; see exported packages only
  2. Automatic moduleshave a name; read every module, including the unnamed one; export all
  3. Unnamed module (class path)reads every module; cannot be required by named modules
  4. JDK modulesjava.base and the others: named modules read by everything above

4 layers, from the top down. Step through them one at a time.

Automatic modules are the bridge from named modules to class path code.

But there is a catch that follows from the generous rules. Since automatic modules export everything and read everything, they add no encapsulation, and since a package may belong to only one module, two automatic modules with the same package are a split package and stop the application. Moving a jar from the class path to the module path is therefore not free; it is the step where split packages and bad names come to light.

6Why Libraries Should Set Automatic-Module-Name

For a library author, the cheapest useful step is a single manifest line. With Automatic-Module-Name set, every modular consumer gets the same stable name, whatever the jar file is called, and the library can later add a full module-info with the same name without breaking anyone. The convention is a reverse domain name based on the library's main package, such as com.acme.billing.client, the same rule a full descriptor would use. Class path consumers ignore the manifest entry entirely, so the change carries almost no risk, which is why many major open source libraries added it years before they shipped descriptors, and some never went further.

7Follow-up questions

Can an automatic module be required with requires transitive?

Yes. A named module can say requires transitive on an automatic module, which is how an API that exposes an old library's types can pass readability on to its own consumers.

Why does javac warn about requires directives on automatic modules?

With -Xlint, javac warns when a module requires an automatic module whose name was derived from the file name, because that name is unstable. It does not warn when the name comes from Automatic-Module-Name, which is another reason for libraries to set it.

Can jlink include automatic modules?

No. jlink only links named modules with explicit descriptors, because an automatic module's dependencies are unknown. Applications that depend on automatic modules can still use jlink for the JDK modules and put the libraries on the module path or class path at launch.

8Conclusion

In this answer, we saw that a jar without a module-info on the module path becomes an automatic module, named by its Automatic-Module-Name manifest entry or by a name derived from its file name, and that automatic modules export and open all their packages and read every module, including the unnamed one. The unnamed module holds all class path code, reads every module, and cannot be required by named modules, so automatic modules are the bridge between them. Because derived names change with file names and can even be invalid, libraries should set Automatic-Module-Name.

What to say in the interviewAbout 80 seconds aloud

Open with

An automatic module is what a plain jar without module-info becomes when it is on the module path. The module system has to make assumptions about it, so it exports and opens all of its packages, reads every other module, including the unnamed module, and its service files become provides.

Then, if they want more

The name matters because named modules require it by name. If the jar's manifest has an Automatic-Module-Name entry, that is the name. Otherwise the name is derived from the file name: remove .jar, cut off the version starting at a hyphen followed by a digit, and turn other non-alphanumeric characters into dots. So acme-billing-client-2.3.1.jar becomes acme.billing.client.

That derived name is unstable, because it depends on how the file is named, and it can even be invalid, for example if it contains a keyword like native. That is why libraries should set Automatic-Module-Name, which gives modular consumers a stable name that a future module-info can keep. The unnamed module is where everything on the class path lives.

It reads every module and exports everything, but a named module cannot require it, because it has no name. So in mixed applications, automatic modules are the bridge: named modules require them, and they can see class path code.

About this answer

Last updated
12 November 2026
Versions it names
Java 9
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 "What are automatic modules and the unnamed module? How is an automatic module's name...": https://scrivio-interview-library.netlify.app/java/modules/eed9aa8c1a/