jdeps --generate-module-info forgets to close the resource after checking any unnamed package

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 9
    • Affects Version/s: 9
    • Component/s: tools
    • b141

      test/tools/jdeps/modules/UnnamedPackage.java
      test/tools/jdeps/modules/GenModuleInfo.java

      may fail on windows.

      --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
      +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java
      @@ -680,9 +680,9 @@
           private boolean genModuleInfo(JdepsConfiguration config) throws IOException {
               // check if any JAR file contains unnamed package
               for (String arg : inputArgs) {
      + try (ClassFileReader reader = ClassFileReader.newInstance(Paths.get(arg))) {
                   Optional<String> classInUnnamedPackage =
      - ClassFileReader.newInstance(Paths.get(arg))
      - .entries().stream()
      + reader.entries().stream()
                           .filter(n -> n.endsWith(".class"))
                           .filter(cn -> toPackageName(cn).isEmpty())
                           .findFirst();
      @@ -696,6 +696,7 @@
                       return false;
                   }
               }
      + }

            Assignee:
            Mandy Chung (Inactive)
            Reporter:
            Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: