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

URLClassLoader.getResource throws undocumented IllegalArgumentException

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      It is possible that some code is catching the undocumented IllegalArgumentException and treating it in a specific way.
    • Interface Kind:
      Java API
    • Scope:
      Implementation

      Description

      Summary

      Modify the implementation of java.net.URLClassLoader such that an undocumented IllegalArgumentException is no longer thrown from the getResource[s] and findResource[s] methods.

      Problem

      The javadocs for URLClassLoader.findResource(), and those inherited from ClassLoader.getResource(), indicate that null will be returned if there are problems getting a resource. However, the implementation throws an undocumented IllegalArgumentException under specific conditions (when getting a resource named with a Windows path, "c:/windows" from a URL ending in '/'). This can cause incorrect behavior (most likely on Windows systems). An example of such a problem was discovered in Spring Framework, necessitating a workaround.

      Similarly, an IllegalArgumentException can occur when using Enumerations returned from findResources() and getResources().

      Solution

      Modify the implementation of java.net.URLClassLoader to not throw IllegalArgumentException when finding resources.

      Specification

      No specification changes

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bchristi Brent Christian
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Alan Bateman, Lance Andersen, Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: