Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.harmony.tests.java.util;
Expand Down Expand Up @@ -46,7 +46,7 @@ public void test_ConstructorLjava_lang_String() {
// Test for method java.util.NoSuchElementException(java.lang.String)

assertNotNull(new NoSuchElementException("String"));
assertNotNull(new NoSuchElementException(null));
assertNotNull(new NoSuchElementException((String)null));

try {
Vector v = new Vector();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2018, 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
Expand All @@ -26,30 +26,30 @@
package java.util;

/**
* This class provides a skeletal implementation of the <tt>Collection</tt>
* This class provides a skeletal implementation of the {@code Collection}
* interface, to minimize the effort required to implement this interface. <p>
*
* To implement an unmodifiable collection, the programmer needs only to
* extend this class and provide implementations for the <tt>iterator</tt> and
* <tt>size</tt> methods. (The iterator returned by the <tt>iterator</tt>
* method must implement <tt>hasNext</tt> and <tt>next</tt>.)<p>
* extend this class and provide implementations for the {@code iterator} and
* {@code size} methods. (The iterator returned by the {@code iterator}
* method must implement {@code hasNext} and {@code next}.)<p>
*
* To implement a modifiable collection, the programmer must additionally
* override this class's <tt>add</tt> method (which otherwise throws an
* <tt>UnsupportedOperationException</tt>), and the iterator returned by the
* <tt>iterator</tt> method must additionally implement its <tt>remove</tt>
* override this class's {@code add} method (which otherwise throws an
* {@code UnsupportedOperationException}), and the iterator returned by the
* {@code iterator} method must additionally implement its {@code remove}
* method.<p>
*
* The programmer should generally provide a void (no argument) and
* <tt>Collection</tt> constructor, as per the recommendation in the
* <tt>Collection</tt> interface specification.<p>
* {@code Collection} constructor, as per the recommendation in the
* {@code Collection} interface specification.<p>
*
* The documentation for each non-abstract method in this class describes its
* implementation in detail. Each of these methods may be overridden if
* the collection being implemented admits a more efficient implementation.<p>
*
* This class is a member of the
* <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/collections/index.html">
* <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
* Java Collections Framework</a>.
*
* @author Josh Bloch
Expand Down Expand Up @@ -80,7 +80,8 @@ protected AbstractCollection() {
/**
* {@inheritDoc}
*
* <p>This implementation returns <tt>size() == 0</tt>.
* @implSpec
* This implementation returns {@code size() == 0}.
*/
public boolean isEmpty() {
return size() == 0;
Expand All @@ -89,7 +90,8 @@ public boolean isEmpty() {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over the elements in the collection,
* @implSpec
* This implementation iterates over the elements in the collection,
* checking each element in turn for equality with the specified element.
*
* @throws ClassCastException {@inheritDoc}
Expand All @@ -112,7 +114,8 @@ public boolean contains(Object o) {
/**
* {@inheritDoc}
*
* <p>This implementation returns an array containing all the elements
* @implSpec
* This implementation returns an array containing all the elements
* returned by this collection's iterator, in the same order, stored in
* consecutive elements of the array, starting with index {@code 0}.
* The length of the returned array is equal to the number of elements
Expand All @@ -139,7 +142,8 @@ public native Object[] toArray() /*-[
/**
* {@inheritDoc}
*
* <p>This implementation returns an array containing all the elements
* @implSpec
* This implementation returns an array containing all the elements
* returned by this collection's iterator in the same order, stored in
* consecutive elements of the array, starting with index {@code 0}.
* If the number of elements returned by the iterator is too large to
Expand Down Expand Up @@ -226,8 +230,9 @@ private static int hugeCapacity(int minCapacity) {
/**
* {@inheritDoc}
*
* <p>This implementation always throws an
* <tt>UnsupportedOperationException</tt>.
* @implSpec
* This implementation always throws an
* {@code UnsupportedOperationException}.
*
* @throws UnsupportedOperationException {@inheritDoc}
* @throws ClassCastException {@inheritDoc}
Expand All @@ -242,13 +247,14 @@ public boolean add(E e) {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over the collection looking for the
* @implSpec
* This implementation iterates over the collection looking for the
* specified element. If it finds the element, it removes the element
* from the collection using the iterator's remove method.
*
* <p>Note that this implementation throws an
* <tt>UnsupportedOperationException</tt> if the iterator returned by this
* collection's iterator method does not implement the <tt>remove</tt>
* {@code UnsupportedOperationException} if the iterator returned by this
* collection's iterator method does not implement the {@code remove}
* method and this collection contains the specified object.
*
* @throws UnsupportedOperationException {@inheritDoc}
Expand Down Expand Up @@ -281,10 +287,11 @@ public boolean remove(Object o) {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over the specified collection,
* @implSpec
* This implementation iterates over the specified collection,
* checking each element returned by the iterator in turn to see
* if it's contained in this collection. If all elements are so
* contained <tt>true</tt> is returned, otherwise <tt>false</tt>.
* contained {@code true} is returned, otherwise {@code false}.
*
* @throws ClassCastException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
Expand All @@ -300,11 +307,12 @@ public boolean containsAll(Collection<?> c) {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over the specified collection, and adds
* @implSpec
* This implementation iterates over the specified collection, and adds
* each object returned by the iterator to this collection, in turn.
*
* <p>Note that this implementation will throw an
* <tt>UnsupportedOperationException</tt> unless <tt>add</tt> is
* {@code UnsupportedOperationException} unless {@code add} is
* overridden (assuming the specified collection is non-empty).
*
* @throws UnsupportedOperationException {@inheritDoc}
Expand All @@ -326,14 +334,15 @@ public boolean addAll(Collection<? extends E> c) {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over this collection, checking each
* @implSpec
* This implementation iterates over this collection, checking each
* element returned by the iterator in turn to see if it's contained
* in the specified collection. If it's so contained, it's removed from
* this collection with the iterator's <tt>remove</tt> method.
* this collection with the iterator's {@code remove} method.
*
* <p>Note that this implementation will throw an
* <tt>UnsupportedOperationException</tt> if the iterator returned by the
* <tt>iterator</tt> method does not implement the <tt>remove</tt> method
* {@code UnsupportedOperationException} if the iterator returned by the
* {@code iterator} method does not implement the {@code remove} method
* and this collection contains one or more elements in common with the
* specified collection.
*
Expand All @@ -360,14 +369,15 @@ public boolean removeAll(Collection<?> c) {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over this collection, checking each
* @implSpec
* This implementation iterates over this collection, checking each
* element returned by the iterator in turn to see if it's contained
* in the specified collection. If it's not so contained, it's removed
* from this collection with the iterator's <tt>remove</tt> method.
* from this collection with the iterator's {@code remove} method.
*
* <p>Note that this implementation will throw an
* <tt>UnsupportedOperationException</tt> if the iterator returned by the
* <tt>iterator</tt> method does not implement the <tt>remove</tt> method
* {@code UnsupportedOperationException} if the iterator returned by the
* {@code iterator} method does not implement the {@code remove} method
* and this collection contains one or more elements not present in the
* specified collection.
*
Expand All @@ -394,15 +404,16 @@ public boolean retainAll(Collection<?> c) {
/**
* {@inheritDoc}
*
* <p>This implementation iterates over this collection, removing each
* element using the <tt>Iterator.remove</tt> operation. Most
* @implSpec
* This implementation iterates over this collection, removing each
* element using the {@code Iterator.remove} operation. Most
* implementations will probably choose to override this method for
* efficiency.
*
* <p>Note that this implementation will throw an
* <tt>UnsupportedOperationException</tt> if the iterator returned by this
* collection's <tt>iterator</tt> method does not implement the
* <tt>remove</tt> method and this collection is non-empty.
* {@code UnsupportedOperationException} if the iterator returned by this
* collection's {@code iterator} method does not implement the
* {@code remove} method and this collection is non-empty.
*
* @throws UnsupportedOperationException {@inheritDoc}
*/
Expand All @@ -421,8 +432,8 @@ public void clear() {
* Returns a string representation of this collection. The string
* representation consists of a list of the collection's elements in the
* order they are returned by its iterator, enclosed in square brackets
* (<tt>"[]"</tt>). Adjacent elements are separated by the characters
* <tt>", "</tt> (comma and space). Elements are converted to strings as
* ({@code "[]"}). Adjacent elements are separated by the characters
* {@code ", "} (comma and space). Elements are converted to strings as
* by {@link String#valueOf(Object)}.
*
* @return a string representation of this collection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2018, 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
Expand Down Expand Up @@ -62,7 +62,7 @@
* collection being implemented admits a more efficient implementation.
*
* <p>This class is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
* Java Collections Framework</a>.
*
* @author Josh Bloch
Expand Down Expand Up @@ -374,7 +374,7 @@ public E next() {
return next;
} catch (IndexOutOfBoundsException e) {
checkForComodification();
throw new NoSuchElementException();
throw new NoSuchElementException(e);
}
}

Expand Down Expand Up @@ -418,7 +418,7 @@ public E previous() {
return previous;
} catch (IndexOutOfBoundsException e) {
checkForComodification();
throw new NoSuchElementException();
throw new NoSuchElementException(e);
}
}

Expand Down
Loading