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

Constructor URL(URL, String) not compatible with older versions of Java

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • core-libs
    • beta
    • x86
    • windows_nt



      Name: yyT116575 Date: 10/24/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      The constructor URL(URL, String) works different in 1.3 as in older versions.
      For instance:

      System.out.println(new URL(new URL("http://www.acme.com/a/"), "/a/./"));

      will print:

      http://www.acme.com/a/

      on 1.2.2 and older versions, but on 1.3 it will print:

      http://www.acme.com/a/./

      This may not seem important, but in some cases it can cause endless growth of
      URLs (e.g.: at web spidering).

      source code:
      import java.io.*;
      import java.net.*;

      public class JdkTest {

        public static void main(String[] args) {
          try {
            System.out.println(new URL(new URL("http://www.acme.com/a/"), "/a/./"));

          } catch (MalformedURLException e) {}
        }
      }

      Best regards
                 Samo
      (Review ID: 108866)
      ======================================================================

            michaelm Michael McMahon
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: