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

(1.1) get_field should resolve unresolved classes, not assert.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1.6
    • core-libs
    • generic
    • generic



      Name: clC74495 Date: 07/07/98


      get_field ( field.c ) asserts if the class containing the
      field hasn't been resolved.

      It should just resolve the class, as getInterfaces does.

      BTW, this bug has been made visible by the changes in class
      initialization that were done for 116. Perhaps there is a bug
      there as well.

      1. Build I0.java, C0.java, C1.java ( below )
      2. Run the class C0.
         The VM will exit with an assertion in field.c, line 107.
         ( function get_field )

      // I0.java
      public interface I0
      {
          String field1 = "fielddata";
      }

      // C0.java
      public class C0 implements I0
      {
          public void doit()
          {
              try
              {
                  Class c = Class.forName( "C1" );
                  Class[] formalParms;
                  Object[] actualParms;

                  formalParms = new Class[ 0 ];
                  java.lang.reflect.Method m = c.getMethod("doit", formalParms);
                  actualParms = new Object[ 0 ];
                  m.invoke(null, actualParms);
              }
              catch( Exception e )
              {
                  System.out.println( e );
                  e.printStackTrace();
              }
          }

          public static void main( String[] args )
          {
              C0 instance = new C0();
              instance.doit();
          }
      }

      // C1.java
           public class C1
           {
               public static void doit()
               {
                   try
                   {
                       Class c = Class.forName( "C0" );
                       java.lang.reflect.Field f = c.getField( "field1" );
                       // You can uncomment the line below to work around the
           bug.
                       // c.getInterfaces();
           
                       // Line below causes assert in field.c, line 107.
                       // ( function get field. )
                       String s = ( String )f.get( null );
                       System.out.println( s );
                   }
                   catch( Exception e )
                   {
                       System.out.println( e );
                       e.printStackTrace();
                   }
               }
           }


      // Output
      java_g -nojit C0

      Full thread dump:
          "Finalizer thread" (TID:0xc80088, sys_thread_t:0x894640, Win32ID:0x137, state:CW) prio=2
          "main" (TID:0xc800b0, sys_thread_t:0x893840, Win32ID:0x129, state:R) prio=5 *current thread*
              C1.doit(C1.java:9)
              C0.doit(C0.java:14)
              C0.main(C0.java:26)

      *** panic: "..\..\..\..\src\share\java\lang\field.c", line 107: assertion failure


      abnormal program termination
      (Review ID: 34395)
      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: