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

java.net.Inet4Address.isMCGlobal() does not work as expected

    XMLWordPrintable

Details

    • beta
    • sparc
    • solaris_2.6

    Description



      Name: dfR10049 Date: 01/19/2001



      isMCGlobal() method of Inet4Address class does not work as expected.

      According to rfc2365 the range of IPv4 multicast addresses with global scope is:
      224.0.1.0 - 238.255.255.255. But the Inet4Address.isMCGlobal() incorrectly returns
      false for addresses from this range.

      This is the test demonstrating the bug:
      ========== Test.java ==============
      import java.net.*;
      import java.io.*;


      public class Test {

          final static byte[][] MCGlobal_4 = {
              { (byte)224, 0, 1, 0 },
              { (byte)224, 0, 1, 1 },

              { (byte)225, 0, 0, 0 },
              { (byte)230, 11, 22, 33 },
              { (byte)237, -1, -1, -1 },

              { (byte)238, 0, 0, 0 },
              { (byte)238, -1, -1, -1 },
          };

          public static void main (String args[]){
             

              boolean passed = true;
              try {
                  for (int i = 0; i < MCGlobal_4.length; i++) {
                      Inet4Address address =
                          (Inet4Address)InetAddress.getByAddr(MCGlobal_4[i]);

                      if (!address.isMCGlobal()) {
                          System.out.println(address + " has not global scope");
                          passed = false;
                      };
                 }
              } catch (Exception e) {
                  System.out.println(" " + e);
                  passed = false;
              }
          }
      }

      ================================================
      output from the test:

      #> java Test
      /224.0.1.0 has not global scope
      /224.0.1.1 has not global scope
      /225.0.0.0 has not global scope
      /230.11.22.33 has not global scope
      /237.255.255.255 has not global scope
      /238.0.0.0 has not global scope
      /238.255.255.255 has not global scope

      #> java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
      Java HotSpot(TM) Client VM (build 1.4beta-B45, mixed mode)

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

      Attachments

        Activity

          People

            ywangsunw Yingxian Wang (Inactive)
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: