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

java.lang.Class.getFields() returns null instead of empty array

XMLWordPrintable

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



      Name: dbT83986 Date: 02/08/99


      When calling java.lang.Class.getFields() on a class that has no fields a null is being returned instead of an empty array.

      This happens consistently when using Iona's OrbixWeb runtime libraries. I am sure it happens at other times, but I have
      no other consistent example. The very strangest property of this bug is that if I write a simple class that does not have any
      fields, the getFields() method correctly returns an empty array. Only when I call getFields() from the IE.Iona.OrbixWeb.CORBA.ORB
      class do I consistently see this behavior. I am hypothesizing that this behavior is related to how the classes involved are being loaded.

      Here is my consistently error-generating code:

      import java.lang.reflect.Field;
      import org.omg.CORBA.ORB;

      public class FieldNullTest extends Object
      {
          /**
           * This method initializes the CORBA orb and then
           * prints the number of fields on the orb class.
           * The <code>orb.init()</code> method returns
           * an instance of <code>IE.Iona.OrbixWeb.CORBA.ORB</code>.
           */
          public static void main( String args[] ) {
              ORB orb = ORB.init();
              Class orbClass = orb.getClass();
              Field[] fields = orbClass.getFields();
              
              //the following line throws a NullPointerException
              //because fields is null
              System.out.println( fields.length );
          }
      }


      This problem was identified while using JPython 1.0rc3 and 1.0.3, but occurs outside of JPython.

      I am using OrbixWeb 3.0.

      This problem occurs using both JDK 1.1.7A and 1.1.7B on Windows NT 4.0, Build 1381, Service Pack 3.

      I first noticed this bug while moving my development environment from Solaris 2.5.1, JDK 1.1.5 to Windows NT 4.0, JDK 1.1.7.
      This problem did not occur on Solaris 2.5.1 using JDK 1.1.5.
      (Review ID: 52422)
      ======================================================================

            iris Iris Clark
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: