< prev index next >

## src/java.base/share/classes/java/io/FilePermission.java

Print this page

    1230
    1231     @java.io.Serial
    1232     private static final long serialVersionUID = 2202956749081564585L;
    1233
    1234     // Need to maintain serialization interoperability with earlier releases,
    1235     // which had the serializable field:
    1236     //    private Vector permissions;
    1237
    1238     /**
    1239      * @serialField permissions java.util.Vector
    1240      *     A list of FilePermission objects.
    1241      */
    1242     @java.io.Serial
    1243     private static final ObjectStreamField[] serialPersistentFields = {
    1244         new ObjectStreamField("permissions", Vector.class),
    1245     };
    1246
    1247     /**
    1248      * @serialData "permissions" field (a Vector containing the FilePermissions).
    1249      */
    1250     /*
    1251      * Writes the contents of the perms field out as a Vector for
    1252      * serialization compatibility with earlier releases.

    1253      */
    1254     @java.io.Serial
    1255     private void writeObject(ObjectOutputStream out) throws IOException {
    1256         // Don't call out.defaultWriteObject()
    1257
    1258         // Write out Vector
    1259         Vector<Permission> permissions = new Vector<>(perms.values());
    1260
    1261         ObjectOutputStream.PutField pfields = out.putFields();
    1262         pfields.put("permissions", permissions);
    1263         out.writeFields();
    1264     }
    1265
    1266     /*
    1267      * Reads in a Vector of FilePermissions and saves them in the perms field.

    1268      */
    1269     @java.io.Serial
    1270     private void readObject(ObjectInputStream in)
    1271         throws IOException, ClassNotFoundException
    1272     {
    1273         // Don't call defaultReadObject()
    1274
    1275         // Read in serialized fields
    1276         ObjectInputStream.GetField gfields = in.readFields();
    1277
    1278         // Get the one we want
    1279         @SuppressWarnings("unchecked")
    1280         Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
    1281         perms = new ConcurrentHashMap<>(permissions.size());
    1282         for (Permission perm : permissions) {
    1283             perms.put(perm.getName(), perm);
    1284         }
    1285     }
    1286 }
    1230
    1231     @java.io.Serial
    1232     private static final long serialVersionUID = 2202956749081564585L;
    1233
    1234     // Need to maintain serialization interoperability with earlier releases,
    1235     // which had the serializable field:
    1236     //    private Vector permissions;
    1237
    1238     /**
    1239      * @serialField permissions java.util.Vector
    1240      *     A list of FilePermission objects.
    1241      */
    1242     @java.io.Serial
    1243     private static final ObjectStreamField[] serialPersistentFields = {
    1244         new ObjectStreamField("permissions", Vector.class),
    1245     };
    1246
    1247     /**
    1248      * @serialData "permissions" field (a Vector containing the FilePermissions).
    1249      */
    1250     /**
    1251      * Writes the contents of the perms field out as a Vector for
    1252      * serialization compatibility with earlier releases.
    1253      *
    1254      * @param  out the {@code ObjectOutputStream} to which data is written
    1255      * @throws IOException if an I/O error occurs
    1256      */
    1257     @java.io.Serial
    1258     private void writeObject(ObjectOutputStream out) throws IOException {
    1259         // Don't call out.defaultWriteObject()
    1260
    1261         // Write out Vector
    1262         Vector<Permission> permissions = new Vector<>(perms.values());
    1263
    1264         ObjectOutputStream.PutField pfields = out.putFields();
    1265         pfields.put("permissions", permissions);
    1266         out.writeFields();
    1267     }
    1268
    1269     /**
    1270      * Reads in a Vector of FilePermissions and saves them in the perms field.
    1271      *
    1272      * @param  in the {@code ObjectInputStream} from which data is read
    1273      * @throws IOException if an I/O error occurs
    1274      * @throws ClassNotFoundException if a serialized class cannot be loaded
    1275      */
    1276     @java.io.Serial
    1277     private void readObject(ObjectInputStream in)
    1278         throws IOException, ClassNotFoundException
    1279     {
    1280         // Don't call defaultReadObject()
    1281
    1282         // Read in serialized fields
    1283         ObjectInputStream.GetField gfields = in.readFields();
    1284
    1285         // Get the one we want
    1286         @SuppressWarnings("unchecked")
    1287         Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
    1288         perms = new ConcurrentHashMap<>(permissions.size());
    1289         for (Permission perm : permissions) {
    1290             perms.put(perm.getName(), perm);
    1291         }
    1292     }
    1293 }

< prev index next >