8189764: Miscellaneous changes imported from jsr166 CVS 2017-11
Reviewed-by: martin, psandoz, dholmes
This commit is contained in:
parent
e2cbace23d
commit
5d5334f305
test/jdk/java/util
AbstractList
AbstractSequentialList
Collection
Collections
AddAll.javaBinarySearchNullComparator.javaCheckedListBash.javaCheckedMapBash.javaCheckedSetBash.javaDisjoint.javaEmptyNavigableMap.javaEmptyNavigableSet.javaEnum.javaFindSubList.javaFrequency.javaNullComparator.javaReplaceAll.javaRotate.javaRotateEmpty.javaSer.javaSwap.javaViewSynch.javaWrappedNull.java
HashMap
Hashtable
LinkedHashMap
LinkedHashSet
LinkedList
NavigableMap
Random
TreeMap
Vector
WeakHashMap
concurrent
ConcurrentHashMap
CountDownLatch
ThreadPoolExecutor
locks/Lock
tck
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4189896
|
||||
* @summary AbstractList iterators previously checked for co-modification
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4295163
|
||||
* @summary AddAll(int, Collection) intersperses the Collection with this List.
|
||||
|
@ -233,7 +233,7 @@ public class IteratorMicroBenchmark {
|
||||
}
|
||||
|
||||
// Checks for correctness *and* prevents loop optimizations
|
||||
class Check {
|
||||
static class Check {
|
||||
private int sum;
|
||||
public void sum(int sum) {
|
||||
if (this.sum == 0)
|
||||
|
@ -1584,11 +1584,11 @@ public class MOAT {
|
||||
}
|
||||
interface Fun {void f() throws Throwable;}
|
||||
private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
|
||||
for (Fun f : fs)
|
||||
try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
|
||||
catch (Throwable t) {
|
||||
if (k.isAssignableFrom(t.getClass())) pass();
|
||||
else unexpected(t);}}
|
||||
for (Fun f : fs)
|
||||
try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
|
||||
catch (Throwable t) {
|
||||
if (k.isAssignableFrom(t.getClass())) pass();
|
||||
else unexpected(t);}}
|
||||
static byte[] serializedForm(Object obj) {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
@ -230,7 +230,7 @@ public class RemoveMicroBenchmark {
|
||||
}
|
||||
|
||||
// Checks for correctness *and* prevents loop optimizations
|
||||
class Check {
|
||||
static class Check {
|
||||
private int sum;
|
||||
public void sum(int sum) {
|
||||
if (this.sum == 0)
|
||||
|
@ -33,7 +33,7 @@ import java.util.*;
|
||||
|
||||
public class AddAll {
|
||||
static final int N = 100;
|
||||
public static void main(String args[]) {
|
||||
public static void main(String[] args) {
|
||||
test(new ArrayList<Integer>());
|
||||
test(new LinkedList<Integer>());
|
||||
test(new HashSet<Integer>());
|
||||
|
@ -30,7 +30,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class BinarySearchNullComparator {
|
||||
public static void main(String args[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
List list = Arrays.asList(new String[] {"I", "Love", "You"});
|
||||
|
||||
int result = Collections.binarySearch(list, "You", null);
|
||||
|
@ -209,15 +209,14 @@ public class CheckedListBash {
|
||||
}
|
||||
|
||||
static void AddRandoms(List s, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
int r = rnd.nextInt() % n;
|
||||
Integer e = new Integer(r < 0 ? -r : r);
|
||||
for (int i = 0; i < n; i++) {
|
||||
Integer e = rnd.nextInt(n);
|
||||
|
||||
int preSize = s.size();
|
||||
if (!s.add(e))
|
||||
fail("Add failed.");
|
||||
int postSize = s.size();
|
||||
if (postSize-preSize != 1)
|
||||
if (postSize - preSize != 1)
|
||||
fail("Add didn't increase size by 1.");
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
import static org.testng.Assert.fail;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class CheckedMapBash {
|
||||
static final Random rnd = new Random();
|
||||
|
@ -122,9 +122,8 @@ public class CheckedSetBash {
|
||||
}
|
||||
|
||||
static void AddRandoms(Set s, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
int r = rnd.nextInt() % n;
|
||||
Integer e = new Integer(r < 0 ? -r : r);
|
||||
for (int i = 0; i < n; i++) {
|
||||
Integer e = rnd.nextInt(n);
|
||||
|
||||
int preSize = s.size();
|
||||
boolean prePresent = s.contains(e);
|
||||
|
@ -34,7 +34,7 @@ import java.util.*;
|
||||
public class Disjoint {
|
||||
static final int N = 20;
|
||||
|
||||
public static void main(String args[]) {
|
||||
public static void main(String[] args) {
|
||||
// Make an array of lists each of which shares a single element
|
||||
// with its "neighbors," and no elements with other lists in the array
|
||||
Random rnd = new Random();
|
||||
|
@ -48,7 +48,7 @@ import static org.testng.Assert.assertFalse;
|
||||
public class EmptyNavigableMap {
|
||||
|
||||
public static <T> void assertInstance(T actual, Class<? extends T> expected) {
|
||||
assertInstance(expected.isInstance(actual), null);
|
||||
assertInstance(actual, expected, null);
|
||||
}
|
||||
|
||||
public static <T> void assertInstance(T actual, Class<? extends T> expected, String message) {
|
||||
|
@ -50,7 +50,7 @@ import static org.testng.Assert.assertTrue;
|
||||
public class EmptyNavigableSet {
|
||||
|
||||
public static <T> void assertInstance(T actual, Class<? extends T> expected) {
|
||||
assertInstance(expected.isInstance(actual), null);
|
||||
assertInstance(actual, expected, null);
|
||||
}
|
||||
|
||||
public static <T> void assertInstance(T actual, Class<? extends T> expected, String message) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4323074
|
||||
* @summary Basic test for new Enumeration -> List converter
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4323074
|
||||
* @summary Basic test for Collections.indexOfSubList/lastIndexOfSubList
|
||||
@ -33,8 +33,8 @@ public class FindSubList {
|
||||
public static void main(String[] args) throws Exception {
|
||||
int N = 500;
|
||||
List source = new ArrayList(3 * N);
|
||||
List target[]= new List[N+1];
|
||||
int index[] = new int[N+1];
|
||||
List[] target = new List[N+1];
|
||||
int[] index = new int[N+1];
|
||||
for (int i=0; i<=N; i++) {
|
||||
List t = new ArrayList();
|
||||
String s = Integer.toString(i, 2);
|
||||
@ -50,8 +50,12 @@ public class FindSubList {
|
||||
}
|
||||
}
|
||||
|
||||
List src[] = {source, new LinkedList(source), new Vector(source),
|
||||
Arrays.asList(source.toArray())};
|
||||
List[] src = {
|
||||
source,
|
||||
new LinkedList(source),
|
||||
new Vector(source),
|
||||
Arrays.asList(source.toArray())
|
||||
};
|
||||
for (int j=0; j<src.length; j++) {
|
||||
List s = src[j];
|
||||
|
||||
@ -75,8 +79,12 @@ public class FindSubList {
|
||||
if (i != N)
|
||||
index[i] = srcSize - index[i] - target[i].size();
|
||||
}
|
||||
List src2[] = {source, new LinkedList(source), new Vector(source),
|
||||
Arrays.asList(source.toArray())};
|
||||
List[] src2 = {
|
||||
source,
|
||||
new LinkedList(source),
|
||||
new Vector(source),
|
||||
Arrays.asList(source.toArray())
|
||||
};
|
||||
for (int j=0; j<src2.length; j++) {
|
||||
List s = src2[j];
|
||||
|
||||
|
@ -32,7 +32,7 @@ import java.util.*;
|
||||
|
||||
public class Frequency {
|
||||
static final int N = 100;
|
||||
public static void main(String args[]) {
|
||||
public static void main(String[] args) {
|
||||
test(new ArrayList<Integer>());
|
||||
test(new LinkedList<Integer>());
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4224271
|
||||
* @summary A null Comparator is now specified to indicate natural ordering.
|
||||
@ -37,7 +37,7 @@ public class NullComparator {
|
||||
List sorted = new ArrayList(list);
|
||||
Collections.shuffle(list);
|
||||
|
||||
Object a[] = list.toArray();
|
||||
Object[] a = list.toArray();
|
||||
Arrays.sort(a, null);
|
||||
if (!Arrays.asList(a).equals(sorted))
|
||||
throw new Exception("Arrays.sort");
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4323074
|
||||
* @summary Basic test for new replaceAll algorithm
|
||||
@ -33,7 +33,7 @@ public class ReplaceAll {
|
||||
static final int SIZE = 20;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
List a[] = {new ArrayList(), new LinkedList(), new Vector()};
|
||||
List[] a = {new ArrayList(), new LinkedList(), new Vector()};
|
||||
|
||||
for (int i=0; i<a.length; i++) {
|
||||
List lst = a[i];
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4323074
|
||||
* @summary Basic test for new rotate algorithm
|
||||
@ -37,7 +37,7 @@ public class Rotate {
|
||||
static Random rnd = new Random();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
List a[] = {new ArrayList(), new LinkedList(), new Vector()};
|
||||
List[] a = {new ArrayList(), new LinkedList(), new Vector()};
|
||||
|
||||
for (int i=0; i<a.length; i++) {
|
||||
List lst = a[i];
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4389747
|
||||
* @summary Collections.rotate(...) returns ArithmeticException
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4190323
|
||||
* @summary EMPTY_SET, EMPTY_LIST, and the collections returned by
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4323074
|
||||
* @summary Basic test for newly public swap algorithm
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4268780
|
||||
* @summary Collection-views of submap-views of synchronized-views of
|
||||
|
@ -31,152 +31,152 @@
|
||||
import java.util.*;
|
||||
|
||||
public class WrappedNull {
|
||||
public static void main(String argv[]) throws Exception {
|
||||
boolean testSucceeded = false;
|
||||
try {
|
||||
List l = Arrays.asList(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("Arrays.asList");
|
||||
public static void main(String[] args) throws Exception {
|
||||
boolean testSucceeded = false;
|
||||
try {
|
||||
List l = Arrays.asList(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("Arrays.asList");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Collection c = Collections.unmodifiableCollection(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableCollection");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Collection c = Collections.unmodifiableCollection(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableCollection");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Set c = Collections.unmodifiableSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableSet");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Set c = Collections.unmodifiableSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableSet");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
List c = Collections.unmodifiableList(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableList");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
List c = Collections.unmodifiableList(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableList");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Map c = Collections.unmodifiableMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableMap");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Map c = Collections.unmodifiableMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableMap");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedSet c = Collections.unmodifiableSortedSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableSortedSet");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedSet c = Collections.unmodifiableSortedSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableSortedSet");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedMap c = Collections.unmodifiableSortedMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableSortedMap");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedMap c = Collections.unmodifiableSortedMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("unmodifiableSortedMap");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Collection c = Collections.synchronizedCollection(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedCollection");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Collection c = Collections.synchronizedCollection(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedCollection");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Set c = Collections.synchronizedSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedSet");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Set c = Collections.synchronizedSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedSet");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
List c = Collections.synchronizedList(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedList");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
List c = Collections.synchronizedList(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedList");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Map c = Collections.synchronizedMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedMap");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
Map c = Collections.synchronizedMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedMap");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedSet c = Collections.synchronizedSortedSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedSortedSet");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedSet c = Collections.synchronizedSortedSet(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedSortedSet");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedMap c = Collections.synchronizedSortedMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedSortedMap");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
SortedMap c = Collections.synchronizedSortedMap(null);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("synchronizedSortedMap");
|
||||
|
||||
// Make sure that non-null arguments don't throw exc.
|
||||
List l = Arrays.asList(new Object[0]);
|
||||
Collection c = Collections.unmodifiableCollection(
|
||||
Collections.EMPTY_SET);
|
||||
Set s = Collections.unmodifiableSet(Collections.EMPTY_SET);
|
||||
l = Collections.unmodifiableList(Collections.EMPTY_LIST);
|
||||
Map m = Collections.unmodifiableMap(Collections.EMPTY_MAP);
|
||||
SortedSet ss = Collections.unmodifiableSortedSet(new TreeSet());
|
||||
SortedMap sm = Collections.unmodifiableSortedMap(new TreeMap());
|
||||
// Make sure that non-null arguments don't throw exc.
|
||||
List l = Arrays.asList(new Object[0]);
|
||||
Collection c = Collections.unmodifiableCollection(
|
||||
Collections.EMPTY_SET);
|
||||
Set s = Collections.unmodifiableSet(Collections.EMPTY_SET);
|
||||
l = Collections.unmodifiableList(Collections.EMPTY_LIST);
|
||||
Map m = Collections.unmodifiableMap(Collections.EMPTY_MAP);
|
||||
SortedSet ss = Collections.unmodifiableSortedSet(new TreeSet());
|
||||
SortedMap sm = Collections.unmodifiableSortedMap(new TreeMap());
|
||||
|
||||
c = Collections.synchronizedCollection(Collections.EMPTY_SET);
|
||||
s = Collections.synchronizedSet(Collections.EMPTY_SET);
|
||||
l = Collections.synchronizedList(Collections.EMPTY_LIST);
|
||||
m = Collections.synchronizedMap(Collections.EMPTY_MAP);
|
||||
ss = Collections.synchronizedSortedSet(new TreeSet());
|
||||
sm = Collections.synchronizedSortedMap(new TreeMap());
|
||||
}
|
||||
c = Collections.synchronizedCollection(Collections.EMPTY_SET);
|
||||
s = Collections.synchronizedSet(Collections.EMPTY_SET);
|
||||
l = Collections.synchronizedList(Collections.EMPTY_LIST);
|
||||
m = Collections.synchronizedMap(Collections.EMPTY_MAP);
|
||||
ss = Collections.synchronizedSortedSet(new TreeSet());
|
||||
sm = Collections.synchronizedSortedMap(new TreeMap());
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4286765
|
||||
* @summary HashMap and TreeMap entrySet().remove(k) spuriously returned
|
||||
@ -31,8 +31,8 @@
|
||||
import java.util.*;
|
||||
|
||||
public class KeySetRemove {
|
||||
public static void main(String args[]) throws Exception {
|
||||
Map m[] = {new HashMap(), new TreeMap()};
|
||||
public static void main(String[] args) throws Exception {
|
||||
Map[] m = {new HashMap(), new TreeMap()};
|
||||
for (int i=0; i<m.length; i++) {
|
||||
m[i].put("bananas", null);
|
||||
if (!m[i].keySet().remove("bananas"))
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4627516
|
||||
* @summary HashMap.Entry.setValue() returns new value (as opposed to old)
|
||||
@ -35,7 +35,7 @@ public class SetValue {
|
||||
static final String oldValue = "old";
|
||||
static final String newValue = "new";
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Map m = new HashMap();
|
||||
m.put(key, oldValue);
|
||||
Map.Entry e = (Map.Entry) m.entrySet().iterator().next();
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4189821
|
||||
* @summary HashMap's entry.toString threw a null pointer exc if the HashMap
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4208530
|
||||
* @summary Hashtable was less robust to extension that it could have been
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4559052
|
||||
* @summary Hashtable's hashCode method always returns zero(!)
|
||||
|
@ -34,101 +34,100 @@ import java.util.*;
|
||||
*/
|
||||
public class IllegalLoadFactor {
|
||||
|
||||
public static void main(String argv[]) throws Exception {
|
||||
boolean testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
Hashtable bad1 = new Hashtable(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("Hashtable, negative load factor");
|
||||
public static void main(String[] args) throws Exception {
|
||||
boolean testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
Hashtable bad1 = new Hashtable(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("Hashtable, negative load factor");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
Hashtable bad1 = new Hashtable(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("Hashtable, NaN load factor");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
Hashtable bad1 = new Hashtable(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("Hashtable, NaN load factor");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashMap bad1 = new HashMap(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashMap, negative load factor");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashMap bad1 = new HashMap(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashMap, negative load factor");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashMap bad1 = new HashMap(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashMap, NaN load factor");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashMap bad1 = new HashMap(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashMap, NaN load factor");
|
||||
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashSet bad1 = new HashSet(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashSet, negative load factor");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashSet bad1 = new HashSet(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashSet, negative load factor");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashSet bad1 = new HashSet(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashSet, NaN load factor");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
HashSet bad1 = new HashSet(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("HashSet, NaN load factor");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
WeakHashMap bad1 = new WeakHashMap(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("WeakHashMap, negative load factor");
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
WeakHashMap bad1 = new WeakHashMap(100, -3);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("WeakHashMap, negative load factor");
|
||||
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
WeakHashMap bad1 = new WeakHashMap(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("WeakHashMap, NaN load factor");
|
||||
|
||||
// Make sure that legal creates don't throw exceptions
|
||||
Map goodMap = new Hashtable(100, .69f);
|
||||
goodMap = new HashMap(100, .69f);
|
||||
Set goodSet = new HashSet(100, .69f);
|
||||
goodMap = new WeakHashMap(100, .69f);
|
||||
}
|
||||
testSucceeded = false;
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
WeakHashMap bad1 = new WeakHashMap(100, Float.NaN);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded = true;
|
||||
}
|
||||
if (!testSucceeded)
|
||||
throw new Exception("WeakHashMap, NaN load factor");
|
||||
|
||||
// Make sure that legal creates don't throw exceptions
|
||||
Map goodMap = new Hashtable(100, .69f);
|
||||
goodMap = new HashMap(100, .69f);
|
||||
Set goodSet = new HashSet(100, .69f);
|
||||
goodMap = new WeakHashMap(100, .69f);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4421469 6282555
|
||||
* @summary Hashtable's toString method should detect self-referential
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4245809 8029795
|
||||
* @summary Basic test for LinkedHashMap. (Based on MapBash)
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4245809
|
||||
* @summary Basic test of removeEldestElement method.
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4473440
|
||||
* @summary iterators on collection views of empty map weren't fail-fast.
|
||||
@ -30,7 +30,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class EmptyMapIterator {
|
||||
public static void main(String args[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
HashMap map = new HashMap();
|
||||
Iterator iter = iter = map.entrySet().iterator();
|
||||
map.put("key", "value");
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4245809
|
||||
* @summary Basic test for LinkedHashSet. (Based on SetBash)
|
||||
@ -133,9 +133,8 @@ public class Basic {
|
||||
}
|
||||
|
||||
static void AddRandoms(Set s, int n) throws Exception {
|
||||
for (int i=0; i<n; i++) {
|
||||
int r = rnd.nextInt() % n;
|
||||
Integer e = new Integer(r < 0 ? -r : r);
|
||||
for (int i = 0; i < n; i++) {
|
||||
Integer e = rnd.nextInt(n);
|
||||
|
||||
int preSize = s.size();
|
||||
boolean prePresent = s.contains(e);
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4163207
|
||||
* @summary AddAll was prepending instead of appending!
|
||||
|
@ -848,11 +848,11 @@ public class LockStep {
|
||||
}
|
||||
interface Fun {void f() throws Throwable;}
|
||||
static void THROWS(Class<? extends Throwable> k, Fun... fs) {
|
||||
for (Fun f : fs)
|
||||
try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
|
||||
catch (Throwable t) {
|
||||
if (k.isAssignableFrom(t.getClass())) pass();
|
||||
else unexpected(t);}}
|
||||
for (Fun f : fs)
|
||||
try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
|
||||
catch (Throwable t) {
|
||||
if (k.isAssignableFrom(t.getClass())) pass();
|
||||
else unexpected(t);}}
|
||||
static byte[] serializedForm(Object obj) {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4187412
|
||||
* @summary The FCS release of 1.2 did not special case the Random.nextInt
|
||||
|
@ -31,7 +31,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class HeadTailTypeError {
|
||||
public static void main(String argv[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
SortedMap m = new TreeMap();
|
||||
m.headMap(new Object());
|
||||
|
@ -30,7 +30,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class SubMap {
|
||||
public static void main(String args[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SortedMap m = new TreeMap();
|
||||
m.put(new Integer(1), new Integer(1));
|
||||
m.put(new Integer(2), new Integer(2));
|
||||
|
@ -39,7 +39,7 @@ public class SubMapClear {
|
||||
Set subSet = treeSet.subSet(new Integer(4),new Integer(10));
|
||||
subSet.clear(); // Used to throw exception
|
||||
|
||||
int a[] = new int[] {1, 2, 3, 10};
|
||||
int[] a = { 1, 2, 3, 10 };
|
||||
Set s = new TreeSet();
|
||||
for (int i = 0; i < a.length; i++)
|
||||
s.add(new Integer(a[i]));
|
||||
|
@ -36,12 +36,12 @@ import java.util.*;
|
||||
*/
|
||||
public class IllegalConstructorArgs {
|
||||
|
||||
public static void main(String argv[]) {
|
||||
int testSucceeded=0;
|
||||
public static void main(String[] args) {
|
||||
int testSucceeded=0;
|
||||
|
||||
try {
|
||||
// this should generate an IllegalArgumentException
|
||||
Vector bad1 = new Vector(-100, 10);
|
||||
// this should generate an IllegalArgumentException
|
||||
Vector bad1 = new Vector(-100, 10);
|
||||
}
|
||||
catch (IllegalArgumentException e1) {
|
||||
testSucceeded =1;
|
||||
|
@ -31,7 +31,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class LastIndexOf {
|
||||
public static void main(String argv[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Vector v = new Vector(10);
|
||||
|
||||
try {
|
||||
|
@ -46,7 +46,7 @@ public class SyncLastIndexOf {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
public static void main(String[] args) {
|
||||
Integer x = new Integer(1);
|
||||
v.addElement(x);
|
||||
new RemovingThread().start();
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4503146
|
||||
* @summary Zero initial capacity should be legal
|
||||
@ -31,7 +31,7 @@ import java.util.*;
|
||||
*/
|
||||
|
||||
public class ZeroInitCap {
|
||||
public static void main(String[] argv) {
|
||||
public static void main(String[] args) {
|
||||
Map map = new WeakHashMap(0);
|
||||
map.put("a","b");
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class ToArray {
|
||||
}
|
||||
|
||||
static void executeTest() throws Throwable {
|
||||
final Throwable throwable[] = new Throwable[1];
|
||||
final Throwable[] throwable = new Throwable[1];
|
||||
final ConcurrentHashMap<Integer, Integer> m = new ConcurrentHashMap<>();
|
||||
|
||||
// Number of workers equal to the number of processors
|
||||
|
@ -96,7 +96,7 @@ public class Basic {
|
||||
int count = 0;
|
||||
Basic test = new Basic();
|
||||
CountDownLatch latch = new CountDownLatch(3);
|
||||
Awaiter a[] = new Awaiter[12];
|
||||
Awaiter[] a = new Awaiter[12];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
CountDownLatch gate = new CountDownLatch(4);
|
||||
@ -125,7 +125,7 @@ public class Basic {
|
||||
int count = 0;
|
||||
Basic test = new Basic();
|
||||
CountDownLatch latch = new CountDownLatch(3);
|
||||
Awaiter a[] = new Awaiter[12];
|
||||
Awaiter[] a = new Awaiter[12];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
CountDownLatch gate = new CountDownLatch(4);
|
||||
@ -156,7 +156,7 @@ public class Basic {
|
||||
int count =0;
|
||||
Basic test = new Basic();
|
||||
CountDownLatch latch = new CountDownLatch(3);
|
||||
Awaiter a[] = new Awaiter[12];
|
||||
Awaiter[] a = new Awaiter[12];
|
||||
|
||||
long[] timeout = { 0L, 5L, 10L };
|
||||
|
||||
|
@ -57,12 +57,14 @@ public class FlakyThreadFactory {
|
||||
}});
|
||||
test(OutOfMemoryError.class,
|
||||
new ThreadFactory() {
|
||||
public Thread newThread(Runnable r) {
|
||||
new Thread(null, r, "a natural OOME", 1L << 60);
|
||||
// """On some platforms, the value of the stackSize
|
||||
// parameter may have no effect whatsoever."""
|
||||
throw new OutOfMemoryError("artificial OOME");
|
||||
}});
|
||||
@SuppressWarnings("DeadThread")
|
||||
public Thread newThread(Runnable r) {
|
||||
// We expect this to throw OOME, but ...
|
||||
new Thread(null, r, "a natural OOME", 1L << 60);
|
||||
// """On some platforms, the value of the stackSize
|
||||
// parameter may have no effect whatsoever."""
|
||||
throw new OutOfMemoryError("artificial OOME");
|
||||
}});
|
||||
test(null,
|
||||
new ThreadFactory() {
|
||||
public Thread newThread(Runnable r) {
|
||||
|
@ -108,6 +108,7 @@ public class FlakyMutex implements Lock {
|
||||
case 0: throw new MyError();
|
||||
case 1: throw new MyRuntimeException();
|
||||
case 2: FlakyMutex.<RuntimeException>uncheckedThrow(new MyException());
|
||||
// fall through ... NOT!
|
||||
default: return compareAndSetState(0, 1);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -593,7 +593,7 @@ public class SubmissionPublisherTest extends JSR166TestCase {
|
||||
|
||||
/**
|
||||
* estimateMinimumDemand reports 0 until request, nonzero after
|
||||
* request, and zero again after delivery
|
||||
* request
|
||||
*/
|
||||
public void testEstimateMinimumDemand() {
|
||||
TestSubscriber s = new TestSubscriber();
|
||||
@ -604,9 +604,6 @@ public class SubmissionPublisherTest extends JSR166TestCase {
|
||||
assertEquals(0, p.estimateMinimumDemand());
|
||||
s.sn.request(1);
|
||||
assertEquals(1, p.estimateMinimumDemand());
|
||||
p.submit(1);
|
||||
s.awaitNext(1);
|
||||
assertEquals(0, p.estimateMinimumDemand());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user