Home > Java > javaTutorial > Java 9 Module Descriptor Errors: How to Handle Auto-Generated Names like \'native\'?

Java 9 Module Descriptor Errors: How to Handle Auto-Generated Names like \'native\'?

Barbara Streisand
Release: 2024-11-28 17:36:10
Original
787 people have browsed it

Java 9 Module Descriptor Errors: How to Handle Auto-Generated Names like

Java 9 Unable to Derive Module Descriptor for Auto Generated Names: Exploring Workarounds

In Java 9, the introduction of modules brought forth a requirement to define module names according to Java identifier rules. However, this requirement poses a challenge for certain auto-generated module names, particularly those that include the keyword "native."

Consider the case of the Netty Epoll transport dependency:

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-transport-native-epoll</artifactId>
    <version>${netty.version}</version>
    <classifier>${epoll.os}</classifier>
</dependency>
Copy after login

The auto-generated module name for this dependency is "netty.transport.native.epoll," which violates Java identifier rules due to the presence of the "native" keyword.

To address this issue, one potential workaround lies in modifying the artifact's META-INF/MANIFEST.MF file to include the Automatic-Module-Name attribute. This attribute defines the module name as it should be used in the module descriptor:

<manifestEntries>
   <Automatic-Module-Name>netty.transport.epoll</Automatic-Module-Name>
</manifestEntries>
Copy after login

However, this solution requires collaboration with the artifact's owners, making it a less immediate option.

An alternative approach involves having artifact owners include module declarations using module-info.java in their JARs. This action triggers a bottom-up migration process, where dependencies that do not provide module information are assumed to export all packages.

The above is the detailed content of Java 9 Module Descriptor Errors: How to Handle Auto-Generated Names like \'native\'?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template