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

InetAddress.getAllByName() and InetAddress.getByName() fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta
    • sparc
    • solaris_8
    • Verified

    Description

      InetAddress.getAllByname() fails when its been called
      InetAddress.getAllByName(InetAddress.getHostName()) and host name is an IP address Solaris 8 machine.

      InetAddress.getByName() also fails when its called in the same way.

      How to reproduce this:

      The following code is throwing exception at
         " InetAddress[] iadrtest = InetAddress.getAllByName(iadr[i].getHostName()); "
         
         statement when I executed this script as
         
         % java GetIP ff15::1234:1234:1234:1234
         
         
         Exception Message:
              exp mesg [ff15::1234:1234:1234:1234]
         
      import java.net.*;
      import java.io.*;

      public class GetIP {


         public static void main(String[] arg)
         {
             try {
               InetAddress[] iadr = InetAddress.getAllByName(arg[0]);
              System.out.println("iadr length " + iadr.length);

               for(int i=0; i< iadr.length; i++)
               {
                System.out.println("ip address : " + iadr[i].getHostAddress());
                System.out.println(" Host Name :" + iadr[i].getHostName());
                //System.out.println("family " + iadr[i].getFamily());
                System.out.println("Host aadd byte arr " + iadr[i].getAddress());
                if(iadr[i] instanceof Inet4Address)
                      System.out.println("v4 address");
                if(iadr[i] instanceof Inet6Address)
                      System.out.println("v6 address ");

                if(!iadr[i].isMCOrgLocal()) {
                    System.out.println("NOt org local scope");
                 }
                InetAddress[] iadrtest = InetAddress.getAllByName(iadr[i].getHostName());
                System.out.println("working....");
               }
              InetAddress iad = InetAddress.getByName(arg[0]);
              System.out.println("ip of that host : " + iad.getHostAddress());
              System.out.println("inet add tostring : " + iad);
            } catch(Exception exp) {
               System.out.println("exp mesg " + exp.getMessage());
            }
         } // End of main

      }
       

      Attachments

        Activity

          People

            ywangsunw Yingxian Wang (Inactive)
            vakellasunw Venkata Akella (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: