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

ObjectInputStream.GetField.get(name, object) should throw ClassNotFoundException

    XMLWordPrintable

    Details

      Description

      Currently, there is a bug in ObjectInputStream.FieldValues.get(name, val).

              public Object get(String name, Object val) {
                  int off = getFieldOffset(name, Object.class);
                  if (off >= 0) {
                      int objHandle = objHandles[off];
                      handles.markDependency(passHandle, objHandle);
                      return (handles.lookupException(objHandle) == null) ?
                          objValues[off] : null;
                  } else {
                      return val;
                  }

      Here, a call to handles.lookupException is made, however rather than throwing the associated exception, the method simply returns null.

      This is causing ClassNotFoundExceptions to be buried by the stack and the exception being thrown further up the stack by the caller of the method.

      The method signature for FieldValues.get does not declare it throws ClassNotFoundException.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rriggs Roger Riggs
              Reporter:
              rriggs Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: