Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8240910

jmod rejects duplicate entries in --class-path jars

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 15
    • None
    • tools
    • None
    • b23

      jmod warns on duplicate entries in directories (see JDK-8134779), but crashes if it sees duplicate entries in `.jar` files on the `--class-path` (e.g. if both jars contain a `META-INF/MANIFEST.MF`. The inconsistency seems like a bug, I'd expect it to either emit errors or warnings for both the directory and jar cases.

      Repro:

      Creating a jmod from directories with overlapping resources is a warning:

      ```
      ${JAVA_HOME}/bin/jmod extract \
        --dir java.base \
        ${JAVA_HOME}/jmods/java.base.jmod
      mkdir a
      cp -R java.base/classes/META-INF/ a/
      rm out.jmod; ${JAVA_HOME}/bin/jmod create --class-path java.base/classes:a out.jmod
      ...
      Warning: ignoring duplicate entry META-INF/services/java.nio.file.spi.FileSystemProvider, in section CLASSES
      ```

      Creating equivalent jars to the directories above results in an error:

      ```
      (cd java.base/classes/; jar cvf ../../a.jar .)
      (cd a/; jar cvf ../b.jar .)
      rm out.jmod; ${JAVA_HOME}/bin/jmod create --class-path a.jar:b.jar out.jmod
      ...
      Error: java.util.zip.ZipException: duplicate entry: classes/META-INF/MANIFEST.MF
      java.io.UncheckedIOException: java.util.zip.ZipException: duplicate entry: classes/META-INF/MANIFEST.MF
              at jdk.jlink/jdk.tools.jmod.JmodTask$JmodFileWriter$JarEntryConsumer.accept(JmodTask.java:827)
              at jdk.jlink/jdk.tools.jmod.JmodTask$JmodFileWriter$JarEntryConsumer.accept(JmodTask.java:815)
              at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
              at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
              at java.base/java.util.zip.ZipFile$EntrySpliterator.tryAdvance(ZipFile.java:580)
              at java.base/java.util.Spliterator.forEachRemaining(Spliterator.java:326)
              at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
              at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
              at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
              at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
              at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
              at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
              at jdk.jlink/jdk.tools.jmod.JmodTask$JmodFileWriter.processClasses(JmodTask.java:756)
              at jdk.jlink/jdk.tools.jmod.JmodTask$JmodFileWriter.write(JmodTask.java:484)
              at jdk.jlink/jdk.tools.jmod.JmodTask.create(JmodTask.java:438)
              at jdk.jlink/jdk.tools.jmod.JmodTask.run(JmodTask.java:208)
              at jdk.jlink/jdk.tools.jmod.Main.main(Main.java:34)
      Caused by: java.util.zip.ZipException: duplicate entry: classes/META-INF/MANIFEST.MF
              at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:233)
              at jdk.jlink/jdk.tools.jmod.JmodOutputStream.writeEntry(JmodOutputStream.java:74)
              at jdk.jlink/jdk.tools.jmod.JmodTask$JmodFileWriter$JarEntryConsumer.accept(JmodTask.java:825)
              ... 16 more
      ```

            mchung Mandy Chung
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: