Avoid using ArrayDeque in jdk.internal.loader.URLClassPath

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: core-libs
    • None

      URLClassPath currently uses an ArrayDeque for its unopenedUrls dequeue.

      The motivation for using a double-ended queue seems to be that "original" path URLs are added to the tail of the queue while any "discovered" loader class path URLs are added to the head.

      URLClassPath is the only client of ArrayDeque in a "hello world" Java program, so causes loading of ArrayDeque, Deque and Queue during startup.

      An additional concern is how URLClassPath delicately dances around calling ArrayDeque#addAll or new ArrayDeque(Collection) to avoid calling into lambdas.

      If we handle original path and loader-discovered URLs in separate lists, we no longer need a double-ended queue and can use plain ArrayLists instead.

      Besides avoiding additional class loading, this also simplifies the current code a bit and also allows any loader-discovered list to be created lazily.

            Assignee:
            Eirik Bjørsnøs
            Reporter:
            Eirik Bjørsnøs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: