< prev index next >

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

Print this page

    @@ -1,7 +1,7 @@
      /*
    -  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
    +  * Copyright (c) 1997, 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

    @@ -23,10 +23,12 @@
       * questions.
       */

      package java.security;

    + import java.io.IOException;
    +
      /**
       * A GuardedObject is an object that is used to protect access to
       * another object.
       *
       * <p>A GuardedObject encapsulates a target object and a Guard object,

    @@ -50,14 +52,21 @@
      public class GuardedObject implements java.io.Serializable {

          @java.io.Serial
          private static final long serialVersionUID = -5240450096227834308L;

    +     /**
    +      * The object we are guarding.
    +      */
          @SuppressWarnings("serial") // Not statically typed as Serializable
    -     private Object object; // the object we are guarding
    +     private Object object;
    +
    +     /**
    +      * The guard object.
    +      */
          @SuppressWarnings("serial") // Not statically typed as Serializable
    -     private Guard guard;   // the guard
    +     private Guard guard;

          /**
           * Constructs a GuardedObject using the specified object and guard.
           * If the Guard object is null, then no restrictions will
           * be placed on who can access the object.

    @@ -92,14 +101,17 @@
          }

          /**
           * Writes this object out to a stream (i.e., serializes it).
           * We check the guard if there is one.
    +      *
    +      * @param  oos the {@code ObjectOutputStream} to which data is written
    +      * @throws IOException if an I/O error occurs
           */
          @java.io.Serial
          private void writeObject(java.io.ObjectOutputStream oos)
    -         throws java.io.IOException
    +         throws IOException
          {
              if (guard != null)
                  guard.checkGuard(object);

              oos.defaultWriteObject();

< prev index next >