hyperxpro / Brotli4j

Brotli4j provides Brotli compression and decompression for Java.
Apache License 2.0
102 stars 35 forks source link

[BUG] native java module reading error #132

Closed jkuhn1 closed 7 months ago

jkuhn1 commented 7 months ago

Describe the bug When upgrading brotli4j from 1.12.0 to 1.13.0 (and onwards) in a Java modular application the following error was reported:

Error reading module: /home/jkuhn/.m2/repository/com/aayushatharva/brotli4j/native-linux-x86_64/1.15.0/native-linux-x86_64-1.15.0.jar'
java.lang.module.InvalidModuleDescriptorException: Package com.aayushatharva.brotli4j.linux.ppc64le not found in module'.

I've compared META-INF/versions/9/module-info.class files:

for native-linux-x86_64-1.12.0.jar:

module com.aayushatharva.brotli4j.linux.x86_64 {
  requires com.aayushatharva.brotli4j.service;
  requires java.base;

  exports com.aayushatharva.brotli4j.linux.x86_64 to com.aayushatharva.brotli4j;

  provides com.aayushatharva.brotli4j.service.BrotliNativeProvider with com.aayushatharva.brotli4j.linux.x86_64.NativeLoader;
}

from native-linux-x86_64-1.13.0.jar:

module com.aayushatharva.brotli4j.linux.ppc64le {
  requires com.aayushatharva.brotli4j.service;
  requires java.base;

  exports com.aayushatharva.brotli4j.linux.ppc64le to com.aayushatharva.brotli4j;

  provides com.aayushatharva.brotli4j.service.BrotliNativeProvider with com.aayushatharva.brotli4j.linux.ppc64le.NativeLoader;
}

So it seems from 1.13.0, x86_64 jar contains module descriptor for ppc64le and since the exported ppc64le package does not exist in the Jar the module is corrupted and can't be loaded. I haven't checked for other architectures but maybe they are also impacted.

To Reproduce Create a Java modular application on linux x86_64 platform which uses brotli modules.

Expected behavior native-linux-x86_64-1.15.0.jar must contain module com.aayushatharva.brotli4j.linux.x86_64. ModuleFinder can load module com.aayushatharva.brotli4j.linux.x86_64 from native-linux-x86_64-1.15.0.jar

Logs If applicable, add logs to help explain your problem.

Platform (please complete the following information):

Additional context Add any other context about the problem here.

hyperxpro commented 7 months ago

Fixed in #130

Release will be cut soon

jkuhn1 commented 7 months ago

Fixed in #130

Release will be cut soon

Actually #130 won't solve that particular issue for linux_x86_64 platform. If you look at https://github.com/hyperxpro/Brotli4j/blob/main/natives/linux-x86_64/pom.xml you'll see the javaModuleName property is not correctly set:

<properties>
    <javaModuleName>com.aayushatharva.brotli4j.linux.s390x</javaModuleName>
    <javaModuleName>com.aayushatharva.brotli4j.linux.ppc64le</javaModuleName>
</properties>

instead of:

<properties>
    <javaModuleName>com.aayushatharva.brotli4j.linux.x86_64</javaModuleName>
</properties>

This bug was introduced in #102