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

(Class.getResource((String) null)).getContent() unexpected handling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.1.8
    • core-libs



      Name: mgC56079 Date: 05/26/99



      JLS for Class.getResource(String name) says :

      ----------------------
      Finds a resource with a given name. This method returns null if no resource with this name is found. The
            rules for searching resources associated with a given class are implemented by the * defining class
            loader of the class.
      ----------------------

      null is not a object, it is not a 'name' for anything and it is expected that
      call getResource((String)null)) will throw NullPointerException or return null.
      But this call returns valid URL without any exceptions. If it is correct behavour
      it should be reflected in documentation

      Note that when you call .getContent method on this URL, you get null on win32
      and InputStream on solaris

      ----------------------Test.java
      public class Test {
          public static void main(String[] args) throws java.io.IOException {
              java.net.URL url = new Test().getClass().getResource((String)null);
              System.out.println(""+url);
              System.out.println(""+url.getContent());
          }
      }
      ----------------------Output on solaris
      systemresource:/FILE0/+/
      java.io.BufferedInputStream@1dc6094d
      ----------------------Output on win32
      systemresource:/FILE0/+/
      null
      ----------------------

      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            gorsunw Gor Gor (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: