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>
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>
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!