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

hashCode() on some getResource() URLs raises an exception() [null host!]

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1.5
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description

      A getResource() on a resource in CLASSPATH yields a URL whose getHost() returns null. This breaks hashCode() [which should know better, imho].

      Reproduce as follows:

      calterra% cat Test.java
      import java.net.*;

      public class Test {
          public static void main(String args[]) {
      URL u = ClassLoader.getSystemResource("Test.java");
      System.err.println("url: "+u);
      if (u!=null) {
      int i = u.hashCode();
      System.err.println("hash: "+i);
      }
          }
      }
      ===

      calterra% which java
      /usr/local/java/jdk-pumpkin/solaris/bin/java
      calterra% javac Test.java
      calterra% java Test
      url: systemresource:/FILE0/+/Test.java
      java.lang.NullPointerException
      at java.net.URL.hashCode(URL.java)
      at Test.main(Test.java:8)

      ===

      calterra% setenv PATH $PATHe
      calterra% which java
      /export/home2/pelegri/jdk-pumpkin/build/bin/java
      calterra% javac Test.java
      calterra% java Test
      SystemResource.parseURL(); host is:
      url: systemresource:/FILE0/+/Test.java
      hash: 1274556635

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


      pelegri@Eng 1997-11-03

        Attachments

          Activity

            People

            Assignee:
            epelegrisunw Eduardo Pelegrillopart (Inactive)
            Reporter:
            epelegrisunw Eduardo Pelegrillopart (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: