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

REGRESSION: AppletClassLoader.getResourceAsStream() behaviour is wrong in some cases

    Details

    • Subcomponent:
    • Introduced In Build:
      b40
    • Introduced In Version:
      6
    • Resolved In Build:
      beta
    • CPU:
      generic
    • OS:
      windows_xp

      Description

      java.lang.ClassLoader.getResourceAsStream() method returns null value if:

      1) resource is *existing empty* file and
      2) classLoader is *sun.applet.AppletClassLoader* and
      3) path in codebase is undicated via http schema


      Example:
      ----------------------------------------------------------------
      <applet
          code="TestApplet"
          codebase="http://jcklab8.russia.sun.com/set/java/jck/tmp/Yulia"
          width=600 height=400
          >
      </applet>

      ****
      import java.applet.*;
      import java.io.InputStream;

      public class TestApplet extends Applet {
          public void init() {
              ClassLoader cl = this.getClass().getClassLoader();
              if (cl != null) {
                  try {
                      String serName="tmp.ser";
                      InputStream ins=cl.getResourceAsStream(serName);
                      System.out.println("ins = "+ ins);
                  } catch (Exception ex) {
                      System.out.println(ex);
                  }
              } else {
                  System.out.println("ClassLoader == null");
              }
          }
      }
      ******
      Test output:
      1) [ if tmp.ser == *empty* file]
      ins = null

      2) [ if tmp.ser == *NOT empty* file]
      ins = sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1e6e305

      *************

      In case if codebase is indicated via file scheme, everything is ok:

      --------------------------------------------------
      <applet
          code="TestApplet"
          codebase="../IdeaProjects//Beans_bags//classes"
          width=600 height=400
          >
      </applet>
      *****
      Test output:
      1) [tmp.ser == *empty* file]
      ins = www.MeteredStream@b23d12'>sun.net.www.MeteredStream@b23d12

      2) [tmp.ser == *NOT empty* file]
      ins = www.MeteredStream@9fa8f'>sun.net.www.MeteredStream@9fa8f
      ---------------------------------------------

      The following JCK6.0 tests fail on windows platform under mustang due to such behaviour:
      api/java_beans/Beans/index.html#Beans
      api/java_beans/Beans/index.html#Beans12


      ###@###.### 2005-07-13 14:11:41 GMT
      ###@###.### 2005-07-13 16:05:17 GMT

        Attachments

          Activity

            People

            • Assignee:
              chegar Chris Hegarty
              Reporter:
              ynovozhi Yulia Novozhilova (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: