URLClassPath should not propagate IllegalArgumentException when finding resources in classpath URLs

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 24
    • Affects Version/s: 8
    • Component/s: core-libs
    • None
    • b27

      The jdk.internal.loader.URLClassPath is used by ClassLoader implementations in the JDK to locate resources within a classpath constructed out of one or more URLs. The internal implementation of URLClassPath does the necessary work to create appropriate resource loaders out of these individual URLs. Any exceptions that occur when constructing these internal loaders is handled internally within the URLClassPath implementation and such failing loaders won't be able to locate resources, but other loaders that were successfully constructed maybe able to.

      It has been noticed that in a certain specific case, when trying to construct the internal loader, a failure to parse a URL propagates an IllegalArgumentException to the callers of URLClassPath:

      Exception in thread "main" java.lang.IllegalArgumentException: Error decoding percent encoded characters
          at java.base/sun.net.www.ParseUtil.decode(ParseUtil.java:221)
          at java.base/jdk.internal.loader.URLClassPath$FileLoader.<init>(URLClassPath.java:906)
          at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:451)
          at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:407)
          at java.base/jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:329)
          at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:688)
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:620)
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:578)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
          at java.base/java.lang.Class.forName0(Native Method)
          at java.base/java.lang.Class.forName(Class.java:545)

      This should be fixed to handle the IllegalArgumentException internally in the implementation of the URLClassPath.

            Assignee:
            Jaikiran Pai
            Reporter:
            Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: