"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to connect modular and non-modular Java code to automatic modules?

How to connect modular and non-modular Java code to automatic modules?

Posted on 2025-04-13
Browse:844

How Do Automatic Modules Bridge the Gap Between Modular and Non-Modular Java Code?

What Makes an Automatic Module?

Automatic modules, a prevalent topic on Stackoverflow, are created automatically by the Java module system from non-modular JARs on the module path. These modules enable modular dependencies on legacy code.

Module Properties

  • Name: Derived from the Automatic-Module-Name manifest header or the JAR filename
  • Requires: Automatically granted access to all other modules including the unnamed module (the class path)
  • Exports/Opens: All packages are exported and opened for reflection

Additional Features

  • Automatic modules provide services listed in META-INF/services.
  • They can be launched via their Main-Class entry.

Purpose of Automatic Modules

Automatic modules serve to bridge the gap between modular and non-modular code, allowing modular JARs to depend on plain JARs. They act as a bridge between modules and the class path.

By placing plain JARs on the module path and requiring their automatically created modules, developers can retain class path dependencies while maintaining module functionality. As dependencies become modular, they can seamlessly transition onto the bridge, drawing their own dependencies as automatic modules. This process gradually modularizes the ecosystem while preserving connectivity between legacy code and modern modules.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3