< prev index next >

## src/java.base/share/classes/java/security/PrivilegedActionException.java

Print this page

    *** 1,7 ***
      /*
    !  * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
       * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       *
       * This code is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License version 2 only, as
       * published by the Free Software Foundation.  Oracle designates this
    --- 1,7 ---
      /*
    !  * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
       * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       *
       * This code is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License version 2 only, as
       * published by the Free Software Foundation.  Oracle designates this

    *** 96,38 ***

          /**
           * Serializable fields for UndeclaredThrowableException.
           *
    !      * @serialField undeclaredThrowable Throwable
           */
          @java.io.Serial
          private static final ObjectStreamField[] serialPersistentFields = {
              new ObjectStreamField("exception", Exception.class)
          };

    !     /*
           * Reconstitutes the PrivilegedActionException instance from a stream
           * and initialize the cause properly when deserializing from an older
           * version.
           *
    !      * The getException and getCause method returns the private "exception"
           * field in the older implementation and PrivilegedActionException::cause
           * was set to null.
           */
          @java.io.Serial
          private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
              ObjectInputStream.GetField fields = s.readFields();
              Exception exception = (Exception) fields.get("exception", null);
              if (exception != null) {
                  SharedSecrets.getJavaLangAccess().setCause(this, exception);
              }
          }

    !     /*
           * To maintain compatibility with older implementation, write a serial
           * "exception" field with the cause as the value.
           */
          @java.io.Serial
          private void writeObject(ObjectOutputStream out) throws IOException {
              ObjectOutputStream.PutField fields = out.putFields();
              fields.put("exception", super.getCause());
    --- 96,45 ---

          /**
           * Serializable fields for UndeclaredThrowableException.
           *
    !      * @serialField exception Exception the undeclaredThrowable
           */
          @java.io.Serial
          private static final ObjectStreamField[] serialPersistentFields = {
              new ObjectStreamField("exception", Exception.class)
          };

    !     /**
           * Reconstitutes the PrivilegedActionException instance from a stream
           * and initialize the cause properly when deserializing from an older
           * version.
           *
    !      * <p>The getException and getCause method returns the private "exception"
           * field in the older implementation and PrivilegedActionException::cause
           * was set to null.
    +      *
    +      * @param  s the {@code ObjectInputStream} from which data is read
    +      * @throws IOException if an I/O error occurs
    +      * @throws ClassNotFoundException if a serialized class cannot be loaded
           */
          @java.io.Serial
          private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
              ObjectInputStream.GetField fields = s.readFields();
              Exception exception = (Exception) fields.get("exception", null);
              if (exception != null) {
                  SharedSecrets.getJavaLangAccess().setCause(this, exception);
              }
          }

    !     /**
           * To maintain compatibility with older implementation, write a serial
           * "exception" field with the cause as the value.
    +      *
    +      * @param  out the {@code ObjectOutputStream} to which data is written
    +      * @throws IOException if an I/O error occurs
           */
          @java.io.Serial
          private void writeObject(ObjectOutputStream out) throws IOException {
              ObjectOutputStream.PutField fields = out.putFields();
              fields.put("exception", super.getCause());

< prev index next >