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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 15
    • None
    • tools

      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.

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

              Created:
              Updated:
              Resolved: