提交 b79620e4 编写于 作者: I igerasim

8189977: Improve permission portability

Reviewed-by: rriggs
上级 485c4cc3
...@@ -833,6 +833,8 @@ final class FilePermissionCollection extends PermissionCollection ...@@ -833,6 +833,8 @@ final class FilePermissionCollection extends PermissionCollection
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null); Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
perms = new ArrayList<>(permissions.size()); perms = new ArrayList<>(permissions.size());
perms.addAll(permissions); for (Permission perm : permissions) {
perms.add(perm);
}
} }
} }
...@@ -1194,6 +1194,10 @@ public class Hashtable<K,V> ...@@ -1194,6 +1194,10 @@ public class Hashtable<K,V>
length--; length--;
length = Math.min(length, origlength); length = Math.min(length, origlength);
if (length < 0) { // overflow
length = origlength;
}
// Check Map.Entry[].class since it's the nearest public type to // Check Map.Entry[].class since it's the nearest public type to
// what we're actually creating. // what we're actually creating.
SharedSecrets.getJavaOISAccess().checkArray(s, Map.Entry[].class, length); SharedSecrets.getJavaOISAccess().checkArray(s, Map.Entry[].class, length);
......
/* /*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
package java.util; package java.util;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.StreamCorruptedException;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
...@@ -1058,6 +1061,29 @@ public class Vector<E> ...@@ -1058,6 +1061,29 @@ public class Vector<E>
elementData[--elementCount] = null; elementData[--elementCount] = null;
} }
/**
* Loads a {@code Vector} instance from a stream
* (that is, deserializes it).
* This method performs checks to ensure the consistency
* of the fields.
*
* @param in the stream
* @throws java.io.IOException if an I/O error occurs
* @throws ClassNotFoundException if the stream contains data
* of a non-existing class
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
int count = gfields.get("elementCount", 0);
Object[] data = (Object[])gfields.get("elementData", null);
if (count < 0 || data == null || count > data.length) {
throw new StreamCorruptedException("Inconsistent vector internals");
}
elementCount = count;
elementData = data.clone();
}
/** /**
* Save the state of the {@code Vector} instance to a stream (that * Save the state of the {@code Vector} instance to a stream (that
* is, serialize it). * is, serialize it).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册