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

java.util.zip reader intermittently fails with a jmod file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: External
    • Icon: P4 P4
    • None
    • 17, 18, 19
    • core-libs

      java.util.zip reader intermittently fails with a jmod file.

      Test:

      import jdk.internal.org.objectweb.asm.*;
      import java.nio.file.*;
      import java.io.*;
      import java.util.zip.*;

      class StripDebugJmodWithZip {
          public static void main(String[] args) throws Exception {
              Path jmodPath;

              if (args.length != 0) {
                  jmodPath = Paths.get(args[0]);
              } else {
                  jmodPath = Paths.get(System.getProperty("java.home"), "jmods",
                      "jdk.localedata.jmod");
              }
              
              System.out.println("parsing jmod " + jmodPath);

              try (var zf = new ZipFile(jmodPath.toFile())) {
                  var entries = zf.entries();
                  while (entries.hasMoreElements()) {
                      var ze = entries.nextElement();
                      if (ze.isDirectory() || !ze.getName().endsWith(".class")) {
                          continue;
                      }
                      System.out.println("parsing class " + ze.getName());
                      try (var stream = zf.getInputStream(ze)) {
                          var reader = new ClassReader(stream);
                          var writer = new ClassWriter(reader, ClassWriter.COMPUTE_MAXS);
                          reader.accept(writer, ClassReader.SKIP_DEBUG);
                      } catch (IOException ioExp) {
                          System.err.println("failed for " + ze.getName());
                          throw new UncheckedIOException(ioExp);
                      }
                  }
              }
          }
      }

      The above test fails intermittently on OSX/aarch64.

      [~thartmann] reproduced the test failure on OSX/aarch64 (macOS 12.0.1 (build 21A559) with a M1 CPU) with latest and unmodified 19-ea+13-808.

        1. run-zip-test.sh
          0.4 kB
          Jaikiran Pai
        2. zlib.patch
          2 kB
          Dean Long

            jpai Jaikiran Pai
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: