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

Class.getField fails for member inherited from interface of superclass

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • core-libs



      Name: bsC130419 Date: 06/28/2001


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


      We use the PROTOCOL_VERSION_1 flag in serialization to maintain compatibility
      with a product first released under JDK 1.1.7. We use the following code to
      set the protocol, in a subclass of ObjectOutputStream.

      try {
           // see if the useProtocolVersion method is implemented
           Method m = getClass().getMethod("useProtocolVersion", new Class[] {
      Integer.TYPE });
          Field f = getClass().getField("PROTOCOL_VERSION_1");
          m.invoke(this, new Object[] { new Integer(f.getInt(this)) });
      } catch (NoSuchMethodException e) {
          // no problem, if the method's not there, we don't call it
      }

      Under 1.4beta, this is throwing a NoSuchFieldException, implying that I can't
      get the PROTOCOL_VERSION_1 field. This code has worked in all previous
      releases of Java.
      (Review ID: 127515)
      ======================================================================

            kbr Kenneth Russell (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: