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

URLClassPath should not propagate IllegalArgumentException when finding resources in classpath URLs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 8
    • 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.

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

              Created:
              Updated:
              Resolved: