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

REGRESSION: getResourceAsStream is broken in JDK1.5.0-rc

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 1.4.2_12, 5.0
    • core-libs
    • b08
    • generic, x86
    • generic, windows_2000, windows_xp

        Name: rmT116609 Date: 09/16/2004


        FULL PRODUCT VERSION :
        java version "1.5.0-rc"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
        Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows 2000 [Version 5.00.2195]

        A DESCRIPTION OF THE PROBLEM :
        getResourceAsStream is broken in JDK1.5.0-rc

        In versions of Java up to and including JDK1.5.0-beta2 Class.getResourceAsStream(String aName) was returning the Resource as specified in the documentation.

        It says aName starting with / it is unchanged.
        Now any resources that require Web Address escape codes (%'s) can not be loaded from a jar in this way.

        Even some legal java identifiers don't work anymore such as TestM-^OÀ».class
        (The compatibility issues note that only binary names for some methods can be used now, so I thought this might be the case, but this implies otherwise).

        The method is also very inefficient as not just does it get the resource as it should, but then it makes a garbage URL with the % signs in it and does the security checks for a 2nd time and tries to get the Resource for a 2nd time from the garbage URL and then returns null.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        put the class in a jar
        run the class with the jar in its classpath

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Resource Found to be displayed
        ACTUAL -
        Resource Not Found is displayed

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        Test case using pound symbol:
        public class TestÃú {
         public static void main(String[] args) {
           System.out.println(TestÃú.class.getResourceAsStream("/TestÃú.class") == null ?
        "Resource Not Found" : "Resource Found");
         }
        }

        Test case using unicode for the pound symbol:
        public class Test\u00a3 {
         public static void main(String[] args) {
           System.out.println(Test\u00a3.class.getResourceAsStream("/Test\u00a3.class") == null ?
        "Resource Not Found" : "Resource Found");
         }
        }
        ---------- END SOURCE ----------

        Release Regression From : tiger-beta2
        The above release value was the last known release where this
        bug was known to work. Since then there has been a regression.

        (Incident Review ID: 302077)
        ======================================================================
        ###@###.### 10/8/04 16:17 GMT

              michaelm Michael McMahon
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: