--- a/make/RunTests.gmk Tue Dec 05 12:57:48 2017 +0100
+++ b/make/RunTests.gmk Tue Dec 05 13:32:07 2017 +0100
@@ -263,6 +263,15 @@
)
endef
+# Helper function to determine if a test specification is a special test
+#
+# It is a special test if it is "special:" followed by a test name.
+define ParseSpecialTestSelection
+ $(if $(filter special:%, $1), \
+ $1 \
+ )
+endef
+
ifeq ($(TEST), )
$(info No test selection given in TEST!)
$(info Please use e.g. 'run-test TEST=tier1' or 'run-test-tier1')
@@ -282,6 +291,9 @@
$(eval PARSED_TESTS += $(call ParseJtregTestSelection, $(test))) \
) \
$(if $(strip $(PARSED_TESTS)), , \
+ $(eval PARSED_TESTS += $(call ParseSpecialTestSelection, $(test))) \
+ ) \
+ $(if $(strip $(PARSED_TESTS)), , \
$(eval UNKNOWN_TEST := $(test)) \
) \
$(eval TESTS_TO_RUN += $(PARSED_TESTS)) \
@@ -565,6 +577,69 @@
TARGETS += $1
endef
+################################################################################
+
+### Rules for special tests
+
+SetupRunSpecialTest = $(NamedParamsMacroTemplate)
+define SetupRunSpecialTestBody
+ $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
+ $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
+ $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
+
+ $1_FULL_TEST_NAME := $$(strip $$(patsubst special:%, %, $$($1_TEST)))
+ ifneq ($$(findstring :, $$($1_FULL_TEST_NAME)), )
+ $1_TEST_NAME := $$(firstword $$(subst :, ,$$($1_FULL_TEST_NAME)))
+ $1_TEST_ARGS := $$(strip $$(patsubst special:$$($1_TEST_NAME):%, %, $$($1_TEST)))
+ else
+ $1_TEST_NAME := $$($1_FULL_TEST_NAME)
+ $1_TEST_ARGS :=
+ endif
+
+ ifeq ($$($1_TEST_NAME), hotspot-internal)
+ $1_TEST_COMMAND_LINE := \
+ $$(JDK_IMAGE_DIR)/bin/java -XX:+ExecuteInternalVMTests \
+ -XX:+ShowMessageBoxOnError -version
+ else ifeq ($$($1_TEST_NAME), failure-handler)
+ $1_TEST_COMMAND_LINE := \
+ ($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f \
+ BuildFailureHandler.gmk test)
+ else ifeq ($$($1_TEST_NAME), make)
+ $1_TEST_COMMAND_LINE := \
+ ($(CD) $(TOPDIR)/test/make && $(MAKE) $(MAKE_ARGS) -f \
+ TestMake.gmk $$($1_TEST_ARGS))
+ else
+ $$(error Invalid special test specification: $$($1_TEST_NAME))
+ endif
+
+ run-test-$1:
+ $$(call LogWarn)
+ $$(call LogWarn, Running test '$$($1_TEST)')
+ $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
+ $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/test-execution, \
+ $$($1_TEST_COMMAND_LINE) \
+ > >($(TEE) $$($1_TEST_RESULTS_DIR)/test-output.txt) \
+ && $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ || $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ )
+
+ $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
+
+ # We can not parse the various "special" tests.
+ parse-test-$1: run-test-$1
+ $$(call LogWarn, Finished running test '$$($1_TEST)')
+ $$(call LogWarn, Test report is stored in $$(strip \
+ $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
+ $$(call LogWarn, Warning: Special test results are not properly parsed!)
+ $$(eval $1_PASSED := 0)
+ $$(eval $1_FAILED := 0)
+ $$(eval $1_ERROR := 0)
+ $$(eval $1_TOTAL := 0)
+
+ $1: run-test-$1 parse-test-$1
+
+ TARGETS += $1
+endef
################################################################################
# Setup and execute make rules for all selected tests
@@ -577,6 +652,9 @@
UseJtregTestHandler = \
$(if $(filter jtreg:%, $1), true)
+UseSpecialTestHandler = \
+ $(if $(filter special:%, $1), true)
+
# Now process each test to run and setup a proper make rule
$(foreach test, $(TESTS_TO_RUN), \
$(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
@@ -597,6 +675,11 @@
TEST := $(test), \
)) \
) \
+ $(if $(call UseSpecialTestHandler, $(test)), \
+ $(eval $(call SetupRunSpecialTest, $(TEST_ID), \
+ TEST := $(test), \
+ )) \
+ ) \
)
# Sort also removes duplicates, so if there is any we'll get fewer words.
--- a/src/java.base/share/classes/java/util/Collection.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/java.base/share/classes/java/util/Collection.java Tue Dec 05 13:32:07 2017 +0100
@@ -54,19 +54,15 @@
* constructors) but all of the general-purpose {@code Collection}
* implementations in the Java platform libraries comply.
*
- * <p>The "destructive" methods contained in this interface, that is, the
- * methods that modify the collection on which they operate, are specified to
- * throw {@code UnsupportedOperationException} if this collection does not
- * support the operation. If this is the case, these methods may, but are not
- * required to, throw an {@code UnsupportedOperationException} if the
- * invocation would have no effect on the collection. For example, invoking
- * the {@link #addAll(Collection)} method on an unmodifiable collection may,
- * but is not required to, throw the exception if the collection to be added
- * is empty.
+ * <p>Certain methods are specified to be
+ * <i>optional</i>. If a collection implementation doesn't implement a
+ * particular operation, it should define the corresponding method to throw
+ * {@code UnsupportedOperationException}. Such methods are marked "optional
+ * operation" in method specifications of the collections interfaces.
*
- * <p><a id="optional-restrictions">
- * Some collection implementations have restrictions on the elements that
- * they may contain.</a> For example, some implementations prohibit null elements,
+ * <p><a id="optional-restrictions"></a>Some collection implementations
+ * have restrictions on the elements that they may contain.
+ * For example, some implementations prohibit null elements,
* and some have restrictions on the types of their elements. Attempting to
* add an ineligible element throws an unchecked exception, typically
* {@code NullPointerException} or {@code ClassCastException}. Attempting
@@ -111,6 +107,86 @@
* methods. Implementations may optionally handle the self-referential scenario,
* however most current implementations do not do so.
*
+ * <h2><a id="view">View Collections</a></h2>
+ *
+ * <p>Most collections manage storage for elements they contain. By contrast, <i>view
+ * collections</i> themselves do not store elements, but instead they rely on a
+ * backing collection to store the actual elements. Operations that are not handled
+ * by the view collection itself are delegated to the backing collection. Examples of
+ * view collections include the wrapper collections returned by methods such as
+ * {@link Collections#checkedCollection Collections.checkedCollection},
+ * {@link Collections#synchronizedCollection Collections.synchronizedCollection}, and
+ * {@link Collections#unmodifiableCollection Collections.unmodifiableCollection}.
+ * Other examples of view collections include collections that provide a
+ * different representation of the same elements, for example, as
+ * provided by {@link List#subList List.subList},
+ * {@link NavigableSet#subSet NavigableSet.subSet}, or
+ * {@link Map#entrySet Map.entrySet}.
+ * Any changes made to the backing collection are visible in the view collection.
+ * Correspondingly, any changes made to the view collection — if changes
+ * are permitted — are written through to the backing collection.
+ * Although they technically aren't collections, instances of
+ * {@link Iterator} and {@link ListIterator} can also allow modifications
+ * to be written through to the backing collection, and in some cases,
+ * modifications to the backing collection will be visible to the Iterator
+ * during iteration.
+ *
+ * <h2><a id="unmodifiable">Unmodifiable Collections</a></h2>
+ *
+ * <p>Certain methods of this interface are considered "destructive" and are called
+ * "mutator" methods in that they modify the group of objects contained within
+ * the collection on which they operate. They can be specified to throw
+ * {@code UnsupportedOperationException} if this collection implementation
+ * does not support the operation. Such methods should (but are not required
+ * to) throw an {@code UnsupportedOperationException} if the invocation would
+ * have no effect on the collection. For example, consider a collection that
+ * does not support the {@link #add add} operation. What will happen if the
+ * {@link #addAll addAll} method is invoked on this collection, with an empty
+ * collection as the argument? The addition of zero elements has no effect,
+ * so it is permissible for this collection simply to do nothing and not to throw
+ * an exception. However, it is recommended that such cases throw an exception
+ * unconditionally, as throwing only in certain cases can lead to
+ * programming errors.
+ *
+ * <p>An <i>unmodifiable collection</i> is a collection, all of whose
+ * mutator methods (as defined above) are specified to throw
+ * {@code UnsupportedOperationException}. Such a collection thus cannot be
+ * modified by calling any methods on it. For a collection to be properly
+ * unmodifiable, any view collections derived from it must also be unmodifiable.
+ * For example, if a List is unmodifiable, the List returned by
+ * {@link List#subList List.subList} is also unmodifiable.
+ *
+ * <p>An unmodifiable collection is not necessarily immutable. If the
+ * contained elements are mutable, the entire collection is clearly
+ * mutable, even though it might be unmodifiable. For example, consider
+ * two unmodifiable lists containing mutable elements. The result of calling
+ * {@code list1.equals(list2)} might differ from one call to the next if
+ * the elements had been mutated, even though both lists are unmodifiable.
+ * However, if an unmodifiable collection contains all immutable elements,
+ * it can be considered effectively immutable.
+ *
+ * <h2><a id="unmodview">Unmodifiable View Collections</a></h2>
+ *
+ * <p>An <i>unmodifiable view collection</i> is a collection that is unmodifiable
+ * and that is also a view onto a backing collection. Its mutator methods throw
+ * {@code UnsupportedOperationException}, as described above, while
+ * reading and querying methods are delegated to the backing collection.
+ * The effect is to provide read-only access to the backing collection.
+ * This is useful for a component to provide users with read access to
+ * an internal collection, while preventing them from modifying such
+ * collections unexpectedly. Examples of unmodifiable view collections
+ * are those returned by the
+ * {@link Collections#unmodifiableCollection Collections.unmodifiableCollection},
+ * {@link Collections#unmodifiableList Collections.unmodifiableList}, and
+ * related methods.
+ *
+ * <p>Note that changes to the backing collection might still be possible,
+ * and if they occur, they are visible through the unmodifiable view. Thus,
+ * an unmodifiable view collection is not necessarily immutable. However,
+ * if the backing collection of an unmodifiable view is effectively immutable,
+ * or if the only reference to the backing collection is through an
+ * unmodifiable view, the view can be considered effectively immutable.
+ *
* <p>This interface is a member of the
* <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
* Java Collections Framework</a>.
--- a/src/java.base/share/classes/java/util/Collections.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/java.base/share/classes/java/util/Collections.java Tue Dec 05 13:32:07 2017 +0100
@@ -989,9 +989,8 @@
// Unmodifiable Wrappers
/**
- * Returns an unmodifiable view of the specified collection. This method
- * allows modules to provide users with "read-only" access to internal
- * collections. Query operations on the returned collection "read through"
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified collection. Query operations on the returned collection "read through"
* to the specified collection, and attempts to modify the returned
* collection, whether direct or via its iterator, result in an
* {@code UnsupportedOperationException}.<p>
@@ -1102,9 +1101,8 @@
}
/**
- * Returns an unmodifiable view of the specified set. This method allows
- * modules to provide users with "read-only" access to internal sets.
- * Query operations on the returned set "read through" to the specified
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified set. Query operations on the returned set "read through" to the specified
* set, and attempts to modify the returned set, whether direct or via its
* iterator, result in an {@code UnsupportedOperationException}.<p>
*
@@ -1132,9 +1130,8 @@
}
/**
- * Returns an unmodifiable view of the specified sorted set. This method
- * allows modules to provide users with "read-only" access to internal
- * sorted sets. Query operations on the returned sorted set "read
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified sorted set. Query operations on the returned sorted set "read
* through" to the specified sorted set. Attempts to modify the returned
* sorted set, whether direct, via its iterator, or via its
* {@code subSet}, {@code headSet}, or {@code tailSet} views, result in
@@ -1180,9 +1177,8 @@
}
/**
- * Returns an unmodifiable view of the specified navigable set. This method
- * allows modules to provide users with "read-only" access to internal
- * navigable sets. Query operations on the returned navigable set "read
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified navigable set. Query operations on the returned navigable set "read
* through" to the specified navigable set. Attempts to modify the returned
* navigable set, whether direct, via its iterator, or via its
* {@code subSet}, {@code headSet}, or {@code tailSet} views, result in
@@ -1269,9 +1265,8 @@
}
/**
- * Returns an unmodifiable view of the specified list. This method allows
- * modules to provide users with "read-only" access to internal
- * lists. Query operations on the returned list "read through" to the
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified list. Query operations on the returned list "read through" to the
* specified list, and attempts to modify the returned list, whether
* direct or via its iterator, result in an
* {@code UnsupportedOperationException}.<p>
@@ -1415,9 +1410,8 @@
}
/**
- * Returns an unmodifiable view of the specified map. This method
- * allows modules to provide users with "read-only" access to internal
- * maps. Query operations on the returned map "read through"
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified map. Query operations on the returned map "read through"
* to the specified map, and attempts to modify the returned
* map, whether direct or via its collection views, result in an
* {@code UnsupportedOperationException}.<p>
@@ -1765,9 +1759,8 @@
}
/**
- * Returns an unmodifiable view of the specified sorted map. This method
- * allows modules to provide users with "read-only" access to internal
- * sorted maps. Query operations on the returned sorted map "read through"
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified sorted map. Query operations on the returned sorted map "read through"
* to the specified sorted map. Attempts to modify the returned
* sorted map, whether direct, via its collection views, or via its
* {@code subMap}, {@code headMap}, or {@code tailMap} views, result in
@@ -1809,9 +1802,8 @@
}
/**
- * Returns an unmodifiable view of the specified navigable map. This method
- * allows modules to provide users with "read-only" access to internal
- * navigable maps. Query operations on the returned navigable map "read
+ * Returns an <a href="Collection.html#unmodview">unmodifiable view</a> of the
+ * specified navigable map. Query operations on the returned navigable map "read
* through" to the specified navigable map. Attempts to modify the returned
* navigable map, whether direct, via its collection views, or via its
* {@code subMap}, {@code headMap}, or {@code tailMap} views, result in
--- a/src/java.base/share/classes/java/util/List.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/java.base/share/classes/java/util/List.java Tue Dec 05 13:32:07 2017 +0100
@@ -87,15 +87,16 @@
* Such exceptions are marked as "optional" in the specification for this
* interface.
*
- * <h2><a id="immutable">Immutable List Static Factory Methods</a></h2>
- * <p>The {@link List#of(Object...) List.of()} static factory methods
- * provide a convenient way to create immutable lists. The {@code List}
+ * <h2><a id="unmodifiable">Unmodifiable Lists</a></h2>
+ * <p>The {@link List#of(Object...) List.of} and
+ * {@link List#copyOf List.copyOf} static factory methods
+ * provide a convenient way to create unmodifiable lists. The {@code List}
* instances created by these methods have the following characteristics:
*
* <ul>
- * <li>They are <em>structurally immutable</em>. Elements cannot be added, removed,
- * or replaced. Calling any mutator method will always cause
- * {@code UnsupportedOperationException} to be thrown.
+ * <li>They are <a href="Collection.html#unmodifiable"><i>unmodifiable</i></a>. Elements cannot
+ * be added, removed, or replaced. Calling any mutator method on the List
+ * will always cause {@code UnsupportedOperationException} to be thrown.
* However, if the contained elements are themselves mutable,
* this may cause the List's contents to appear to change.
* <li>They disallow {@code null} elements. Attempts to create them with
@@ -777,9 +778,9 @@
}
/**
- * Returns an immutable list containing zero elements.
+ * Returns an unmodifiable list containing zero elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @return an empty {@code List}
@@ -791,9 +792,9 @@
}
/**
- * Returns an immutable list containing one element.
+ * Returns an unmodifiable list containing one element.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the single element
@@ -807,9 +808,9 @@
}
/**
- * Returns an immutable list containing two elements.
+ * Returns an unmodifiable list containing two elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -824,9 +825,9 @@
}
/**
- * Returns an immutable list containing three elements.
+ * Returns an unmodifiable list containing three elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -842,9 +843,9 @@
}
/**
- * Returns an immutable list containing four elements.
+ * Returns an unmodifiable list containing four elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -861,9 +862,9 @@
}
/**
- * Returns an immutable list containing five elements.
+ * Returns an unmodifiable list containing five elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -881,9 +882,9 @@
}
/**
- * Returns an immutable list containing six elements.
+ * Returns an unmodifiable list containing six elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -903,9 +904,9 @@
}
/**
- * Returns an immutable list containing seven elements.
+ * Returns an unmodifiable list containing seven elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -926,9 +927,9 @@
}
/**
- * Returns an immutable list containing eight elements.
+ * Returns an unmodifiable list containing eight elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -950,9 +951,9 @@
}
/**
- * Returns an immutable list containing nine elements.
+ * Returns an unmodifiable list containing nine elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -975,9 +976,9 @@
}
/**
- * Returns an immutable list containing ten elements.
+ * Returns an unmodifiable list containing ten elements.
*
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @param <E> the {@code List}'s element type
* @param e1 the first element
@@ -1001,8 +1002,8 @@
}
/**
- * Returns an immutable list containing an arbitrary number of elements.
- * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ * Returns an unmodifiable list containing an arbitrary number of elements.
+ * See <a href="#unmodifiable">Unmodifiable Lists</a> for details.
*
* @apiNote
* This method also accepts a single array as an argument. The element type of
@@ -1039,4 +1040,29 @@
return new ImmutableCollections.ListN<>(elements);
}
}
+
+ /**
+ * Returns an <a href="#unmodifiable">unmodifiable List</a> containing the elements of
+ * the given Collection, in its iteration order. The given Collection must not be null,
+ * and it must not contain any null elements. If the given Collection is subsequently
+ * modified, the returned List will not reflect such modifications.
+ *
+ * @implNote
+ * If the given Collection is an <a href="#unmodifiable">unmodifiable List</a>,
+ * calling copyOf will generally not create a copy.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param coll a {@code Collection} from which elements are drawn, must be non-null
+ * @return a {@code List} containing the elements of the given {@code Collection}
+ * @throws NullPointerException if coll is null, or if it contains any nulls
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ static <E> List<E> copyOf(Collection<? extends E> coll) {
+ if (coll instanceof ImmutableCollections.AbstractImmutableList) {
+ return (List<E>)coll;
+ } else {
+ return (List<E>)List.of(coll.toArray());
+ }
+ }
}
--- a/src/java.base/share/classes/java/util/Map.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/java.base/share/classes/java/util/Map.java Tue Dec 05 13:32:07 2017 +0100
@@ -110,17 +110,18 @@
* Implementations may optionally handle the self-referential scenario, however
* most current implementations do not do so.
*
- * <h2><a id="immutable">Immutable Map Static Factory Methods</a></h2>
- * <p>The {@link Map#of() Map.of()} and
- * {@link Map#ofEntries(Map.Entry...) Map.ofEntries()}
- * static factory methods provide a convenient way to create immutable maps.
+ * <h2><a id="unmodifiable">Unmodifiable Maps</a></h2>
+ * <p>The {@link Map#of() Map.of},
+ * {@link Map#ofEntries(Map.Entry...) Map.ofEntries}, and
+ * {@link Map#copyOf Map.copyOf}
+ * static factory methods provide a convenient way to create unmodifiable maps.
* The {@code Map}
* instances created by these methods have the following characteristics:
*
* <ul>
- * <li>They are <em>structurally immutable</em>. Keys and values cannot be added,
- * removed, or updated. Calling any mutator method will always cause
- * {@code UnsupportedOperationException} to be thrown.
+ * <li>They are <a href="Collection.html#unmodifiable"><i>unmodifiable</i></a>. Keys and values
+ * cannot be added, removed, or updated. Calling any mutator method on the Map
+ * will always cause {@code UnsupportedOperationException} to be thrown.
* However, if the contained keys or values are themselves mutable, this may cause the
* Map to behave inconsistently or its contents to appear to change.
* <li>They disallow {@code null} keys and values. Attempts to create them with
@@ -1276,8 +1277,8 @@
}
/**
- * Returns an immutable map containing zero mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing zero mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1290,8 +1291,8 @@
}
/**
- * Returns an immutable map containing a single mapping.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing a single mapping.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1307,8 +1308,8 @@
}
/**
- * Returns an immutable map containing two mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing two mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1327,8 +1328,8 @@
}
/**
- * Returns an immutable map containing three mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing three mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1349,8 +1350,8 @@
}
/**
- * Returns an immutable map containing four mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing four mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1373,8 +1374,8 @@
}
/**
- * Returns an immutable map containing five mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing five mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1399,8 +1400,8 @@
}
/**
- * Returns an immutable map containing six mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing six mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1429,8 +1430,8 @@
}
/**
- * Returns an immutable map containing seven mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing seven mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1461,8 +1462,8 @@
}
/**
- * Returns an immutable map containing eight mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing eight mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1495,8 +1496,8 @@
}
/**
- * Returns an immutable map containing nine mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing nine mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1531,8 +1532,8 @@
}
/**
- * Returns an immutable map containing ten mappings.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * Returns an unmodifiable map containing ten mappings.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
@@ -1569,9 +1570,9 @@
}
/**
- * Returns an immutable map containing keys and values extracted from the given entries.
+ * Returns an unmodifiable map containing keys and values extracted from the given entries.
* The entries themselves are not stored in the map.
- * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*
* @apiNote
* It is convenient to create the map entries using the {@link Map#entry Map.entry()} method.
@@ -1602,15 +1603,17 @@
@SafeVarargs
@SuppressWarnings("varargs")
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
- if (entries.length == 0) { // implicit null check of entries
+ if (entries.length == 0) { // implicit null check of entries array
return ImmutableCollections.Map0.instance();
} else if (entries.length == 1) {
+ // implicit null check of the array slot
return new ImmutableCollections.Map1<>(entries[0].getKey(),
entries[0].getValue());
} else {
Object[] kva = new Object[entries.length << 1];
int a = 0;
for (Entry<? extends K, ? extends V> entry : entries) {
+ // implicit null checks of each array slot
kva[a++] = entry.getKey();
kva[a++] = entry.getValue();
}
@@ -1619,7 +1622,7 @@
}
/**
- * Returns an immutable {@link Entry} containing the given key and value.
+ * Returns an unmodifiable {@link Entry} containing the given key and value.
* These entries are suitable for populating {@code Map} instances using the
* {@link Map#ofEntries Map.ofEntries()} method.
* The {@code Entry} instances created by this method have the following characteristics:
@@ -1627,7 +1630,7 @@
* <ul>
* <li>They disallow {@code null} keys and values. Attempts to create them using a {@code null}
* key or value result in {@code NullPointerException}.
- * <li>They are immutable. Calls to {@link Entry#setValue Entry.setValue()}
+ * <li>They are unmodifiable. Calls to {@link Entry#setValue Entry.setValue()}
* on a returned {@code Entry} result in {@code UnsupportedOperationException}.
* <li>They are not serializable.
* <li>They are <a href="../lang/doc-files/ValueBased.html">value-based</a>.
@@ -1655,4 +1658,30 @@
// KeyValueHolder checks for nulls
return new KeyValueHolder<>(k, v);
}
+
+ /**
+ * Returns an <a href="#unmodifiable">unmodifiable Map</a> containing the entries
+ * of the given Map. The given Map must not be null, and it must not contain any
+ * null keys or values. If the given Map is subsequently modified, the returned
+ * Map will not reflect such modifications.
+ *
+ * @implNote
+ * If the given Map is an <a href="#unmodifiable">unmodifiable Map</a>,
+ * calling copyOf will generally not create a copy.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param map a {@code Map} from which entries are drawn, must be non-null
+ * @return a {@code Map} containing the entries of the given {@code Map}
+ * @throws NullPointerException if map is null, or if it contains any null keys or values
+ * @since 10
+ */
+ @SuppressWarnings({"rawtypes","unchecked"})
+ static <K, V> Map<K, V> copyOf(Map<? extends K, ? extends V> map) {
+ if (map instanceof ImmutableCollections.AbstractImmutableMap) {
+ return (Map<K,V>)map;
+ } else {
+ return (Map<K,V>)Map.ofEntries(map.entrySet().toArray(new Entry[0]));
+ }
+ }
}
--- a/src/java.base/share/classes/java/util/Set.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/java.base/share/classes/java/util/Set.java Tue Dec 05 13:32:07 2017 +0100
@@ -63,15 +63,16 @@
* Such exceptions are marked as "optional" in the specification for this
* interface.
*
- * <h2><a id="immutable">Immutable Set Static Factory Methods</a></h2>
- * <p>The {@link Set#of(Object...) Set.of()} static factory methods
- * provide a convenient way to create immutable sets. The {@code Set}
+ * <h2><a id="unmodifiable">Unmodifiable Sets</a></h2>
+ * <p>The {@link Set#of(Object...) Set.of} and
+ * {@link Set#copyOf Set.copyOf} static factory methods
+ * provide a convenient way to create unmodifiable sets. The {@code Set}
* instances created by these methods have the following characteristics:
*
* <ul>
- * <li>They are <em>structurally immutable</em>. Elements cannot be added or
- * removed. Calling any mutator method will always cause
- * {@code UnsupportedOperationException} to be thrown.
+ * <li>They are <a href="Collection.html#unmodifiable"><i>unmodifiable</i></a>. Elements cannot
+ * be added or removed. Calling any mutator method on the Set
+ * will always cause {@code UnsupportedOperationException} to be thrown.
* However, if the contained elements are themselves mutable, this may cause the
* Set to behave inconsistently or its contents to appear to change.
* <li>They disallow {@code null} elements. Attempts to create them with
@@ -439,8 +440,8 @@
}
/**
- * Returns an immutable set containing zero elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing zero elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @return an empty {@code Set}
@@ -452,8 +453,8 @@
}
/**
- * Returns an immutable set containing one element.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing one element.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the single element
@@ -467,8 +468,8 @@
}
/**
- * Returns an immutable set containing two elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing two elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -484,8 +485,8 @@
}
/**
- * Returns an immutable set containing three elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing three elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -502,8 +503,8 @@
}
/**
- * Returns an immutable set containing four elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing four elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -521,8 +522,8 @@
}
/**
- * Returns an immutable set containing five elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing five elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -541,8 +542,8 @@
}
/**
- * Returns an immutable set containing six elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing six elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -563,8 +564,8 @@
}
/**
- * Returns an immutable set containing seven elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing seven elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -586,8 +587,8 @@
}
/**
- * Returns an immutable set containing eight elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing eight elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -610,8 +611,8 @@
}
/**
- * Returns an immutable set containing nine elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing nine elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -635,8 +636,8 @@
}
/**
- * Returns an immutable set containing ten elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing ten elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @param <E> the {@code Set}'s element type
* @param e1 the first element
@@ -661,8 +662,8 @@
}
/**
- * Returns an immutable set containing an arbitrary number of elements.
- * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ * Returns an unmodifiable set containing an arbitrary number of elements.
+ * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*
* @apiNote
* This method also accepts a single array as an argument. The element type of
@@ -700,4 +701,30 @@
return new ImmutableCollections.SetN<>(elements);
}
}
+
+ /**
+ * Returns an <a href="#unmodifiable">unmodifiable Set</a> containing the elements
+ * of the given Collection. The given Collection must not be null, and it must not
+ * contain any null elements. If the given Collection contains duplicate elements,
+ * an arbitrary element of the duplicates is preserved. If the given Collection is
+ * subsequently modified, the returned Set will not reflect such modifications.
+ *
+ * @implNote
+ * If the given Collection is an <a href="#unmodifiable">unmodifiable Set</a>,
+ * calling copyOf will generally not create a copy.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param coll a {@code Collection} from which elements are drawn, must be non-null
+ * @return a {@code Set} containing the elements of the given {@code Collection}
+ * @throws NullPointerException if coll is null, or if it contains any nulls
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ static <E> Set<E> copyOf(Collection<? extends E> coll) {
+ if (coll instanceof ImmutableCollections.AbstractImmutableSet) {
+ return (Set<E>)coll;
+ } else {
+ return (Set<E>)Set.of(new HashSet<>(coll).toArray());
+ }
+ }
}
--- a/src/java.base/share/classes/java/util/stream/Collectors.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/java.base/share/classes/java/util/stream/Collectors.java Tue Dec 05 13:32:07 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -116,6 +116,8 @@
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED,
Collector.Characteristics.IDENTITY_FINISH));
static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet();
+ static final Set<Collector.Characteristics> CH_UNORDERED_NOID
+ = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED));
private Collectors() { }
@@ -279,6 +281,26 @@
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * <a href="../List.html#unmodifiable">unmodifiable List</a> in encounter
+ * order. The returned Collector disallows null values and will throw
+ * {@code NullPointerException} if it is presented with a null value.
+ *
+ * @param <T> the type of the input elements
+ * @return a {@code Collector} that accumulates the input elements into an
+ * <a href="../List.html#unmodifiable">unmodifiable List</a> in encounter order
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ public static <T>
+ Collector<T, ?, List<T>> toUnmodifiableList() {
+ return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add,
+ (left, right) -> { left.addAll(right); return left; },
+ list -> (List<T>)List.of(list.toArray()),
+ CH_NOID);
+ }
+
+ /**
* Returns a {@code Collector} that accumulates the input elements into a
* new {@code Set}. There are no guarantees on the type, mutability,
* serializability, or thread-safety of the {@code Set} returned; if more
@@ -306,6 +328,36 @@
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * <a href="../Set.html#unmodifiable">unmodifiable Set</a>. The returned
+ * Collector disallows null values and will throw {@code NullPointerException}
+ * if it is presented with a null value. If the input contains duplicate elements,
+ * an arbitrary element of the duplicates is preserved.
+ *
+ * <p>This is an {@link Collector.Characteristics#UNORDERED unordered}
+ * Collector.
+ *
+ * @param <T> the type of the input elements
+ * @return a {@code Collector} that accumulates the input elements into an
+ * <a href="../Set.html#unmodifiable">unmodifiable Set</a>
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ public static <T>
+ Collector<T, ?, Set<T>> toUnmodifiableSet() {
+ return new CollectorImpl<>((Supplier<Set<T>>) HashSet::new, Set::add,
+ (left, right) -> {
+ if (left.size() < right.size()) {
+ right.addAll(left); return right;
+ } else {
+ left.addAll(right); return left;
+ }
+ },
+ set -> (Set<T>)Set.of(set.toArray()),
+ CH_UNORDERED_NOID);
+ }
+
+ /**
* Returns a {@code Collector} that concatenates the input elements into a
* {@code String}, in encounter order.
*
@@ -1353,7 +1405,7 @@
* <p>If the mapped keys contain duplicates (according to
* {@link Object#equals(Object)}), an {@code IllegalStateException} is
* thrown when the collection operation is performed. If the mapped keys
- * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)}
+ * might have duplicates, use {@link #toMap(Function, Function, BinaryOperator)}
* instead.
*
* <p>There are no guarantees on the type, mutability, serializability,
@@ -1411,6 +1463,45 @@
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * <a href="../Map.html#unmodifiable">unmodifiable Map</a>,
+ * whose keys and values are the result of applying the provided
+ * mapping functions to the input elements.
+ *
+ * <p>If the mapped keys contain duplicates (according to
+ * {@link Object#equals(Object)}), an {@code IllegalStateException} is
+ * thrown when the collection operation is performed. If the mapped keys
+ * might have duplicates, use {@link #toUnmodifiableMap(Function, Function, BinaryOperator)}
+ * to handle merging of the values.
+ *
+ * <p>The returned Collector disallows null keys and values. If either mapping function
+ * returns null, {@code NullPointerException} will be thrown.
+ *
+ * @param <T> the type of the input elements
+ * @param <K> the output type of the key mapping function
+ * @param <U> the output type of the value mapping function
+ * @param keyMapper a mapping function to produce keys, must be non-null
+ * @param valueMapper a mapping function to produce values, must be non-null
+ * @return a {@code Collector} that accumulates the input elements into an
+ * <a href="../Map.html#unmodifiable">unmodifiable Map</a>, whose keys and values
+ * are the result of applying the provided mapping functions to the input elements
+ * @throws NullPointerException if either keyMapper or valueMapper is null
+ *
+ * @see #toUnmodifiableMap(Function, Function, BinaryOperator)
+ * @since 10
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static <T, K, U>
+ Collector<T, ?, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper,
+ Function<? super T, ? extends U> valueMapper) {
+ Objects.requireNonNull(keyMapper, "keyMapper");
+ Objects.requireNonNull(valueMapper, "valueMapper");
+ return collectingAndThen(
+ toMap(keyMapper, valueMapper),
+ map -> (Map<K,U>)Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])));
+ }
+
+ /**
* Returns a {@code Collector} that accumulates elements into a
* {@code Map} whose keys and values are the result of applying the provided
* mapping functions to the input elements.
@@ -1473,6 +1564,51 @@
return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new);
}
+
+ /**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * <a href="../Map.html#unmodifiable">unmodifiable Map</a>,
+ * whose keys and values are the result of applying the provided
+ * mapping functions to the input elements.
+ *
+ * <p>If the mapped
+ * keys contain duplicates (according to {@link Object#equals(Object)}),
+ * the value mapping function is applied to each equal element, and the
+ * results are merged using the provided merging function.
+ *
+ * <p>The returned Collector disallows null keys and values. If either mapping function
+ * returns null, {@code NullPointerException} will be thrown.
+ *
+ * @param <T> the type of the input elements
+ * @param <K> the output type of the key mapping function
+ * @param <U> the output type of the value mapping function
+ * @param keyMapper a mapping function to produce keys, must be non-null
+ * @param valueMapper a mapping function to produce values, must be non-null
+ * @param mergeFunction a merge function, used to resolve collisions between
+ * values associated with the same key, as supplied
+ * to {@link Map#merge(Object, Object, BiFunction)},
+ * must be non-null
+ * @return a {@code Collector} that accumulates the input elements into an
+ * <a href="../Map.html#unmodifiable">unmodifiable Map</a>, whose keys and values
+ * are the result of applying the provided mapping functions to the input elements
+ * @throws NullPointerException if the keyMapper, valueMapper, or mergeFunction is null
+ *
+ * @see #toUnmodifiableMap(Function, Function)
+ * @since 10
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static <T, K, U>
+ Collector<T, ?, Map<K,U>> toUnmodifiableMap(Function<? super T, ? extends K> keyMapper,
+ Function<? super T, ? extends U> valueMapper,
+ BinaryOperator<U> mergeFunction) {
+ Objects.requireNonNull(keyMapper, "keyMapper");
+ Objects.requireNonNull(valueMapper, "valueMapper");
+ Objects.requireNonNull(mergeFunction, "mergeFunction");
+ return collectingAndThen(
+ toMap(keyMapper, valueMapper, mergeFunction, HashMap::new),
+ map -> (Map<K,U>)Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])));
+ }
+
/**
* Returns a {@code Collector} that accumulates elements into a
* {@code Map} whose keys and values are the result of applying the provided
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java Tue Dec 05 13:32:07 2017 +0100
@@ -145,11 +145,19 @@
/**
* Visits a HiddenTree node.
+ *
+ * @implSpec Visits a {@code HiddenTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitHidden(HiddenTree node, P p);
+ default R visitHidden(HiddenTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits an IdentifierTree node.
@@ -161,11 +169,19 @@
/**
* Visits an IndexTree node.
+ *
+ * @implSpec Visits an {@code IndexTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitIndex(IndexTree node, P p);
+ default R visitIndex(IndexTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits an InheritDocTree node.
@@ -201,11 +217,19 @@
/**
* Visits a ProvidesTree node.
+ *
+ * @implSpec Visits a {@code ProvidesTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitProvides(ProvidesTree node, P p);
+ default R visitProvides(ProvidesTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits a ReferenceTree node.
@@ -320,11 +344,19 @@
/**
* Visits a UsesTree node.
+ *
+ * @implSpec Visits a {@code UsesTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitUses(UsesTree node, P p);
+ default R visitUses(UsesTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits a ValueTree node.
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Tue Dec 05 12:57:48 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Tue Dec 05 13:32:07 2017 +0100
@@ -220,6 +220,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitHidden(HiddenTree node, P p) {
@@ -244,6 +246,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitIndex(IndexTree node, P p) {
@@ -304,6 +308,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitProvides(ProvidesTree node, P p) {
@@ -473,6 +479,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitUses(UsesTree node, P p) {
--- a/test/jdk/java/awt/Component/GetScreenLocTest/ComponentGetLocationOnScreenNPETest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/awt/Component/GetScreenLocTest/ComponentGetLocationOnScreenNPETest.java Tue Dec 05 13:32:07 2017 +0100
@@ -25,6 +25,7 @@
* @test
* @bug 8189204
* @summary Possible NPE in Component::getLocationOnScreen()
+ * @key headful
* @run main ComponentGetLocationOnScreenNPETest
*/
--- a/test/jdk/java/awt/Dialog/SiblingChildOrder/SiblingChildOrderTest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/awt/Dialog/SiblingChildOrder/SiblingChildOrderTest.java Tue Dec 05 13:32:07 2017 +0100
@@ -21,9 +21,11 @@
* questions.
*/
-/* @test
+/**
+ * @test
* @bug 8190230
* @summary [macosx] Order of overlapping of modal dialogs is wrong
+ * @key headful
* @run main SiblingChildOrderTest
*/
--- a/test/jdk/java/awt/Focus/FocusTransitionTest/FocusTransitionTest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/awt/Focus/FocusTransitionTest/FocusTransitionTest.java Tue Dec 05 13:32:07 2017 +0100
@@ -21,10 +21,12 @@
* questions.
*/
-/* @test
+/**
+ * @test
* @bug 8155197
* @summary Tests whether the value of mostRecentFocusOwner for a window is correct, if
* another window is displayed during focus transition
+ * @key headful
* @library ../../regtesthelpers
* @build Util
* @run main FocusTransitionTest
--- a/test/jdk/java/util/Collection/MOAT.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/util/Collection/MOAT.java Tue Dec 05 13:32:07 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -57,6 +57,8 @@
import java.util.concurrent.*;
import static java.util.Collections.*;
import java.lang.reflect.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class MOAT {
// Collections under test must not be initialized to contain this value,
@@ -230,6 +232,17 @@
testListMutatorsAlwaysThrow(list);
}
+ List<Integer> listCopy = List.copyOf(Arrays.asList(1, 2, 3));
+ testCollection(listCopy);
+ testImmutableList(listCopy);
+ testListMutatorsAlwaysThrow(listCopy);
+
+ List<Integer> listCollected = Stream.of(1, 2, 3).collect(Collectors.toUnmodifiableList());
+ equal(listCollected, List.of(1, 2, 3));
+ testCollection(listCollected);
+ testImmutableList(listCollected);
+ testListMutatorsAlwaysThrow(listCollected);
+
// Immutable Set
testEmptySet(Set.of());
testCollMutatorsAlwaysThrow(Set.of());
@@ -252,6 +265,18 @@
testCollMutatorsAlwaysThrow(set);
}
+ Set<Integer> setCopy = Set.copyOf(Arrays.asList(1, 2, 3));
+ testCollection(setCopy);
+ testImmutableSet(setCopy);
+ testCollMutatorsAlwaysThrow(setCopy);
+
+ Set<Integer> setCollected = Stream.of(1, 1, 2, 3, 2, 3)
+ .collect(Collectors.toUnmodifiableSet());
+ equal(setCollected, Set.of(1, 2, 3));
+ testCollection(setCollected);
+ testImmutableSet(setCollected);
+ testCollMutatorsAlwaysThrow(setCollected);
+
// Immutable Map
@SuppressWarnings("unchecked")
@@ -280,6 +305,35 @@
testImmutableMap(map);
testMapMutatorsAlwaysThrow(map);
}
+
+ Map<Integer,Integer> mapCopy = Map.copyOf(new HashMap<>(Map.of(1, 101, 2, 202, 3, 303)));
+ testMap(mapCopy);
+ testImmutableMap(mapCopy);
+ testMapMutatorsAlwaysThrow(mapCopy);
+
+ Map<Integer,Integer> mapCollected1 =
+ Stream.of(1, 2, 3)
+ .collect(Collectors.toUnmodifiableMap(i -> i, i -> 101 * i));
+ equal(mapCollected1, Map.of(1, 101, 2, 202, 3, 303));
+ testMap(mapCollected1);
+ testImmutableMap(mapCollected1);
+ testMapMutatorsAlwaysThrow(mapCollected1);
+
+ try {
+ Stream.of(1, 1, 2, 3, 2, 3)
+ .collect(Collectors.toUnmodifiableMap(i -> i, i -> 101 * i));
+ fail("duplicates should have thrown an exception");
+ } catch (IllegalStateException ise) {
+ pass();
+ }
+
+ Map<Integer,Integer> mapCollected2 =
+ Stream.of(1, 1, 2, 3, 2, 3)
+ .collect(Collectors.toUnmodifiableMap(i -> i, i -> 101 * i, Integer::sum));
+ equal(mapCollected2, Map.of(1, 202, 2, 404, 3, 606));
+ testMap(mapCollected2);
+ testImmutableMap(mapCollected2);
+ testMapMutatorsAlwaysThrow(mapCollected2);
}
private static void checkContainsSelf(Collection<Integer> c) {
--- a/test/jdk/java/util/Collection/SetFactories.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/util/Collection/SetFactories.java Tue Dec 05 13:32:07 2017 +0100
@@ -40,6 +40,9 @@
import org.testng.annotations.Test;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -275,9 +278,9 @@
static <T> T serialClone(T obj) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
+ try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+ oos.writeObject(obj);
+ }
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
return (T) ois.readObject();
@@ -285,4 +288,53 @@
throw new AssertionError(e);
}
}
+
+ Set<Integer> genSet() {
+ return new HashSet<>(Arrays.asList(1, 2, 3));
+ }
+
+ @Test
+ public void copyOfResultsEqual() {
+ Set<Integer> orig = genSet();
+ Set<Integer> copy = Set.copyOf(orig);
+
+ assertEquals(orig, copy);
+ assertEquals(copy, orig);
+ }
+
+ @Test
+ public void copyOfModifiedUnequal() {
+ Set<Integer> orig = genSet();
+ Set<Integer> copy = Set.copyOf(orig);
+ orig.add(4);
+
+ assertNotEquals(orig, copy);
+ assertNotEquals(copy, orig);
+ }
+
+ @Test
+ public void copyOfIdentity() {
+ Set<Integer> orig = genSet();
+ Set<Integer> copy1 = Set.copyOf(orig);
+ Set<Integer> copy2 = Set.copyOf(copy1);
+
+ assertNotSame(orig, copy1);
+ assertSame(copy1, copy2);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullCollection() {
+ Set<Integer> set = Set.copyOf(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullElements() {
+ Set<Integer> set = Set.copyOf(Arrays.asList(1, null, 3));
+ }
+
+ @Test
+ public void copyOfAcceptsDuplicates() {
+ Set<Integer> set = Set.copyOf(Arrays.asList(1, 1, 2, 3, 3, 3));
+ assertEquals(set, Set.of(1, 2, 3));
+ }
}
--- a/test/jdk/java/util/List/ListFactories.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/util/List/ListFactories.java Tue Dec 05 13:32:07 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -39,6 +39,9 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -221,9 +224,9 @@
static <T> T serialClone(T obj) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
+ try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+ oos.writeObject(obj);
+ }
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
return (T) ois.readObject();
@@ -231,4 +234,47 @@
throw new AssertionError(e);
}
}
+
+ List<Integer> genList() {
+ return new ArrayList<>(Arrays.asList(1, 2, 3));
+ }
+
+ @Test
+ public void copyOfResultsEqual() {
+ List<Integer> orig = genList();
+ List<Integer> copy = List.copyOf(orig);
+
+ assertEquals(orig, copy);
+ assertEquals(copy, orig);
+ }
+
+ @Test
+ public void copyOfModifiedUnequal() {
+ List<Integer> orig = genList();
+ List<Integer> copy = List.copyOf(orig);
+ orig.add(4);
+
+ assertNotEquals(orig, copy);
+ assertNotEquals(copy, orig);
+ }
+
+ @Test
+ public void copyOfIdentity() {
+ List<Integer> orig = genList();
+ List<Integer> copy1 = List.copyOf(orig);
+ List<Integer> copy2 = List.copyOf(copy1);
+
+ assertNotSame(orig, copy1);
+ assertSame(copy1, copy2);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullCollection() {
+ List<Integer> list = List.copyOf(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullElements() {
+ List<Integer> list = List.copyOf(Arrays.asList(1, null, 3));
+ }
}
--- a/test/jdk/java/util/Map/MapFactories.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/java/util/Map/MapFactories.java Tue Dec 05 13:32:07 2017 +0100
@@ -42,6 +42,9 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -70,6 +73,12 @@
}
// for varargs Map.Entry methods
+
+ @SuppressWarnings("unchecked")
+ Map.Entry<Integer,String>[] genEmptyEntryArray1() {
+ return (Map.Entry<Integer,String>[])new Map.Entry<?,?>[1];
+ }
+
@SuppressWarnings("unchecked")
Map.Entry<Integer,String>[] genEntries(int n) {
return IntStream.range(0, n)
@@ -322,21 +331,41 @@
}
@Test(expectedExceptions=NullPointerException.class)
- public void nullKeyDisallowedN() {
- Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
- entries[0] = new AbstractMap.SimpleImmutableEntry(null, "a");
+ public void nullKeyDisallowedVar1() {
+ Map.Entry<Integer,String>[] entries = genEmptyEntryArray1();
+ entries[0] = new AbstractMap.SimpleImmutableEntry<>(null, "a");
+ Map<Integer, String> map = Map.ofEntries(entries);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void nullValueDisallowedVar1() {
+ Map.Entry<Integer,String>[] entries = genEmptyEntryArray1();
+ entries[0] = new AbstractMap.SimpleImmutableEntry<>(0, null);
Map<Integer, String> map = Map.ofEntries(entries);
}
@Test(expectedExceptions=NullPointerException.class)
- public void nullValueDisallowedN() {
- Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
- entries[0] = new AbstractMap.SimpleImmutableEntry(0, null);
+ public void nullEntryDisallowedVar1() {
+ Map.Entry<Integer,String>[] entries = genEmptyEntryArray1();
Map<Integer, String> map = Map.ofEntries(entries);
}
@Test(expectedExceptions=NullPointerException.class)
- public void nullEntryDisallowedN() {
+ public void nullKeyDisallowedVarN() {
+ Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
+ entries[0] = new AbstractMap.SimpleImmutableEntry<>(null, "a");
+ Map<Integer, String> map = Map.ofEntries(entries);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void nullValueDisallowedVarN() {
+ Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
+ entries[0] = new AbstractMap.SimpleImmutableEntry<>(0, null);
+ Map<Integer, String> map = Map.ofEntries(entries);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void nullEntryDisallowedVarN() {
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES);
entries[5] = null;
Map<Integer, String> map = Map.ofEntries(entries);
@@ -344,7 +373,7 @@
@Test(expectedExceptions=NullPointerException.class)
public void nullArrayDisallowed() {
- Map.ofEntries(null);
+ Map.ofEntries((Map.Entry<?,?>[])null);
}
@Test(dataProvider="all")
@@ -359,9 +388,9 @@
static <T> T serialClone(T obj) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
+ try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+ oos.writeObject(obj);
+ }
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
return (T) ois.readObject();
@@ -370,6 +399,62 @@
}
}
+ Map<Integer, String> genMap() {
+ Map<Integer, String> map = new HashMap<>();
+ map.put(1, "a");
+ map.put(2, "b");
+ map.put(3, "c");
+ return map;
+ }
+
+ @Test
+ public void copyOfResultsEqual() {
+ Map<Integer, String> orig = genMap();
+ Map<Integer, String> copy = Map.copyOf(orig);
+
+ assertEquals(orig, copy);
+ assertEquals(copy, orig);
+ }
+
+ @Test
+ public void copyOfModifiedUnequal() {
+ Map<Integer, String> orig = genMap();
+ Map<Integer, String> copy = Map.copyOf(orig);
+ orig.put(4, "d");
+
+ assertNotEquals(orig, copy);
+ assertNotEquals(copy, orig);
+ }
+
+ @Test
+ public void copyOfIdentity() {
+ Map<Integer, String> orig = genMap();
+ Map<Integer, String> copy1 = Map.copyOf(orig);
+ Map<Integer, String> copy2 = Map.copyOf(copy1);
+
+ assertNotSame(orig, copy1);
+ assertSame(copy1, copy2);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullMap() {
+ Map<Integer, String> map = Map.copyOf(null);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullKey() {
+ Map<Integer, String> map = genMap();
+ map.put(null, "x");
+ Map<Integer, String> copy = Map.copyOf(map);
+ }
+
+ @Test(expectedExceptions=NullPointerException.class)
+ public void copyOfRejectsNullValue() {
+ Map<Integer, String> map = genMap();
+ map.put(-1, null);
+ Map<Integer, String> copy = Map.copyOf(map);
+ }
+
// Map.entry() tests
@Test(expectedExceptions=NullPointerException.class)
@@ -386,7 +471,7 @@
public void entryBasicTests() {
Map.Entry<String,String> kvh1 = Map.entry("xyzzy", "plugh");
Map.Entry<String,String> kvh2 = Map.entry("foobar", "blurfl");
- Map.Entry<String,String> sie = new AbstractMap.SimpleImmutableEntry("xyzzy", "plugh");
+ Map.Entry<String,String> sie = new AbstractMap.SimpleImmutableEntry<>("xyzzy", "plugh");
assertTrue(kvh1.equals(sie));
assertTrue(sie.equals(kvh1));
@@ -404,5 +489,4 @@
Map<Number,Number> map = Map.ofEntries(e1, e2);
assertEquals(map.size(), 2);
}
-
}
--- a/test/jdk/javax/swing/DefaultButtonModel/DefaultButtonModelCrashTest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/DefaultButtonModel/DefaultButtonModelCrashTest.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,12 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8182577
* @summary Verifies if moving focus via custom ButtonModel causes crash
+ * @key headful
* @run main DefaultButtonModelCrashTest
*/
+
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Point;
@@ -61,7 +64,7 @@
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
} finally {
- SwingUtilities.invokeAndWait(()->frame .dispose());
+ if (frame != null) { SwingUtilities.invokeAndWait(()->frame.dispose()); }
}
}
--- a/test/jdk/javax/swing/GraphicsConfigNotifier/TestMultiScreenGConfigNotify.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/GraphicsConfigNotifier/TestMultiScreenGConfigNotify.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,12 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8178025
* @summary Verifies if graphicsConfiguration property notification is sent
* when frame is moved from one screen to another in multiscreen
* environment.
+ * @key headful
* @run main TestMultiScreenGConfigNotify
*/
--- a/test/jdk/javax/swing/JButton/TestGlyphBreak.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/JButton/TestGlyphBreak.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,10 +20,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8191428
* @summary Verifies if text view is not borken into multiple lines
+ * @key headful
* @run main/othervm -Dsun.java2d.uiScale=1.2 TestGlyphBreak
*/
--- a/test/jdk/javax/swing/JComboBox/8182031/ComboPopupTest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/JComboBox/8182031/ComboPopupTest.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,12 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8182031
* @summary Verifies if ComboBox Popup opens and closes immediately
+ * @key headful
* @run main ComboPopupTest
*/
+
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
@@ -80,7 +83,7 @@
throw new RuntimeException("combobox popup is not visible");
}
} finally {
- SwingUtilities.invokeAndWait(()->frame.dispose());
+ if (frame != null) { SwingUtilities.invokeAndWait(()->frame.dispose()); }
}
}
--- a/test/jdk/javax/swing/JMenu/8178430/LabelDotTest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/JMenu/8178430/LabelDotTest.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,13 +20,16 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8178430
* @summary JMenu in GridBagLayout flickers when label text shows "..." and
* is updated
+ * @key headful
* @run main LabelDotTest
*/
+
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -112,7 +115,9 @@
SwingUtilities.invokeAndWait(() -> createUI());
runTest(50);
} finally {
- SwingUtilities.invokeAndWait(() -> frame.dispose());
+ if (frame != null) {
+ SwingUtilities.invokeAndWait(() -> frame.dispose());
+ }
if (isException)
throw new RuntimeException("Size of Menu bar is not correct.");
}
--- a/test/jdk/javax/swing/JTextArea/TestTabSize.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/JTextArea/TestTabSize.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,10 +20,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8187957
* @summary Verifies Tab Size works correctly in JTextArea
+ * @key headful
* @run main TestTabSize
*/
@@ -96,7 +98,9 @@
} catch (BadLocationException ex) {
excpnthrown = true;
} finally {
- f.dispose();
+ if (f != null) {
+ f.dispose();
+ }
}
});
if (excpnthrown) {
--- a/test/jdk/javax/swing/dnd/8139050/NativeErrorsInTableDnD.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/dnd/8139050/NativeErrorsInTableDnD.java Tue Dec 05 13:32:07 2017 +0100
@@ -40,10 +40,12 @@
/**
* @test
* @bug 8139050 8153871
+ * @key headful
* @library ../../../../lib/testlibrary
* @build ExtendedRobot
* @run main/othervm/timeout=360 -Xcheck:jni NativeErrorsInTableDnD
*/
+
public final class NativeErrorsInTableDnD {
private static JFrame frame;
--- a/test/jdk/javax/swing/plaf/nimbus/TestNimbusOverride.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/plaf/nimbus/TestNimbusOverride.java Tue Dec 05 13:32:07 2017 +0100
@@ -20,13 +20,16 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
* @bug 8043315
* @summary Verifies if setting Nimbus.Overrides property affects
* keymap installation
+ * @key headful
* @run main TestNimbusOverride
*/
+
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
--- a/test/jdk/javax/swing/text/DefaultCaret/HidingSelection/HidingSelectionTest.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/javax/swing/text/DefaultCaret/HidingSelection/HidingSelectionTest.java Tue Dec 05 13:32:07 2017 +0100
@@ -30,6 +30,7 @@
* @test
* @bug 8188081
* @summary Text selection does not clear after focus is lost
+ * @key headful
* @run main HidingSelectionTest
*/
--- a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java Tue Dec 05 12:57:48 2017 +0100
+++ b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java Tue Dec 05 13:32:07 2017 +0100
@@ -694,11 +694,15 @@
gencert("ts", "-ext eku:critical=ts");
- // Issue another cert for "ts" with a different EKU.
- // Length should be the same. Try several times.
- keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " +
- "-ext eku:critical=1.3.6.1.5.5.7.3.9");
for (int i = 0; i < 5; i++) {
+ // Issue another cert for "ts" with a different EKU.
+ // Length might be different because serial number is
+ // random. Try several times until a cert with the same
+ // length is generated so we can substitute ts.cert
+ // embedded in the PKCS7 block with ts2.cert.
+ // If cannot create one, related test will be ignored.
+ keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " +
+ "-ext eku:critical=1.3.6.1.5.5.7.3.9");
if (Files.size(Paths.get("ts.cert")) != Files.size(Paths.get("ts2.cert"))) {
Files.delete(Paths.get("ts2.cert"));
System.out.println("Warning: cannot create same length");