diff options
| author | Tobias Thierer <tobiast@google.com> | 2018-02-20 16:39:17 +0000 |
|---|---|---|
| committer | Tobias Thierer <tobiast@google.com> | 2020-01-17 14:43:13 +0000 |
| commit | 72d94d47ac32bd55de714e40696f4cb253295f1b (patch) | |
| tree | b03c074012b12b9d29fe4c36030a60d0a50e8a13 /ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java | |
| parent | ab1c6c4c7a7dd103bf58288bf3f50652985fdc32 (diff) | |
Update misc java.util classes to OpenJDK 9+181 and immediately expose API
This covers
- integration of all changes from OpenJDK 9+181 into
java.util.{AbstractList,List,Map,Objects,Set}.
- Map, List, Set gain static of() / ofEntries() factory methods.
- Objects gains misc static checker methods.
- When implementing RandomAccess, AbstractList.spliterator() as
well as subList.spliterator() is now built on top of random-access
List.get(int) rather than List.iterator().
- addition of various new files that are needed by those.
- addition of Nullablity annotations for the new APIs.
Changes to reference upstream versions
--------------------------------------
While the other files were previously derived from OpenJDK 8u121-b13,
Map.java was previously derived from OpenJDK 9b113+. After this CL,
all of the touched files derive from OpenJDK 9+181 with no further
changes waiting to be integrated; Android-changed and similar markers
note where Android carries local patches.
Notes on test coverage
----------------------
This CL adds test coverage for the new APIs/behavior.
The test coverage for Set.of() duplicates a bunch of logic from
the List.of() coverage. I experimented with ways to reuse code
but that reduced clarity and I didn't want to spend a lot of effort
on a major rearchitecture of the tests.
AbstractListTest asserts that iterator() is not called
while exercising basic existing Android spliterator, and checks
the fail-fast behavior guaranteed by the documentation.
Bug: 147483640
Test: atest CtsLibcoreTestCases:libcore.java.util.{Map,List,Set}OfTest
Test: atest CtsLibcoreTestCases:libcore.java.util.{AbstractList,Objects}Test
Test: atest CtsLibcoreTestCases
Test: Checked how the added @implSpec appear in generated docs: they
appear under headings "Implementation Requirements:".
Change-Id: I362ec405b270ba00fe3176dc19f08943b7d350d5
Diffstat (limited to 'ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java')
| -rw-r--r-- | ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java b/ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java index 591a022fab..ee1b692b58 100644 --- a/ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java +++ b/ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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 @@ -55,5 +55,9 @@ public static boolean isNull(@libcore.util.Nullable java.lang.Object obj) { thro public static boolean nonNull(@libcore.util.Nullable java.lang.Object obj) { throw new RuntimeException("Stub!"); } +@libcore.util.NonNull public static <T> T requireNonNullElse(@libcore.util.Nullable T obj, @libcore.util.NonNull T defaultObj) { throw new RuntimeException("Stub!"); } + +@libcore.util.NonNull public static <T> T requireNonNullElseGet(@libcore.util.Nullable T obj, @libcore.util.NonNull java.util.function.Supplier<? extends @libcore.util.NonNull T> supplier) { throw new RuntimeException("Stub!"); } + @libcore.util.NonNull public static <T> T requireNonNull(@libcore.util.Nullable T obj, @libcore.util.NonNull java.util.function.Supplier<@libcore.util.NonNull java.lang.String> messageSupplier) { throw new RuntimeException("Stub!"); } } |
