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

URLClassLoader.getResource throws undocumented IllegalArgumentException

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • core-libs
    • None
    • behavioral
    • low
    • It is possible that some code is catching the undocumented IllegalArgumentException and treating it in a specific way.
    • Java API
    • Implementation

      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

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

              Created:
              Updated:
              Resolved: