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

ImageReader.Node::getChildren() returns "uncompleted" children

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 15
    • Component/s: tools

      Description

      Consider the following code that expects to walk the contents of java.base:

              ImageReader imageReader = ImageReaderFactory.getImageReader();
              ImageReader.Node top = imageReader.findNode("/modules/java.base");
              Deque<ImageReader.Node> stack = new ArrayDeque<>();
              stack.push(top);
              while (!stack.isEmpty()) {
                  ImageReader.Node dir = stack.poll();
                  for (ImageReader.Node node : dir.getChildren()) {
                      if (node.isDirectory()) {
                          stack.push(node);
                      } else {
                          System.out.println(node.getName());
                      }
                  }
              }

      It only prints out module-info.class when it should list all resources in the module.

      The issue seems to be that getChildren() returns a Node that is not completed.

      The ModuleReader list() implementation in jigsaw/jake works arounds this issue by calling findNode to re-find child nodes that are also directories.

        Attachments

          Activity

            People

            • Assignee:
              sundar Sundararajan Athijegannathan
              Reporter:
              alanb Alan Bateman
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: