Merge "Snap for 6198741 from f2679e9bb8aabf4963425941bdbfd0683e5ff843 to sdk-release" into sdk-release
diff --git a/Android.bp b/Android.bp
index 268ea18..d205aeb 100644
--- a/Android.bp
+++ b/Android.bp
@@ -24,7 +24,7 @@
genrule {
name: "notices-for-framework-stubs",
visibility: [
- "//development/build",
+ "//frameworks/base",
],
tool_files: [
"NOTICE",
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index a9218db..407b30f 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -120,10 +120,7 @@
"//frameworks/base",
],
srcs: [
- ":android_icu4j_src_files",
- ":core_oj_api_files",
- ":core_libart_api_files",
- ":conscrypt_public_api_files",
+ ":android_icu4j_public_api_files",
],
}
@@ -142,8 +139,14 @@
tools: [
"merge_zips",
],
+ srcs: [
+ ":art-module-public-api-stubs-source",
+ ":conscrypt-module-public-api-stubs-source",
+ ],
out: ["core-current-stubs-source.srcjar"],
- cmd: "$(location merge_zips) $(out)",
+ cmd: "$(location merge_zips) $(out)" +
+ " $(location :art-module-public-api-stubs-source)" +
+ " $(location :conscrypt-module-public-api-stubs-source)",
}
// The set of files for the ART module that contribute to one or more API
@@ -205,6 +208,7 @@
":core_libart_java_files",
":openjdk_lambda_stub_files",
":openjdk_generated_annotation_stub_files",
+ ":app-compat-annotations-source",
],
sdk_version: "none",
@@ -257,6 +261,10 @@
"//external/wycheproof",
"//libcore/benchmarks",
],
+ apex_available: [
+ "com.android.art.release",
+ "com.android.art.debug",
+ ],
defaults: ["libcore_java_defaults"],
installable: true,
hostdex: true,
@@ -301,6 +309,10 @@
"//libcore/benchmarks",
"//frameworks/layoutlib",
],
+ apex_available: [
+ "com.android.art.release",
+ "com.android.art.debug",
+ ],
defaults: ["libcore_java_defaults"],
installable: true,
hostdex: true,
@@ -472,8 +484,11 @@
java_library_static {
name: "core-test-rules",
visibility: [
+ "//art/build/sdk",
"//external/conscrypt",
"//frameworks/base/location/tests/locationtests",
+ "//frameworks/base/core/tests/coretests",
+ "//frameworks/base/wifi/tests",
],
hostdex: true,
srcs: [
@@ -488,29 +503,33 @@
// Builds platform_compat test rules
java_library_static {
- name: "platform_compat-test-rules",
- visibility: ["//visibility:public"],
+ name: "core-compat-test-rules",
+ visibility: [
+ "//art/build/sdk",
+ "//frameworks/base/tests/PlatformCompatGating/test-rules",
+ ],
srcs: [
"luni/src/main/java/android/compat/**/*.java",
"test-rules/src/platform_compat/**/*.java",
"luni/src/main/java/libcore/api/CorePlatformApi.java",
"luni/src/main/java/libcore/api/IntraCoreApi.java",
-
],
static_libs: [
"junit",
"guava",
- "android-support-test",
],
- platform_apis: true,
+ sdk_version: "none",
+ system_modules: "core-all-system-modules",
// This builds classes that are in the java.base Java module:
patch_module: "java.base",
+ hostdex: true,
}
// Builds the core-tests-support library used by various tests.
java_library_static {
name: "core-tests-support",
visibility: [
+ "//art/build/sdk",
"//cts/apps/CtsVerifier",
"//cts/tests/tests/keystore",
"//cts/tests/tests/net",
@@ -555,6 +574,14 @@
visibility: ["//libcore/luni/src/test/java9language"],
}
+genrule {
+ name: "core-tests-smali-dex",
+ srcs: ["luni/src/test/java/**/*.smali"],
+ cmd: "$(location smali) ass --api 28 -o $(out) $(in)",
+ out: ["core-tests-smali.dex"],
+ tools: ["smali"],
+}
+
// Builds the core-tests library.
java_test {
name: "core-tests",
@@ -591,6 +618,7 @@
":annotations-test",
":filesystemstest",
":parameter-metadata-test",
+ ":core-tests-smali-dex",
],
sdk_version: "none",
@@ -601,7 +629,7 @@
],
static_libs: [
- "archive-patcher",
+ "core-compat-test-rules",
"core-java-9-language-tests",
"core-test-rules",
"core-tests-support",
@@ -613,7 +641,7 @@
"slf4j-jdk14",
"sqlite-jdbc",
"tzdata-testing",
- "truth-prebuilt",
+ "truth-prebuilt-jar",
],
errorprone: {
@@ -707,9 +735,6 @@
// available to metalava. Used for nullability annotations in OpenJDK source.
droiddoc_exported_dir {
name: "ojluni-annotated-sdk-stubs",
- visibility: [
- "//frameworks/base",
- ],
path: "ojluni/annotations/sdk",
}
@@ -742,11 +767,16 @@
],
}
-// Generates stubs for the parts of the public SDK API provided by the ART module.
+// A special set of stubs containing the minimal set of self consistent
+// classes for which a system module can be created. Every system module must
+// contain the java.lang classes so the set was constructed by starting with
+// the java.lang classes and then adding their transitive dependencies without
+// splitting packages. So, if one class from a package is used then all classes
+// in that package were added to the set.
//
-// Only for use by art.module.public.api.stubs target below.
+// Needed for java-current-stubs-system-modules.
droidstubs {
- name: "art-module-public-api-stubs-gen",
+ name: "java-current-stubs-source",
srcs: [
":core_oj_api_files",
":core_libart_api_files",
@@ -755,12 +785,13 @@
installable: false,
sdk_version: "none",
system_modules: "none",
+
+ args: "--stub-packages java.*:javax.*:org.w3c.dom.*:org.xml.sax.*",
}
-// A stubs target containing the parts of the public SDK API provided by the ART module.
java_library {
- name: "art.module.public.api.stubs",
- srcs: [":art-module-public-api-stubs-gen"],
+ name: "java.current.stubs",
+ srcs: [":java-current-stubs-source"],
errorprone: {
javacflags: [
"-Xep:MissingOverride:OFF",
@@ -771,6 +802,82 @@
system_modules: "none",
}
+// A special set of system modules needed to build art.module.public.api.stubs
+// that contain nullability annotations when targeting java language level 1.9
+// and above.
+java_system_modules {
+ name: "java-current-stubs-system-modules",
+ libs: [
+ // Minimal set of classes required for a system module.
+ "java.current.stubs",
+
+ // The nullability annotations used by the generated stubs.
+ "stub-annotations",
+ ],
+}
+
+// http://b/129765390 Rewrite links to "platform" or "technotes" folders
+// which are siblings (and thus outside of) {@docRoot}.
+//
+// We have to escape \ as \\ and $ as $$ here because they get resolved by
+// different layers of the build tooling. The arguments are wrapped in '' so
+// that the shell doesn't add yet another level of escaping.
+rewrite_openjdk_doc_args = "--replace-documentation " +
+ // packages whose descendants to apply replacement to (all packages from
+ // libcore/ojluni/src/main/java that contribute to documentation).
+ "com.sun:java:javax:jdk.net:sun " +
+ // regex of the string to replace
+ "'(<a\\s+href\\s?=[\\*\\s]*\")(?:(?:\\{@docRoot\\}/\\.\\./)|(?:(?:\\.\\./)+))((?:platform|technotes).+)\">' " +
+ // replacement (with $1, $2 backreferences to the regex groups)
+ "'$$1https://docs.oracle.com/javase/8/docs/$$2\">' "
+
+// Generates stubs for the parts of the public SDK API provided by the ART module.
+//
+// Only for use by art.module.public.api.stubs target below.
+droidstubs {
+ name: "art-module-public-api-stubs-source",
+ srcs: [
+ ":core_oj_api_files",
+ ":core_libart_api_files",
+ ],
+ java_version: "1.9",
+ installable: false,
+ sdk_version: "none",
+ system_modules: "java-current-stubs-system-modules",
+ libs: [
+ // Provide access to I18N constants that are used to initialize
+ // constants in the public API. i.e. to allow the value of the
+ // java.text.CollectionElementIterator.NULLORDER to be initialized from
+ // android.icu.text.CollationElementIterator.NULLORDER.
+ "i18n.module.intra.core.api.stubs",
+ ],
+
+ args: rewrite_openjdk_doc_args,
+
+ create_doc_stubs: true,
+
+ // Emit nullability annotations from the source to the stub files.
+ annotations_enabled: true,
+
+ merge_annotations_dirs: [
+ "ojluni-annotated-sdk-stubs",
+ ],
+}
+
+// A stubs target containing the parts of the public SDK API provided by the ART module.
+java_library {
+ name: "art.module.public.api.stubs",
+ srcs: [":art-module-public-api-stubs-source"],
+ errorprone: {
+ javacflags: [
+ "-Xep:MissingOverride:OFF",
+ ],
+ },
+ patch_module: "java.base",
+ sdk_version: "none",
+ system_modules: "java-current-stubs-system-modules",
+}
+
// Used when compiling higher-level code against art.module.public.api.stubs.
//
// This is only intended for use within core libraries and must not be used
@@ -778,6 +885,7 @@
java_system_modules {
name: "art-module-public-api-stubs-system-modules",
visibility: [
+ "//art/build/sdk",
"//external/conscrypt",
"//external/icu/android_icu4j",
"//external/wycheproof",
@@ -797,6 +905,12 @@
// the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
// annotations.
"art.module.api.annotations.for.system.modules",
+
+ // Make nullability annotations available when compiling public stubs.
+ // They are provided as a separate library because while the
+ // annotations are not themselves part of the public API provided by
+ // this module they are used in the stubs.
+ "stub-annotations",
],
}
@@ -858,7 +972,6 @@
"--validate-nullability-from-merged-stubs ",
merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
merge_annotations_dirs: [
- "metalava-manual",
// N.B. Stubs in this filegroup will be validated:
"ojluni-annotated-nullability-stubs",
],
@@ -875,6 +988,7 @@
java_library_host {
name: "timezone-host",
visibility: [
+ "//art/build/sdk",
"//system/timezone/distro/core",
],
srcs: [":timezone_host_files"],
@@ -917,5 +1031,6 @@
srcs: [
":api_surface_annotation_files",
],
+ java_version: "1.9",
sdk_version: "core_current",
}
diff --git a/NativeCode.bp b/NativeCode.bp
index a27fa74..9619420 100644
--- a/NativeCode.bp
+++ b/NativeCode.bp
@@ -50,6 +50,10 @@
visibility: [
"//art/build/apex",
],
+ apex_available: [
+ "com.android.art.release",
+ "com.android.art.debug",
+ ],
defaults: [
"core_native_default_flags",
"core_native_default_libs",
@@ -88,6 +92,15 @@
name: "libandroidio",
visibility: [
"//art/build/apex",
+ "//external/conscrypt",
+ ],
+ apex_available: [
+ "com.android.art.release",
+ "com.android.art.debug",
+ // TODO(b/147813447) remove this. This is currently due to the 'runtime_libs'
+ // dependency from libjavacrypto in the conscrypt APEX.
+ "com.android.conscrypt",
+ "test_com.android.conscrypt",
],
defaults: [
"core_native_default_flags",
@@ -164,6 +177,10 @@
visibility: [
"//art/build/apex",
],
+ apex_available: [
+ "com.android.art.release",
+ "com.android.art.debug",
+ ],
defaults: ["libopenjdk_native_defaults"],
shared_libs: [
"libopenjdkjvm",
@@ -176,6 +193,9 @@
visibility: [
"//art/build/apex",
],
+ apex_available: [
+ "com.android.art.debug",
+ ],
defaults: ["libopenjdk_native_defaults"],
shared_libs: [
"libopenjdkjvmd",
@@ -186,6 +206,7 @@
cc_library_shared {
name: "libjavacoretests",
visibility: [
+ "//art/build/sdk",
"//cts/tests/libcore/luni",
],
defaults: ["core_native_default_flags"],
diff --git a/OWNERS b/OWNERS
index 1dcf25e..174fb87 100644
--- a/OWNERS
+++ b/OWNERS
@@ -5,7 +5,7 @@
# People who can approve changes for submission; don't send review emails to them
# unless you know what you're doing.
-flooey@google.com
+dauletz@google.com
narayan@google.com
nfuller@google.com
nikitai@google.com
diff --git a/dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java b/dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java
deleted file mode 100644
index aaebbb8..0000000
--- a/dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 dalvik.annotation.compat;
-
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-import dalvik.system.VersionCodes;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import libcore.api.CorePlatformApi;
-import libcore.api.IntraCoreApi;
-
-/**
- * Indicates that a class member, that is not part of the SDK, is used by apps.
- * Since the member is not part of the SDK, such use is not supported.
- *
- * <p>This annotation acts as a heads up that changing a given method or field
- * may affect apps, potentially breaking them when the next Android version is
- * released. In some cases, for members that are heavily used, this annotation
- * may imply restrictions on changes to the member.
- *
- * <p>This annotation also results in access to the member being permitted by the
- * runtime, with a warning being generated in debug builds.
- *
- * <p>For more details, see go/UnsupportedAppUsage.
- *
- * {@hide}
- */
-@Retention(CLASS)
-@Target({CONSTRUCTOR, METHOD, FIELD, TYPE})
-@Repeatable(UnsupportedAppUsage.Container.class)
-@CorePlatformApi
-@IntraCoreApi
-public @interface UnsupportedAppUsage {
-
- /**
- * Associates a bug tracking the work to add a public alternative to this API. Optional.
- *
- * @return ID of the associated tracking bug
- */
- @CorePlatformApi
- @IntraCoreApi
- long trackingBug() default 0;
-
- /**
- * Indicates that usage of this API is limited to apps based on their target SDK version.
- *
- * <p>Access to the API is allowed if the targetSdkVersion in the apps manifest is no greater
- * than this value. Access checks are performed at runtime.
- *
- * <p>This is used to give app developers a grace period to migrate off a non-SDK interface.
- * When making Android version N, existing APIs can have a maxTargetSdk of N-1 added to them.
- * Developers must then migrate off the API when their app is updated in future, but it will
- * continue working in the meantime.
- *
- * <p>Possible values are:
- * <ul>
- * <li>
- * {@link VersionCodes#O} - in which case the API is available up to and including the
- * O release and all intermediate releases between O and P. Or in other words the API
- * is blacklisted (unavailable) from P onwards.
- * </li>
- * <li>
- * {@link VersionCodes#P} - in which case the API is available up to and including the
- * P release and all intermediate releases between P and Q. Or in other words the API
- * is blacklisted (unavailable) from Q onwards.
- * </li>
- * <li>
- * absent (default value) - All apps can access this API, but doing so may result in
- * warnings in the log, UI warnings (on developer builds) and/or strictmode violations.
- * The API is likely to be further restricted in future.
- * </li>
- *
- * </ul>
- *
- * @return The maximum value for an apps targetSdkVersion in order to access this API.
- */
- @CorePlatformApi
- @IntraCoreApi
- int maxTargetSdk() default Integer.MAX_VALUE;
-
- /**
- * For debug use only. The expected dex signature to be generated for this API, used to verify
- * parts of the build process.
- *
- * @return A dex API signature.
- */
- @CorePlatformApi
- @IntraCoreApi
- String expectedSignature() default "";
-
- /**
- * The signature of an implicit (not present in the source) member that forms part of the
- * hiddenapi.
- *
- * <p>Allows access to non-SDK API elements that are not represented in the input source to be
- * managed.
- *
- * <p>This must only be used when applying the annotation to a type, using it in any other
- * situation is an error.
- *
- * @return A dex API signature.
- */
- @CorePlatformApi
- @IntraCoreApi
- String implicitMember() default "";
-
- /**
- * Public API alternatives to this API.
- *
- * <p>If non-empty, the string must be a description of the public API alternative(s) to this
- * API. The explanation must contain at least one Javadoc link tag to public API methods or
- * fields. e.g.:
- * {@literal @UnsupportedAppUsage(publicAlternatives="Use {@link foo.bar.Baz#bat()} instead.")}
- *
- * <p>Any elements that can be deduced can be omitted, e.g.:
- * <ul>
- * <li>
- * the class, if it's the same as for the annotated element.
- * </li>
- * <li>
- * the package name, if it's the same as for the annotated element.
- * </li>
- * <li>
- * the method parameters, if there is only one method with that name in the given
- * package and class.
- * </li>
- * </ul>
- * @return A Javadoc-formatted string.
- */
- @SuppressWarnings("JavadocReference")
- @CorePlatformApi
- @IntraCoreApi
- String publicAlternatives() default "";
-
- /**
- * Container for {@link UnsupportedAppUsage} that allows it to be applied repeatedly to types.
- */
- @Retention(CLASS)
- @Target(TYPE)
- @CorePlatformApi
- @IntraCoreApi
- @interface Container {
- @CorePlatformApi
- @IntraCoreApi
- UnsupportedAppUsage[] value();
- }
-}
diff --git a/dalvik/src/main/java/dalvik/system/VersionCodes.java b/dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java
similarity index 97%
rename from dalvik/src/main/java/dalvik/system/VersionCodes.java
rename to dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java
index b20af83..8f7bcd2 100644
--- a/dalvik/src/main/java/dalvik/system/VersionCodes.java
+++ b/dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package dalvik.system;
+package dalvik.annotation.compat;
import libcore.api.CorePlatformApi;
import libcore.api.IntraCoreApi;
diff --git a/dalvik/src/main/java/dalvik/system/BaseDexClassLoader.java b/dalvik/src/main/java/dalvik/system/BaseDexClassLoader.java
index 1c129e2..d0a449b 100644
--- a/dalvik/src/main/java/dalvik/system/BaseDexClassLoader.java
+++ b/dalvik/src/main/java/dalvik/system/BaseDexClassLoader.java
@@ -16,7 +16,7 @@
package dalvik.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -159,6 +159,20 @@
}
/**
+ * Computes the classloader contexts for each classpath entry in {@code pathList.getDexPaths()}.
+ *
+ * Note that this method is not thread safe, i.e. it is the responsibility of the caller to
+ * ensure that {@code pathList.getDexPaths()} is not modified concurrently with this method
+ * being called.
+ *
+ * @return A non-null array of non-null strings of length
+ * {@code 2 * pathList.getDexPaths().size()}. Every even index (0 is even here) is a dex file
+ * path and every odd entry is the class loader context used to load the previously listed dex
+ * file. E.g. a result might be {@code { "foo.dex", "PCL[]", "bar.dex", "PCL[foo.dex]" } }.
+ */
+ private native String[] computeClassLoaderContextsNative();
+
+ /**
* Constructs an instance.
*
* dexFile must be an in-memory representation of a full dexFile.
@@ -330,14 +344,7 @@
}
@Override public String toString() {
- String sharedLibs = "";
- if (sharedLibraryLoaders != null) {
- for (Object obj : sharedLibraryLoaders) {
- sharedLibs += obj + ",";
- }
- }
- return getClass().getName() + "[" + pathList + "; parent=(" + getParent()
- + "), shared-libs=(" + sharedLibs + ")]";
+ return getClass().getName() + "[" + pathList + "]";
}
/**
diff --git a/dalvik/src/main/java/dalvik/system/BlockGuard.java b/dalvik/src/main/java/dalvik/system/BlockGuard.java
index c608407..192e450 100644
--- a/dalvik/src/main/java/dalvik/system/BlockGuard.java
+++ b/dalvik/src/main/java/dalvik/system/BlockGuard.java
@@ -16,10 +16,10 @@
package dalvik.system;
-import libcore.util.NonNull;
+import android.compat.annotation.UnsupportedAppUsage;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import java.util.Objects;
+import libcore.util.NonNull;
/**
* Interface that enables {@code StrictMode} to install callbacks to implement
diff --git a/dalvik/src/main/java/dalvik/system/CloseGuard.java b/dalvik/src/main/java/dalvik/system/CloseGuard.java
index 818f289..4607f2d 100644
--- a/dalvik/src/main/java/dalvik/system/CloseGuard.java
+++ b/dalvik/src/main/java/dalvik/system/CloseGuard.java
@@ -16,7 +16,7 @@
package dalvik.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* CloseGuard is a mechanism for flagging implicit finalizer cleanup of
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java
index 486ee90..176fde4 100644
--- a/dalvik/src/main/java/dalvik/system/DexFile.java
+++ b/dalvik/src/main/java/dalvik/system/DexFile.java
@@ -16,9 +16,9 @@
package dalvik.system;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.ErrnoException;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.annotation.optimization.ReachabilitySensitive;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -28,6 +28,8 @@
import java.util.List;
import libcore.io.Libcore;
+import dalvik.annotation.optimization.ReachabilitySensitive;
+
/**
* Loads DEX files. This class is meant for internal use and should not be used
* by applications.
diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java
index e430b55..798166c 100644
--- a/dalvik/src/main/java/dalvik/system/DexPathList.java
+++ b/dalvik/src/main/java/dalvik/system/DexPathList.java
@@ -16,11 +16,13 @@
package dalvik.system;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.ErrnoException;
import android.system.StructStat;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
@@ -219,32 +221,25 @@
suppressedExceptionList, definingContext, isTrusted);
if (newElements != null && newElements.length > 0) {
- final Element[] oldElements = dexElements;
- dexElements = new Element[oldElements.length + newElements.length];
- System.arraycopy(
- oldElements, 0, dexElements, 0, oldElements.length);
- System.arraycopy(
- newElements, 0, dexElements, oldElements.length, newElements.length);
+ dexElements = concat(Element.class, dexElements, newElements);
}
if (suppressedExceptionList.size() > 0) {
- final IOException[] newSuppressedExceptions = suppressedExceptionList.toArray(
+ final IOException[] newSuppExceptions = suppressedExceptionList.toArray(
new IOException[suppressedExceptionList.size()]);
- if (dexElementsSuppressedExceptions != null) {
- final IOException[] oldSuppressedExceptions = dexElementsSuppressedExceptions;
- final int suppressedExceptionsLength = oldSuppressedExceptions.length +
- newSuppressedExceptions.length;
- dexElementsSuppressedExceptions = new IOException[suppressedExceptionsLength];
- System.arraycopy(oldSuppressedExceptions, 0, dexElementsSuppressedExceptions,
- 0, oldSuppressedExceptions.length);
- System.arraycopy(newSuppressedExceptions, 0, dexElementsSuppressedExceptions,
- oldSuppressedExceptions.length, newSuppressedExceptions.length);
- } else {
- dexElementsSuppressedExceptions = newSuppressedExceptions;
- }
+ dexElementsSuppressedExceptions = dexElementsSuppressedExceptions != null
+ ? concat(IOException.class, dexElementsSuppressedExceptions, newSuppExceptions)
+ : newSuppExceptions;
}
}
+ private static<T> T[] concat(Class<T> componentType, T[] inputA, T[] inputB) {
+ T[] output = (T[]) Array.newInstance(componentType, inputA.length + inputB.length);
+ System.arraycopy(inputA, 0, output, 0, inputA.length);
+ System.arraycopy(inputB, 0, output, inputA.length, inputB.length);
+ return output;
+ }
+
/**
* For InMemoryDexClassLoader. Initializes {@code dexElements} with dex files
* loaded from {@code dexFiles} buffers.
@@ -603,12 +598,8 @@
return path;
}
}
- // Don't give up even if we failed to find the library in the native lib paths.
- // The underlying dynamic linker might be able to find the lib in one of the linker
- // namespaces associated with the current linker namespace. In order to give the
- // dynamic linker a chance, proceed to load the library with its soname, which
- // is the fileName.
- return fileName;
+
+ return null;
}
/**
diff --git a/dalvik/src/main/java/dalvik/system/EmulatedStackFrame.java b/dalvik/src/main/java/dalvik/system/EmulatedStackFrame.java
index b479d6f..7a1c20b 100644
--- a/dalvik/src/main/java/dalvik/system/EmulatedStackFrame.java
+++ b/dalvik/src/main/java/dalvik/system/EmulatedStackFrame.java
@@ -346,20 +346,29 @@
return this;
}
- protected void checkType(Class<?> type) {
+ private Class<?> getCurrentArgumentType() {
if (argumentIdx >= numArgs || argumentIdx == (RETURN_VALUE_IDX + 1)) {
throw new IllegalArgumentException("Invalid argument index: " + argumentIdx);
}
-
- final Class<?> expectedType = (argumentIdx == RETURN_VALUE_IDX) ?
+ return (argumentIdx == RETURN_VALUE_IDX) ?
frame.type.rtype() : frame.type.ptypes()[argumentIdx];
+ }
- if (expectedType != type) {
- throw new IllegalArgumentException("Incorrect type: " + type +
- ", expected: " + expectedType);
+ private static void checkAssignable(Class<?> expectedType, Class<?> actualType) {
+ if (!expectedType.isAssignableFrom(actualType)) {
+ throw new IllegalArgumentException("Incorrect type: " + actualType
+ + ", expected: " + expectedType);
}
}
+ protected void checkWriteType(Class<?> type) {
+ checkAssignable(getCurrentArgumentType(), type);
+ }
+
+ protected void checkReadType(Class<?> expectedType) {
+ checkAssignable(expectedType, getCurrentArgumentType());
+ }
+
/**
* Positions the cursor at the return value location, either in the references array
* or in the stack frame array. The next put* or next* call will result in a read or
@@ -408,55 +417,55 @@
*/
public static class StackFrameWriter extends StackFrameAccessor {
public void putNextByte(byte value) {
- checkType(byte.class);
+ checkWriteType(byte.class);
argumentIdx++;
frameBuf.putInt(value);
}
public void putNextInt(int value) {
- checkType(int.class);
+ checkWriteType(int.class);
argumentIdx++;
frameBuf.putInt(value);
}
public void putNextLong(long value) {
- checkType(long.class);
+ checkWriteType(long.class);
argumentIdx++;
frameBuf.putLong(value);
}
public void putNextChar(char value) {
- checkType(char.class);
+ checkWriteType(char.class);
argumentIdx++;
frameBuf.putInt((int) value);
}
public void putNextBoolean(boolean value) {
- checkType(boolean.class);
+ checkWriteType(boolean.class);
argumentIdx++;
frameBuf.putInt(value ? 1 : 0);
}
public void putNextShort(short value) {
- checkType(short.class);
+ checkWriteType(short.class);
argumentIdx++;
frameBuf.putInt((int) value);
}
public void putNextFloat(float value) {
- checkType(float.class);
+ checkWriteType(float.class);
argumentIdx++;
frameBuf.putFloat(value);
}
public void putNextDouble(double value) {
- checkType(double.class);
+ checkWriteType(double.class);
argumentIdx++;
frameBuf.putDouble(value);
}
public void putNextReference(Object value, Class<?> expectedType) {
- checkType(expectedType);
+ checkWriteType(expectedType);
argumentIdx++;
frame.references[referencesOffset++] = value;
}
@@ -468,55 +477,55 @@
*/
public static class StackFrameReader extends StackFrameAccessor {
public byte nextByte() {
- checkType(byte.class);
+ checkReadType(byte.class);
argumentIdx++;
return (byte) frameBuf.getInt();
}
public int nextInt() {
- checkType(int.class);
+ checkReadType(int.class);
argumentIdx++;
return frameBuf.getInt();
}
public long nextLong() {
- checkType(long.class);
+ checkReadType(long.class);
argumentIdx++;
return frameBuf.getLong();
}
public char nextChar() {
- checkType(char.class);
+ checkReadType(char.class);
argumentIdx++;
return (char) frameBuf.getInt();
}
public boolean nextBoolean() {
- checkType(boolean.class);
+ checkReadType(boolean.class);
argumentIdx++;
return (frameBuf.getInt() != 0);
}
public short nextShort() {
- checkType(short.class);
+ checkReadType(short.class);
argumentIdx++;
return (short) frameBuf.getInt();
}
public float nextFloat() {
- checkType(float.class);
+ checkReadType(float.class);
argumentIdx++;
return frameBuf.getFloat();
}
public double nextDouble() {
- checkType(double.class);
+ checkReadType(double.class);
argumentIdx++;
return frameBuf.getDouble();
}
public <T> T nextReference(Class<T> expectedType) {
- checkType(expectedType);
+ checkReadType(expectedType);
argumentIdx++;
return (T) frame.references[referencesOffset++];
}
diff --git a/dalvik/src/main/java/dalvik/system/RuntimeHooks.java b/dalvik/src/main/java/dalvik/system/RuntimeHooks.java
index 320ea28..f1af867 100644
--- a/dalvik/src/main/java/dalvik/system/RuntimeHooks.java
+++ b/dalvik/src/main/java/dalvik/system/RuntimeHooks.java
@@ -16,10 +16,15 @@
package dalvik.system;
+import dalvik.system.ThreadPrioritySetter;
+
import java.util.Objects;
import java.util.TimeZone;
import java.util.function.Supplier;
+import libcore.util.NonNull;
+import libcore.util.Nullable;
+
/**
* Provides lifecycle methods and other hooks for an Android runtime "container" to call into the
* runtime and core libraries during initialization. For example, from
@@ -35,6 +40,10 @@
private static Supplier<String> zoneIdSupplier;
+ // BEGIN Android-added: Customize behavior of Thread.setPriority(). http://b/139521784
+ private static volatile ThreadPrioritySetter threadPrioritySetter;
+ // END Android-added: Customize behavior of Thread.setPriority(). http://b/139521784
+
private RuntimeHooks() {
// No need to construct an instance. All methods are static.
}
@@ -77,4 +86,27 @@
Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
Thread.setUncaughtExceptionPreHandler(uncaughtExceptionHandler);
}
+
+ // BEGIN Android-added: Customize behavior of Thread.setPriority(). http://b/139521784
+ /**
+ * Sets a {@link ThreadPrioritySetter} that will be invoked instead of
+ * the default implementation during {@link Thread.setPriority(int)}.
+ * @hide
+ */
+ @libcore.api.CorePlatformApi
+ public static void setThreadPrioritySetter(@NonNull ThreadPrioritySetter threadPrioritySetter) {
+ RuntimeHooks.threadPrioritySetter = Objects.requireNonNull(threadPrioritySetter);
+ }
+
+ /**
+ * Returns the last {@code ThreadPrioritySetter} that has been
+ * {@code #setThreadPrioritySetter(ThreadPrioritySetter) set}, or
+ * null if the setter has not yet been called.
+ * @hide
+ */
+ @libcore.api.CorePlatformApi
+ public static @Nullable ThreadPrioritySetter getThreadPrioritySetter() {
+ return threadPrioritySetter;
+ }
+ // END Android-added: Customize behavior of Thread.setPriority(). http://b/139521784
}
diff --git a/dalvik/src/main/java/dalvik/system/SocketTagger.java b/dalvik/src/main/java/dalvik/system/SocketTagger.java
index 54ede15..0493daa 100644
--- a/dalvik/src/main/java/dalvik/system/SocketTagger.java
+++ b/dalvik/src/main/java/dalvik/system/SocketTagger.java
@@ -16,7 +16,7 @@
package dalvik.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.FileDescriptor;
import java.net.DatagramSocket;
import java.net.Socket;
diff --git a/dalvik/src/main/java/dalvik/system/ThreadPrioritySetter.java b/dalvik/src/main/java/dalvik/system/ThreadPrioritySetter.java
new file mode 100644
index 0000000..484784b
--- /dev/null
+++ b/dalvik/src/main/java/dalvik/system/ThreadPrioritySetter.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 dalvik.system;
+
+/**
+ * Interface for hooking to thread priority runtime setting
+ * @hide
+ */
+@libcore.api.CorePlatformApi
+@FunctionalInterface
+public interface ThreadPrioritySetter {
+ @libcore.api.CorePlatformApi
+ void setPriority(int nativeTid, int priority);
+}
diff --git a/dalvik/src/main/java/dalvik/system/VMDebug.java b/dalvik/src/main/java/dalvik/system/VMDebug.java
index 2a0e4ef..4436e3f 100644
--- a/dalvik/src/main/java/dalvik/system/VMDebug.java
+++ b/dalvik/src/main/java/dalvik/system/VMDebug.java
@@ -16,13 +16,15 @@
package dalvik.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.annotation.optimization.FastNative;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.io.FileDescriptor;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import dalvik.annotation.optimization.FastNative;
+
/**
* Provides access to some VM-specific debug features. Though this class and
* many of its members are public, this class is meant to be wrapped in a more
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index 13769e1..0339b4d 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -112,8 +112,8 @@
* before {@code postForkChild} for system server.
*/
@libcore.api.CorePlatformApi
- public static void postForkSystemServer() {
- nativePostForkSystemServer();
+ public static void postForkSystemServer(int runtimeFlags) {
+ nativePostForkSystemServer(runtimeFlags);
}
/**
@@ -136,13 +136,14 @@
*/
@libcore.api.CorePlatformApi
public static void postForkCommon() {
- Daemons.startPostZygoteFork();
+ // Notify the runtime before creating new threads.
nativePostZygoteFork();
+ Daemons.startPostZygoteFork();
}
// Hook for SystemServer specific early initialization post-forking.
- private static native void nativePostForkSystemServer();
+ private static native void nativePostForkSystemServer(int runtimeFlags);
private static native long nativePreFork();
private static native void nativePostZygoteFork();
diff --git a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java
index 373364b..292e967 100644
--- a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java
+++ b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java
@@ -16,7 +16,7 @@
package org.apache.harmony.dalvik.ddmc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.nio.ByteBuffer;
/**
diff --git a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java
index d7f370d..0fb74f8 100644
--- a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java
+++ b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java
@@ -16,7 +16,7 @@
package org.apache.harmony.dalvik.ddmc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
diff --git a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java
index e961d56..f1f58b6 100644
--- a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java
+++ b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java
@@ -16,12 +16,14 @@
package org.apache.harmony.dalvik.ddmc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.annotation.optimization.FastNative;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import dalvik.annotation.optimization.FastNative;
+
/**
* This represents our connection to the DDM Server.
diff --git a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java
index ac994bb..2c961da 100644
--- a/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java
+++ b/dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmVmInternal.java
@@ -16,7 +16,7 @@
package org.apache.harmony.dalvik.ddmc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import dalvik.annotation.optimization.FastNative;
/**
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index b700a96..80e1c97 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -1791,11 +1791,5 @@
result: EXEC_FAILED,
bug: 62408076,
name: "libcore.java.lang.reflect.annotations.AnnotatedElementParameterTest#testImplicitConstructorParameters_singleAnnotation"
-},
-{
- description: "Failing following zlib upgrade",
- result: EXEC_FAILED,
- bug: 135017266,
- name: "libcore.java.util.zip.DeflateRegressionTest#deterministicOutput"
}
]
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FilterOutputStreamTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FilterOutputStreamTest.java
index 666955d..2ba710b 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FilterOutputStreamTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FilterOutputStreamTest.java
@@ -17,14 +17,16 @@
package org.apache.harmony.tests.java.io;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import junit.framework.TestCase;
-
public class FilterOutputStreamTest extends TestCase {
private OutputStream os;
@@ -59,6 +61,29 @@
}
/**
+ * java.io.FilterOutputStream#close()
+ */
+ public void test_doubleClose() throws IOException {
+ OutputStream outputStream = Mockito.mock(OutputStream.class);
+ IOException testException = new IOException("test exception");
+ Mockito.doThrow(testException).when(outputStream).flush();
+ FilterOutputStream filterOutputStream = new FilterOutputStream(outputStream);
+ // FilterOutputStream.close() flushes and closes the underlying stream.
+ try {
+ filterOutputStream.close();
+ fail();
+ } catch (IOException expected) {
+ assertEquals(testException, expected);
+ }
+ Mockito.verify(outputStream, Mockito.times(1)).flush();
+ Mockito.verify(outputStream, Mockito.times(1)).close();
+ // A second close() does not delegate to the already-closed underlying stream again.
+ filterOutputStream.close();
+ Mockito.verify(outputStream, Mockito.times(1)).flush();
+ Mockito.verify(outputStream, Mockito.times(1)).close();
+ }
+
+ /**
* java.io.FilterOutputStream#flush()
*/
public void test_flush() throws IOException {
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
index a5007f0..2465071 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
@@ -747,8 +747,13 @@
assertTrue(Character.getType((int) '$') == Character.CURRENCY_SYMBOL);
assertTrue(Character.getType((int) '\u2029') == Character.PARAGRAPH_SEPARATOR);
+ // Unicode 13 defines a new range 0x30000–0x3134A
+ assertTrue(Character.getType(0x30000) == Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR);
+ assertTrue(Character.getType(0x3134A) == Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR);
+ assertTrue(Character.getType(0x2FFFF) == Character.UNASSIGNED);
+ assertTrue(Character.getType(0x3134B) == Character.UNASSIGNED);
+
assertTrue(Character.getType(0x9FFF) == Character.UNASSIGNED);
- assertTrue(Character.getType(0x30000) == Character.UNASSIGNED);
assertTrue(Character.getType(0x110000) == Character.UNASSIGNED);
assertTrue(Character.getType(0x0041) == Character.UPPERCASE_LETTER);
@@ -860,9 +865,14 @@
assertTrue(Character.isDefined((int) '\u6039'));
assertTrue(Character.isDefined(0x10300));
- assertFalse(Character.isDefined(0x30000));
assertFalse(Character.isDefined(0x3FFFF));
assertFalse(Character.isDefined(0x110000));
+
+ // Unicode 13 adds a new range 0x30000–0x3134A
+ assertTrue(Character.isDefined(0x30000));
+ assertTrue(Character.isDefined(0x3134A));
+ assertFalse(Character.isDefined(0x2FFFF));
+ assertFalse(Character.isDefined(0x3134B));
}
/**
@@ -1557,10 +1567,15 @@
*/
public void test_isDirectionaliy_I() {
assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character.getDirectionality(0xFFFE));
- assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character.getDirectionality(0x30000));
assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character.getDirectionality(0x110000));
assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character.getDirectionality(-1));
+ // Unicode 13 adds a new range 0x30000–0x3134A
+ assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character.getDirectionality(0x30000));
+ assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character.getDirectionality(0x3134A));
+ assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character.getDirectionality(0x2FFFF));
+ assertEquals(Character.DIRECTIONALITY_UNDEFINED, Character.getDirectionality(0x3134B));
+
assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character.getDirectionality(0x0041));
assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character.getDirectionality(0x10000));
assertEquals(Character.DIRECTIONALITY_LEFT_TO_RIGHT, Character.getDirectionality(0x104A9));
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java
index 74c3a7f..d820689 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/HandshakeCompletedEventTest.java
@@ -431,8 +431,6 @@
assertEquals(i, j);
}
- istream.close();
-
OutputStream ostream = clientSocket.getOutputStream();
for (int i = 0; i < 256; i++) {
@@ -503,7 +501,6 @@
}
ostream.flush();
- ostream.close();
InputStream istream = socket.getInputStream();
diff --git a/json/src/main/java/org/json/JSONArray.java b/json/src/main/java/org/json/JSONArray.java
index 5e758d7..df0b243 100644
--- a/json/src/main/java/org/json/JSONArray.java
+++ b/json/src/main/java/org/json/JSONArray.java
@@ -16,7 +16,7 @@
package org.json;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/json/src/main/java/org/json/JSONObject.java b/json/src/main/java/org/json/JSONObject.java
index 0565b25..40d15bb 100644
--- a/json/src/main/java/org/json/JSONObject.java
+++ b/json/src/main/java/org/json/JSONObject.java
@@ -16,7 +16,8 @@
package org.json;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
diff --git a/json/src/main/java/org/json/JSONStringer.java b/json/src/main/java/org/json/JSONStringer.java
index 3d1738c..ef1b47c 100644
--- a/json/src/main/java/org/json/JSONStringer.java
+++ b/json/src/main/java/org/json/JSONStringer.java
@@ -16,7 +16,7 @@
package org.json;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
diff --git a/json/src/main/java/org/json/JSONTokener.java b/json/src/main/java/org/json/JSONTokener.java
index 55667b0..6266860 100644
--- a/json/src/main/java/org/json/JSONTokener.java
+++ b/json/src/main/java/org/json/JSONTokener.java
@@ -16,7 +16,7 @@
package org.json;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
// Note: this class was written without inspecting the non-free org.json sourcecode.
diff --git a/libart/src/main/java/dalvik/system/VMRuntime.java b/libart/src/main/java/dalvik/system/VMRuntime.java
index 6f89b99..863f85d 100644
--- a/libart/src/main/java/dalvik/system/VMRuntime.java
+++ b/libart/src/main/java/dalvik/system/VMRuntime.java
@@ -16,14 +16,20 @@
package dalvik.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.annotation.optimization.FastNative;
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledAfter;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import dalvik.annotation.compat.VersionCodes;
+
import java.lang.ref.FinalizerReference;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import dalvik.annotation.optimization.FastNative;
+
/**
* Provides an interface to VM-global, Dalvik-specific features.
* An application cannot create its own Runtime instance, and must obtain
@@ -57,6 +63,16 @@
}
/**
+ * Remove meta-reflection workaround for hidden api usage for apps targeting R+. This allowed
+ * apps to obtain references to blacklisted fields and methods through an extra layer of
+ * reflection.
+ */
+ @ChangeId
+ @EnabledAfter(targetSdkVersion = VersionCodes.Q)
+ private static final long
+ PREVENT_META_REFLECTION_BLACKLIST_ACCESS = 142365358; // This is a bug id.
+
+ /**
* Interface for logging hidden API usage events.
*/
@libcore.api.CorePlatformApi
@@ -149,6 +165,8 @@
// Allocations since last call to native layer. See notifyNativeAllocation().
private final AtomicInteger allocationCount = new AtomicInteger(0);
+ private long[] disabledCompatChanges = new long[0];
+
/**
* Prevents this class from being instantiated.
*/
@@ -281,6 +299,18 @@
setTargetSdkVersionNative(this.targetSdkVersion);
}
+
+ /**
+ * Sets the disabled compat changes. Should only be called before the
+ * app starts to run, because it may change the VM's behavior in
+ * dangerous ways. Defaults to empty.
+ */
+ @libcore.api.CorePlatformApi
+ public synchronized void setDisabledCompatChanges(long[] disabledCompatChanges) {
+ this.disabledCompatChanges = disabledCompatChanges;
+ setDisabledCompatChangesNative(this.disabledCompatChanges);
+ }
+
/**
* Gets the target SDK version. See {@link #setTargetSdkVersion} for
* special values.
@@ -291,6 +321,7 @@
}
private native void setTargetSdkVersionNative(int targetSdkVersion);
+ private native void setDisabledCompatChangesNative(long[] disabledCompatChanges);
/**
* This method exists for binary compatibility. It was part of a
@@ -444,12 +475,6 @@
public native void clampGrowthLimit();
/**
- * Returns true if either a Java debugger or native debugger is active.
- */
- @FastNative
- public native boolean isDebuggerActive();
-
- /**
* Returns true if native debugging is on.
*/
@libcore.api.CorePlatformApi
@@ -658,6 +683,14 @@
public static native void bootCompleted();
/**
+ * Used to notify the runtime to reset Jit counters. This is done for the boot image
+ * profiling configuration to avoid samples during class preloading. This helps avoid
+ * the regression from disabling class profiling.
+ */
+ @libcore.api.CorePlatformApi
+ public static native void resetJitCounters();
+
+ /**
* Returns the instruction set of the current runtime.
*/
@UnsupportedAppUsage
@@ -711,4 +744,15 @@
*/
@libcore.api.CorePlatformApi
public static native void setProcessDataDirectory(String dataDir);
+
+ /**
+ * Returns whether {@code encodedClassLoaderContext} is a valid encoded class loader context.
+ * A class loader context is an internal opaque format used by the runtime to encode the
+ * class loader hierarchy (including each ClassLoader's classpath) used to load a dex file.
+ *
+ * @return True if encodedClassLoaderContext is a non-null valid encoded class loader context.
+ * Throws NullPointerException if encodedClassLoaderContext is null.
+ */
+ @libcore.api.CorePlatformApi
+ public static native boolean isValidClassLoaderContext(String encodedClassLoaderContext);
}
diff --git a/libart/src/main/java/dalvik/system/VMStack.java b/libart/src/main/java/dalvik/system/VMStack.java
index d84fef6..89ce215 100644
--- a/libart/src/main/java/dalvik/system/VMStack.java
+++ b/libart/src/main/java/dalvik/system/VMStack.java
@@ -16,7 +16,8 @@
package dalvik.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
+
import dalvik.annotation.optimization.FastNative;
/**
diff --git a/libart/src/main/java/java/lang/CaseMapper.java b/libart/src/main/java/java/lang/CaseMapper.java
index 66d5030..04eef09 100644
--- a/libart/src/main/java/java/lang/CaseMapper.java
+++ b/libart/src/main/java/java/lang/CaseMapper.java
@@ -17,8 +17,8 @@
package java.lang;
import android.icu.text.Transliterator;
+import com.android.icu.util.CaseMapperNative;
import java.util.Locale;
-import libcore.icu.ICU;
/**
* Performs case operations as described by http://unicode.org/reports/tr21/tr21-5.html.
@@ -47,7 +47,7 @@
// Note that Greek isn't a particularly hard case for toLowerCase, only toUpperCase.
String languageCode = locale.getLanguage();
if (languageCode.equals("tr") || languageCode.equals("az") || languageCode.equals("lt")) {
- return ICU.toLowerCase(s, locale);
+ return CaseMapperNative.toLowerCase(s, locale);
}
char[] newValue = null;
@@ -56,7 +56,7 @@
char newCh;
if (ch == LATIN_CAPITAL_I_WITH_DOT || Character.isHighSurrogate(ch)) {
// Punt these hard cases.
- return ICU.toLowerCase(s, locale);
+ return CaseMapperNative.toLowerCase(s, locale);
} else if (ch == GREEK_CAPITAL_SIGMA && isFinalSigma(s, i)) {
newCh = GREEK_SMALL_FINAL_SIGMA;
} else {
@@ -146,7 +146,7 @@
public static String toUpperCase(Locale locale, String s, int count) {
String languageCode = locale.getLanguage();
if (languageCode.equals("tr") || languageCode.equals("az") || languageCode.equals("lt")) {
- return ICU.toUpperCase(s, locale);
+ return CaseMapperNative.toUpperCase(s, locale);
}
if (languageCode.equals("el")) {
return EL_UPPER.get().transliterate(s);
@@ -157,7 +157,7 @@
for (int o = 0; o < count; o++) {
char ch = s.charAt(o);
if (Character.isHighSurrogate(ch)) {
- return ICU.toUpperCase(s, locale);
+ return CaseMapperNative.toUpperCase(s, locale);
}
int index = upperIndex(ch);
if (index == -1) {
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java
index 7d0eca2..568614f 100644
--- a/libart/src/main/java/java/lang/Daemons.java
+++ b/libart/src/main/java/java/lang/Daemons.java
@@ -16,19 +16,21 @@
package java.lang;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.Os;
import android.system.OsConstants;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VMRuntime;
+
import java.lang.ref.FinalizerReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
import libcore.util.EmptyArray;
+import dalvik.system.VMRuntime;
+import dalvik.system.VMDebug;
+
/**
* Calls Object.finalize() on objects in the finalizer reference queue. The VM
* will abort if any finalize() call takes more than the maximum finalize time
@@ -321,7 +323,7 @@
continue;
}
final Object finalizing = waitForFinalization();
- if (finalizing != null && !VMRuntime.getRuntime().isDebuggerActive()) {
+ if (finalizing != null && !VMDebug.isDebuggerConnected()) {
finalizerTimedOut(finalizing);
break;
}
diff --git a/libart/src/main/java/java/lang/DexCache.java b/libart/src/main/java/java/lang/DexCache.java
index 7c4a6ed..f9e3ea3 100644
--- a/libart/src/main/java/java/lang/DexCache.java
+++ b/libart/src/main/java/java/lang/DexCache.java
@@ -32,7 +32,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import dalvik.annotation.optimization.FastNative;
/**
diff --git a/luni/src/main/java/android/compat/Compatibility.java b/luni/src/main/java/android/compat/Compatibility.java
index 1fbdf76..e5d7cbb 100644
--- a/luni/src/main/java/android/compat/Compatibility.java
+++ b/luni/src/main/java/android/compat/Compatibility.java
@@ -121,13 +121,14 @@
}
@CorePlatformApi
protected void reportChange(long changeId) {
- throw new IllegalStateException(String.format(
+ System.logW(String.format(
"No Compatibility callbacks set! Reporting change %d", changeId));
}
@CorePlatformApi
protected boolean isChangeEnabled(long changeId) {
- throw new IllegalStateException(String.format(
+ System.logW(String.format(
"No Compatibility callbacks set! Querying change %d", changeId));
+ return true;
}
}
diff --git a/luni/src/main/java/android/compat/TEST_MAPPING b/luni/src/main/java/android/compat/TEST_MAPPING
new file mode 100644
index 0000000..c8b07b4
--- /dev/null
+++ b/luni/src/main/java/android/compat/TEST_MAPPING
@@ -0,0 +1,17 @@
+{
+ "presubmit": [
+ // Unit tests for CoreCompatChangeRule
+ {
+ "name": "CtsLibcoreTestCases",
+ "options": [
+ {
+ "include-filter": "libcore.junit.util.compat"
+ }
+ ]
+ },
+ // CTS test for CompatChanges System
+ {
+ "name": "CtsAppCompatHostTestCases"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/luni/src/main/java/android/compat/annotation/ChangeId.java b/luni/src/main/java/android/compat/annotation/ChangeId.java
deleted file mode 100644
index ea91223..0000000
--- a/luni/src/main/java/android/compat/annotation/ChangeId.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 android.compat.annotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-import libcore.api.CorePlatformApi;
-import libcore.api.IntraCoreApi;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that a field is a compatibility change ID.
- *
- * <p>A compatibility change is a change to the Android platform that may impact app behavior,
- * relative to previous releases of Android. A change ID is a unique {@code long} identifying one
- * such change. Compatibility change IDs should be defined as a {@code static final long}:
- *
- * <pre>{@code
- * @ChangeId
- * public static final long MY_CHANGE_ID = 123456789l;
- * }</pre>
- *
- * <p>The value of the constant is the ID of an issue in <a href="https://issuetracker.google.com/">
- * buganizer</a>.
- *
- * @hide
- */
-@Retention(CLASS)
-@Target({FIELD, PARAMETER})
-@CorePlatformApi
-@IntraCoreApi
-public @interface ChangeId {
-}
diff --git a/luni/src/main/java/android/compat/annotation/Disabled.java b/luni/src/main/java/android/compat/annotation/Disabled.java
deleted file mode 100644
index 4779a24..0000000
--- a/luni/src/main/java/android/compat/annotation/Disabled.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 android.compat.annotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-import libcore.api.CorePlatformApi;
-import libcore.api.IntraCoreApi;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Used to indicate that a compatibility {@link ChangeId change} is disabled for all apps.
- *
- * <p>This annotation should only be applied to change ID constants that are also annotated with
- * {@link ChangeId}. In any other context, this annotation will have no effect.
- *
- * @hide
- */
-@Retention(CLASS)
-@Target({FIELD})
-@CorePlatformApi
-@IntraCoreApi
-public @interface Disabled {
-}
diff --git a/luni/src/main/java/android/compat/annotation/EnabledAfter.java b/luni/src/main/java/android/compat/annotation/EnabledAfter.java
deleted file mode 100644
index aeb62fd..0000000
--- a/luni/src/main/java/android/compat/annotation/EnabledAfter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 android.compat.annotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-import libcore.api.CorePlatformApi;
-import libcore.api.IntraCoreApi;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Used to indicate that a compatibility {@link ChangeId change} is enabled only for apps with a
- * {@code targetSdkVersion} of <em>greater than</em> the given value.
- *
- * <p>This annotation should only be applied to change ID constants that are also annotated with
- * {@link ChangeId}. In any other context, this annotation will have no effect.
- *
- * @hide
- */
-@Retention(CLASS)
-@Target({FIELD})
-@CorePlatformApi
-@IntraCoreApi
-public @interface EnabledAfter {
- /**
- * @return The maximum {@code targetSdkVersion} for which this change does not apply. Apps with
- * a {@code targetSdkVersion} of greater than this value will get the change.
- */
- @CorePlatformApi
- @IntraCoreApi
- int targetSdkVersion();
-}
diff --git a/luni/src/main/java/android/system/Int32Ref.java b/luni/src/main/java/android/system/Int32Ref.java
index 8ffcfc5..c43c796 100644
--- a/luni/src/main/java/android/system/Int32Ref.java
+++ b/luni/src/main/java/android/system/Int32Ref.java
@@ -18,7 +18,7 @@
import libcore.util.Objects;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* @hide
diff --git a/luni/src/main/java/android/system/NetlinkSocketAddress.java b/luni/src/main/java/android/system/NetlinkSocketAddress.java
index 64b0eab..b4f6e74 100644
--- a/luni/src/main/java/android/system/NetlinkSocketAddress.java
+++ b/luni/src/main/java/android/system/NetlinkSocketAddress.java
@@ -16,9 +16,10 @@
package android.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import libcore.util.Objects;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.net.SocketAddress;
+import libcore.util.Objects;
/**
* Netlink socket address.
diff --git a/luni/src/main/java/android/system/Os.java b/luni/src/main/java/android/system/Os.java
index cc6b0a5..70fdce5 100644
--- a/luni/src/main/java/android/system/Os.java
+++ b/luni/src/main/java/android/system/Os.java
@@ -16,11 +16,7 @@
package android.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-
-import libcore.io.Libcore;
-import libcore.util.NonNull;
-import libcore.util.Nullable;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.FileDescriptor;
import java.io.InterruptedIOException;
@@ -29,6 +25,9 @@
import java.net.SocketAddress;
import java.net.SocketException;
import java.nio.ByteBuffer;
+import libcore.io.Libcore;
+import libcore.util.NonNull;
+import libcore.util.Nullable;
/**
* Access to low-level system functionality. Most of these are system calls. Most users will want
@@ -152,9 +151,10 @@
*/
public static void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { Libcore.os.fchown(fd, uid, gid); }
- /** @hide */
- @libcore.api.CorePlatformApi
- public static int fcntlInt(FileDescriptor fd, int cmd, int arg) throws ErrnoException { return Libcore.os.fcntlInt(fd, cmd, arg); }
+ /**
+ * See <a href="http://man7.org/linux/man-pages/man2/fcntl.2.html">fcntl(2)</a>.
+ */
+ public static int fcntlInt(@NonNull FileDescriptor fd, int cmd, int arg) throws ErrnoException { return Libcore.os.fcntlInt(fd, cmd, arg); }
/** @hide */
public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); }
@@ -362,6 +362,11 @@
public static StructStat lstat(String path) throws ErrnoException { return Libcore.os.lstat(path); }
/**
+ * See <a href="http://man7.org/linux/man-pages/man2/memfd_create.2.html">memfd_create(2)</a>.
+ */
+ public static @NonNull FileDescriptor memfd_create(@NonNull String name, int flags) throws ErrnoException { return Libcore.os.memfd_create(name, flags); }
+
+ /**
* See <a href="http://man7.org/linux/man-pages/man2/mincore.2.html">mincore(2)</a>.
*/
public static void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { Libcore.os.mincore(address, byteCount, vector); }
diff --git a/luni/src/main/java/android/system/OsConstants.java b/luni/src/main/java/android/system/OsConstants.java
index 50448d0..1b0dc16 100644
--- a/luni/src/main/java/android/system/OsConstants.java
+++ b/luni/src/main/java/android/system/OsConstants.java
@@ -16,7 +16,7 @@
package android.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* Constants and helper functions for use with {@link Os}.
@@ -359,6 +359,7 @@
@libcore.api.CorePlatformApi
public static final int _LINUX_CAPABILITY_VERSION_3 = placeholder();
public static final int MAP_FIXED = placeholder();
+ public static final int MAP_ANONYMOUS = placeholder();
/** @hide */
@UnsupportedAppUsage
@libcore.api.CorePlatformApi
@@ -373,6 +374,7 @@
public static final int MCAST_UNBLOCK_SOURCE = placeholder();
public static final int MCL_CURRENT = placeholder();
public static final int MCL_FUTURE = placeholder();
+ public static final int MFD_CLOEXEC = placeholder();
public static final int MSG_CTRUNC = placeholder();
public static final int MSG_DONTROUTE = placeholder();
public static final int MSG_EOR = placeholder();
@@ -383,9 +385,6 @@
public static final int MS_ASYNC = placeholder();
public static final int MS_INVALIDATE = placeholder();
public static final int MS_SYNC = placeholder();
- /** @hide */
- @UnsupportedAppUsage
- @libcore.api.CorePlatformApi
public static final int NETLINK_NETFILTER = placeholder();
public static final int NETLINK_ROUTE = placeholder();
/**
diff --git a/luni/src/main/java/android/system/PacketSocketAddress.java b/luni/src/main/java/android/system/PacketSocketAddress.java
index ce4081d..c3f15a6 100644
--- a/luni/src/main/java/android/system/PacketSocketAddress.java
+++ b/luni/src/main/java/android/system/PacketSocketAddress.java
@@ -16,9 +16,10 @@
package android.system;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import libcore.util.Objects;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.net.SocketAddress;
+import libcore.util.Objects;
/**
* Packet socket address.
diff --git a/luni/src/main/java/java/lang/ref/FinalizerReference.java b/luni/src/main/java/java/lang/ref/FinalizerReference.java
index 9589a9d..037af4a 100644
--- a/luni/src/main/java/java/lang/ref/FinalizerReference.java
+++ b/luni/src/main/java/java/lang/ref/FinalizerReference.java
@@ -16,7 +16,7 @@
package java.lang.ref;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import dalvik.annotation.optimization.FastNative;
/**
diff --git a/luni/src/main/java/java/math/BigInteger.java b/luni/src/main/java/java/math/BigInteger.java
index f7c0be2..b96fdb2 100644
--- a/luni/src/main/java/java/math/BigInteger.java
+++ b/luni/src/main/java/java/math/BigInteger.java
@@ -885,6 +885,26 @@
* @throws NullPointerException if {@code value == null}.
*/
@NonNull public BigInteger gcd(@NonNull BigInteger value) {
+ // First optimize the case in which the two arguments have very different
+ // length.
+ int thisLen = bitLength();
+ int valueLen = value.bitLength();
+ final int gcdDirectRatio = 16;
+ if (thisLen > gcdDirectRatio * valueLen) {
+ // A division-based step reduces the length of this by a factor of at
+ // least gcdDirectRatio, thus ensuring that a division-based step will
+ // easily pay for itself.
+ if (value.signum() == 0) {
+ return this.abs();
+ }
+ return value.gcd(this.mod(value.abs()));
+ } else if (valueLen > gcdDirectRatio * thisLen) {
+ if (signum() == 0) {
+ return value.abs();
+ }
+ return this.gcd(value.mod(this.abs()));
+ }
+
return new BigInteger(BigInt.gcd(getBigInt(), value.getBigInt()));
}
diff --git a/luni/src/main/java/java/net/AddressCache.java b/luni/src/main/java/java/net/AddressCache.java
index ac5a029..3026923 100644
--- a/luni/src/main/java/java/net/AddressCache.java
+++ b/luni/src/main/java/java/net/AddressCache.java
@@ -16,7 +16,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import libcore.util.BasicLruCache;
/**
diff --git a/luni/src/main/java/java/net/DefaultFileNameMap.java b/luni/src/main/java/java/net/DefaultFileNameMap.java
index cdd4214..da67d14 100644
--- a/luni/src/main/java/java/net/DefaultFileNameMap.java
+++ b/luni/src/main/java/java/net/DefaultFileNameMap.java
@@ -22,24 +22,34 @@
* Implements {@link FileNameMap} in terms of {@link MimeMap}.
*/
class DefaultFileNameMap implements FileNameMap {
- public String getContentTypeFor(String filename) {
- String ext = extensionOf(filename);
- return MimeMap.getDefault().guessMimeTypeFromExtension(ext);
- }
- private static String extensionOf(String filename) {
+ public String getContentTypeFor(String filename) {
int fragmentIndex = filename.indexOf('#');
if (fragmentIndex >= 0) {
filename = filename.substring(0, fragmentIndex);
}
if (filename.endsWith("/")) { // a directory
- return "html";
+ return "text/html";
}
+
int slashIndex = filename.lastIndexOf('/');
if (slashIndex >= 0) {
filename = filename.substring(slashIndex);
}
- int dotIndex = filename.lastIndexOf('.');
- return (dotIndex >= 0) ? filename.substring(dotIndex + 1) : "";
+
+ MimeMap mimeMap = MimeMap.getDefault();
+ int dotIndex = -1;
+ do {
+ String ext = filename.substring(dotIndex + 1);
+ String result = mimeMap.guessMimeTypeFromExtension(ext);
+ if ((result != null) &&
+ // Compat behavior: If there's a '/', then extension must not be the
+ // whole string. http://b/144977800
+ (slashIndex < 0 || dotIndex >= 0)) {
+ return result;
+ }
+ dotIndex = filename.indexOf('.', dotIndex + 1);
+ } while (dotIndex >= 0);
+ return null;
}
}
diff --git a/luni/src/main/java/java/nio/NIOAccess.java b/luni/src/main/java/java/nio/NIOAccess.java
index 7a07e3d..81b205d 100644
--- a/luni/src/main/java/java/nio/NIOAccess.java
+++ b/luni/src/main/java/java/nio/NIOAccess.java
@@ -16,7 +16,7 @@
package java.nio;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* This class is used via JNI by code in frameworks/base/.
diff --git a/luni/src/main/java/java/nio/NioUtils.java b/luni/src/main/java/java/nio/NioUtils.java
index 657be6e..aca91b0 100644
--- a/luni/src/main/java/java/nio/NioUtils.java
+++ b/luni/src/main/java/java/nio/NioUtils.java
@@ -16,19 +16,19 @@
package java.nio;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.io.Closeable;
import java.io.FileDescriptor;
-import java.io.IOException;
-import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
-import java.util.Set;
-import static android.system.OsConstants.*;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import sun.misc.Cleaner;
-import sun.nio.ch.DirectBuffer;
import sun.nio.ch.FileChannelImpl;
+import static android.system.OsConstants.O_ACCMODE;
+import static android.system.OsConstants.O_APPEND;
+import static android.system.OsConstants.O_RDONLY;
+import static android.system.OsConstants.O_WRONLY;
+
/**
* @hide internal use only
*/
diff --git a/luni/src/main/java/java/nio/charset/CharsetDecoderICU.java b/luni/src/main/java/java/nio/charset/CharsetDecoderICU.java
deleted file mode 100644
index f695694..0000000
--- a/luni/src/main/java/java/nio/charset/CharsetDecoderICU.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
-*******************************************************************************
-* Copyright (C) 1996-2006, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-*******************************************************************************
-*
-*******************************************************************************
-*/
- /**
- * A JNI interface for ICU converters.
- *
- *
- * @author Ram Viswanadha, IBM
- */
-package java.nio.charset;
-
-import dalvik.annotation.optimization.ReachabilitySensitive;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import libcore.icu.ICU;
-import libcore.icu.NativeConverter;
-import libcore.util.EmptyArray;
-
-final class CharsetDecoderICU extends CharsetDecoder {
- private static final int MAX_CHARS_PER_BYTE = 2;
-
- private static final int INPUT_OFFSET = 0;
- private static final int OUTPUT_OFFSET = 1;
- private static final int INVALID_BYTE_COUNT = 2;
- /*
- * data[INPUT_OFFSET] = on input contains the start of input and on output the number of input bytes consumed
- * data[OUTPUT_OFFSET] = on input contains the start of output and on output the number of output chars written
- * data[INVALID_BYTE_COUNT] = number of invalid bytes
- */
- private final int[] data = new int[3];
-
- /* Handle to the ICU converter that is opened, cleaned up via NativeAllocationRegistry. */
- @ReachabilitySensitive
- private long converterHandle = 0;
-
- private byte[] input = null;
- private char[] output= null;
-
- private byte[] allocatedInput = null;
- private char[] allocatedOutput = null;
-
- // These instance variables are always assigned in the methods before being used. This class
- // is inherently thread-unsafe so we don't have to worry about synchronization.
- private int inEnd;
- private int outEnd;
-
- public static CharsetDecoderICU newInstance(Charset cs, String icuCanonicalName) {
- // This complexity is necessary to ensure that even if the constructor, superclass
- // constructor, or call to updateCallback throw, we still free the native peer.
- long address = 0;
- CharsetDecoderICU result;
- try {
- address = NativeConverter.openConverter(icuCanonicalName);
- float averageCharsPerByte = NativeConverter.getAveCharsPerByte(address);
- result = new CharsetDecoderICU(cs, averageCharsPerByte, address);
- } catch (Throwable t) {
- if (address != 0) {
- NativeConverter.closeConverter(address);
- }
- throw t;
- }
- // An exception in registerConverter() will deallocate address:
- NativeConverter.registerConverter(result, address);
- result.updateCallback();
- return result;
- }
-
- private CharsetDecoderICU(Charset cs, float averageCharsPerByte, long address) {
- super(cs, averageCharsPerByte, MAX_CHARS_PER_BYTE);
- this.converterHandle = address;
- }
-
- @Override protected void implReplaceWith(String newReplacement) {
- updateCallback();
- }
-
- @Override protected final void implOnMalformedInput(CodingErrorAction newAction) {
- updateCallback();
- }
-
- @Override protected final void implOnUnmappableCharacter(CodingErrorAction newAction) {
- updateCallback();
- }
-
- private void updateCallback() {
- NativeConverter.setCallbackDecode(converterHandle, this);
- }
-
- @Override protected void implReset() {
- NativeConverter.resetByteToChar(converterHandle);
- data[INPUT_OFFSET] = 0;
- data[OUTPUT_OFFSET] = 0;
- data[INVALID_BYTE_COUNT] = 0;
- output = null;
- input = null;
- allocatedInput = null;
- allocatedOutput = null;
- inEnd = 0;
- outEnd = 0;
- }
-
- @Override protected final CoderResult implFlush(CharBuffer out) {
- try {
- // ICU needs to see an empty input.
- input = EmptyArray.BYTE;
- inEnd = 0;
- data[INPUT_OFFSET] = 0;
-
- data[OUTPUT_OFFSET] = getArray(out);
- data[INVALID_BYTE_COUNT] = 0; // Make sure we don't see earlier errors.
-
- int error = NativeConverter.decode(converterHandle, input, inEnd, output, outEnd, data, true);
- if (ICU.U_FAILURE(error)) {
- if (error == ICU.U_BUFFER_OVERFLOW_ERROR) {
- return CoderResult.OVERFLOW;
- } else if (error == ICU.U_TRUNCATED_CHAR_FOUND) {
- if (data[INVALID_BYTE_COUNT] > 0) {
- return CoderResult.malformedForLength(data[INVALID_BYTE_COUNT]);
- }
- }
- }
- return CoderResult.UNDERFLOW;
- } finally {
- setPosition(out);
- implReset();
- }
- }
-
- @Override protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
- if (!in.hasRemaining()) {
- return CoderResult.UNDERFLOW;
- }
-
- data[INPUT_OFFSET] = getArray(in);
- data[OUTPUT_OFFSET]= getArray(out);
-
- try {
- int error = NativeConverter.decode(converterHandle, input, inEnd, output, outEnd, data, false);
- if (ICU.U_FAILURE(error)) {
- if (error == ICU.U_BUFFER_OVERFLOW_ERROR) {
- return CoderResult.OVERFLOW;
- } else if (error == ICU.U_INVALID_CHAR_FOUND) {
- return CoderResult.unmappableForLength(data[INVALID_BYTE_COUNT]);
- } else if (error == ICU.U_ILLEGAL_CHAR_FOUND) {
- return CoderResult.malformedForLength(data[INVALID_BYTE_COUNT]);
- } else {
- throw new AssertionError(error);
- }
- }
- // Decoding succeeded: give us more data.
- return CoderResult.UNDERFLOW;
- } finally {
- setPosition(in);
- setPosition(out);
- }
- }
-
-
- private int getArray(CharBuffer out) {
- if (out.hasArray()) {
- output = out.array();
- outEnd = out.arrayOffset() + out.limit();
- return out.arrayOffset() + out.position();
- } else {
- outEnd = out.remaining();
- if (allocatedOutput == null || outEnd > allocatedOutput.length) {
- allocatedOutput = new char[outEnd];
- }
- // The array's start position is 0.
- output = allocatedOutput;
- return 0;
- }
- }
-
- private int getArray(ByteBuffer in) {
- if (in.hasArray()) {
- input = in.array();
- inEnd = in.arrayOffset() + in.limit();
- return in.arrayOffset() + in.position();
- } else {
- inEnd = in.remaining();
- if (allocatedInput == null || inEnd > allocatedInput.length) {
- allocatedInput = new byte[inEnd];
- }
- // Copy the input buffer into the allocated array.
- int pos = in.position();
- in.get(allocatedInput, 0, inEnd);
- in.position(pos);
- // The array's start position is 0.
- input = allocatedInput;
- return 0;
- }
- }
-
- private void setPosition(CharBuffer out) {
- if (out.hasArray()) {
- out.position(out.position() + data[OUTPUT_OFFSET]);
- } else {
- out.put(output, 0, data[OUTPUT_OFFSET]);
- }
- // release reference to output array, which may not be ours
- output = null;
- }
-
- private void setPosition(ByteBuffer in) {
- in.position(in.position() + data[INPUT_OFFSET]);
- // release reference to input array, which may not be ours
- input = null;
- }
-}
diff --git a/luni/src/main/java/java/nio/charset/CharsetEncoderICU.java b/luni/src/main/java/java/nio/charset/CharsetEncoderICU.java
deleted file mode 100644
index c57aafd..0000000
--- a/luni/src/main/java/java/nio/charset/CharsetEncoderICU.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
-*******************************************************************************
-* Copyright (C) 1996-2006, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-*******************************************************************************
-*
-*******************************************************************************
-*/
-/**
- * A JNI interface for ICU converters.
- *
- *
- * @author Ram Viswanadha, IBM
- */
-package java.nio.charset;
-
-import dalvik.annotation.optimization.ReachabilitySensitive;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.util.HashMap;
-import java.util.Map;
-import libcore.icu.ICU;
-import libcore.icu.NativeConverter;
-import libcore.util.EmptyArray;
-
-final class CharsetEncoderICU extends CharsetEncoder {
- private static final Map<String, byte[]> DEFAULT_REPLACEMENTS = new HashMap<String, byte[]>();
- static {
- // ICU has different default replacements to the RI in some cases. There are many
- // additional cases, but this covers all the charsets that Java guarantees will be
- // available, which is where compatibility seems most important. (The RI even uses
- // the byte corresponding to '?' in ASCII as the replacement byte for charsets where that
- // byte corresponds to an entirely different character.)
- // It's odd that UTF-8 doesn't use U+FFFD, given that (unlike ISO-8859-1 and US-ASCII) it
- // can represent it, but this is what the RI does...
- byte[] questionMark = new byte[] { (byte) '?' };
- DEFAULT_REPLACEMENTS.put("UTF-8", questionMark);
- DEFAULT_REPLACEMENTS.put("ISO-8859-1", questionMark);
- DEFAULT_REPLACEMENTS.put("US-ASCII", questionMark);
- }
-
- private static final int INPUT_OFFSET = 0;
- private static final int OUTPUT_OFFSET = 1;
- private static final int INVALID_CHAR_COUNT = 2;
- /*
- * data[INPUT_OFFSET] = on input contains the start of input and on output the number of input chars consumed
- * data[OUTPUT_OFFSET] = on input contains the start of output and on output the number of output bytes written
- * data[INVALID_CHARS] = number of invalid chars
- */
- private int[] data = new int[3];
-
- /* handle to the ICU converter that is opened */
- @ReachabilitySensitive
- private final long converterHandle;
-
- private char[] input = null;
- private byte[] output = null;
-
- private char[] allocatedInput = null;
- private byte[] allocatedOutput = null;
-
- // These instance variables are always assigned in the methods before being used. This class
- // is inherently thread-unsafe so we don't have to worry about synchronization.
- private int inEnd;
- private int outEnd;
-
- public static CharsetEncoderICU newInstance(Charset cs, String icuCanonicalName) {
- // This complexity is necessary to ensure that even if the constructor, superclass
- // constructor, or call to updateCallback throw, we still free the native peer.
- long address = 0;
- CharsetEncoderICU result;
- try {
- address = NativeConverter.openConverter(icuCanonicalName);
- float averageBytesPerChar = NativeConverter.getAveBytesPerChar(address);
- float maxBytesPerChar = NativeConverter.getMaxBytesPerChar(address);
- byte[] replacement = makeReplacement(icuCanonicalName, address);
- result = new CharsetEncoderICU(cs, averageBytesPerChar, maxBytesPerChar, replacement, address);
- } catch (Throwable t) {
- if (address != 0) {
- NativeConverter.closeConverter(address);
- }
- throw t;
- }
- // An exception in registerConverter() will deallocate address:
- NativeConverter.registerConverter(result, address);
- result.updateCallback();
- return result;
- }
-
- private static byte[] makeReplacement(String icuCanonicalName, long address) {
- // We have our own map of RI-compatible default replacements (where ICU disagrees)...
- byte[] replacement = DEFAULT_REPLACEMENTS.get(icuCanonicalName);
- if (replacement != null) {
- return replacement.clone();
- }
- // ...but fall back to asking ICU.
- return NativeConverter.getSubstitutionBytes(address);
- }
-
- private CharsetEncoderICU(Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement, long address) {
- super(cs, averageBytesPerChar, maxBytesPerChar, replacement, true);
- // Our native peer needs to know what just happened...
- this.converterHandle = address;
- }
-
- @Override protected void implReplaceWith(byte[] newReplacement) {
- updateCallback();
- }
-
- @Override protected void implOnMalformedInput(CodingErrorAction newAction) {
- updateCallback();
- }
-
- @Override protected void implOnUnmappableCharacter(CodingErrorAction newAction) {
- updateCallback();
- }
-
- private void updateCallback() {
- NativeConverter.setCallbackEncode(converterHandle, this);
- }
-
- @Override protected void implReset() {
- NativeConverter.resetCharToByte(converterHandle);
- data[INPUT_OFFSET] = 0;
- data[OUTPUT_OFFSET] = 0;
- data[INVALID_CHAR_COUNT] = 0;
- output = null;
- input = null;
- allocatedInput = null;
- allocatedOutput = null;
- inEnd = 0;
- outEnd = 0;
- }
-
- @Override protected CoderResult implFlush(ByteBuffer out) {
- try {
- // ICU needs to see an empty input.
- input = EmptyArray.CHAR;
- inEnd = 0;
- data[INPUT_OFFSET] = 0;
-
- data[OUTPUT_OFFSET] = getArray(out);
- data[INVALID_CHAR_COUNT] = 0; // Make sure we don't see earlier errors.
-
- int error = NativeConverter.encode(converterHandle, input, inEnd, output, outEnd, data, true);
- if (ICU.U_FAILURE(error)) {
- if (error == ICU.U_BUFFER_OVERFLOW_ERROR) {
- return CoderResult.OVERFLOW;
- } else if (error == ICU.U_TRUNCATED_CHAR_FOUND) {
- if (data[INVALID_CHAR_COUNT] > 0) {
- return CoderResult.malformedForLength(data[INVALID_CHAR_COUNT]);
- }
- }
- }
- return CoderResult.UNDERFLOW;
- } finally {
- setPosition(out);
- implReset();
- }
- }
-
- @Override protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
- if (!in.hasRemaining()) {
- return CoderResult.UNDERFLOW;
- }
-
- data[INPUT_OFFSET] = getArray(in);
- data[OUTPUT_OFFSET]= getArray(out);
- data[INVALID_CHAR_COUNT] = 0; // Make sure we don't see earlier errors.
-
- try {
- int error = NativeConverter.encode(converterHandle, input, inEnd, output, outEnd, data, false);
- if (ICU.U_FAILURE(error)) {
- if (error == ICU.U_BUFFER_OVERFLOW_ERROR) {
- return CoderResult.OVERFLOW;
- } else if (error == ICU.U_INVALID_CHAR_FOUND) {
- return CoderResult.unmappableForLength(data[INVALID_CHAR_COUNT]);
- } else if (error == ICU.U_ILLEGAL_CHAR_FOUND) {
- return CoderResult.malformedForLength(data[INVALID_CHAR_COUNT]);
- } else {
- throw new AssertionError(error);
- }
- }
- // Decoding succeeded: give us more data.
- return CoderResult.UNDERFLOW;
- } finally {
- setPosition(in);
- setPosition(out);
- }
- }
-
- private int getArray(ByteBuffer out) {
- if (out.hasArray()) {
- output = out.array();
- outEnd = out.arrayOffset() + out.limit();
- return out.arrayOffset() + out.position();
- } else {
- outEnd = out.remaining();
- if (allocatedOutput == null || outEnd > allocatedOutput.length) {
- allocatedOutput = new byte[outEnd];
- }
- // The array's start position is 0
- output = allocatedOutput;
- return 0;
- }
- }
-
- private int getArray(CharBuffer in) {
- if (in.hasArray()) {
- input = in.array();
- inEnd = in.arrayOffset() + in.limit();
- return in.arrayOffset() + in.position();
- } else {
- inEnd = in.remaining();
- if (allocatedInput == null || inEnd > allocatedInput.length) {
- allocatedInput = new char[inEnd];
- }
- // Copy the input buffer into the allocated array.
- int pos = in.position();
- in.get(allocatedInput, 0, inEnd);
- in.position(pos);
- // The array's start position is 0
- input = allocatedInput;
- return 0;
- }
- }
-
- private void setPosition(ByteBuffer out) {
- if (out.hasArray()) {
- out.position(data[OUTPUT_OFFSET] - out.arrayOffset());
- } else {
- out.put(output, 0, data[OUTPUT_OFFSET]);
- }
- // release reference to output array, which may not be ours
- output = null;
- }
-
- private void setPosition(CharBuffer in) {
- int position = in.position() + data[INPUT_OFFSET] - data[INVALID_CHAR_COUNT];
- if (position < 0) {
- // The calculated position might be negative if we encountered an
- // invalid char that spanned input buffers. We adjust it to 0 in this case.
- //
- // NOTE: The API doesn't allow us to adjust the position of the previous
- // input buffer. (Doing that wouldn't serve any useful purpose anyway.)
- position = 0;
- }
-
- in.position(position);
- // release reference to input array, which may not be ours
- input = null;
- }
-}
diff --git a/luni/src/main/java/java/nio/charset/CharsetICU.java b/luni/src/main/java/java/nio/charset/CharsetICU.java
deleted file mode 100644
index 63ffd3e..0000000
--- a/luni/src/main/java/java/nio/charset/CharsetICU.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
-*******************************************************************************
-* Copyright (C) 1996-2005, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-*******************************************************************************
-*
-*******************************************************************************
-*/
-
-package java.nio.charset;
-
-import libcore.icu.NativeConverter;
-
-/**
- * This class is used from native code associated with {@link NativeConverter}.
- */
-final class CharsetICU extends Charset {
- private final String icuCanonicalName;
-
- protected CharsetICU(String canonicalName, String icuCanonName, String[] aliases) {
- super(canonicalName, aliases);
- icuCanonicalName = icuCanonName;
- }
-
- public CharsetDecoder newDecoder() {
- return CharsetDecoderICU.newInstance(this, icuCanonicalName);
- }
-
- public CharsetEncoder newEncoder() {
- return CharsetEncoderICU.newInstance(this, icuCanonicalName);
- }
-
- public boolean contains(Charset cs) {
- if (cs == null) {
- return false;
- } else if (this.equals(cs)) {
- return true;
- }
- return NativeConverter.contains(this.name(), cs.name());
- }
-}
diff --git a/luni/src/main/java/java/nio/charset/ModifiedUtf8.java b/luni/src/main/java/java/nio/charset/ModifiedUtf8.java
deleted file mode 100644
index 51638ee..0000000
--- a/luni/src/main/java/java/nio/charset/ModifiedUtf8.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 java.nio.charset;
-
-import java.io.UTFDataFormatException;
-
-/**
- * Encoding and decoding methods for Modified UTF-8
- *
- * <p>Modified UTF-8 is a simple variation of UTF-8 in which {@code \u0000} is encoded as
- * 0xc0 0x80 . This avoids the presence of bytes 0 in the output.
- *
- * @hide
- */
-public class ModifiedUtf8 {
-
- /**
- * Count the number of bytes in the modified UTF-8 representation of {@code s}.
- *
- * <p>Additionally, if {@code shortLength} is true, throw a {@code UTFDataFormatException} if
- * the size cannot be presented in an (unsigned) java short.
- */
- public static long countBytes(String s, boolean shortLength) throws UTFDataFormatException {
- long counter = 0;
- int strLen = s.length();
- for (int i = 0; i < strLen; i++) {
- char c = s.charAt(i);
- if (c < '\u0080') {
- counter++;
- if (c == '\u0000') {
- counter++;
- }
- } else if (c < '\u0800') {
- counter += 2;
- } else {
- counter += 3;
- }
- }
- // Allow up to the maximum value of an unsigned short (as the value is known to be
- // unsigned.
- if (shortLength && counter > 0xffff) {
- throw new UTFDataFormatException(
- "Size of the encoded string doesn't fit in two bytes");
- }
- return counter;
- }
-
- /**
- * Encode {@code s} into {@code dst} starting at offset {@code offset}.
- *
- * <p>The output buffer is guaranteed to have enough space.
- */
- public static void encode(byte[] dst, int offset, String s) {
- int strLen = s.length();
- for (int i = 0; i < strLen; i++) {
- char c = s.charAt(i);
- if (c < '\u0080') {
- if (c == 0) {
- dst[offset++] = (byte) 0xc0;
- dst[offset++] = (byte) 0x80;
- } else {
- dst[offset++] = (byte) c;
- }
- } else if (c < '\u0800') {
- dst[offset++] = (byte) ((c >>> 6) | 0xc0);
- dst[offset++] = (byte) ((c & 0x3f) | 0x80);
- } else {
- dst[offset++] = (byte) ((c >>> 12) | 0xe0);
- dst[offset++] = (byte) (((c >>> 6) & 0x3f) | 0x80);
- dst[offset++] = (byte) ((c & 0x3f) | 0x80);
- }
- }
- }
-
- /**
- * Encodes {@code s} into a buffer with the following format:
- *
- * <p>- the first two bytes of the buffer are the length of the modified-utf8 output
- * (as a big endian short. A UTFDataFormatException is thrown if the encoded size cannot be
- * represented as a short.
- *
- * <p>- the remainder of the buffer contains the modified-utf8 output (equivalent to
- * {@code encode(buf, 2, s)}).
- */
- public static byte[] encode(String s) throws UTFDataFormatException {
- long size = countBytes(s, true);
- byte[] output = new byte[(int) size + 2];
- encode(output, 2, s);
- output[0] = (byte) (size >>> 8);
- output[1] = (byte) size;
- return output;
- }
-
- /**
- * Decodes {@code length} utf-8 bytes from {@code in} starting at offset {@code offset} to
- * {@code out},
- *
- * <p>A maximum of {@code length} chars are written to the output starting at offset 0.
- * {@code out} is assumed to have enough space for the output (a standard
- * {@code ArrayIndexOutOfBoundsException} is thrown otherwise).
- *
- * <p>If a ‘0’ byte is encountered, it is converted to U+0000.
- */
- public static String decode(byte[] in, char[] out, int offset, int length)
- throws UTFDataFormatException {
- if (offset < 0 || length < 0) {
- throw new IllegalArgumentException("Illegal arguments: offset " + offset
- + ". Length: " + length);
- }
- int outputIndex = 0;
- int limitIndex = offset + length;
- while (offset < limitIndex) {
- int i = in[offset] & 0xff;
- offset++;
- if (i < 0x80) {
- out[outputIndex] = (char) i;
- outputIndex++;
- continue;
- }
- if (0xc0 <= i && i < 0xe0) {
- // This branch covers the case 0 = 0xc080.
-
- // The result is: 5 least-significant bits of i + 6 l-s bits of next input byte.
- i = (i & 0x1f) << 6;
- if(offset == limitIndex) {
- throw new UTFDataFormatException("unexpected end of input");
- }
- // Include 6 least-significant bits of the input byte.
- if ((in[offset] & 0xc0) != 0x80) {
- throw new UTFDataFormatException("bad second byte at " + offset);
- }
- out[outputIndex] = (char) (i | (in[offset] & 0x3f));
- offset++;
- outputIndex++;
- } else if(i < 0xf0) {
- // The result is: 5 least-significant bits of i + 6 l-s bits of next input byte
- // + 6 l-s of next to next input byte.
- i = (i & 0x1f) << 12;
- // Make sure there are are at least two bytes left.
- if (offset + 1 >= limitIndex) {
- throw new UTFDataFormatException("unexpected end of input");
- }
- // Include 6 least-significant bits of the input byte, with 6 bits of room
- // for the next byte.
- if ((in[offset] & 0xc0) != 0x80) {
- throw new UTFDataFormatException("bad second byte at " + offset);
- }
- i = i | (in[offset] & 0x3f) << 6;
- offset++;
- // Include 6 least-significant bits of the input byte.
- if ((in[offset] & 0xc0) != 0x80) {
- throw new UTFDataFormatException("bad third byte at " + offset);
- }
- out[outputIndex] = (char) (i | (in[offset] & 0x3f));
- offset++;
- outputIndex++;
- } else {
- throw new UTFDataFormatException("Invalid UTF8 byte "
- + (int) i + " at position " + (offset - 1));
- }
- }
- return String.valueOf(out, 0, outputIndex);
- }
-}
diff --git a/luni/src/main/java/java/nio/charset/TEST_MAPPING b/luni/src/main/java/java/nio/charset/TEST_MAPPING
deleted file mode 100644
index ec926f9..0000000
--- a/luni/src/main/java/java/nio/charset/TEST_MAPPING
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "presubmit": [
- {
- "name": "CtsLibcoreTestCases",
- "options": [
- {
- "include-filter": "libcore.java.nio.charset"
- },
- {
- "include-filter": "org.apache.harmony.tests.java.nio.charset"
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/luni/src/main/java/libcore/icu/DateIntervalFormat.java b/luni/src/main/java/libcore/icu/DateIntervalFormat.java
index 9a4f9a0..74aca08 100644
--- a/luni/src/main/java/libcore/icu/DateIntervalFormat.java
+++ b/luni/src/main/java/libcore/icu/DateIntervalFormat.java
@@ -16,10 +16,10 @@
package libcore.icu;
+import android.compat.annotation.UnsupportedAppUsage;
import android.icu.util.Calendar;
import android.icu.util.ULocale;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import java.text.FieldPosition;
import java.util.TimeZone;
import libcore.util.BasicLruCache;
diff --git a/luni/src/main/java/libcore/icu/ICU.java b/luni/src/main/java/libcore/icu/ICU.java
index 2114523..f6e5fed 100644
--- a/luni/src/main/java/libcore/icu/ICU.java
+++ b/luni/src/main/java/libcore/icu/ICU.java
@@ -16,7 +16,9 @@
package libcore.icu;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
+import android.icu.util.ULocale;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -31,7 +33,6 @@
* Makes ICU data accessible to Java.
* @hide
*/
-@libcore.api.IntraCoreApi
@libcore.api.CorePlatformApi
public final class ICU {
@@ -267,10 +268,6 @@
return availableLocalesCache.clone();
}
- public static Locale[] getAvailableCollatorLocales() {
- return localesFromStrings(getAvailableCollatorLocalesNative());
- }
-
@UnsupportedAppUsage
@libcore.api.CorePlatformApi
public static String getBestDateTimePattern(String skeleton, Locale locale) {
@@ -332,96 +329,38 @@
return result;
}
- /**
- * Returns the version of the CLDR data in use, such as "22.1.1".
- */
- public static native String getCldrVersion();
-
- /**
- * Returns the icu4c version in use, such as "50.1.1".
- */
- @libcore.api.IntraCoreApi
- public static native String getIcuVersion();
-
- /**
- * Returns the Unicode version our ICU supports, such as "6.2".
- */
- public static native String getUnicodeVersion();
-
- // --- Case mapping.
-
- public static String toLowerCase(String s, Locale locale) {
- return toLowerCase(s, locale.toLanguageTag());
- }
-
- private static native String toLowerCase(String s, String languageTag);
-
- public static String toUpperCase(String s, Locale locale) {
- return toUpperCase(s, locale.toLanguageTag());
- }
-
- private static native String toUpperCase(String s, String languageTag);
-
// --- Errors.
- // Just the subset of error codes needed by CharsetDecoderICU/CharsetEncoderICU.
- public static final int U_ZERO_ERROR = 0;
- public static final int U_INVALID_CHAR_FOUND = 10;
- public static final int U_TRUNCATED_CHAR_FOUND = 11;
- public static final int U_ILLEGAL_CHAR_FOUND = 12;
- public static final int U_BUFFER_OVERFLOW_ERROR = 15;
-
- public static boolean U_FAILURE(int error) {
- return error > U_ZERO_ERROR;
- }
-
// --- Native methods accessing ICU's database.
- private static native String[] getAvailableCollatorLocalesNative();
private static native String[] getAvailableLocalesNative();
public static native String getCurrencyCode(String countryCode);
- public static String getDisplayCountry(Locale targetLocale, Locale locale) {
- return getDisplayCountryNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayCountryNative(String targetLanguageTag, String languageTag);
-
- public static String getDisplayLanguage(Locale targetLocale, Locale locale) {
- return getDisplayLanguageNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayLanguageNative(String targetLanguageTag, String languageTag);
-
- public static String getDisplayVariant(Locale targetLocale, Locale locale) {
- return getDisplayVariantNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayVariantNative(String targetLanguageTag, String languageTag);
-
- public static String getDisplayScript(Locale targetLocale, Locale locale) {
- return getDisplayScriptNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayScriptNative(String targetLanguageTag, String languageTag);
-
public static native String getISO3Country(String languageTag);
public static native String getISO3Language(String languageTag);
- @UnsupportedAppUsage
- @libcore.api.CorePlatformApi
- public static Locale addLikelySubtags(Locale locale) {
- return Locale.forLanguageTag(addLikelySubtags(locale.toLanguageTag()).replace('_', '-'));
- }
-
/**
- * @deprecated use {@link #addLikelySubtags(java.util.Locale)} instead.
+ * @deprecated Use {@link android.icu.util.ULocale#addLikelySubtags(ULocale)} instead.
+ * The method is only kept for @UnsupportedAppUsage.
*/
@UnsupportedAppUsage
@Deprecated
- public static native String addLikelySubtags(String locale);
+ public static Locale addLikelySubtags(Locale locale) {
+ return ULocale.addLikelySubtags(ULocale.forLocale(locale)).toLocale();
+ }
+
+ /**
+ * @return ICU localeID
+ * @deprecated Use {@link android.icu.util.ULocale#addLikelySubtags(ULocale)} instead.
+ * The method is only kept for @UnsupportedAppUsage.
+ */
+ @UnsupportedAppUsage
+ @Deprecated
+ public static String addLikelySubtags(String locale) {
+ return ULocale.addLikelySubtags(new ULocale(locale)).getName();
+ }
/**
* @deprecated use {@link java.util.Locale#getScript()} instead. This has been kept
@@ -445,8 +384,4 @@
* Returns a locale name, not a BCP-47 language tag. e.g. en_US not en-US.
*/
public static native String getDefaultLocale();
-
- /** Returns the TZData version as reported by ICU4C. */
- @libcore.api.CorePlatformApi
- public static native String getTZDataVersion();
}
diff --git a/luni/src/main/java/libcore/icu/LocaleData.java b/luni/src/main/java/libcore/icu/LocaleData.java
index cf3fec0..ea6fe6f 100644
--- a/luni/src/main/java/libcore/icu/LocaleData.java
+++ b/luni/src/main/java/libcore/icu/LocaleData.java
@@ -16,11 +16,12 @@
package libcore.icu;
+import android.compat.annotation.UnsupportedAppUsage;
import android.icu.impl.ICUData;
import android.icu.impl.ICUResourceBundle;
import android.icu.text.NumberingSystem;
import android.icu.util.UResourceBundle;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+
import java.text.DateFormat;
import java.util.HashMap;
import java.util.Locale;
diff --git a/luni/src/main/java/libcore/icu/NativeConverter.java b/luni/src/main/java/libcore/icu/NativeConverter.java
deleted file mode 100644
index 956c701..0000000
--- a/luni/src/main/java/libcore/icu/NativeConverter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
-*******************************************************************************
-* Copyright (C) 1996-2006, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-*******************************************************************************
-*
-*******************************************************************************
-*/
-
-package libcore.icu;
-
-import libcore.util.NativeAllocationRegistry;
-
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CodingErrorAction;
-
-public final class NativeConverter {
- private static final NativeAllocationRegistry registry = new NativeAllocationRegistry(
- NativeConverter.class.getClassLoader(), getNativeFinalizer(), getNativeSize());
-
- public static native int decode(long converterHandle, byte[] input, int inEnd,
- char[] output, int outEnd, int[] data, boolean flush);
-
- public static native int encode(long converterHandle, char[] input, int inEnd,
- byte[] output, int outEnd, int[] data, boolean flush);
-
- public static native long openConverter(String charsetName);
- public static native void closeConverter(long converterHandle);
-
- public static void registerConverter(Object referrent, long converterHandle) {
- registry.registerNativeAllocation(referrent, converterHandle);
- }
-
- public static native void resetByteToChar(long converterHandle);
- public static native void resetCharToByte(long converterHandle);
-
- public static native byte[] getSubstitutionBytes(long converterHandle);
-
- public static native int getMaxBytesPerChar(long converterHandle);
- public static native int getMinBytesPerChar(long converterHandle);
- public static native float getAveBytesPerChar(long converterHandle);
- public static native float getAveCharsPerByte(long converterHandle);
-
- public static native boolean contains(String converterName1, String converterName2);
-
- public static native String[] getAvailableCharsetNames();
- public static native Charset charsetForName(String charsetName);
-
- // Translates from Java's enum to the magic numbers #defined in "NativeConverter.cpp".
- private static int translateCodingErrorAction(CodingErrorAction action) {
- if (action == CodingErrorAction.REPORT) {
- return 0;
- } else if (action == CodingErrorAction.IGNORE) {
- return 1;
- } else if (action == CodingErrorAction.REPLACE) {
- return 2;
- } else {
- throw new AssertionError(); // Someone changed the enum.
- }
- }
-
- public static void setCallbackDecode(long converterHandle, CharsetDecoder decoder) {
- setCallbackDecode(converterHandle,
- translateCodingErrorAction(decoder.malformedInputAction()),
- translateCodingErrorAction(decoder.unmappableCharacterAction()),
- decoder.replacement());
- }
- private static native void setCallbackDecode(long converterHandle, int onMalformedInput, int onUnmappableInput, String subChars);
-
- public static void setCallbackEncode(long converterHandle, CharsetEncoder encoder) {
- setCallbackEncode(converterHandle,
- translateCodingErrorAction(encoder.malformedInputAction()),
- translateCodingErrorAction(encoder.unmappableCharacterAction()),
- encoder.replacement());
- }
- private static native void setCallbackEncode(long converterHandle, int onMalformedInput, int onUnmappableInput, byte[] subBytes);
-
- public static native long getNativeFinalizer();
- public static native long getNativeSize();
-}
diff --git a/luni/src/main/java/libcore/icu/TimeZoneNames.java b/luni/src/main/java/libcore/icu/TimeZoneNames.java
index caeaefd..ec0fb8e 100644
--- a/luni/src/main/java/libcore/icu/TimeZoneNames.java
+++ b/luni/src/main/java/libcore/icu/TimeZoneNames.java
@@ -16,7 +16,6 @@
package libcore.icu;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
@@ -24,7 +23,6 @@
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import libcore.util.BasicLruCache;
-import libcore.timezone.ZoneInfoDB;
/**
* Provides access to ICU's time zone name data.
@@ -36,17 +34,16 @@
/*
* Offsets into the arrays returned by DateFormatSymbols.getZoneStrings.
*/
- public static final int OLSON_NAME = 0;
- public static final int LONG_NAME = 1;
- public static final int SHORT_NAME = 2;
- public static final int LONG_NAME_DST = 3;
- public static final int SHORT_NAME_DST = 4;
- public static final int NAME_COUNT = 5;
+ private static final int OLSON_NAME = 0;
+ private static final int LONG_NAME = 1;
+ private static final int SHORT_NAME = 2;
+ private static final int LONG_NAME_DST = 3;
+ private static final int SHORT_NAME_DST = 4;
+ private static final int NAME_COUNT = 5;
private static final ZoneStringsCache cachedZoneStrings = new ZoneStringsCache();
- /** @hide */
- public static class ZoneStringsCache extends BasicLruCache<Locale, String[][]> {
+ private static class ZoneStringsCache extends BasicLruCache<Locale, String[][]> {
public ZoneStringsCache() {
super(5); // Room for a handful of locales.
}
diff --git a/luni/src/main/java/libcore/io/AsynchronousCloseMonitor.java b/luni/src/main/java/libcore/io/AsynchronousCloseMonitor.java
index 76ef5e4..49d71a0 100644
--- a/luni/src/main/java/libcore/io/AsynchronousCloseMonitor.java
+++ b/luni/src/main/java/libcore/io/AsynchronousCloseMonitor.java
@@ -16,13 +16,21 @@
package libcore.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.FileDescriptor;
+import libcore.api.IntraCoreApi;
+/**
+ * Implements interruption of threads blocked in I/O system calls.
+ *
+ * @hide
+ */
+@IntraCoreApi
public final class AsynchronousCloseMonitor {
private AsynchronousCloseMonitor() {
}
@UnsupportedAppUsage
+ @IntraCoreApi
public static native void signalBlockedThreads(FileDescriptor fd);
}
diff --git a/luni/src/main/java/libcore/io/BlockGuardOs.java b/luni/src/main/java/libcore/io/BlockGuardOs.java
index bd95a93..f3793d6 100644
--- a/luni/src/main/java/libcore/io/BlockGuardOs.java
+++ b/luni/src/main/java/libcore/io/BlockGuardOs.java
@@ -16,6 +16,7 @@
package libcore.io;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.ErrnoException;
import android.system.GaiException;
import android.system.Int64Ref;
@@ -25,9 +26,7 @@
import android.system.StructPollfd;
import android.system.StructStat;
import android.system.StructStatVfs;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.BlockGuard;
-import dalvik.system.SocketTagger;
+
import java.io.FileDescriptor;
import java.io.InterruptedIOException;
import java.net.InetAddress;
@@ -36,6 +35,9 @@
import java.net.SocketException;
import java.nio.ByteBuffer;
+import dalvik.system.BlockGuard;
+import dalvik.system.SocketTagger;
+
import static android.system.OsConstants.*;
/**
diff --git a/luni/src/main/java/libcore/io/BufferIterator.java b/luni/src/main/java/libcore/io/BufferIterator.java
index 97890c3..fb97250 100644
--- a/luni/src/main/java/libcore/io/BufferIterator.java
+++ b/luni/src/main/java/libcore/io/BufferIterator.java
@@ -16,7 +16,7 @@
package libcore.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* Iterates over big- or little-endian bytes. See {@link MemoryMappedFile#bigEndianIterator} and
diff --git a/luni/src/main/java/libcore/io/ForwardingOs.java b/luni/src/main/java/libcore/io/ForwardingOs.java
index c82cbe0..f9fb2d4 100644
--- a/luni/src/main/java/libcore/io/ForwardingOs.java
+++ b/luni/src/main/java/libcore/io/ForwardingOs.java
@@ -35,7 +35,7 @@
import android.system.StructUcred;
import android.system.StructUtsname;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.FileDescriptor;
import java.io.InterruptedIOException;
import java.net.InetAddress;
@@ -150,6 +150,7 @@
public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return os.lseek(fd, offset, whence); }
@UnsupportedAppUsage
public StructStat lstat(String path) throws ErrnoException { return os.lstat(path); }
+ public FileDescriptor memfd_create(String name, int flags) throws ErrnoException { return os.memfd_create(name, flags); }
public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { os.mincore(address, byteCount, vector); }
@UnsupportedAppUsage
public void mkdir(String path, int mode) throws ErrnoException { os.mkdir(path, mode); }
diff --git a/luni/src/main/java/libcore/io/IoBridge.java b/luni/src/main/java/libcore/io/IoBridge.java
index 0631176..aa66f14 100644
--- a/luni/src/main/java/libcore/io/IoBridge.java
+++ b/luni/src/main/java/libcore/io/IoBridge.java
@@ -16,6 +16,7 @@
package libcore.io;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.ErrnoException;
import android.system.Int32Ref;
import android.system.StructGroupReq;
@@ -23,9 +24,6 @@
import android.system.StructPollfd;
import android.system.StructTimeval;
-import libcore.util.ArrayUtils;
-
-import dalvik.annotation.compat.UnsupportedAppUsage;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -46,6 +44,7 @@
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeUnit;
+import libcore.util.ArrayUtils;
import static android.system.OsConstants.*;
diff --git a/luni/src/main/java/libcore/io/IoUtils.java b/luni/src/main/java/libcore/io/IoUtils.java
index 72a2d3d..4b4870b 100644
--- a/luni/src/main/java/libcore/io/IoUtils.java
+++ b/luni/src/main/java/libcore/io/IoUtils.java
@@ -16,8 +16,10 @@
package libcore.io;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.ErrnoException;
import android.system.StructStat;
+
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
@@ -27,10 +29,12 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
-
-import dalvik.annotation.compat.UnsupportedAppUsage;
import libcore.util.NonNull;
-import static android.system.OsConstants.*;
+
+import static android.system.OsConstants.F_GETFL;
+import static android.system.OsConstants.F_SETFL;
+import static android.system.OsConstants.O_NONBLOCK;
+import static android.system.OsConstants.O_RDONLY;
/** @hide */
@libcore.api.CorePlatformApi
diff --git a/luni/src/main/java/libcore/io/Libcore.java b/luni/src/main/java/libcore/io/Libcore.java
index 823d866..29b5f7f 100644
--- a/luni/src/main/java/libcore/io/Libcore.java
+++ b/luni/src/main/java/libcore/io/Libcore.java
@@ -16,7 +16,7 @@
package libcore.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.util.Objects;
/** @hide */
diff --git a/luni/src/main/java/libcore/io/Linux.java b/luni/src/main/java/libcore/io/Linux.java
index e2a4c54..74608d3 100644
--- a/luni/src/main/java/libcore/io/Linux.java
+++ b/luni/src/main/java/libcore/io/Linux.java
@@ -121,6 +121,7 @@
public native String[] listxattr(String path) throws ErrnoException;
public native long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException;
public native StructStat lstat(String path) throws ErrnoException;
+ public native FileDescriptor memfd_create(String name, int flags) throws ErrnoException;
public native void mincore(long address, long byteCount, byte[] vector) throws ErrnoException;
public native void mkdir(String path, int mode) throws ErrnoException;
public native void mkfifo(String path, int mode) throws ErrnoException;
diff --git a/luni/src/main/java/libcore/io/Memory.java b/luni/src/main/java/libcore/io/Memory.java
index 4042300..9e7f4ea 100644
--- a/luni/src/main/java/libcore/io/Memory.java
+++ b/luni/src/main/java/libcore/io/Memory.java
@@ -17,13 +17,12 @@
package libcore.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.annotation.optimization.FastNative;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.nio.ByteBuffer;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.nio.ByteOrder;
+import dalvik.annotation.optimization.FastNative;
+
/**
* Unsafe access to memory.
*
diff --git a/luni/src/main/java/libcore/io/MemoryMappedFile.java b/luni/src/main/java/libcore/io/MemoryMappedFile.java
index 20b08e5..5e003ea 100644
--- a/luni/src/main/java/libcore/io/MemoryMappedFile.java
+++ b/luni/src/main/java/libcore/io/MemoryMappedFile.java
@@ -16,17 +16,15 @@
package libcore.io;
+import android.compat.annotation.UnsupportedAppUsage;
import android.system.ErrnoException;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+
import java.io.FileDescriptor;
-import java.io.IOException;
-import java.io.RandomAccessFile;
import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-import java.nio.NioUtils;
-import libcore.io.Libcore;
-import libcore.io.Memory;
-import static android.system.OsConstants.*;
+
+import static android.system.OsConstants.MAP_SHARED;
+import static android.system.OsConstants.O_RDONLY;
+import static android.system.OsConstants.PROT_READ;
/**
* A memory-mapped file. Use {@link #mmapRO} to map a file, {@link #close} to unmap a file,
diff --git a/luni/src/main/java/libcore/io/Os.java b/luni/src/main/java/libcore/io/Os.java
index a7bae10..4953186 100644
--- a/luni/src/main/java/libcore/io/Os.java
+++ b/luni/src/main/java/libcore/io/Os.java
@@ -35,7 +35,7 @@
import android.system.StructUcred;
import android.system.StructUtsname;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.FileDescriptor;
import java.io.InterruptedIOException;
import java.net.InetAddress;
@@ -123,6 +123,7 @@
public String[] listxattr(String path) throws ErrnoException;
public long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException;
public StructStat lstat(String path) throws ErrnoException;
+ public FileDescriptor memfd_create(String name, int flags) throws ErrnoException;
public void mincore(long address, long byteCount, byte[] vector) throws ErrnoException;
public void mkdir(String path, int mode) throws ErrnoException;
public void mkfifo(String path, int mode) throws ErrnoException;
diff --git a/luni/src/main/java/libcore/io/Streams.java b/luni/src/main/java/libcore/io/Streams.java
index 4274399..f83f5c1 100644
--- a/luni/src/main/java/libcore/io/Streams.java
+++ b/luni/src/main/java/libcore/io/Streams.java
@@ -16,9 +16,8 @@
package libcore.io;
-import libcore.util.ArrayUtils;
+import android.compat.annotation.UnsupportedAppUsage;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -27,6 +26,7 @@
import java.io.Reader;
import java.io.StringWriter;
import java.util.concurrent.atomic.AtomicReference;
+import libcore.util.ArrayUtils;
/** @hide */
@libcore.api.CorePlatformApi
diff --git a/luni/src/main/java/libcore/net/NetworkSecurityPolicy.java b/luni/src/main/java/libcore/net/NetworkSecurityPolicy.java
index 3a3a5d9..1ce58d9 100644
--- a/luni/src/main/java/libcore/net/NetworkSecurityPolicy.java
+++ b/luni/src/main/java/libcore/net/NetworkSecurityPolicy.java
@@ -16,7 +16,7 @@
package libcore.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* Network security policy for this process/application.
diff --git a/luni/src/main/java/libcore/net/event/NetworkEventDispatcher.java b/luni/src/main/java/libcore/net/event/NetworkEventDispatcher.java
index 5399e89..4c2acee 100644
--- a/luni/src/main/java/libcore/net/event/NetworkEventDispatcher.java
+++ b/luni/src/main/java/libcore/net/event/NetworkEventDispatcher.java
@@ -16,7 +16,7 @@
package libcore.net.event;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
diff --git a/luni/src/main/java/libcore/net/event/NetworkEventListener.java b/luni/src/main/java/libcore/net/event/NetworkEventListener.java
index d7d011b..07c62c5 100644
--- a/luni/src/main/java/libcore/net/event/NetworkEventListener.java
+++ b/luni/src/main/java/libcore/net/event/NetworkEventListener.java
@@ -16,7 +16,7 @@
package libcore.net.event;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* A base class for objects interested in network events.
diff --git a/luni/src/main/java/libcore/net/http/HttpDate.java b/luni/src/main/java/libcore/net/http/HttpDate.java
index c295503..de05cea 100644
--- a/luni/src/main/java/libcore/net/http/HttpDate.java
+++ b/luni/src/main/java/libcore/net/http/HttpDate.java
@@ -16,7 +16,7 @@
package libcore.net.http;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
diff --git a/luni/src/main/java/libcore/timezone/CountryTimeZones.java b/luni/src/main/java/libcore/timezone/CountryTimeZones.java
index d0fa081..4ff8470 100644
--- a/luni/src/main/java/libcore/timezone/CountryTimeZones.java
+++ b/luni/src/main/java/libcore/timezone/CountryTimeZones.java
@@ -40,25 +40,33 @@
@libcore.api.CorePlatformApi
public static final class OffsetResult {
- /** A zone that matches the supplied criteria. See also {@link #mOneMatch}. */
- @libcore.api.CorePlatformApi
- public final TimeZone mTimeZone;
+ /** A zone that matches the supplied criteria. See also {@link #isOnlyMatch}. */
+ private final TimeZone timeZone;
/** True if there is one match for the supplied criteria */
- @libcore.api.CorePlatformApi
- public final boolean mOneMatch;
+ private final boolean isOnlyMatch;
- public OffsetResult(TimeZone timeZone, boolean oneMatch) {
- mTimeZone = java.util.Objects.requireNonNull(timeZone);
- mOneMatch = oneMatch;
+ public OffsetResult(TimeZone timeZone, boolean isOnlyMatch) {
+ this.timeZone = java.util.Objects.requireNonNull(timeZone);
+ this.isOnlyMatch = isOnlyMatch;
+ }
+
+ @libcore.api.CorePlatformApi
+ public TimeZone getTimeZone() {
+ return timeZone;
+ }
+
+ @libcore.api.CorePlatformApi
+ public boolean isOnlyMatch() {
+ return isOnlyMatch;
}
@Override
public String toString() {
- return "Result{" +
- "mTimeZone='" + mTimeZone + '\'' +
- ", mOneMatch=" + mOneMatch +
- '}';
+ return "Result{"
+ + "timeZone='" + timeZone + '\''
+ + ", isOnlyMatch=" + isOnlyMatch
+ + '}';
}
}
@@ -69,22 +77,34 @@
*/
@libcore.api.CorePlatformApi
public static final class TimeZoneMapping {
- @libcore.api.CorePlatformApi
- public final String timeZoneId;
- @libcore.api.CorePlatformApi
- public final boolean showInPicker;
- @libcore.api.CorePlatformApi
- public final Long notUsedAfter;
+ private final String timeZoneId;
+ private final boolean shownInPicker;
+ private final Long notUsedAfter;
/** Memoized TimeZone object for {@link #timeZoneId}. */
private TimeZone timeZone;
- TimeZoneMapping(String timeZoneId, boolean showInPicker, Long notUsedAfter) {
+ TimeZoneMapping(String timeZoneId, boolean shownInPicker, Long notUsedAfter) {
this.timeZoneId = Objects.requireNonNull(timeZoneId);
- this.showInPicker = showInPicker;
+ this.shownInPicker = shownInPicker;
this.notUsedAfter = notUsedAfter;
}
+ @libcore.api.CorePlatformApi
+ public String getTimeZoneId() {
+ return timeZoneId;
+ }
+
+ @libcore.api.CorePlatformApi
+ public boolean isShownInPicker() {
+ return shownInPicker;
+ }
+
+ @libcore.api.CorePlatformApi
+ public Long getNotUsedAfter() {
+ return notUsedAfter;
+ }
+
/**
* Returns a {@link TimeZone} object for this mapping, or {@code null} if the ID is unknown.
*/
@@ -97,7 +117,7 @@
if (TimeZone.UNKNOWN_ZONE_ID.equals(timeZone.getID())) {
// This shouldn't happen given the validation that takes place in
// createValidatedCountryTimeZones().
- System.logW("Skipping invalid zone in TimeZoneMapping: " + timeZoneId);
+ throw new IllegalStateException("Invalid zone in TimeZoneMapping: " + this);
}
}
}
@@ -132,21 +152,21 @@
return false;
}
TimeZoneMapping that = (TimeZoneMapping) o;
- return showInPicker == that.showInPicker &&
+ return shownInPicker == that.shownInPicker &&
Objects.equals(timeZoneId, that.timeZoneId) &&
Objects.equals(notUsedAfter, that.notUsedAfter);
}
@Override
public int hashCode() {
- return Objects.hash(timeZoneId, showInPicker, notUsedAfter);
+ return Objects.hash(timeZoneId, shownInPicker, notUsedAfter);
}
@Override
public String toString() {
return "TimeZoneMapping{"
+ "timeZoneId='" + timeZoneId + '\''
- + ", showInPicker=" + showInPicker
+ + ", shownInPicker=" + shownInPicker
+ ", notUsedAfter=" + notUsedAfter
+ '}';
}
@@ -172,7 +192,7 @@
* {@code true} indicates the default time zone for a country is a good choice if a time zone
* cannot be determined by other means.
*/
- private final boolean defaultTimeZoneBoost;
+ private final boolean defaultTimeZoneBoosted;
private final List<TimeZoneMapping> timeZoneMappings;
private final boolean everUsesUtc;
@@ -183,11 +203,11 @@
private TimeZone defaultTimeZone;
private CountryTimeZones(String countryIso, String defaultTimeZoneId,
- boolean defaultTimeZoneBoost, boolean everUsesUtc,
+ boolean defaultTimeZoneBoosted, boolean everUsesUtc,
List<TimeZoneMapping> timeZoneMappings) {
this.countryIso = java.util.Objects.requireNonNull(countryIso);
this.defaultTimeZoneId = defaultTimeZoneId;
- this.defaultTimeZoneBoost = defaultTimeZoneBoost;
+ this.defaultTimeZoneBoosted = defaultTimeZoneBoosted;
this.everUsesUtc = everUsesUtc;
// Create a defensive copy of the mapping list.
this.timeZoneMappings = Collections.unmodifiableList(new ArrayList<>(timeZoneMappings));
@@ -197,13 +217,13 @@
* Creates a {@link CountryTimeZones} object containing only known time zone IDs.
*/
public static CountryTimeZones createValidated(String countryIso, String defaultTimeZoneId,
- boolean defaultTimeZoneBoost, boolean everUsesUtc,
+ boolean defaultTimeZoneBoosted, boolean everUsesUtc,
List<TimeZoneMapping> timeZoneMappings, String debugInfo) {
// We rely on ZoneInfoDB to tell us what the known valid time zone IDs are. ICU may
// recognize more but we want to be sure that zone IDs can be used with java.util as well as
// android.icu and ICU is expected to have a superset.
- String[] validTimeZoneIdsArray = ZoneInfoDB.getInstance().getAvailableIDs();
+ String[] validTimeZoneIdsArray = ZoneInfoDb.getInstance().getAvailableIDs();
HashSet<String> validTimeZoneIdsSet = new HashSet<>(Arrays.asList(validTimeZoneIdsArray));
List<TimeZoneMapping> validCountryTimeZoneMappings = new ArrayList<>();
for (TimeZoneMapping timeZoneMapping : timeZoneMappings) {
@@ -227,7 +247,7 @@
String normalizedCountryIso = normalizeCountryIso(countryIso);
return new CountryTimeZones(
- normalizedCountryIso, defaultTimeZoneId, defaultTimeZoneBoost, everUsesUtc,
+ normalizedCountryIso, defaultTimeZoneId, defaultTimeZoneBoosted, everUsesUtc,
validCountryTimeZoneMappings);
}
@@ -281,8 +301,8 @@
* would be a good choice <em>generally</em> when there's no other information available.
*/
@libcore.api.CorePlatformApi
- public boolean getDefaultTimeZoneBoost() {
- return defaultTimeZoneBoost;
+ public boolean isDefaultTimeZoneBoosted() {
+ return defaultTimeZoneBoosted;
}
/**
@@ -322,7 +342,7 @@
return false;
}
CountryTimeZones that = (CountryTimeZones) o;
- return defaultTimeZoneBoost == that.defaultTimeZoneBoost
+ return defaultTimeZoneBoosted == that.defaultTimeZoneBoosted
&& everUsesUtc == that.everUsesUtc
&& countryIso.equals(that.countryIso)
&& Objects.equals(defaultTimeZoneId, that.defaultTimeZoneId)
@@ -332,10 +352,21 @@
@Override
public int hashCode() {
return Objects.hash(
- countryIso, defaultTimeZoneId, defaultTimeZoneBoost, timeZoneMappings,
+ countryIso, defaultTimeZoneId, defaultTimeZoneBoosted, timeZoneMappings,
everUsesUtc);
}
+ @Override
+ public String toString() {
+ return "CountryTimeZones{"
+ + "countryIso='" + countryIso + '\''
+ + ", defaultTimeZoneId='" + defaultTimeZoneId + '\''
+ + ", defaultTimeZoneBoosted=" + defaultTimeZoneBoosted
+ + ", timeZoneMappings=" + timeZoneMappings
+ + ", everUsesUtc=" + everUsesUtc
+ + '}';
+ }
+
/**
* Returns true if the country has at least one zone that is the same as UTC at the given time.
*/
@@ -356,23 +387,58 @@
}
/**
- * Returns a time zone for the country, if there is one, that matches the desired properties. If
- * there are multiple matches and the {@code bias} is one of them then it is returned, otherwise
- * an arbitrary match is returned based on the {@link #getEffectiveTimeZoneMappingsAt(long)}
- * ordering.
+ * Returns a time zone for the country, if there is one, that matches the supplied properties.
+ * If there are multiple matches and the {@code bias} is one of them then it is returned,
+ * otherwise an arbitrary match is returned based on the {@link
+ * #getEffectiveTimeZoneMappingsAt(long)} ordering.
*
+ * @param whenMillis the UTC time to match against
+ * @param bias the time zone to prefer, can be {@code null} to indicate there is no preference
+ * @param totalOffsetMillis the offset from UTC at {@code whenMillis}
+ * @param isDst the Daylight Savings Time state at {@code whenMillis}. {@code true} means DST,
+ * {@code false} means not DST
+ * @return an {@link OffsetResult} with information about a matching zone, or {@code null} if
+ * there is no match
+ */
+ @libcore.api.CorePlatformApi
+ public OffsetResult lookupByOffsetWithBias(long whenMillis, TimeZone bias,
+ int totalOffsetMillis, boolean isDst) {
+ return lookupByOffsetWithBiasInternal(whenMillis, bias, totalOffsetMillis, isDst);
+ }
+
+ /**
+ * Returns a time zone for the country, if there is one, that matches the supplied properties.
+ * If there are multiple matches and the {@code bias} is one of them then it is returned,
+ * otherwise an arbitrary match is returned based on the {@link
+ * #getEffectiveTimeZoneMappingsAt(long)} ordering.
+ *
+ * @param whenMillis the UTC time to match against
+ * @param bias the time zone to prefer, can be {@code null} to indicate there is no preference
+ * @param totalOffsetMillis the offset from UTC at {@code whenMillis}
+ * @return an {@link OffsetResult} with information about a matching zone, or {@code null} if
+ * there is no match
+ */
+ @libcore.api.CorePlatformApi
+ public OffsetResult lookupByOffsetWithBias(long whenMillis, TimeZone bias,
+ int totalOffsetMillis) {
+ final Boolean isDst = null;
+ return lookupByOffsetWithBiasInternal(whenMillis, bias, totalOffsetMillis, isDst);
+ }
+
+ /**
+ * Returns a time zone for the country, if there is one, that matches the supplied properties.
+ * If there are multiple matches and the {@code bias} is one of them then it is returned,
+ * otherwise an arbitrary match is returned based on the {@link
+ * #getEffectiveTimeZoneMappingsAt(long)} ordering.
+ *
+ * @param whenMillis the UTC time to match against
+ * @param bias the time zone to prefer, can be {@code null}
* @param totalOffsetMillis the offset from UTC at {@code whenMillis}
* @param isDst the Daylight Savings Time state at {@code whenMillis}. {@code true} means DST,
* {@code false} means not DST, {@code null} means unknown
- * @param dstOffsetMillis the part of {@code totalOffsetMillis} contributed by DST, only used if
- * {@code isDst} is {@code true}. The value can be {@code null} if the DST offset is
- * unknown
- * @param whenMillis the UTC time to match against
- * @param bias the time zone to prefer, can be {@code null}
*/
- @libcore.api.CorePlatformApi
- public OffsetResult lookupByOffsetWithBias(int totalOffsetMillis, Boolean isDst,
- Integer dstOffsetMillis, long whenMillis, TimeZone bias) {
+ private OffsetResult lookupByOffsetWithBiasInternal(long whenMillis, TimeZone bias,
+ int totalOffsetMillis, Boolean isDst) {
List<TimeZoneMapping> timeZoneMappings = getEffectiveTimeZoneMappingsAt(whenMillis);
if (timeZoneMappings.isEmpty()) {
return null;
@@ -383,8 +449,8 @@
boolean oneMatch = true;
for (TimeZoneMapping timeZoneMapping : timeZoneMappings) {
TimeZone match = timeZoneMapping.getTimeZone();
- if (match == null || !offsetMatchesAtTime(match, totalOffsetMillis, isDst,
- dstOffsetMillis, whenMillis)) {
+ if (match == null
+ || !offsetMatchesAtTime(whenMillis, match, totalOffsetMillis, isDst)) {
continue;
}
@@ -409,18 +475,15 @@
}
/**
- * Returns {@code true} if the specified {@code totalOffset}, {@code isDst},
- * {@code dstOffsetMillis} would be valid in the {@code timeZone} at time {@code whenMillis}.
+ * Returns {@code true} if the specified {@code totalOffset} and {@code isDst} would be valid in
+ * the {@code timeZone} at time {@code whenMillis}.
* {@code totalOffetMillis} is always matched.
- * If {@code isDst} is {@code null} this means the DST state is unknown, so
- * {@code dstOffsetMillis} is ignored.
- * If {@code isDst} is {@code false}, {@code dstOffsetMillis} is ignored.
- * If {@code isDst} is {@code true}, the DST state is considered. When considering DST state
- * {@code dstOffsetMillis} can be {@code null} if it is unknown but when {@code dstOffsetMillis}
- * is known then it is also matched.
+ * If {@code isDst} is {@code null}, this means the DST state is unknown.
+ * If {@code isDst} is {@code false}, this means the zone must not be in DST.
+ * If {@code isDst} is {@code true}, this means the zone must be in DST.
*/
- private static boolean offsetMatchesAtTime(TimeZone timeZone, int totalOffsetMillis,
- Boolean isDst, Integer dstOffsetMillis, long whenMillis) {
+ private static boolean offsetMatchesAtTime(long whenMillis, TimeZone timeZone,
+ int totalOffsetMillis, Boolean isDst) {
int[] offsets = new int[2];
timeZone.getOffset(whenMillis, false /* local */, offsets);
@@ -428,15 +491,7 @@
return false;
}
- if (isDst == null) {
- return true;
- } else if (!isDst) {
- return offsets[1] == 0;
- } else {
- // isDst
- return (dstOffsetMillis == null && offsets[1] != 0)
- || (dstOffsetMillis != null && dstOffsetMillis == offsets[1]);
- }
+ return isDst == null || (isDst == (offsets[1] != 0));
}
private static String normalizeCountryIso(String countryIso) {
diff --git a/luni/src/main/java/libcore/timezone/CountryZonesFinder.java b/luni/src/main/java/libcore/timezone/CountryZonesFinder.java
index 92f6631..1a9d6a6 100644
--- a/luni/src/main/java/libcore/timezone/CountryZonesFinder.java
+++ b/luni/src/main/java/libcore/timezone/CountryZonesFinder.java
@@ -16,6 +16,8 @@
package libcore.timezone;
+import static libcore.timezone.XmlUtils.normalizeCountryIso;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -76,7 +78,7 @@
*/
@libcore.api.CorePlatformApi
public CountryTimeZones lookupCountryTimeZones(String countryIso) {
- String normalizedCountryIso = TimeZoneFinder.normalizeCountryIso(countryIso);
+ String normalizedCountryIso = normalizeCountryIso(countryIso);
for (CountryTimeZones countryTimeZones : countryTimeZonesList) {
if (countryTimeZones.getCountryIso().equals(normalizedCountryIso)) {
return countryTimeZones;
diff --git a/luni/src/main/java/libcore/timezone/TelephonyLookup.java b/luni/src/main/java/libcore/timezone/TelephonyLookup.java
new file mode 100644
index 0000000..10d9a35
--- /dev/null
+++ b/luni/src/main/java/libcore/timezone/TelephonyLookup.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.timezone;
+
+import static libcore.timezone.XmlUtils.checkOnEndTag;
+import static libcore.timezone.XmlUtils.consumeUntilEndTag;
+import static libcore.timezone.XmlUtils.findNextStartTagOrEndTagNoRecurse;
+import static libcore.timezone.XmlUtils.findNextStartTagOrThrowNoRecurse;
+import static libcore.timezone.XmlUtils.normalizeCountryIso;
+
+import libcore.timezone.TelephonyNetwork.MccMnc;
+import libcore.timezone.XmlUtils.ReaderSupplier;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A class that can find time zone-related information about telephony networks by loading data from
+ * the telephonylookup.xml file.
+ *
+ * @hide
+ */
+@libcore.api.CorePlatformApi
+public final class TelephonyLookup {
+
+ // VisibleForTesting
+ public static final String TELEPHONYLOOKUP_FILE_NAME = "telephonylookup.xml";
+
+ // Root element. e.g. <telephony_lookup>
+ private static final String TELEPHONY_LOOKUP_ELEMENT = "telephony_lookup";
+
+ // Networks section. e.g. <networks>
+ private static final String NETWORKS_ELEMENT = "networks";
+
+ // Network data. e.g.
+ // <network mcc="310" mnc="370" country="gu">
+ private static final String NETWORK_ELEMENT = "network";
+ private static final String MOBILE_COUNTRY_CODE_ATTRIBUTE = "mcc";
+ private static final String MOBILE_NETWORK_CODE_ATTRIBUTE = "mnc";
+ // This is the ISO 3166 alpha-2 code (in lower case).
+ private static final String COUNTRY_ISO_CODE_ATTRIBUTE = "country";
+
+ private static TelephonyLookup instance;
+
+ private final ReaderSupplier xmlSource;
+
+ private TelephonyLookup(ReaderSupplier xmlSource) {
+ this.xmlSource = xmlSource;
+ }
+
+ /**
+ * Obtains an instance for use when resolving networks. This method handles using the correct
+ * file when there are several to choose from. This method never returns {@code null}. No
+ * in-depth validation is performed on the file content, see {@link #validate()}.
+ */
+ @libcore.api.CorePlatformApi
+ public static TelephonyLookup getInstance() {
+ synchronized(TelephonyLookup.class) {
+ if (instance == null) {
+ String[] telephonyLookupFilePaths =
+ TimeZoneDataFiles.getTimeZoneFilePaths(TELEPHONYLOOKUP_FILE_NAME);
+ instance = createInstanceWithFallback(telephonyLookupFilePaths);
+ }
+ }
+ return instance;
+ }
+
+ // VisibleForTesting
+ public static TelephonyLookup createInstanceWithFallback(String... telephonyLookupFilePaths) {
+ IOException lastException = null;
+ for (String tzLookupFilePath : telephonyLookupFilePaths) {
+ try {
+ // We assume that any file in /data was validated before install, and the system
+ // file was validated before the device shipped. Therefore, we do not pay the
+ // validation cost here.
+ return createInstance(tzLookupFilePath);
+ } catch (IOException e) {
+ // There's expected to be two files, and it's normal for the first file not to
+ // exist so we don't log, but keep the lastException so we can log it if there
+ // are no valid files available.
+ if (lastException != null) {
+ e.addSuppressed(lastException);
+ }
+ lastException = e;
+ }
+ }
+
+ System.logE("No valid file found in set: " + Arrays.toString(telephonyLookupFilePaths)
+ + " Printing exceptions and falling back to empty map.", lastException);
+ return createInstanceForTests("<telephony_lookup><networks /></telephony_lookup>");
+ }
+
+ /**
+ * Obtains an instance using a specific data file, throwing an IOException if the file does not
+ * exist or is not readable. This method never returns {@code null}. No in-depth validation is
+ * performed on the file content, see {@link #validate()}.
+ */
+ @libcore.api.CorePlatformApi
+ public static TelephonyLookup createInstance(String path) throws IOException {
+ ReaderSupplier xmlSupplier = ReaderSupplier.forFile(path, StandardCharsets.UTF_8);
+ return new TelephonyLookup(xmlSupplier);
+ }
+
+ /** Used to create an instance using an in-memory XML String instead of a file. */
+ // VisibleForTesting
+ public static TelephonyLookup createInstanceForTests(String xml) {
+ return new TelephonyLookup(ReaderSupplier.forString(xml));
+ }
+
+ /**
+ * Parses the data file, throws an exception if it is invalid or cannot be read.
+ */
+ @libcore.api.CorePlatformApi
+ public void validate() throws IOException {
+ try {
+ processXml(new TelephonyNetworkValidator());
+ } catch (XmlPullParserException e) {
+ throw new IOException("Parsing error", e);
+ }
+ }
+
+ /**
+ * Loads all the network <-> country mapping data into memory. This method can return
+ * {@code null} in the event of an error while reading the underlying data files.
+ */
+ @libcore.api.CorePlatformApi
+ public TelephonyNetworkFinder getTelephonyNetworkFinder() {
+ TelephonyNetworksExtractor extractor = new TelephonyNetworksExtractor();
+ try {
+ processXml(extractor);
+
+ return extractor.getTelephonyNetworkFinder();
+ } catch (XmlPullParserException | IOException e) {
+ System.logW("Error reading telephony networks", e);
+ return null;
+ }
+ }
+
+ /**
+ * Processes the XML, applying the {@link TelephonyNetworkProcessor} to the <countryzones>
+ * element. Processing can terminate early if {@link TelephonyNetworkProcessor
+ * #processNetwork(int, int, String, String)} it throws an exception.
+ */
+ private void processXml(TelephonyNetworkProcessor processor)
+ throws XmlPullParserException, IOException {
+ try (Reader reader = xmlSource.get()) {
+ XmlPullParserFactory xmlPullParserFactory = XmlPullParserFactory.newInstance();
+ xmlPullParserFactory.setNamespaceAware(false);
+
+ XmlPullParser parser = xmlPullParserFactory.newPullParser();
+ parser.setInput(reader);
+
+ /*
+ * The expected XML structure is:
+ * <telephony_lookup>
+ * <networks>
+ * <network mcc="123" mnc="456" country="ab"/>
+ * <network mcc="123" mnc="567" country="cd"/>
+ * </networks>
+ * </telephony_lookup>
+ */
+
+ findNextStartTagOrThrowNoRecurse(parser, TELEPHONY_LOOKUP_ELEMENT);
+
+ // There is only one expected sub-element <telephony_lookup> in the format currently,
+ // skip over anything before it.
+ findNextStartTagOrThrowNoRecurse(parser, NETWORKS_ELEMENT);
+
+ processNetworks(parser, processor);
+
+ // Make sure we are on the </networks> tag.
+ checkOnEndTag(parser, NETWORKS_ELEMENT);
+
+ // Advance to the next event.
+ parser.next();
+
+ // Skip anything until </telephony_lookup>, and make sure the file is not truncated and
+ // we can find the end.
+ consumeUntilEndTag(parser, TELEPHONY_LOOKUP_ELEMENT);
+
+ // Make sure we are on the </telephony_lookup> tag.
+ checkOnEndTag(parser, TELEPHONY_LOOKUP_ELEMENT);
+ }
+ }
+
+ private static void processNetworks(XmlPullParser parser,
+ TelephonyNetworkProcessor processor) throws IOException, XmlPullParserException {
+
+ // Skip over any unexpected elements and process <network> elements.
+ while (findNextStartTagOrEndTagNoRecurse(parser, NETWORK_ELEMENT)) {
+ String mcc = parser.getAttributeValue(
+ null /* namespace */, MOBILE_COUNTRY_CODE_ATTRIBUTE);
+ if (mcc == null) {
+ throw new XmlPullParserException(
+ "Unable to find mcc: " + parser.getPositionDescription());
+ }
+
+ String mnc = parser.getAttributeValue(
+ null /* namespace */, MOBILE_NETWORK_CODE_ATTRIBUTE);
+ if (mnc == null) {
+ throw new XmlPullParserException(
+ "Unable to find mnc: " + parser.getPositionDescription());
+ }
+
+ String countryCode =
+ parser.getAttributeValue(null /* namespace */, COUNTRY_ISO_CODE_ATTRIBUTE);
+ if (countryCode == null) {
+ throw new XmlPullParserException(
+ "Unable to find country: " + parser.getPositionDescription());
+ }
+
+ String debugInfo = parser.getPositionDescription();
+ processor.processNetwork(mcc, mnc, countryCode, debugInfo);
+ // Advance to the next event.
+ parser.next();
+
+ // Skip anything until </network>.
+ consumeUntilEndTag(parser, NETWORK_ELEMENT);
+ }
+ }
+
+ /**
+ * Processes <network> data.
+ */
+ private interface TelephonyNetworkProcessor {
+
+ boolean CONTINUE = true;
+ boolean HALT = false;
+
+ /**
+ * Process network data. Problems with the data are reported as an exception.
+ */
+ void processNetwork(String mcc, String mnc, String countryIso, String debugInfo)
+ throws XmlPullParserException;
+ }
+
+ /**
+ * Validates <network> elements. Intended to be used before a proposed installation of new
+ * data. To be valid the MCC + MNC combination must generate a unique ID, country ISO code must
+ * be normalized.
+ */
+ private static class TelephonyNetworkValidator implements TelephonyNetworkProcessor {
+
+ private final Set<MccMnc> knownMccMncs = new HashSet<>();
+
+ @Override
+ public void processNetwork(String mcc, String mnc, String countryIso, String debugInfo)
+ throws XmlPullParserException {
+ if (mcc == null || mcc.length() != 3 || !isAsciiNumeric(mcc)) {
+ throw new XmlPullParserException(
+ "MCC is not valid: mcc=" + mcc + " at " + debugInfo);
+ }
+
+ if (mnc == null || !(mnc.length() == 2 || mnc.length() == 3) || !isAsciiNumeric(mnc)) {
+ throw new XmlPullParserException(
+ "MNC is not valid: mnc=" + mnc + " at " + debugInfo);
+ }
+
+ if (!normalizeCountryIso(countryIso).equals(countryIso)) {
+ throw new XmlPullParserException("Country code: " + countryIso
+ + " is not normalized at " + debugInfo);
+ }
+
+ MccMnc mccMnc = new MccMnc(mcc, mnc);
+ if (knownMccMncs.contains(mccMnc)) {
+ throw new XmlPullParserException("Second entry for MCC + MNC: " + mccMnc
+ + " at " + debugInfo);
+ }
+ knownMccMncs.add(mccMnc);
+ }
+
+ private static boolean isAsciiNumeric(String string) {
+ for (int i = 0; i < string.length(); i++) {
+ char character = string.charAt(i);
+ if (character < '0' || character > '9') {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Reads all telephony network time zone information into memory and makes it available as a
+ * {@link TelephonyNetworkFinder}.
+ */
+ private static class TelephonyNetworksExtractor implements TelephonyNetworkProcessor {
+ private List<TelephonyNetwork> networksList = new ArrayList<>(10 /* default */);
+
+ @Override
+ public void processNetwork(String mcc, String mnc, String countryIso, String debugInfo)
+ throws XmlPullParserException {
+ TelephonyNetwork network = TelephonyNetwork.create(mcc, mnc, countryIso);
+ networksList.add(network);
+ }
+
+ TelephonyNetworkFinder getTelephonyNetworkFinder() {
+ return TelephonyNetworkFinder.create(networksList);
+ }
+ }
+}
diff --git a/luni/src/main/java/libcore/timezone/TelephonyNetwork.java b/luni/src/main/java/libcore/timezone/TelephonyNetwork.java
new file mode 100644
index 0000000..e0f26ad
--- /dev/null
+++ b/luni/src/main/java/libcore/timezone/TelephonyNetwork.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.timezone;
+
+import static libcore.timezone.XmlUtils.normalizeCountryIso;
+
+import java.util.Objects;
+
+/**
+ * Information about a telephony network.
+ *
+ * @hide
+ */
+@libcore.api.CorePlatformApi
+public final class TelephonyNetwork {
+
+ /**
+ * A numeric network identifier consisting of the Mobile Country Code (MCC) and the Mobile
+ * Network Code (MNC).
+ *
+ * @hide
+ */
+ public static final class MccMnc {
+ final String mcc;
+ final String mnc;
+
+ public MccMnc(String mcc, String mnc) {
+ this.mcc = mcc;
+ this.mnc = mnc;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ MccMnc mccMnc = (MccMnc) o;
+ return Objects.equals(mcc, mccMnc.mcc)
+ && Objects.equals(mnc, mccMnc.mnc);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mcc, mnc);
+ }
+
+ @Override
+ public String toString() {
+ return "MccMnc{"
+ + "mcc=" + mcc
+ + ", mnc=" + mnc
+ + '}';
+ }
+ }
+
+ private final MccMnc mccMnc;
+ private final String countryIsoCode;
+
+ public static TelephonyNetwork create(String mcc, String mnc, String countryIsoCode) {
+ String normalizedCountryIso = normalizeCountryIso(countryIsoCode);
+ return new TelephonyNetwork(new MccMnc(mcc, mnc), normalizedCountryIso);
+ }
+
+ private TelephonyNetwork(MccMnc mccMnc, String countryIsoCode) {
+ this.mccMnc = mccMnc;
+ this.countryIsoCode = Objects.requireNonNull(countryIsoCode);
+ }
+
+ public MccMnc getMccMnc() {
+ return mccMnc;
+ }
+
+ @libcore.api.CorePlatformApi
+ public String getMcc() {
+ return mccMnc.mcc;
+ }
+
+ @libcore.api.CorePlatformApi
+ public String getMnc() {
+ return mccMnc.mnc;
+ }
+
+ @libcore.api.CorePlatformApi
+ public String getCountryIsoCode() {
+ return countryIsoCode;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ TelephonyNetwork that = (TelephonyNetwork) o;
+ return mccMnc.equals(that.mccMnc) &&
+ countryIsoCode.equals(that.countryIsoCode);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mccMnc, countryIsoCode);
+ }
+
+ @Override
+ public String toString() {
+ return "TelephonyNetwork{"
+ + "mccMnc=" + mccMnc
+ + ", countryIsoCode='" + countryIsoCode + '\''
+ + '}';
+ }
+}
diff --git a/luni/src/main/java/libcore/timezone/TelephonyNetworkFinder.java b/luni/src/main/java/libcore/timezone/TelephonyNetworkFinder.java
new file mode 100644
index 0000000..f244159
--- /dev/null
+++ b/luni/src/main/java/libcore/timezone/TelephonyNetworkFinder.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.timezone;
+
+import static libcore.timezone.XmlUtils.normalizeCountryIso;
+
+import libcore.timezone.TelephonyNetwork.MccMnc;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A class that can find telephony networks loaded via {@link TelephonyLookup}.
+ * @hide
+ */
+@libcore.api.CorePlatformApi
+public final class TelephonyNetworkFinder {
+
+ private final Map<MccMnc, TelephonyNetwork> networksMap;
+ private final List<TelephonyNetwork> networksList;
+
+ public static TelephonyNetworkFinder create(List<TelephonyNetwork> networksList) {
+ Set<String> validCountryIsoCodes = new HashSet<>();
+ for (String validCountryIsoCode : Locale.getISOCountries()) {
+ validCountryIsoCodes.add(normalizeCountryIso(validCountryIsoCode));
+ }
+
+ Map<MccMnc, TelephonyNetwork> networksMap = new HashMap<>();
+ for (TelephonyNetwork network : networksList) {
+ if (!validCountryIsoCodes.contains(network.getCountryIsoCode())) {
+ System.logW("Unrecognized country code: " + network.getCountryIsoCode()
+ + " for telephony network=" + network);
+ }
+
+ MccMnc mccMnc = network.getMccMnc();
+ TelephonyNetwork existingEntry = networksMap.put(mccMnc, network);
+ if (existingEntry != null) {
+ System.logW("Duplicate MccMnc detected for " + mccMnc
+ + ". New entry=" + network + " replacing previous entry.");
+ }
+ }
+ return new TelephonyNetworkFinder(
+ Collections.unmodifiableList(new ArrayList<>(networksList)),
+ networksMap);
+ }
+
+ private TelephonyNetworkFinder(List<TelephonyNetwork> networksList,
+ Map<MccMnc, TelephonyNetwork> networksMap) {
+ this.networksList = networksList;
+ this.networksMap = networksMap;
+ }
+
+ @libcore.api.CorePlatformApi
+ public TelephonyNetwork findNetworkByMccMnc(String mcc, String mnc) {
+ return networksMap.get(new MccMnc(mcc, mnc));
+ }
+
+ // @VisibleForTesting
+ public List<TelephonyNetwork> getAll() {
+ return networksList;
+ }
+}
diff --git a/luni/src/main/java/libcore/timezone/TimeZoneDataFiles.java b/luni/src/main/java/libcore/timezone/TimeZoneDataFiles.java
index d95ff50..b4c8976 100644
--- a/luni/src/main/java/libcore/timezone/TimeZoneDataFiles.java
+++ b/luni/src/main/java/libcore/timezone/TimeZoneDataFiles.java
@@ -55,6 +55,7 @@
return System.getenv(ANDROID_DATA_ENV) + "/misc/zoneinfo/";
}
+ // Remove from CorePlatformApi when all users in platform code are removed. http://b/123398797
@libcore.api.CorePlatformApi
public static String getDataTimeZoneFile(String fileName) {
return getDataTimeZoneRootDir() + "current/" + fileName;
diff --git a/luni/src/main/java/libcore/timezone/TimeZoneFinder.java b/luni/src/main/java/libcore/timezone/TimeZoneFinder.java
index d9e92bd..3f18e36 100644
--- a/luni/src/main/java/libcore/timezone/TimeZoneFinder.java
+++ b/luni/src/main/java/libcore/timezone/TimeZoneFinder.java
@@ -16,28 +16,31 @@
package libcore.timezone;
+import static libcore.timezone.XmlUtils.checkOnEndTag;
+import static libcore.timezone.XmlUtils.consumeText;
+import static libcore.timezone.XmlUtils.consumeUntilEndTag;
+import static libcore.timezone.XmlUtils.findNextStartTagOrEndTagNoRecurse;
+import static libcore.timezone.XmlUtils.findNextStartTagOrThrowNoRecurse;
+import static libcore.timezone.XmlUtils.normalizeCountryIso;
+import static libcore.timezone.XmlUtils.parseBooleanAttribute;
+import static libcore.timezone.XmlUtils.parseLongAttribute;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
-import java.io.StringReader;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
import libcore.timezone.CountryTimeZones.TimeZoneMapping;
+import libcore.timezone.XmlUtils.ReaderSupplier;
/**
* A class that can find matching time zones by loading data from the tzlookup.xml file.
@@ -74,9 +77,6 @@
private static final String ZONE_SHOW_IN_PICKER_ATTRIBUTE = "picker";
private static final String ZONE_NOT_USED_AFTER_ATTRIBUTE = "notafter";
- private static final String TRUE_ATTRIBUTE_VALUE = "y";
- private static final String FALSE_ATTRIBUTE_VALUE = "n";
-
private static TimeZoneFinder instance;
private final ReaderSupplier xmlSource;
@@ -261,7 +261,7 @@
* </timezones>
*/
- findRequiredStartTag(parser, TIMEZONES_ELEMENT);
+ findNextStartTagOrThrowNoRecurse(parser, TIMEZONES_ELEMENT);
// We do not require the ianaversion attribute be present. It is metadata that helps
// with versioning but is not required.
@@ -273,7 +273,7 @@
// There is only one expected sub-element <countryzones> in the format currently, skip
// over anything before it.
- findRequiredStartTag(parser, COUNTRY_ZONES_ELEMENT);
+ findNextStartTagOrThrowNoRecurse(parser, COUNTRY_ZONES_ELEMENT);
if (processCountryZones(parser, processor) == TimeZonesProcessor.HALT) {
return;
@@ -298,43 +298,39 @@
TimeZonesProcessor processor) throws IOException, XmlPullParserException {
// Skip over any unexpected elements and process <country> elements.
- while (findOptionalStartTag(parser, COUNTRY_ELEMENT)) {
- if (processor == null) {
- consumeUntilEndTag(parser, COUNTRY_ELEMENT);
- } else {
- String code = parser.getAttributeValue(
- null /* namespace */, COUNTRY_CODE_ATTRIBUTE);
- if (code == null || code.isEmpty()) {
- throw new XmlPullParserException(
- "Unable to find country code: " + parser.getPositionDescription());
- }
+ while (findNextStartTagOrEndTagNoRecurse(parser, COUNTRY_ELEMENT)) {
+ String code = parser.getAttributeValue(
+ null /* namespace */, COUNTRY_CODE_ATTRIBUTE);
+ if (code == null || code.isEmpty()) {
+ throw new XmlPullParserException(
+ "Unable to find country code: " + parser.getPositionDescription());
+ }
- String defaultTimeZoneId = parser.getAttributeValue(
- null /* namespace */, DEFAULT_TIME_ZONE_ID_ATTRIBUTE);
- if (defaultTimeZoneId == null || defaultTimeZoneId.isEmpty()) {
- throw new XmlPullParserException("Unable to find default time zone ID: "
- + parser.getPositionDescription());
- }
+ String defaultTimeZoneId = parser.getAttributeValue(
+ null /* namespace */, DEFAULT_TIME_ZONE_ID_ATTRIBUTE);
+ if (defaultTimeZoneId == null || defaultTimeZoneId.isEmpty()) {
+ throw new XmlPullParserException("Unable to find default time zone ID: "
+ + parser.getPositionDescription());
+ }
- boolean defaultTimeZoneBoost = parseBooleanAttribute(parser,
- DEFAULT_TIME_ZONE_BOOST_ATTRIBUTE, false);
+ boolean defaultTimeZoneBoost = parseBooleanAttribute(parser,
+ DEFAULT_TIME_ZONE_BOOST_ATTRIBUTE, false);
- Boolean everUsesUtc = parseBooleanAttribute(
- parser, EVER_USES_UTC_ATTRIBUTE, null /* defaultValue */);
- if (everUsesUtc == null) {
- // There is no valid default: we require this to be specified.
- throw new XmlPullParserException(
- "Unable to find UTC hint attribute (" + EVER_USES_UTC_ATTRIBUTE + "): "
- + parser.getPositionDescription());
- }
+ Boolean everUsesUtc = parseBooleanAttribute(
+ parser, EVER_USES_UTC_ATTRIBUTE, null /* defaultValue */);
+ if (everUsesUtc == null) {
+ // There is no valid default: we require this to be specified.
+ throw new XmlPullParserException(
+ "Unable to find UTC hint attribute (" + EVER_USES_UTC_ATTRIBUTE + "): "
+ + parser.getPositionDescription());
+ }
- String debugInfo = parser.getPositionDescription();
- List<TimeZoneMapping> timeZoneMappings = parseTimeZoneMappings(parser);
- boolean result = processor.processCountryZones(code, defaultTimeZoneId,
- defaultTimeZoneBoost, everUsesUtc, timeZoneMappings, debugInfo);
- if (result == TimeZonesProcessor.HALT) {
- return TimeZonesProcessor.HALT;
- }
+ String debugInfo = parser.getPositionDescription();
+ List<TimeZoneMapping> timeZoneMappings = parseTimeZoneMappings(parser);
+ boolean result = processor.processCountryZones(code, defaultTimeZoneId,
+ defaultTimeZoneBoost, everUsesUtc, timeZoneMappings, debugInfo);
+ if (result == TimeZonesProcessor.HALT) {
+ return TimeZonesProcessor.HALT;
}
// Make sure we are on the </country> element.
@@ -349,7 +345,7 @@
List<TimeZoneMapping> timeZoneMappings = new ArrayList<>();
// Skip over any unexpected elements and process <id> elements.
- while (findOptionalStartTag(parser, ZONE_ID_ELEMENT)) {
+ while (findNextStartTagOrEndTagNoRecurse(parser, ZONE_ID_ELEMENT)) {
// The picker attribute is optional and defaulted to true.
boolean showInPicker = parseBooleanAttribute(
parser, ZONE_SHOW_IN_PICKER_ATTRIBUTE, true /* defaultValue */);
@@ -376,177 +372,6 @@
}
/**
- * Parses an attribute value, which must be either {@code null} or a valid signed long value.
- * If the attribute value is {@code null} then {@code defaultValue} is returned. If the
- * attribute is present but not a valid long value then an XmlPullParserException is thrown.
- */
- private static Long parseLongAttribute(XmlPullParser parser, String attributeName,
- Long defaultValue) throws XmlPullParserException {
- String attributeValueString = parser.getAttributeValue(null /* namespace */, attributeName);
- if (attributeValueString == null) {
- return defaultValue;
- }
- try {
- return Long.parseLong(attributeValueString);
- } catch (NumberFormatException e) {
- throw new XmlPullParserException("Attribute \"" + attributeName
- + "\" is not a long value: " + parser.getPositionDescription());
- }
- }
-
- /**
- * Parses an attribute value, which must be either {@code null}, {@code "y"} or {@code "n"}.
- * If the attribute value is {@code null} then {@code defaultValue} is returned. If the
- * attribute is present but not "y" or "n" then an XmlPullParserException is thrown.
- */
- private static Boolean parseBooleanAttribute(XmlPullParser parser,
- String attributeName, Boolean defaultValue) throws XmlPullParserException {
- String attributeValueString = parser.getAttributeValue(null /* namespace */, attributeName);
- if (attributeValueString == null) {
- return defaultValue;
- }
- boolean isTrue = TRUE_ATTRIBUTE_VALUE.equals(attributeValueString);
- if (!(isTrue || FALSE_ATTRIBUTE_VALUE.equals(attributeValueString))) {
- throw new XmlPullParserException("Attribute \"" + attributeName
- + "\" is not \"y\" or \"n\": " + parser.getPositionDescription());
- }
- return isTrue;
- }
-
- private static void findRequiredStartTag(XmlPullParser parser, String elementName)
- throws IOException, XmlPullParserException {
- findStartTag(parser, elementName, true /* elementRequired */);
- }
-
- /** Called when on a START_TAG. When returning false, it leaves the parser on the END_TAG. */
- private static boolean findOptionalStartTag(XmlPullParser parser, String elementName)
- throws IOException, XmlPullParserException {
- return findStartTag(parser, elementName, false /* elementRequired */);
- }
-
- /**
- * Find a START_TAG with the specified name without decreasing the depth, or increasing the
- * depth by more than one. More deeply nested elements and text are skipped, even START_TAGs
- * with matching names. Returns when the START_TAG is found or the next (non-nested) END_TAG is
- * encountered. The return can take the form of an exception or a false if the START_TAG is not
- * found. True is returned when it is.
- */
- private static boolean findStartTag(
- XmlPullParser parser, String elementName, boolean elementRequired)
- throws IOException, XmlPullParserException {
-
- int type;
- while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
- switch (type) {
- case XmlPullParser.START_TAG:
- String currentElementName = parser.getName();
- if (elementName.equals(currentElementName)) {
- return true;
- }
-
- // It was not the START_TAG we were looking for. Consume until the end.
- parser.next();
- consumeUntilEndTag(parser, currentElementName);
- break;
- case XmlPullParser.END_TAG:
- if (elementRequired) {
- throw new XmlPullParserException(
- "No child element found with name " + elementName);
- }
- return false;
- default:
- // Ignore.
- break;
- }
- }
- throw new XmlPullParserException("Unexpected end of document while looking for "
- + elementName);
- }
-
- /**
- * Consume the remaining contents of an element and move to the END_TAG. Used when processing
- * within an element can stop. The parser must be pointing at either the END_TAG we are looking
- * for, a TEXT, or a START_TAG nested within the element to be consumed.
- */
- private static void consumeUntilEndTag(XmlPullParser parser, String elementName)
- throws IOException, XmlPullParserException {
-
- if (parser.getEventType() == XmlPullParser.END_TAG
- && elementName.equals(parser.getName())) {
- // Early return - we are already there.
- return;
- }
-
- // Keep track of the required depth in case there are nested elements to be consumed.
- // Both the name and the depth must match our expectation to complete.
-
- int requiredDepth = parser.getDepth();
- // A TEXT tag would be at the same depth as the END_TAG we are looking for.
- if (parser.getEventType() == XmlPullParser.START_TAG) {
- // A START_TAG would have incremented the depth, so we're looking for an END_TAG one
- // higher than the current tag.
- requiredDepth--;
- }
-
- while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
- int type = parser.next();
-
- int currentDepth = parser.getDepth();
- if (currentDepth < requiredDepth) {
- throw new XmlPullParserException(
- "Unexpected depth while looking for end tag: "
- + parser.getPositionDescription());
- } else if (currentDepth == requiredDepth) {
- if (type == XmlPullParser.END_TAG) {
- if (elementName.equals(parser.getName())) {
- return;
- }
- throw new XmlPullParserException(
- "Unexpected eng tag: " + parser.getPositionDescription());
- }
- }
- // Everything else is either a type we are not interested in or is too deep and so is
- // ignored.
- }
- throw new XmlPullParserException("Unexpected end of document");
- }
-
- /**
- * Reads the text inside the current element. Should be called when the parser is currently
- * on the START_TAG before the TEXT. The parser will be positioned on the END_TAG after this
- * call when it completes successfully.
- */
- private static String consumeText(XmlPullParser parser)
- throws IOException, XmlPullParserException {
-
- int type = parser.next();
- String text;
- if (type == XmlPullParser.TEXT) {
- text = parser.getText();
- } else {
- throw new XmlPullParserException("Text not found. Found type=" + type
- + " at " + parser.getPositionDescription());
- }
-
- type = parser.next();
- if (type != XmlPullParser.END_TAG) {
- throw new XmlPullParserException(
- "Unexpected nested tag or end of document when expecting text: type=" + type
- + " at " + parser.getPositionDescription());
- }
- return text;
- }
-
- private static void checkOnEndTag(XmlPullParser parser, String elementName)
- throws XmlPullParserException {
- if (!(parser.getEventType() == XmlPullParser.END_TAG
- && parser.getName().equals(elementName))) {
- throw new XmlPullParserException(
- "Unexpected tag encountered: " + parser.getPositionDescription());
- }
- }
-
- /**
* Processes <timezones> data.
*/
private interface TimeZonesProcessor {
@@ -701,32 +526,4 @@
}
}
- /**
- * A source of Readers that can be used repeatedly.
- */
- private interface ReaderSupplier {
- /** Returns a Reader. Throws an IOException if the Reader cannot be created. */
- Reader get() throws IOException;
-
- static ReaderSupplier forFile(String fileName, Charset charSet) throws IOException {
- Path file = Paths.get(fileName);
- if (!Files.exists(file)) {
- throw new FileNotFoundException(fileName + " does not exist");
- }
- if (!Files.isRegularFile(file) && Files.isReadable(file)) {
- throw new IOException(fileName + " must be a regular readable file.");
- }
- return () -> Files.newBufferedReader(file, charSet);
- }
-
- static ReaderSupplier forString(String xml) {
- return () -> new StringReader(xml);
- }
- }
-
- static String normalizeCountryIso(String countryIso) {
- // Lowercase ASCII is normalized for the purposes of the input files and the code in this
- // class and related classes.
- return countryIso.toLowerCase(Locale.US);
- }
}
diff --git a/luni/src/main/java/libcore/timezone/TzDataSetVersion.java b/luni/src/main/java/libcore/timezone/TzDataSetVersion.java
index c2e7d7b..8b97069b 100644
--- a/luni/src/main/java/libcore/timezone/TzDataSetVersion.java
+++ b/luni/src/main/java/libcore/timezone/TzDataSetVersion.java
@@ -29,7 +29,7 @@
* @hide
*/
@libcore.api.CorePlatformApi
-public class TzDataSetVersion {
+public final class TzDataSetVersion {
// Remove from CorePlatformApi when all users in platform code are removed. http://b/123398797
/**
@@ -102,14 +102,10 @@
+ REVISION_PATTERN.pattern()
+ ".*" /* ignore trailing */);
- public final int formatMajorVersion;
- public final int formatMinorVersion;
-
- // Remove from CorePlatformApi when all users in platform code are removed. http://b/123398797
- @libcore.api.CorePlatformApi
- public final String rulesVersion;
-
- public final int revision;
+ private final int formatMajorVersion;
+ private final int formatMinorVersion;
+ private final String rulesVersion;
+ private final int revision;
@libcore.api.CorePlatformApi
public TzDataSetVersion(int formatMajorVersion, int formatMinorVersion, String rulesVersion,
@@ -155,6 +151,38 @@
return fromBytes(versionBytes);
}
+ /**
+ * Reads the version of time zone data supplied by the time zone data module.
+ */
+ @libcore.api.CorePlatformApi
+ public static TzDataSetVersion readTimeZoneModuleVersion()
+ throws IOException, TzDataSetException {
+ String tzVersionFileName =
+ TimeZoneDataFiles.getTimeZoneModuleTzFile(TzDataSetVersion.DEFAULT_FILE_NAME);
+ return readFromFile(new File(tzVersionFileName));
+ }
+
+ @libcore.api.CorePlatformApi
+ public int getFormatMajorVersion() {
+ return formatMajorVersion;
+ }
+
+ @libcore.api.CorePlatformApi
+ public int getFormatMinorVersion() {
+ return formatMinorVersion;
+ }
+
+ @libcore.api.CorePlatformApi
+ public String getRulesVersion() {
+ return rulesVersion;
+ }
+
+ // Remove from CorePlatformApi when all users in platform code are removed. http://b/123398797
+ @libcore.api.CorePlatformApi
+ public int getRevision() {
+ return revision;
+ }
+
// Remove from CorePlatformApi when all users in platform code are removed. http://b/123398797
@libcore.api.CorePlatformApi
public byte[] toBytes() {
diff --git a/luni/src/main/java/libcore/timezone/XmlUtils.java b/luni/src/main/java/libcore/timezone/XmlUtils.java
new file mode 100644
index 0000000..a9616f9
--- /dev/null
+++ b/luni/src/main/java/libcore/timezone/XmlUtils.java
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.timezone;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Locale;
+
+class XmlUtils {
+
+ private static final String TRUE_ATTRIBUTE_VALUE = "y";
+
+ private static final String FALSE_ATTRIBUTE_VALUE = "n";
+
+ private XmlUtils() {}
+
+ /**
+ * Parses an attribute value, which must be either {@code null} or a valid signed long value.
+ * If the attribute value is {@code null} then {@code defaultValue} is returned. If the
+ * attribute is present but not a valid long value then an XmlPullParserException is thrown.
+ */
+ static Long parseLongAttribute(XmlPullParser parser, String attributeName,
+ Long defaultValue) throws XmlPullParserException {
+ String attributeValueString = parser.getAttributeValue(null /* namespace */, attributeName);
+ if (attributeValueString == null) {
+ return defaultValue;
+ }
+ try {
+ return Long.parseLong(attributeValueString);
+ } catch (NumberFormatException e) {
+ throw new XmlPullParserException("Attribute \"" + attributeName
+ + "\" is not a long value: " + parser.getPositionDescription());
+ }
+ }
+
+ /**
+ * Parses an attribute value, which must be either {@code null}, {@code "y"} or {@code "n"}.
+ * If the attribute value is {@code null} then {@code defaultValue} is returned. If the
+ * attribute is present but not "y" or "n" then an XmlPullParserException is thrown.
+ */
+ static Boolean parseBooleanAttribute(XmlPullParser parser,
+ String attributeName, Boolean defaultValue) throws XmlPullParserException {
+ String attributeValueString = parser.getAttributeValue(null /* namespace */, attributeName);
+ if (attributeValueString == null) {
+ return defaultValue;
+ }
+ boolean isTrue = TRUE_ATTRIBUTE_VALUE.equals(attributeValueString);
+ if (!(isTrue || FALSE_ATTRIBUTE_VALUE.equals(attributeValueString))) {
+ throw new XmlPullParserException("Attribute \"" + attributeName
+ + "\" is not \"y\" or \"n\": " + parser.getPositionDescription());
+ }
+ return isTrue;
+ }
+
+ /**
+ * Advances the the parser to the START_TAG for the specified element without decreasing the
+ * depth, or increasing the depth by more than one (i.e. no recursion into child nodes).
+ * If the next (non-nested) END_TAG an exception is thrown. Throws an exception if the end of
+ * the document is encountered unexpectedly.
+ */
+ static void findNextStartTagOrThrowNoRecurse(XmlPullParser parser, String elementName)
+ throws IOException, XmlPullParserException {
+ if (!findNextStartTagOrEndTagNoRecurse(parser, elementName)) {
+ throw new XmlPullParserException("No next element found with name " + elementName);
+ }
+ }
+
+ /**
+ * Advances the the parser to the START_TAG for the specified element without decreasing the
+ * depth, or increasing the depth by more than one (i.e. no recursion into child nodes).
+ * Returns {@code true} if the requested START_TAG is found, or {@code false} when the next
+ * (non-nested) END_TAG is encountered instead. Throws an exception if the end of the document
+ * is encountered unexpectedly.
+ */
+ static boolean findNextStartTagOrEndTagNoRecurse(XmlPullParser parser, String elementName)
+ throws IOException, XmlPullParserException {
+ int type;
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
+ switch (type) {
+ case XmlPullParser.START_TAG:
+ String currentElementName = parser.getName();
+ if (elementName.equals(currentElementName)) {
+ return true;
+ }
+
+ // It was not the START_TAG we were looking for. Consume until the end.
+ parser.next();
+ consumeUntilEndTag(parser, currentElementName);
+ break;
+ case XmlPullParser.END_TAG:
+ return false;
+ default:
+ // Ignore.
+ break;
+ }
+ }
+ throw new XmlPullParserException("Unexpected end of document while looking for "
+ + elementName);
+ }
+
+ /**
+ * Consume any remaining contents of an element and move to the END_TAG. Used when processing
+ * within an element can stop.
+ *
+ * <p>When called, the parser must be pointing at one of:
+ * <ul>
+ * <li>the END_TAG we are looking for</li>
+ * <li>a TEXT</li>
+ * <li>a START_TAG nested within the element that can be consumed</li>
+ * </ul>
+ * Note: The parser synthesizes an END_TAG for self-closing tags so this works for them too.
+ */
+ static void consumeUntilEndTag(XmlPullParser parser, String elementName)
+ throws IOException, XmlPullParserException {
+
+ if (isEndTag(parser, elementName)) {
+ // Early return - we are already there.
+ return;
+ }
+
+ // Keep track of the required depth in case there are nested elements to be consumed.
+ // Both the name and the depth must match our expectation to complete.
+
+ int requiredDepth = parser.getDepth();
+ // A TEXT tag would be at the same depth as the END_TAG we are looking for.
+ if (parser.getEventType() == XmlPullParser.START_TAG) {
+ // A START_TAG would have incremented the depth, so we're looking for an END_TAG one
+ // higher than the current tag.
+ requiredDepth--;
+ }
+
+ while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
+ int type = parser.next();
+
+ int currentDepth = parser.getDepth();
+ if (currentDepth < requiredDepth) {
+ throw new XmlPullParserException(
+ "Unexpected depth while looking for end tag: "
+ + parser.getPositionDescription());
+ } else if (currentDepth == requiredDepth) {
+ if (type == XmlPullParser.END_TAG) {
+ if (elementName.equals(parser.getName())) {
+ return;
+ }
+ throw new XmlPullParserException(
+ "Unexpected eng tag: " + parser.getPositionDescription());
+ }
+ }
+ // Everything else is either a type we are not interested in or is too deep and so is
+ // ignored.
+ }
+ throw new XmlPullParserException("Unexpected end of document");
+ }
+
+ /**
+ * Throws an exception if the current element is not an end tag.
+ * Note: The parser synthesizes an END_TAG for self-closing tags so this works for them too.
+ */
+ static void checkOnEndTag(XmlPullParser parser, String elementName)
+ throws XmlPullParserException {
+ if (!isEndTag(parser, elementName)) {
+ throw new XmlPullParserException(
+ "Unexpected tag encountered: " + parser.getPositionDescription());
+ }
+ }
+
+ /**
+ * Returns true if the current tag is an end tag.
+ * Note: The parser synthesizes an END_TAG for self-closing tags so this works for them too.
+ */
+ private static boolean isEndTag(XmlPullParser parser, String elementName)
+ throws XmlPullParserException {
+ return parser.getEventType() == XmlPullParser.END_TAG
+ && parser.getName().equals(elementName);
+ }
+
+ static String normalizeCountryIso(String countryIso) {
+ // Lowercase ASCII is normalized for the purposes of the input files and the code in this
+ // class and related classes.
+ return countryIso.toLowerCase(Locale.US);
+ }
+
+ /**
+ * Reads the text inside the current element. Should be called when the parser is currently
+ * on the START_TAG before the TEXT. The parser will be positioned on the END_TAG after this
+ * call when it completes successfully.
+ */
+ static String consumeText(XmlPullParser parser)
+ throws IOException, XmlPullParserException {
+
+ int type = parser.next();
+ String text;
+ if (type == XmlPullParser.TEXT) {
+ text = parser.getText();
+ } else {
+ throw new XmlPullParserException("Text not found. Found type=" + type
+ + " at " + parser.getPositionDescription());
+ }
+
+ type = parser.next();
+ if (type != XmlPullParser.END_TAG) {
+ throw new XmlPullParserException(
+ "Unexpected nested tag or end of document when expecting text: type=" + type
+ + " at " + parser.getPositionDescription());
+ }
+ return text;
+ }
+
+ /**
+ * A source of Readers that can be used repeatedly.
+ */
+ interface ReaderSupplier {
+ /** Returns a Reader. Throws an IOException if the Reader cannot be created. */
+ Reader get() throws IOException;
+
+ static ReaderSupplier forFile(String fileName, Charset charSet) throws IOException {
+ Path file = Paths.get(fileName);
+ if (!Files.exists(file)) {
+ throw new FileNotFoundException(fileName + " does not exist");
+ }
+ if (!Files.isRegularFile(file) && Files.isReadable(file)) {
+ throw new IOException(fileName + " must be a regular readable file.");
+ }
+ return () -> Files.newBufferedReader(file, charSet);
+ }
+
+ static ReaderSupplier forString(String xml) {
+ return () -> new StringReader(xml);
+ }
+ }
+}
diff --git a/luni/src/main/java/libcore/timezone/ZoneInfoDB.java b/luni/src/main/java/libcore/timezone/ZoneInfoDB.java
deleted file mode 100644
index 3e2e60e..0000000
--- a/luni/src/main/java/libcore/timezone/ZoneInfoDB.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 libcore.timezone;
-
-import android.system.ErrnoException;
-import dalvik.annotation.optimization.ReachabilitySensitive;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import libcore.io.BufferIterator;
-import libcore.io.MemoryMappedFile;
-import libcore.util.BasicLruCache;
-import libcore.util.ZoneInfo;
-
-/**
- * A class used to initialize the time zone database. This implementation uses the
- * Olson tzdata as the source of time zone information. However, to conserve
- * disk space (inodes) and reduce I/O, all the data is concatenated into a single file,
- * with an index to indicate the starting position of each time zone record.
- *
- * @hide - used to implement TimeZone
- */
-@libcore.api.CorePlatformApi
-public final class ZoneInfoDB {
-
- // VisibleForTesting
- public static final String TZDATA_FILE_NAME = "tzdata";
-
- private static final TzData DATA =
- TzData.loadTzDataWithFallback(TimeZoneDataFiles.getTimeZoneFilePaths(TZDATA_FILE_NAME));
-
- /** @hide */
- @libcore.api.CorePlatformApi
- public static class TzData implements AutoCloseable {
-
- // The database reserves 40 bytes for each id.
- private static final int SIZEOF_TZNAME = 40;
-
- // The database uses 32-bit (4 byte) integers.
- private static final int SIZEOF_TZINT = 4;
-
- // Each index entry takes up this number of bytes.
- public static final int SIZEOF_INDEX_ENTRY = SIZEOF_TZNAME + 3 * SIZEOF_TZINT;
-
- /**
- * {@code true} if {@link #close()} has been called meaning the instance cannot provide any
- * data.
- */
- private boolean closed;
-
- /**
- * Rather than open, read, and close the big data file each time we look up a time zone,
- * we map the big data file during startup, and then just use the MemoryMappedFile.
- *
- * At the moment, this "big" data file is about 500 KiB. At some point, that will be small
- * enough that we could just keep the byte[] in memory, but using mmap(2) like this has the
- * nice property that even if someone replaces the file under us (because multiple gservices
- * updates have gone out, say), we still get a consistent (if outdated) view of the world.
- */
- // Android-added: @ReachabilitySensitive
- @ReachabilitySensitive
- private MemoryMappedFile mappedFile;
-
- private String version;
- private String zoneTab;
-
- /**
- * The 'ids' array contains time zone ids sorted alphabetically, for binary searching.
- * The other two arrays are in the same order. 'byteOffsets' gives the byte offset
- * of each time zone, and 'rawUtcOffsetsCache' gives the time zone's raw UTC offset.
- */
- private String[] ids;
- private int[] byteOffsets;
- private int[] rawUtcOffsetsCache; // Access this via getRawUtcOffsets instead.
-
- /**
- * ZoneInfo objects are worth caching because they are expensive to create.
- * See http://b/8270865 for context.
- */
- private final static int CACHE_SIZE = 1;
- private final BasicLruCache<String, ZoneInfo> cache =
- new BasicLruCache<String, ZoneInfo>(CACHE_SIZE) {
- @Override
- protected ZoneInfo create(String id) {
- try {
- return makeTimeZoneUncached(id);
- } catch (IOException e) {
- throw new IllegalStateException("Unable to load timezone for ID=" + id, e);
- }
- }
- };
-
- /**
- * Loads the data at the specified paths in order, returning the first valid one as a
- * {@link TzData} object. If there is no valid one found a basic fallback instance is created
- * containing just GMT.
- */
- public static TzData loadTzDataWithFallback(String... paths) {
- for (String path : paths) {
- TzData tzData = new TzData();
- if (tzData.loadData(path)) {
- return tzData;
- }
- }
-
- // We didn't find any usable tzdata on disk, so let's just hard-code knowledge of "GMT".
- // This is actually implemented in TimeZone itself, so if this is the only time zone
- // we report, we won't be asked any more questions.
- System.logE("Couldn't find any " + TZDATA_FILE_NAME + " file!");
- return TzData.createFallback();
- }
-
- /**
- * Loads the data at the specified path and returns the {@link TzData} object if it is valid,
- * otherwise {@code null}.
- */
- @libcore.api.CorePlatformApi
- public static TzData loadTzData(String path) {
- TzData tzData = new TzData();
- if (tzData.loadData(path)) {
- return tzData;
- }
- return null;
- }
-
- private static TzData createFallback() {
- TzData tzData = new TzData();
- tzData.populateFallback();
- return tzData;
- }
-
- private TzData() {
- }
-
- /**
- * Visible for testing.
- */
- public BufferIterator getBufferIterator(String id) {
- checkNotClosed();
-
- // Work out where in the big data file this time zone is.
- int index = Arrays.binarySearch(ids, id);
- if (index < 0) {
- return null;
- }
-
- int byteOffset = byteOffsets[index];
- BufferIterator it = mappedFile.bigEndianIterator();
- it.skip(byteOffset);
- return it;
- }
-
- private void populateFallback() {
- version = "missing";
- zoneTab = "# Emergency fallback data.\n";
- ids = new String[] { "GMT" };
- byteOffsets = rawUtcOffsetsCache = new int[1];
- }
-
- /**
- * Loads the data file at the specified path. If the data is valid {@code true} will be
- * returned and the {@link TzData} instance can be used. If {@code false} is returned then the
- * TzData instance is left in a closed state and must be discarded.
- */
- private boolean loadData(String path) {
- try {
- mappedFile = MemoryMappedFile.mmapRO(path);
- } catch (ErrnoException errnoException) {
- return false;
- }
- try {
- readHeader();
- return true;
- } catch (Exception ex) {
- close();
-
- // Something's wrong with the file.
- // Log the problem and return false so we try the next choice.
- System.logE(TZDATA_FILE_NAME + " file \"" + path + "\" was present but invalid!", ex);
- return false;
- }
- }
-
- private void readHeader() throws IOException {
- // byte[12] tzdata_version -- "tzdata2012f\0"
- // int index_offset
- // int data_offset
- // int zonetab_offset
- BufferIterator it = mappedFile.bigEndianIterator();
-
- try {
- byte[] tzdata_version = new byte[12];
- it.readByteArray(tzdata_version, 0, tzdata_version.length);
- String magic = new String(tzdata_version, 0, 6, StandardCharsets.US_ASCII);
- if (!magic.equals("tzdata") || tzdata_version[11] != 0) {
- throw new IOException("bad tzdata magic: " + Arrays.toString(tzdata_version));
- }
- version = new String(tzdata_version, 6, 5, StandardCharsets.US_ASCII);
-
- final int fileSize = mappedFile.size();
- int index_offset = it.readInt();
- validateOffset(index_offset, fileSize);
- int data_offset = it.readInt();
- validateOffset(data_offset, fileSize);
- int zonetab_offset = it.readInt();
- validateOffset(zonetab_offset, fileSize);
-
- if (index_offset >= data_offset || data_offset >= zonetab_offset) {
- throw new IOException("Invalid offset: index_offset=" + index_offset
- + ", data_offset=" + data_offset + ", zonetab_offset=" + zonetab_offset
- + ", fileSize=" + fileSize);
- }
-
- readIndex(it, index_offset, data_offset);
- readZoneTab(it, zonetab_offset, fileSize - zonetab_offset);
- } catch (IndexOutOfBoundsException e) {
- throw new IOException("Invalid read from data file", e);
- }
- }
-
- private static void validateOffset(int offset, int size) throws IOException {
- if (offset < 0 || offset >= size) {
- throw new IOException("Invalid offset=" + offset + ", size=" + size);
- }
- }
-
- private void readZoneTab(BufferIterator it, int zoneTabOffset, int zoneTabSize) {
- byte[] bytes = new byte[zoneTabSize];
- it.seek(zoneTabOffset);
- it.readByteArray(bytes, 0, bytes.length);
- zoneTab = new String(bytes, 0, bytes.length, StandardCharsets.US_ASCII);
- }
-
- private void readIndex(BufferIterator it, int indexOffset, int dataOffset) throws IOException {
- it.seek(indexOffset);
-
- byte[] idBytes = new byte[SIZEOF_TZNAME];
- int indexSize = (dataOffset - indexOffset);
- if (indexSize % SIZEOF_INDEX_ENTRY != 0) {
- throw new IOException("Index size is not divisible by " + SIZEOF_INDEX_ENTRY
- + ", indexSize=" + indexSize);
- }
- int entryCount = indexSize / SIZEOF_INDEX_ENTRY;
-
- byteOffsets = new int[entryCount];
- ids = new String[entryCount];
-
- for (int i = 0; i < entryCount; i++) {
- // Read the fixed length timezone ID.
- it.readByteArray(idBytes, 0, idBytes.length);
-
- // Read the offset into the file where the data for ID can be found.
- byteOffsets[i] = it.readInt();
- byteOffsets[i] += dataOffset;
-
- int length = it.readInt();
- if (length < 44) {
- throw new IOException("length in index file < sizeof(tzhead)");
- }
- it.skip(4); // Skip the unused 4 bytes that used to be the raw offset.
-
- // Calculate the true length of the ID.
- int len = 0;
- while (idBytes[len] != 0 && len < idBytes.length) {
- len++;
- }
- if (len == 0) {
- throw new IOException("Invalid ID at index=" + i);
- }
- ids[i] = new String(idBytes, 0, len, StandardCharsets.US_ASCII);
- if (i > 0) {
- if (ids[i].compareTo(ids[i - 1]) <= 0) {
- throw new IOException("Index not sorted or contains multiple entries with the same ID"
- + ", index=" + i + ", ids[i]=" + ids[i] + ", ids[i - 1]=" + ids[i - 1]);
- }
- }
- }
- }
-
- @libcore.api.CorePlatformApi
- public void validate() throws IOException {
- checkNotClosed();
- // Validate the data in the tzdata file by loading each and every zone.
- for (String id : getAvailableIDs()) {
- ZoneInfo zoneInfo = makeTimeZoneUncached(id);
- if (zoneInfo == null) {
- throw new IOException("Unable to find data for ID=" + id);
- }
- }
- }
-
- ZoneInfo makeTimeZoneUncached(String id) throws IOException {
- BufferIterator it = getBufferIterator(id);
- if (it == null) {
- return null;
- }
-
- return ZoneInfo.readTimeZone(id, it, System.currentTimeMillis());
- }
-
- public String[] getAvailableIDs() {
- checkNotClosed();
- return ids.clone();
- }
-
- public String[] getAvailableIDs(int rawUtcOffset) {
- checkNotClosed();
- List<String> matches = new ArrayList<String>();
- int[] rawUtcOffsets = getRawUtcOffsets();
- for (int i = 0; i < rawUtcOffsets.length; ++i) {
- if (rawUtcOffsets[i] == rawUtcOffset) {
- matches.add(ids[i]);
- }
- }
- return matches.toArray(new String[matches.size()]);
- }
-
- private synchronized int[] getRawUtcOffsets() {
- if (rawUtcOffsetsCache != null) {
- return rawUtcOffsetsCache;
- }
- rawUtcOffsetsCache = new int[ids.length];
- for (int i = 0; i < ids.length; ++i) {
- // This creates a TimeZone, which is quite expensive. Hence the cache.
- // Note that icu4c does the same (without the cache), so if you're
- // switching this code over to icu4j you should check its performance.
- // Telephony shouldn't care, but someone converting a bunch of calendar
- // events might.
- rawUtcOffsetsCache[i] = cache.get(ids[i]).getRawOffset();
- }
- return rawUtcOffsetsCache;
- }
-
- @libcore.api.CorePlatformApi
- public String getVersion() {
- checkNotClosed();
- return version;
- }
-
- public String getZoneTab() {
- checkNotClosed();
- return zoneTab;
- }
-
- @libcore.api.CorePlatformApi
- public ZoneInfo makeTimeZone(String id) throws IOException {
- checkNotClosed();
- ZoneInfo zoneInfo = cache.get(id);
- // The object from the cache is cloned because TimeZone / ZoneInfo are mutable.
- return zoneInfo == null ? null : (ZoneInfo) zoneInfo.clone();
- }
-
- @libcore.api.CorePlatformApi
- public boolean hasTimeZone(String id) throws IOException {
- checkNotClosed();
- return cache.get(id) != null;
- }
-
- public void close() {
- if (!closed) {
- closed = true;
-
- // Clear state that takes up appreciable heap.
- ids = null;
- byteOffsets = null;
- rawUtcOffsetsCache = null;
- cache.evictAll();
-
- // Remove the mapped file (if needed).
- if (mappedFile != null) {
- try {
- mappedFile.close();
- } catch (ErrnoException ignored) {
- }
- mappedFile = null;
- }
- }
- }
-
- private void checkNotClosed() throws IllegalStateException {
- if (closed) {
- throw new IllegalStateException("TzData is closed");
- }
- }
-
- @Override protected void finalize() throws Throwable {
- try {
- close();
- } finally {
- super.finalize();
- }
- }
- }
-
- private ZoneInfoDB() {
- }
-
- @libcore.api.CorePlatformApi
- public static TzData getInstance() {
- return DATA;
- }
-}
diff --git a/luni/src/main/java/libcore/timezone/ZoneInfoDb.java b/luni/src/main/java/libcore/timezone/ZoneInfoDb.java
new file mode 100644
index 0000000..a94d293
--- /dev/null
+++ b/luni/src/main/java/libcore/timezone/ZoneInfoDb.java
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.timezone;
+
+import android.system.ErrnoException;
+import dalvik.annotation.optimization.ReachabilitySensitive;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import libcore.io.BufferIterator;
+import libcore.io.MemoryMappedFile;
+import libcore.util.BasicLruCache;
+import libcore.util.ZoneInfo;
+
+/**
+ * A class used to initialize the time zone database. This implementation uses the
+ * Olson tzdata as the source of time zone information. However, to conserve
+ * disk space (inodes) and reduce I/O, all the data is concatenated into a single file,
+ * with an index to indicate the starting position of each time zone record.
+ *
+ * @hide - used to implement TimeZone
+ */
+@libcore.api.CorePlatformApi
+public final class ZoneInfoDb implements AutoCloseable {
+
+ // VisibleForTesting
+ public static final String TZDATA_FILE_NAME = "tzdata";
+
+ private static final ZoneInfoDb DATA = ZoneInfoDb.loadTzDataWithFallback(
+ TimeZoneDataFiles.getTimeZoneFilePaths(TZDATA_FILE_NAME));
+
+ // The database reserves 40 bytes for each id.
+ private static final int SIZEOF_TZNAME = 40;
+
+ // The database uses 32-bit (4 byte) integers.
+ private static final int SIZEOF_TZINT = 4;
+
+ // Each index entry takes up this number of bytes.
+ public static final int SIZEOF_INDEX_ENTRY = SIZEOF_TZNAME + 3 * SIZEOF_TZINT;
+
+ /**
+ * {@code true} if {@link #close()} has been called meaning the instance cannot provide any
+ * data.
+ */
+ private boolean closed;
+
+ /**
+ * Rather than open, read, and close the big data file each time we look up a time zone,
+ * we map the big data file during startup, and then just use the MemoryMappedFile.
+ *
+ * At the moment, this "big" data file is about 500 KiB. At some point, that will be small
+ * enough that we could just keep the byte[] in memory, but using mmap(2) like this has the
+ * nice property that even if someone replaces the file under us (because multiple gservices
+ * updates have gone out, say), we still get a consistent (if outdated) view of the world.
+ */
+ // Android-added: @ReachabilitySensitive
+ @ReachabilitySensitive
+ private MemoryMappedFile mappedFile;
+
+ private String version;
+ private String zoneTab;
+
+ /**
+ * The 'ids' array contains time zone ids sorted alphabetically, for binary searching.
+ * The other two arrays are in the same order. 'byteOffsets' gives the byte offset
+ * of each time zone, and 'rawUtcOffsetsCache' gives the time zone's raw UTC offset.
+ */
+ private String[] ids;
+ private int[] byteOffsets;
+ private int[] rawUtcOffsetsCache; // Access this via getRawUtcOffsets instead.
+
+ /**
+ * ZoneInfo objects are worth caching because they are expensive to create.
+ * See http://b/8270865 for context.
+ */
+ private final static int CACHE_SIZE = 1;
+ private final BasicLruCache<String, ZoneInfo> cache =
+ new BasicLruCache<String, ZoneInfo>(CACHE_SIZE) {
+ @Override
+ protected ZoneInfo create(String id) {
+ try {
+ return makeTimeZoneUncached(id);
+ } catch (IOException e) {
+ throw new IllegalStateException("Unable to load timezone for ID=" + id, e);
+ }
+ }
+ };
+
+ @libcore.api.CorePlatformApi
+ public static ZoneInfoDb getInstance() {
+ return DATA;
+ }
+
+ /**
+ * Loads the data at the specified paths in order, returning the first valid one as a
+ * {@link ZoneInfoDb} object. If there is no valid one found a basic fallback instance is created
+ * containing just GMT.
+ */
+ public static ZoneInfoDb loadTzDataWithFallback(String... paths) {
+ for (String path : paths) {
+ ZoneInfoDb tzData = new ZoneInfoDb();
+ if (tzData.loadData(path)) {
+ return tzData;
+ }
+ }
+
+ // We didn't find any usable tzdata on disk, so let's just hard-code knowledge of "GMT".
+ // This is actually implemented in TimeZone itself, so if this is the only time zone
+ // we report, we won't be asked any more questions.
+ System.logE("Couldn't find any " + TZDATA_FILE_NAME + " file!");
+ return ZoneInfoDb.createFallback();
+ }
+
+ /**
+ * Loads the data at the specified path and returns the {@link ZoneInfoDb} object if it is valid,
+ * otherwise {@code null}.
+ */
+ @libcore.api.CorePlatformApi
+ public static ZoneInfoDb loadTzData(String path) {
+ ZoneInfoDb tzData = new ZoneInfoDb();
+ if (tzData.loadData(path)) {
+ return tzData;
+ }
+ return null;
+ }
+
+ private static ZoneInfoDb createFallback() {
+ ZoneInfoDb tzData = new ZoneInfoDb();
+ tzData.populateFallback();
+ return tzData;
+ }
+
+ private ZoneInfoDb() {
+ }
+
+ /**
+ * Visible for testing.
+ */
+ public BufferIterator getBufferIterator(String id) {
+ checkNotClosed();
+
+ // Work out where in the big data file this time zone is.
+ int index = Arrays.binarySearch(ids, id);
+ if (index < 0) {
+ return null;
+ }
+
+ int byteOffset = byteOffsets[index];
+ BufferIterator it = mappedFile.bigEndianIterator();
+ it.skip(byteOffset);
+ return it;
+ }
+
+ private void populateFallback() {
+ version = "missing";
+ zoneTab = "# Emergency fallback data.\n";
+ ids = new String[] { "GMT" };
+ byteOffsets = rawUtcOffsetsCache = new int[1];
+ }
+
+ /**
+ * Loads the data file at the specified path. If the data is valid {@code true} will be
+ * returned and the {@link ZoneInfoDb} instance can be used. If {@code false} is returned then the
+ * ZoneInfoDB instance is left in a closed state and must be discarded.
+ */
+ private boolean loadData(String path) {
+ try {
+ mappedFile = MemoryMappedFile.mmapRO(path);
+ } catch (ErrnoException errnoException) {
+ return false;
+ }
+ try {
+ readHeader();
+ return true;
+ } catch (Exception ex) {
+ close();
+
+ // Something's wrong with the file.
+ // Log the problem and return false so we try the next choice.
+ System.logE(TZDATA_FILE_NAME + " file \"" + path + "\" was present but invalid!", ex);
+ return false;
+ }
+ }
+
+ private void readHeader() throws IOException {
+ // byte[12] tzdata_version -- "tzdata2012f\0"
+ // int index_offset
+ // int data_offset
+ // int zonetab_offset
+ BufferIterator it = mappedFile.bigEndianIterator();
+
+ try {
+ byte[] tzdata_version = new byte[12];
+ it.readByteArray(tzdata_version, 0, tzdata_version.length);
+ String magic = new String(tzdata_version, 0, 6, StandardCharsets.US_ASCII);
+ if (!magic.equals("tzdata") || tzdata_version[11] != 0) {
+ throw new IOException("bad tzdata magic: " + Arrays.toString(tzdata_version));
+ }
+ version = new String(tzdata_version, 6, 5, StandardCharsets.US_ASCII);
+
+ final int fileSize = mappedFile.size();
+ int index_offset = it.readInt();
+ validateOffset(index_offset, fileSize);
+ int data_offset = it.readInt();
+ validateOffset(data_offset, fileSize);
+ int zonetab_offset = it.readInt();
+ validateOffset(zonetab_offset, fileSize);
+
+ if (index_offset >= data_offset || data_offset >= zonetab_offset) {
+ throw new IOException("Invalid offset: index_offset=" + index_offset
+ + ", data_offset=" + data_offset + ", zonetab_offset=" + zonetab_offset
+ + ", fileSize=" + fileSize);
+ }
+
+ readIndex(it, index_offset, data_offset);
+ readZoneTab(it, zonetab_offset, fileSize - zonetab_offset);
+ } catch (IndexOutOfBoundsException e) {
+ throw new IOException("Invalid read from data file", e);
+ }
+ }
+
+ private static void validateOffset(int offset, int size) throws IOException {
+ if (offset < 0 || offset >= size) {
+ throw new IOException("Invalid offset=" + offset + ", size=" + size);
+ }
+ }
+
+ private void readZoneTab(BufferIterator it, int zoneTabOffset, int zoneTabSize) {
+ byte[] bytes = new byte[zoneTabSize];
+ it.seek(zoneTabOffset);
+ it.readByteArray(bytes, 0, bytes.length);
+ zoneTab = new String(bytes, 0, bytes.length, StandardCharsets.US_ASCII);
+ }
+
+ private void readIndex(BufferIterator it, int indexOffset, int dataOffset) throws IOException {
+ it.seek(indexOffset);
+
+ byte[] idBytes = new byte[SIZEOF_TZNAME];
+ int indexSize = (dataOffset - indexOffset);
+ if (indexSize % SIZEOF_INDEX_ENTRY != 0) {
+ throw new IOException("Index size is not divisible by " + SIZEOF_INDEX_ENTRY
+ + ", indexSize=" + indexSize);
+ }
+ int entryCount = indexSize / SIZEOF_INDEX_ENTRY;
+
+ byteOffsets = new int[entryCount];
+ ids = new String[entryCount];
+
+ for (int i = 0; i < entryCount; i++) {
+ // Read the fixed length timezone ID.
+ it.readByteArray(idBytes, 0, idBytes.length);
+
+ // Read the offset into the file where the data for ID can be found.
+ byteOffsets[i] = it.readInt();
+ byteOffsets[i] += dataOffset;
+
+ int length = it.readInt();
+ if (length < 44) {
+ throw new IOException("length in index file < sizeof(tzhead)");
+ }
+ it.skip(4); // Skip the unused 4 bytes that used to be the raw offset.
+
+ // Calculate the true length of the ID.
+ int len = 0;
+ while (idBytes[len] != 0 && len < idBytes.length) {
+ len++;
+ }
+ if (len == 0) {
+ throw new IOException("Invalid ID at index=" + i);
+ }
+ ids[i] = new String(idBytes, 0, len, StandardCharsets.US_ASCII);
+ if (i > 0) {
+ if (ids[i].compareTo(ids[i - 1]) <= 0) {
+ throw new IOException("Index not sorted or contains multiple entries with the same ID"
+ + ", index=" + i + ", ids[i]=" + ids[i] + ", ids[i - 1]=" + ids[i - 1]);
+ }
+ }
+ }
+ }
+
+ @libcore.api.CorePlatformApi
+ public void validate() throws IOException {
+ checkNotClosed();
+ // Validate the data in the tzdata file by loading each and every zone.
+ for (String id : getAvailableIDs()) {
+ ZoneInfo zoneInfo = makeTimeZoneUncached(id);
+ if (zoneInfo == null) {
+ throw new IOException("Unable to find data for ID=" + id);
+ }
+ }
+ }
+
+ ZoneInfo makeTimeZoneUncached(String id) throws IOException {
+ BufferIterator it = getBufferIterator(id);
+ if (it == null) {
+ return null;
+ }
+
+ return ZoneInfo.readTimeZone(id, it, System.currentTimeMillis());
+ }
+
+ public String[] getAvailableIDs() {
+ checkNotClosed();
+ return ids.clone();
+ }
+
+ public String[] getAvailableIDs(int rawUtcOffset) {
+ checkNotClosed();
+ List<String> matches = new ArrayList<String>();
+ int[] rawUtcOffsets = getRawUtcOffsets();
+ for (int i = 0; i < rawUtcOffsets.length; ++i) {
+ if (rawUtcOffsets[i] == rawUtcOffset) {
+ matches.add(ids[i]);
+ }
+ }
+ return matches.toArray(new String[matches.size()]);
+ }
+
+ private synchronized int[] getRawUtcOffsets() {
+ if (rawUtcOffsetsCache != null) {
+ return rawUtcOffsetsCache;
+ }
+ rawUtcOffsetsCache = new int[ids.length];
+ for (int i = 0; i < ids.length; ++i) {
+ // This creates a TimeZone, which is quite expensive. Hence the cache.
+ // Note that icu4c does the same (without the cache), so if you're
+ // switching this code over to icu4j you should check its performance.
+ // Telephony shouldn't care, but someone converting a bunch of calendar
+ // events might.
+ rawUtcOffsetsCache[i] = cache.get(ids[i]).getRawOffset();
+ }
+ return rawUtcOffsetsCache;
+ }
+
+ @libcore.api.CorePlatformApi
+ public String getVersion() {
+ checkNotClosed();
+ return version;
+ }
+
+ public String getZoneTab() {
+ checkNotClosed();
+ return zoneTab;
+ }
+
+ @libcore.api.CorePlatformApi
+ public ZoneInfo makeTimeZone(String id) throws IOException {
+ checkNotClosed();
+ ZoneInfo zoneInfo = cache.get(id);
+ // The object from the cache is cloned because TimeZone / ZoneInfo are mutable.
+ return zoneInfo == null ? null : (ZoneInfo) zoneInfo.clone();
+ }
+
+ @libcore.api.CorePlatformApi
+ public boolean hasTimeZone(String id) throws IOException {
+ checkNotClosed();
+ return cache.get(id) != null;
+ }
+
+ public void close() {
+ if (!closed) {
+ closed = true;
+
+ // Clear state that takes up appreciable heap.
+ ids = null;
+ byteOffsets = null;
+ rawUtcOffsetsCache = null;
+ cache.evictAll();
+
+ // Remove the mapped file (if needed).
+ if (mappedFile != null) {
+ try {
+ mappedFile.close();
+ } catch (ErrnoException ignored) {
+ }
+ mappedFile = null;
+ }
+ }
+ }
+
+ private void checkNotClosed() throws IllegalStateException {
+ if (closed) {
+ throw new IllegalStateException("ZoneInfoDB instance is closed");
+ }
+ }
+
+ @Override protected void finalize() throws Throwable {
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
+ }
+}
diff --git a/luni/src/main/java/libcore/util/BasicLruCache.java b/luni/src/main/java/libcore/util/BasicLruCache.java
index 20a3bee..e3ddc64 100644
--- a/luni/src/main/java/libcore/util/BasicLruCache.java
+++ b/luni/src/main/java/libcore/util/BasicLruCache.java
@@ -16,7 +16,7 @@
package libcore.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.util.LinkedHashMap;
import java.util.Map;
diff --git a/luni/src/main/java/libcore/util/CoreLibraryDebug.java b/luni/src/main/java/libcore/util/CoreLibraryDebug.java
index 22b5745..0d6ee46 100644
--- a/luni/src/main/java/libcore/util/CoreLibraryDebug.java
+++ b/luni/src/main/java/libcore/util/CoreLibraryDebug.java
@@ -16,10 +16,12 @@
package libcore.util;
+import com.android.icu.util.Icu4cMetadata;
+
import libcore.timezone.TimeZoneDataFiles;
import libcore.timezone.TzDataSetVersion;
import libcore.timezone.TzDataSetVersion.TzDataSetException;
-import libcore.timezone.ZoneInfoDB;
+import libcore.timezone.ZoneInfoDb;
import java.io.File;
import java.io.IOException;
@@ -81,14 +83,14 @@
try {
TzDataSetVersion tzDataSetVersion =
TzDataSetVersion.readFromFile(file);
- String formatVersionString = tzDataSetVersion.formatMajorVersion + "."
- + tzDataSetVersion.formatMinorVersion;
+ String formatVersionString = tzDataSetVersion.getFormatMajorVersion() + "."
+ + tzDataSetVersion.getFormatMinorVersion();
debugInfo.addStringEntry(statusKey, "OK")
.addStringEntry(debugKeyPrefix + "formatVersion", formatVersionString)
.addStringEntry(debugKeyPrefix + "rulesVersion",
- tzDataSetVersion.rulesVersion)
+ tzDataSetVersion.getRulesVersion())
.addStringEntry(debugKeyPrefix + "revision",
- tzDataSetVersion.revision);
+ tzDataSetVersion.getRevision());
} catch (IOException | TzDataSetException e) {
debugInfo.addStringEntry(statusKey, "ERROR");
debugInfo.addStringEntry(debugKeyPrefix + "exception_class", e.getClass().getName());
@@ -107,9 +109,9 @@
android.icu.util.TimeZone.getTZDataVersion());
debugInfo.addStringEntry(
debugKeyPrefix + "libcore.tzdb_version",
- ZoneInfoDB.getInstance().getVersion());
+ ZoneInfoDb.getInstance().getVersion());
debugInfo.addStringEntry(
debugKeyPrefix + "icu4c.tzdb_version",
- libcore.icu.ICU.getTZDataVersion());
+ Icu4cMetadata.getTzdbVersion());
}
}
diff --git a/luni/src/main/java/libcore/util/EmptyArray.java b/luni/src/main/java/libcore/util/EmptyArray.java
index 5b60683..0d1e321 100644
--- a/luni/src/main/java/libcore/util/EmptyArray.java
+++ b/luni/src/main/java/libcore/util/EmptyArray.java
@@ -16,7 +16,8 @@
package libcore.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
/** @hide */
@libcore.api.CorePlatformApi
@@ -25,22 +26,26 @@
@libcore.api.CorePlatformApi
public static final boolean[] BOOLEAN = new boolean[0];
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk=VersionCodes.Q,
+ publicAlternatives="Use {@code new byte[0]} instead.")
@libcore.api.CorePlatformApi
public static final byte[] BYTE = new byte[0];
public static final char[] CHAR = new char[0];
public static final double[] DOUBLE = new double[0];
@libcore.api.CorePlatformApi
public static final float[] FLOAT = new float[0];
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk=VersionCodes.Q,
+ publicAlternatives="Use {@code new int[0]} instead.")
@libcore.api.CorePlatformApi
public static final int[] INT = new int[0];
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk=VersionCodes.Q,
+ publicAlternatives="Use {@code new long[0]} instead.")
@libcore.api.CorePlatformApi
public static final long[] LONG = new long[0];
public static final Class<?>[] CLASS = new Class[0];
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk=VersionCodes.Q,
+ publicAlternatives="Use {@code new Object[0]} instead.")
@libcore.api.CorePlatformApi
public static final Object[] OBJECT = new Object[0];
@libcore.api.CorePlatformApi
diff --git a/luni/src/main/java/libcore/util/FP16.java b/luni/src/main/java/libcore/util/FP16.java
index 88fe43a..602e1d4 100644
--- a/luni/src/main/java/libcore/util/FP16.java
+++ b/luni/src/main/java/libcore/util/FP16.java
@@ -212,8 +212,8 @@
// Collapse NaNs, akin to halfToIntBits(), but we want to keep
// (signed) short value types to preserve the ordering of -0.0
// and +0.0
- short xBits = (x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY ? NaN : x;
- short yBits = (y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY ? NaN : y;
+ short xBits = isNaN(x) ? NaN : x;
+ short yBits = isNaN(y) ? NaN : y;
return (xBits == yBits ? 0 : (xBits < yBits ? -1 : 1));
}
@@ -237,18 +237,26 @@
@libcore.api.CorePlatformApi
public static short rint(short h) {
int bits = h & 0xffff;
- int e = bits & EXPONENT_SIGNIFICAND_MASK;
+ int abs = bits & EXPONENT_SIGNIFICAND_MASK;
int result = bits;
- if (e < 0x3c00) {
+ if (abs < 0x3c00) {
result &= SIGN_MASK;
- result |= (0x3c00 & (e >= 0x3800 ? 0xffff : 0x0));
- } else if (e < 0x6400) {
- e = 25 - (e >> 10);
- int mask = (1 << e) - 1;
- result += (1 << (e - 1));
+ if (abs > 0x3800){
+ result |= 0x3c00;
+ }
+ } else if (abs < 0x6400) {
+ int exp = 25 - (abs >> 10);
+ int mask = (1 << exp) - 1;
+ result += ((1 << (exp - 1)) - (~(abs >> exp) & 1));
result &= ~mask;
}
+ if (isNaN((short) result)) {
+ // if result is NaN mask with qNaN
+ // (i.e. mask the most significant mantissa bit with 1)
+ // to comply with hardware implementations (ARM64, Intel, etc).
+ result |= NaN;
+ }
return (short) result;
}
@@ -272,18 +280,24 @@
@libcore.api.CorePlatformApi
public static short ceil(short h) {
int bits = h & 0xffff;
- int e = bits & EXPONENT_SIGNIFICAND_MASK;
+ int abs = bits & EXPONENT_SIGNIFICAND_MASK;
int result = bits;
- if (e < 0x3c00) {
+ if (abs < 0x3c00) {
result &= SIGN_MASK;
- result |= 0x3c00 & -(~(bits >> 15) & (e != 0 ? 1 : 0));
- } else if (e < 0x6400) {
- e = 25 - (e >> 10);
- int mask = (1 << e) - 1;
+ result |= 0x3c00 & -(~(bits >> 15) & (abs != 0 ? 1 : 0));
+ } else if (abs < 0x6400) {
+ abs = 25 - (abs >> 10);
+ int mask = (1 << abs) - 1;
result += mask & ((bits >> 15) - 1);
result &= ~mask;
}
+ if (isNaN((short) result)) {
+ // if result is NaN mask with qNaN
+ // (i.e. mask the most significant mantissa bit with 1)
+ // to comply with hardware implementations (ARM64, Intel, etc).
+ result |= NaN;
+ }
return (short) result;
}
@@ -307,18 +321,23 @@
@libcore.api.CorePlatformApi
public static short floor(short h) {
int bits = h & 0xffff;
- int e = bits & EXPONENT_SIGNIFICAND_MASK;
+ int abs = bits & EXPONENT_SIGNIFICAND_MASK;
int result = bits;
- if (e < 0x3c00) {
+ if (abs < 0x3c00) {
result &= SIGN_MASK;
result |= 0x3c00 & (bits > 0x8000 ? 0xffff : 0x0);
- } else if (e < 0x6400) {
- e = 25 - (e >> 10);
- int mask = (1 << e) - 1;
+ } else if (abs < 0x6400) {
+ abs = 25 - (abs >> 10);
+ int mask = (1 << abs) - 1;
result += mask & -(bits >> 15);
result &= ~mask;
}
+ if (isNaN((short) result)) {
+ // if result is NaN mask with qNaN
+ // i.e. (Mask the most significant mantissa bit with 1)
+ result |= NaN;
+ }
return (short) result;
}
@@ -341,14 +360,14 @@
@libcore.api.CorePlatformApi
public static short trunc(short h) {
int bits = h & 0xffff;
- int e = bits & EXPONENT_SIGNIFICAND_MASK;
+ int abs = bits & EXPONENT_SIGNIFICAND_MASK;
int result = bits;
- if (e < 0x3c00) {
+ if (abs < 0x3c00) {
result &= SIGN_MASK;
- } else if (e < 0x6400) {
- e = 25 - (e >> 10);
- int mask = (1 << e) - 1;
+ } else if (abs < 0x6400) {
+ abs = 25 - (abs >> 10);
+ int mask = (1 << abs) - 1;
result &= ~mask;
}
@@ -369,8 +388,8 @@
*/
@libcore.api.CorePlatformApi
public static short min(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return NaN;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return NaN;
+ if (isNaN(x)) return NaN;
+ if (isNaN(y)) return NaN;
if ((x & EXPONENT_SIGNIFICAND_MASK) == 0 && (y & EXPONENT_SIGNIFICAND_MASK) == 0) {
return (x & SIGN_MASK) != 0 ? x : y;
@@ -395,8 +414,8 @@
*/
@libcore.api.CorePlatformApi
public static short max(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return NaN;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return NaN;
+ if (isNaN(x)) return NaN;
+ if (isNaN(y)) return NaN;
if ((x & EXPONENT_SIGNIFICAND_MASK) == 0 && (y & EXPONENT_SIGNIFICAND_MASK) == 0) {
return (x & SIGN_MASK) != 0 ? y : x;
@@ -418,8 +437,8 @@
*/
@libcore.api.CorePlatformApi
public static boolean less(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
+ if (isNaN(x)) return false;
+ if (isNaN(y)) return false;
return ((x & SIGN_MASK) != 0 ? 0x8000 - (x & 0xffff) : x & 0xffff) <
((y & SIGN_MASK) != 0 ? 0x8000 - (y & 0xffff) : y & 0xffff);
@@ -437,8 +456,8 @@
*/
@libcore.api.CorePlatformApi
public static boolean lessEquals(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
+ if (isNaN(x)) return false;
+ if (isNaN(y)) return false;
return ((x & SIGN_MASK) != 0 ? 0x8000 - (x & 0xffff) : x & 0xffff) <=
((y & SIGN_MASK) != 0 ? 0x8000 - (y & 0xffff) : y & 0xffff);
@@ -456,8 +475,8 @@
*/
@libcore.api.CorePlatformApi
public static boolean greater(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
+ if (isNaN(x)) return false;
+ if (isNaN(y)) return false;
return ((x & SIGN_MASK) != 0 ? 0x8000 - (x & 0xffff) : x & 0xffff) >
((y & SIGN_MASK) != 0 ? 0x8000 - (y & 0xffff) : y & 0xffff);
@@ -475,8 +494,8 @@
*/
@libcore.api.CorePlatformApi
public static boolean greaterEquals(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
+ if (isNaN(x)) return false;
+ if (isNaN(y)) return false;
return ((x & SIGN_MASK) != 0 ? 0x8000 - (x & 0xffff) : x & 0xffff) >=
((y & SIGN_MASK) != 0 ? 0x8000 - (y & 0xffff) : y & 0xffff);
@@ -494,8 +513,8 @@
*/
@libcore.api.CorePlatformApi
public static boolean equals(short x, short y) {
- if ((x & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
- if ((y & EXPONENT_SIGNIFICAND_MASK) > POSITIVE_INFINITY) return false;
+ if (isNaN(x)) return false;
+ if (isNaN(y)) return false;
return x == y || ((x | y) & EXPONENT_SIGNIFICAND_MASK) == 0;
}
@@ -626,30 +645,42 @@
} else {
e = e - FP32_EXPONENT_BIAS + EXPONENT_BIAS;
if (e >= 0x1f) { // Overflow
- outE = 0x31;
+ outE = 0x1f;
} else if (e <= 0) { // Underflow
if (e < -10) {
// The absolute fp32 value is less than MIN_VALUE, flush to +/-0
} else {
// The fp32 value is a normalized float less than MIN_NORMAL,
// we convert to a denorm fp16
- m = (m | 0x800000) >> (1 - e);
- if ((m & 0x1000) != 0) m += 0x2000;
- outM = m >> 13;
+ m = m | 0x800000;
+ int shift = 14 - e;
+ outM = m >> shift;
+
+ int lowm = m & ((1 << shift) - 1);
+ int hway = 1 << (shift - 1);
+ // if above halfway or exactly halfway and outM is odd
+ if (lowm + (outM & 1) > hway){
+ // Round to nearest even
+ // Can overflow into exponent bit, which surprisingly is OK.
+ // This increment relies on the +outM in the return statement below
+ outM++;
+ }
}
} else {
outE = e;
outM = m >> 13;
- if ((m & 0x1000) != 0) {
- // Round to nearest "0.5" up
- int out = (outE << EXPONENT_SHIFT) | outM;
- out++;
- return (short) (out | (s << SIGN_SHIFT));
+ // if above halfway or exactly halfway and outM is odd
+ if ((m & 0x1fff) + (outM & 0x1) > 0x1000) {
+ // Round to nearest even
+ // Can overflow into exponent bit, which surprisingly is OK.
+ // This increment relies on the +outM in the return statement below
+ outM++;
}
}
}
-
- return (short) ((s << SIGN_SHIFT) | (outE << EXPONENT_SHIFT) | outM);
+ // The outM is added here as the +1 increments for outM above can
+ // cause an overflow in the exponent bit which is OK.
+ return (short) ((s << SIGN_SHIFT) | (outE << EXPONENT_SHIFT) + outM);
}
/**
diff --git a/luni/src/main/java/libcore/util/NonNull.java b/luni/src/main/java/libcore/util/NonNull.java
index 900e581..db3cd8e 100644
--- a/luni/src/main/java/libcore/util/NonNull.java
+++ b/luni/src/main/java/libcore/util/NonNull.java
@@ -15,6 +15,9 @@
*/
package libcore.util;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -30,7 +33,7 @@
*/
@Documented
@Retention(SOURCE)
-@Target({TYPE_USE})
+@Target({FIELD, METHOD, PARAMETER, TYPE_USE})
@libcore.api.IntraCoreApi
public @interface NonNull {
/**
diff --git a/luni/src/main/java/libcore/util/Nullable.java b/luni/src/main/java/libcore/util/Nullable.java
index c8cbe38..3371978 100644
--- a/luni/src/main/java/libcore/util/Nullable.java
+++ b/luni/src/main/java/libcore/util/Nullable.java
@@ -15,6 +15,9 @@
*/
package libcore.util;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -30,7 +33,7 @@
*/
@Documented
@Retention(SOURCE)
-@Target({TYPE_USE})
+@Target({FIELD, METHOD, PARAMETER, TYPE_USE})
@libcore.api.IntraCoreApi
public @interface Nullable {
/**
diff --git a/luni/src/main/java/libcore/util/ZoneInfo.java b/luni/src/main/java/libcore/util/ZoneInfo.java
index 48665ca..85bf1bc 100644
--- a/luni/src/main/java/libcore/util/ZoneInfo.java
+++ b/luni/src/main/java/libcore/util/ZoneInfo.java
@@ -22,7 +22,8 @@
*/
package libcore.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Arrays;
@@ -31,7 +32,7 @@
import java.util.GregorianCalendar;
import java.util.TimeZone;
import libcore.io.BufferIterator;
-import libcore.timezone.ZoneInfoDB;
+import libcore.timezone.ZoneInfoDb;
/**
* Our concrete TimeZone implementation, backed by zoneinfo data.
@@ -42,7 +43,7 @@
* {@code man 8 zic}) and an index by long name, e.g. Europe/London.
*
* <p>The compacted form is created by {@code external/icu/tools/ZoneCompactor.java} and is used
- * by both this and Bionic. {@link ZoneInfoDB} is responsible for mapping the binary file, and
+ * by both this and Bionic. {@link ZoneInfoDb} is responsible for mapping the binary file, and
* reading the index and creating a {@link BufferIterator} that provides access to an entry for a
* specific file. This class is responsible for reading the data from that {@link BufferIterator}
* and storing it a representation to support the {@link TimeZone} and {@link GregorianCalendar}
diff --git a/luni/src/main/java/org/apache/harmony/xml/ExpatAttributes.java b/luni/src/main/java/org/apache/harmony/xml/ExpatAttributes.java
index 3368f92..22ee4a2 100644
--- a/luni/src/main/java/org/apache/harmony/xml/ExpatAttributes.java
+++ b/luni/src/main/java/org/apache/harmony/xml/ExpatAttributes.java
@@ -16,9 +16,10 @@
package org.apache.harmony.xml;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.xml.sax.Attributes;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* Wraps native attribute array.
*/
diff --git a/luni/src/main/java/org/apache/harmony/xml/ExpatParser.java b/luni/src/main/java/org/apache/harmony/xml/ExpatParser.java
index 71c94f9..8872e1d 100644
--- a/luni/src/main/java/org/apache/harmony/xml/ExpatParser.java
+++ b/luni/src/main/java/org/apache/harmony/xml/ExpatParser.java
@@ -16,15 +16,6 @@
package org.apache.harmony.xml;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.annotation.optimization.ReachabilitySensitive;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import libcore.io.IoUtils;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
@@ -35,6 +26,18 @@
import org.xml.sax.SAXParseException;
import org.xml.sax.ext.LexicalHandler;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import libcore.io.IoUtils;
+
+import dalvik.annotation.optimization.ReachabilitySensitive;
+
/**
* Adapts SAX API to the Expat native XML parser. Not intended for reuse
* across documents.
diff --git a/luni/src/main/java/org/apache/harmony/xml/ExpatReader.java b/luni/src/main/java/org/apache/harmony/xml/ExpatReader.java
index 510a889..a69f364 100644
--- a/luni/src/main/java/org/apache/harmony/xml/ExpatReader.java
+++ b/luni/src/main/java/org/apache/harmony/xml/ExpatReader.java
@@ -16,11 +16,6 @@
package org.apache.harmony.xml;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import libcore.io.IoUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
@@ -32,6 +27,13 @@
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import libcore.io.IoUtils;
+
/**
* SAX wrapper around Expat. Interns strings. Does not support validation.
* Does not support {@link DTDHandler}.
diff --git a/luni/src/main/java/org/apache/harmony/xml/dom/ElementImpl.java b/luni/src/main/java/org/apache/harmony/xml/dom/ElementImpl.java
index a0da24d..b522265 100644
--- a/luni/src/main/java/org/apache/harmony/xml/dom/ElementImpl.java
+++ b/luni/src/main/java/org/apache/harmony/xml/dom/ElementImpl.java
@@ -16,10 +16,6 @@
package org.apache.harmony.xml.dom;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
@@ -28,6 +24,12 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
/**
* Provides a straightforward implementation of the corresponding W3C DOM
* interface. The class is used internally only, thus only notable members that
diff --git a/luni/src/main/java/org/w3c/dom/ls/LSSerializerFilter.java b/luni/src/main/java/org/w3c/dom/ls/LSSerializerFilter.java
index 554807c..9f22f2b 100644
--- a/luni/src/main/java/org/w3c/dom/ls/LSSerializerFilter.java
+++ b/luni/src/main/java/org/w3c/dom/ls/LSSerializerFilter.java
@@ -12,9 +12,10 @@
package org.w3c.dom.ls;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.w3c.dom.traversal.NodeFilter;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* <code>LSSerializerFilter</code>s provide applications the ability to
* examine nodes as they are being serialized and decide what nodes should
diff --git a/luni/src/main/java/org/w3c/dom/traversal/NodeFilter.java b/luni/src/main/java/org/w3c/dom/traversal/NodeFilter.java
index 24f7599..8263d5b 100644
--- a/luni/src/main/java/org/w3c/dom/traversal/NodeFilter.java
+++ b/luni/src/main/java/org/w3c/dom/traversal/NodeFilter.java
@@ -12,9 +12,10 @@
package org.w3c.dom.traversal;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.w3c.dom.Node;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* Filters are objects that know how to "filter out" nodes. If a
* <code>NodeIterator</code> or <code>TreeWalker</code> is given a
diff --git a/luni/src/main/java/org/w3c/dom/traversal/NodeIterator.java b/luni/src/main/java/org/w3c/dom/traversal/NodeIterator.java
index 686beb7..3d1f3af 100644
--- a/luni/src/main/java/org/w3c/dom/traversal/NodeIterator.java
+++ b/luni/src/main/java/org/w3c/dom/traversal/NodeIterator.java
@@ -12,10 +12,11 @@
package org.w3c.dom.traversal;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* <code>NodeIterators</code> are used to step through a set of nodes, e.g.
* the set of nodes in a <code>NodeList</code>, the document subtree
diff --git a/luni/src/main/java/org/xml/sax/InputSource.java b/luni/src/main/java/org/xml/sax/InputSource.java
index 3750cfe..26e027b 100644
--- a/luni/src/main/java/org/xml/sax/InputSource.java
+++ b/luni/src/main/java/org/xml/sax/InputSource.java
@@ -5,7 +5,7 @@
package org.xml.sax;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.InputStream;
import java.io.Reader;
diff --git a/luni/src/main/java/org/xml/sax/SAXException.java b/luni/src/main/java/org/xml/sax/SAXException.java
index ea69d3f..383b4a0 100644
--- a/luni/src/main/java/org/xml/sax/SAXException.java
+++ b/luni/src/main/java/org/xml/sax/SAXException.java
@@ -5,7 +5,7 @@
package org.xml.sax;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* Encapsulate a general SAX error or warning.
diff --git a/luni/src/main/java/org/xml/sax/SAXParseException.java b/luni/src/main/java/org/xml/sax/SAXParseException.java
index 72b16cf..67cb78a 100644
--- a/luni/src/main/java/org/xml/sax/SAXParseException.java
+++ b/luni/src/main/java/org/xml/sax/SAXParseException.java
@@ -5,7 +5,7 @@
package org.xml.sax;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
/**
* Encapsulate an XML parse error or warning.
diff --git a/luni/src/main/java/org/xml/sax/ext/Attributes2Impl.java b/luni/src/main/java/org/xml/sax/ext/Attributes2Impl.java
index b3702a4..6b4ea18 100644
--- a/luni/src/main/java/org/xml/sax/ext/Attributes2Impl.java
+++ b/luni/src/main/java/org/xml/sax/ext/Attributes2Impl.java
@@ -5,11 +5,13 @@
package org.xml.sax.ext;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import libcore.util.EmptyArray;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import libcore.util.EmptyArray;
+
/**
* SAX2 extension helper for additional Attributes information,
* implementing the {@link Attributes2} interface.
diff --git a/luni/src/main/java/org/xml/sax/ext/Locator2Impl.java b/luni/src/main/java/org/xml/sax/ext/Locator2Impl.java
index bb9582f..711639b 100644
--- a/luni/src/main/java/org/xml/sax/ext/Locator2Impl.java
+++ b/luni/src/main/java/org/xml/sax/ext/Locator2Impl.java
@@ -5,10 +5,11 @@
package org.xml.sax.ext;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* SAX2 extension helper for holding additional Entity information,
diff --git a/luni/src/main/java/org/xml/sax/helpers/AttributesImpl.java b/luni/src/main/java/org/xml/sax/helpers/AttributesImpl.java
index 9193075..dcc6ff0 100644
--- a/luni/src/main/java/org/xml/sax/helpers/AttributesImpl.java
+++ b/luni/src/main/java/org/xml/sax/helpers/AttributesImpl.java
@@ -6,9 +6,10 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.xml.sax.Attributes;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* Default implementation of the Attributes interface.
diff --git a/luni/src/main/java/org/xml/sax/helpers/LocatorImpl.java b/luni/src/main/java/org/xml/sax/helpers/LocatorImpl.java
index 944c41a..9997375 100644
--- a/luni/src/main/java/org/xml/sax/helpers/LocatorImpl.java
+++ b/luni/src/main/java/org/xml/sax/helpers/LocatorImpl.java
@@ -5,9 +5,10 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
import org.xml.sax.Locator;
+import android.compat.annotation.UnsupportedAppUsage;
+
/**
* Provide an optional convenience implementation of Locator.
diff --git a/luni/src/main/java/org/xml/sax/helpers/NamespaceSupport.java b/luni/src/main/java/org/xml/sax/helpers/NamespaceSupport.java
index 820f8d2..5322467 100644
--- a/luni/src/main/java/org/xml/sax/helpers/NamespaceSupport.java
+++ b/luni/src/main/java/org/xml/sax/helpers/NamespaceSupport.java
@@ -6,7 +6,7 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EmptyStackException;
diff --git a/luni/src/main/java/org/xml/sax/helpers/ParserAdapter.java b/luni/src/main/java/org/xml/sax/helpers/ParserAdapter.java
index 5acc659..f6a7a51 100644
--- a/luni/src/main/java/org/xml/sax/helpers/ParserAdapter.java
+++ b/luni/src/main/java/org/xml/sax/helpers/ParserAdapter.java
@@ -6,10 +6,6 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -26,6 +22,12 @@
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
/**
* Adapt a SAX1 Parser as a SAX2 XMLReader.
diff --git a/luni/src/main/java/org/xml/sax/helpers/XMLFilterImpl.java b/luni/src/main/java/org/xml/sax/helpers/XMLFilterImpl.java
index 95ae356..9ad32af 100644
--- a/luni/src/main/java/org/xml/sax/helpers/XMLFilterImpl.java
+++ b/luni/src/main/java/org/xml/sax/helpers/XMLFilterImpl.java
@@ -6,8 +6,6 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import java.io.IOException;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
@@ -22,6 +20,10 @@
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import java.io.IOException;
+
/**
* Base class for deriving an XML filter.
diff --git a/luni/src/main/java/org/xml/sax/helpers/XMLReaderAdapter.java b/luni/src/main/java/org/xml/sax/helpers/XMLReaderAdapter.java
index 0ef4d6f..5f0789f 100644
--- a/luni/src/main/java/org/xml/sax/helpers/XMLReaderAdapter.java
+++ b/luni/src/main/java/org/xml/sax/helpers/XMLReaderAdapter.java
@@ -6,9 +6,6 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import java.io.IOException;
-import java.util.Locale;
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -23,6 +20,11 @@
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import java.io.IOException;
+import java.util.Locale;
+
/**
* Adapt a SAX2 XMLReader as a SAX1 Parser.
diff --git a/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java b/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
index b95728f..08d1664 100644
--- a/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
+++ b/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
@@ -7,13 +7,15 @@
package org.xml.sax.helpers;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import android.compat.annotation.UnsupportedAppUsage;
+
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
/**
diff --git a/luni/src/main/native/Android.bp b/luni/src/main/native/Android.bp
index f94ff95..423cdd1 100644
--- a/luni/src/main/native/Android.bp
+++ b/luni/src/main/native/Android.bp
@@ -32,7 +32,6 @@
"java_lang_invoke_VarHandle.cpp",
"java_math_NativeBN.cpp",
"libcore_icu_ICU.cpp",
- "libcore_icu_NativeConverter.cpp",
"libcore_icu_TimeZoneNames.cpp",
"libcore_io_AsynchronousCloseMonitor.cpp",
"libcore_io_Linux.cpp",
diff --git a/luni/src/main/native/JniConstants.cpp b/luni/src/main/native/JniConstants.cpp
index a6b7b9e..478d015 100644
--- a/luni/src/main/native/JniConstants.cpp
+++ b/luni/src/main/native/JniConstants.cpp
@@ -45,7 +45,6 @@
// Constants
jclass booleanClass;
-jclass charsetICUClass;
jclass doubleClass;
jclass errnoExceptionClass;
jclass fileDescriptorClass;
@@ -91,7 +90,6 @@
}
booleanClass = findClass(env, "java/lang/Boolean");
- charsetICUClass = findClass(env, "java/nio/charset/CharsetICU");
doubleClass = findClass(env, "java/lang/Double");
errnoExceptionClass = findClass(env, "android/system/ErrnoException");
fileDescriptorClass = findClass(env, "java/io/FileDescriptor");
@@ -132,6 +130,15 @@
}
void JniConstants::Invalidate() {
+ // This method is called when a new runtime instance is created. There is no
+ // notification of a runtime instance being destroyed in the JNI interface
+ // so we piggyback on creation. Since only one runtime is supported at a
+ // time, we know the constants are invalid when JNI_CreateJavaVM() is
+ // called.
+ //
+ // Clean shutdown would require calling DeleteGlobalRef() for each of the
+ // class references, but JavaVM is unavailable because ART only calls this
+ // once all threads are unregistered.
std::lock_guard guard(g_constants_mutex);
g_constants_valid = false;
}
@@ -141,11 +148,6 @@
return booleanClass;
}
-jclass JniConstants::GetCharsetICUClass(JNIEnv* env) {
- EnsureJniConstantsInitialized(env);
- return charsetICUClass;
-}
-
jclass JniConstants::GetDoubleClass(JNIEnv* env) {
EnsureJniConstantsInitialized(env);
return doubleClass;
diff --git a/luni/src/main/native/JniConstants.h b/luni/src/main/native/JniConstants.h
index 2931411..868e928 100644
--- a/luni/src/main/native/JniConstants.h
+++ b/luni/src/main/native/JniConstants.h
@@ -30,7 +30,6 @@
static void Invalidate();
static jclass GetBooleanClass(JNIEnv* env);
- static jclass GetCharsetICUClass(JNIEnv* env);
static jclass GetDoubleClass(JNIEnv* env);
static jclass GetErrnoExceptionClass(JNIEnv* env);
static jclass GetFileDescriptorClass(JNIEnv* env);
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp
index 40e580e..17ca839 100644
--- a/luni/src/main/native/Register.cpp
+++ b/luni/src/main/native/Register.cpp
@@ -41,7 +41,6 @@
REGISTER(register_java_lang_invoke_VarHandle);
REGISTER(register_java_math_NativeBN);
REGISTER(register_libcore_icu_ICU);
- REGISTER(register_libcore_icu_NativeConverter);
REGISTER(register_libcore_icu_TimeZoneNames);
REGISTER(register_libcore_io_AsynchronousCloseMonitor);
REGISTER(register_libcore_io_Linux);
diff --git a/luni/src/main/native/ScopedIcuULoc.h b/luni/src/main/native/ScopedIcuULoc.h
new file mode 100644
index 0000000..5de5e36
--- /dev/null
+++ b/luni/src/main/native/ScopedIcuULoc.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedUtfChars.h>
+
+#include "unicode/uloc.h"
+
+
+static void getLocale(const char* localeName, std::string& locale, UErrorCode* status) {
+ int length;
+ {
+ // Most common locale name should fit the max capacity.
+ char buffer[ULOC_FULLNAME_CAPACITY];
+ UErrorCode err = U_ZERO_ERROR;
+
+ length = uloc_getName(localeName, buffer, ULOC_FULLNAME_CAPACITY, &err);
+ if (U_SUCCESS(err)) {
+ locale = buffer;
+ *status = err;
+ return;
+ } else if (err != U_BUFFER_OVERFLOW_ERROR) {
+ *status = err;
+ return;
+ }
+ }
+
+ // Case U_BUFFER_OVERFLOW_ERROR
+ std::unique_ptr<char[]> buffer(new char[length+1]);
+ UErrorCode err = U_ZERO_ERROR;
+ uloc_getName(localeName, buffer.get(), length+1, &err);
+ if (U_SUCCESS(err)) {
+ locale = buffer.get();
+ }
+ *status = err;
+ return;
+}
+
+class ScopedIcuULoc {
+ public:
+ ScopedIcuULoc(JNIEnv* env, jstring javaLocaleName) {
+ isValid = false;
+
+ if (javaLocaleName == NULL) {
+ jniThrowNullPointerException(env, "javaLocaleName == null");
+ return;
+ }
+
+ const ScopedUtfChars localeName(env, javaLocaleName);
+ if (localeName.c_str() == NULL) {
+ return;
+ }
+
+ UErrorCode status = U_ZERO_ERROR;
+ getLocale(localeName.c_str(), mLocale, &status);
+ isValid = U_SUCCESS(status);
+ }
+
+ ~ScopedIcuULoc() {
+ }
+
+ bool valid() const {
+ return isValid;
+ }
+
+ const char* locale() const {
+ return mLocale.c_str();
+ }
+
+ int32_t locale_length() const {
+ return mLocale.length();
+ }
+
+ private:
+ bool isValid;
+ std::string mLocale;
+
+ // Disallow copy and assignment.
+ ScopedIcuULoc(const ScopedIcuULoc&);
+ void operator=(const ScopedIcuULoc&);
+};
diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp
index bb19f6e..6cf2c8b 100644
--- a/luni/src/main/native/android_system_OsConstants.cpp
+++ b/luni/src/main/native/android_system_OsConstants.cpp
@@ -351,6 +351,7 @@
initConstant(env, c, "_LINUX_CAPABILITY_VERSION_3", _LINUX_CAPABILITY_VERSION_3);
#endif
initConstant(env, c, "MAP_FIXED", MAP_FIXED);
+ initConstant(env, c, "MAP_ANONYMOUS", MAP_ANONYMOUS);
initConstant(env, c, "MAP_POPULATE", MAP_POPULATE);
initConstant(env, c, "MAP_PRIVATE", MAP_PRIVATE);
initConstant(env, c, "MAP_SHARED", MAP_SHARED);
@@ -374,6 +375,9 @@
#endif
initConstant(env, c, "MCL_CURRENT", MCL_CURRENT);
initConstant(env, c, "MCL_FUTURE", MCL_FUTURE);
+#if defined(MFD_CLOEXEC)
+ initConstant(env, c, "MFD_CLOEXEC", MFD_CLOEXEC);
+#endif
initConstant(env, c, "MSG_CTRUNC", MSG_CTRUNC);
initConstant(env, c, "MSG_DONTROUTE", MSG_DONTROUTE);
initConstant(env, c, "MSG_EOR", MSG_EOR);
diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp
index 58ca587b..9879761 100644
--- a/luni/src/main/native/libcore_icu_ICU.cpp
+++ b/luni/src/main/native/libcore_icu_ICU.cpp
@@ -34,6 +34,7 @@
#include <log/log.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedStringChars.h>
#include <nativehelper/ScopedUtfChars.h>
#include <nativehelper/jni_macros.h>
#include <nativehelper/toStringArray.h>
@@ -42,27 +43,27 @@
#include "JniConstants.h"
#include "JniException.h"
#include "ScopedIcuLocale.h"
+#include "ScopedIcuULoc.h"
#include "ScopedJavaUnicodeString.h"
#include "unicode/brkiter.h"
+#include "unicode/char16ptr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
#include "unicode/dcfmtsym.h"
#include "unicode/decimfmt.h"
#include "unicode/dtfmtsym.h"
-#include "unicode/dtptngen.h"
#include "unicode/gregocal.h"
#include "unicode/locid.h"
#include "unicode/numfmt.h"
#include "unicode/strenum.h"
-#include "unicode/timezone.h"
#include "unicode/ubrk.h"
#include "unicode/ucal.h"
#include "unicode/ucasemap.h"
#include "unicode/ucol.h"
#include "unicode/ucurr.h"
#include "unicode/udat.h"
+#include "unicode/udatpg.h"
#include "unicode/uloc.h"
-#include "unicode/ulocdata.h"
#include "unicode/ures.h"
#include "unicode/ustring.h"
#include "ureslocs.h"
@@ -94,23 +95,21 @@
DISALLOW_COPY_AND_ASSIGN(ScopedResourceBundle);
};
-static jstring ICU_addLikelySubtags(JNIEnv* env, jclass, jstring javaLocaleName) {
- UErrorCode status = U_ZERO_ERROR;
- ScopedUtfChars localeID(env, javaLocaleName);
- char maximizedLocaleID[ULOC_FULLNAME_CAPACITY];
- uloc_addLikelySubtags(localeID.c_str(), maximizedLocaleID, sizeof(maximizedLocaleID), &status);
- if (U_FAILURE(status)) {
- return javaLocaleName;
- }
- return env->NewStringUTF(maximizedLocaleID);
-}
-
static jstring ICU_getScript(JNIEnv* env, jclass, jstring javaLocaleName) {
- ScopedIcuLocale icuLocale(env, javaLocaleName);
+ ScopedIcuULoc icuLocale(env, javaLocaleName);
if (!icuLocale.valid()) {
return NULL;
}
- return env->NewStringUTF(icuLocale.locale().getScript());
+ // Normal script part is 4-char long. Being conservative for allocation size
+ // because if the locale contains script part, it should not be longer than the locale itself.
+ int32_t capacity = std::max(ULOC_SCRIPT_CAPACITY, icuLocale.locale_length() + 1);
+ std::unique_ptr<char[]> buffer(new char(capacity));
+ UErrorCode status = U_ZERO_ERROR;
+ uloc_getScript(icuLocale.locale(), buffer.get(), capacity, &status);
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+ return env->NewStringUTF(buffer.get());
}
// TODO: rewrite this with int32_t ucurr_forLocale(const char* locale, UChar* buff, int32_t buffCapacity, UErrorCode* ec)...
@@ -188,98 +187,34 @@
return (charCount == 0) ? NULL : jniCreateString(env, chars, charCount);
}
-static jstring ICU_getDisplayCountryNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayCountry(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
-static jstring ICU_getDisplayLanguageNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayLanguage(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
-static jstring ICU_getDisplayScriptNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayScript(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
-static jstring ICU_getDisplayVariantNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayVariant(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
static jstring ICU_getISO3Country(JNIEnv* env, jclass, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
+ ScopedIcuULoc icuLocale(env, javaLanguageTag);
if (!icuLocale.valid()) {
return NULL;
}
- return env->NewStringUTF(icuLocale.locale().getISO3Country());
+ return env->NewStringUTF(uloc_getISO3Country(icuLocale.locale()));
}
static jstring ICU_getISO3Language(JNIEnv* env, jclass, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
+ ScopedIcuULoc icuLocale(env, javaLanguageTag);
if (!icuLocale.valid()) {
return NULL;
}
- return env->NewStringUTF(icuLocale.locale().getISO3Language());
+ return env->NewStringUTF(uloc_getISO3Language(icuLocale.locale()));
}
static jobjectArray ICU_getISOCountriesNative(JNIEnv* env, jclass) {
- return toStringArray(env, icu::Locale::getISOCountries());
+ return toStringArray(env, uloc_getISOCountries());
}
static jobjectArray ICU_getISOLanguagesNative(JNIEnv* env, jclass) {
- return toStringArray(env, icu::Locale::getISOLanguages());
+ return toStringArray(env, uloc_getISOLanguages());
}
static jobjectArray ICU_getAvailableLocalesNative(JNIEnv* env, jclass) {
return toStringArray(env, uloc_countAvailable, uloc_getAvailable);
}
-static jobjectArray ICU_getAvailableCollatorLocalesNative(JNIEnv* env, jclass) {
- return toStringArray(env, ucol_countAvailable, ucol_getAvailable);
-}
-
static bool setIntegerField(JNIEnv* env, jobject obj, const char* fieldName, int value) {
ScopedLocalRef<jobject> integerValue(env, integerValueOf(env, value));
if (integerValue.get() == NULL) return false;
@@ -652,133 +587,82 @@
return JNI_TRUE;
}
-static jstring ICU_toLowerCase(JNIEnv* env, jclass, jstring javaString, jstring javaLanguageTag) {
- ScopedJavaUnicodeString scopedString(env, javaString);
- if (!scopedString.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- icu::UnicodeString& s(scopedString.unicodeString());
- icu::UnicodeString original(s);
- s.toLower(icuLocale.locale());
- return s == original ? javaString : jniCreateString(env, s.getBuffer(), s.length());
-}
-
-static jstring ICU_toUpperCase(JNIEnv* env, jclass, jstring javaString, jstring javaLanguageTag) {
- ScopedJavaUnicodeString scopedString(env, javaString);
- if (!scopedString.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- icu::UnicodeString& s(scopedString.unicodeString());
- icu::UnicodeString original(s);
- s.toUpper(icuLocale.locale());
- return s == original ? javaString : jniCreateString(env, s.getBuffer(), s.length());
-}
-
-static jstring versionString(JNIEnv* env, const UVersionInfo& version) {
- char versionString[U_MAX_VERSION_STRING_LENGTH];
- u_versionToString(const_cast<UVersionInfo&>(version), &versionString[0]);
- return env->NewStringUTF(versionString);
-}
-
-static jstring ICU_getCldrVersion(JNIEnv* env, jclass) {
- UErrorCode status = U_ZERO_ERROR;
- UVersionInfo cldrVersion;
- ulocdata_getCLDRVersion(cldrVersion, &status);
- return versionString(env, cldrVersion);
-}
-
-static jstring ICU_getIcuVersion(JNIEnv* env, jclass) {
- UVersionInfo icuVersion;
- u_getVersion(icuVersion);
- return versionString(env, icuVersion);
-}
-
-static jstring ICU_getUnicodeVersion(JNIEnv* env, jclass) {
- UVersionInfo unicodeVersion;
- u_getUnicodeVersion(unicodeVersion);
- return versionString(env, unicodeVersion);
-}
-
-static jstring ICU_getTZDataVersion(JNIEnv* env, jclass) {
- UErrorCode status = U_ZERO_ERROR;
- const char* version = icu::TimeZone::getTZDataVersion(status);
- if (maybeThrowIcuException(env, "icu::TimeZone::getTZDataVersion", status)) {
- return NULL;
- }
- return env->NewStringUTF(version);
-}
-
static jstring ICU_getBestDateTimePatternNative(JNIEnv* env, jclass, jstring javaSkeleton, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
+ ScopedIcuULoc icuLocale(env, javaLanguageTag);
if (!icuLocale.valid()) {
return NULL;
}
UErrorCode status = U_ZERO_ERROR;
- std::unique_ptr<icu::DateTimePatternGenerator> generator(icu::DateTimePatternGenerator::createInstance(icuLocale.locale(), status));
- if (maybeThrowIcuException(env, "DateTimePatternGenerator::createInstance", status)) {
+ std::unique_ptr<UDateTimePatternGenerator, decltype(&udatpg_close)> generator(
+ udatpg_open(icuLocale.locale(), &status), &udatpg_close);
+ if (maybeThrowIcuException(env, "udatpg_open", status)) {
return NULL;
}
- ScopedJavaUnicodeString skeletonHolder(env, javaSkeleton);
- if (!skeletonHolder.valid()) {
- return NULL;
+ const ScopedStringChars skeletonHolder(env, javaSkeleton);
+ // Convert jchar* to UChar* with the inline-able utility provided by char16ptr.h
+ // which prevents certain compiler optimization than reinterpret_cast.
+ icu::ConstChar16Ptr skeletonPtr(skeletonHolder.get());
+ const UChar* skeleton = icu::toUCharPtr(skeletonPtr.get());
+
+ int32_t patternLength;
+ // Try with fixed-size buffer. 128 chars should be enough for most patterns.
+ // If the buffer is not sufficient, run the below case of U_BUFFER_OVERFLOW_ERROR.
+ #define PATTERN_BUFFER_SIZE 128
+ {
+ UChar buffer[PATTERN_BUFFER_SIZE];
+ status = U_ZERO_ERROR;
+ patternLength = udatpg_getBestPattern(generator.get(), skeleton,
+ skeletonHolder.size(), buffer, PATTERN_BUFFER_SIZE, &status);
+ if (U_SUCCESS(status)) {
+ return jniCreateString(env, buffer, patternLength);
+ } else if (status != U_BUFFER_OVERFLOW_ERROR) {
+ maybeThrowIcuException(env, "udatpg_getBestPattern", status);
+ return NULL;
+ }
}
- icu::UnicodeString result(generator->getBestPattern(skeletonHolder.unicodeString(), status));
- if (maybeThrowIcuException(env, "DateTimePatternGenerator::getBestPattern", status)) {
+ #undef PATTERN_BUFFER_SIZE
+
+ // Case U_BUFFER_OVERFLOW_ERROR
+ std::unique_ptr<UChar[]> buffer(new UChar[patternLength+1]);
+ status = U_ZERO_ERROR;
+ patternLength = udatpg_getBestPattern(generator.get(), skeleton,
+ skeletonHolder.size(), buffer.get(), patternLength+1, &status);
+ if (maybeThrowIcuException(env, "udatpg_getBestPattern", status)) {
return NULL;
}
- return jniCreateString(env, result.getBuffer(), result.length());
+ return jniCreateString(env, buffer.get(), patternLength);
}
static void ICU_setDefaultLocale(JNIEnv* env, jclass, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
+ ScopedIcuULoc icuLocale(env, javaLanguageTag);
if (!icuLocale.valid()) {
return;
}
UErrorCode status = U_ZERO_ERROR;
- icu::Locale::setDefault(icuLocale.locale(), status);
- maybeThrowIcuException(env, "Locale::setDefault", status);
+ uloc_setDefault(icuLocale.locale(), &status);
+ maybeThrowIcuException(env, "uloc_setDefault", status);
}
static jstring ICU_getDefaultLocale(JNIEnv* env, jclass) {
- return env->NewStringUTF(icu::Locale::getDefault().getName());
+ return env->NewStringUTF(uloc_getDefault());
}
static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(ICU, addLikelySubtags, "(Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getAvailableCollatorLocalesNative, "()[Ljava/lang/String;"),
NATIVE_METHOD(ICU, getAvailableLocalesNative, "()[Ljava/lang/String;"),
NATIVE_METHOD(ICU, getBestDateTimePatternNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getCldrVersion, "()Ljava/lang/String;"),
NATIVE_METHOD(ICU, getCurrencyCode, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getDefaultLocale, "()Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayCountryNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayLanguageNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayScriptNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayVariantNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISO3Country, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISO3Language, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISOCountriesNative, "()[Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISOLanguagesNative, "()[Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getIcuVersion, "()Ljava/lang/String;"),
NATIVE_METHOD(ICU, getScript, "(Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getTZDataVersion, "()Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getUnicodeVersion, "()Ljava/lang/String;"),
NATIVE_METHOD(ICU, initLocaleDataNative, "(Ljava/lang/String;Llibcore/icu/LocaleData;)Z"),
NATIVE_METHOD(ICU, setDefaultLocale, "(Ljava/lang/String;)V"),
- NATIVE_METHOD(ICU, toLowerCase, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, toUpperCase, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
};
//
diff --git a/luni/src/main/native/libcore_icu_NativeConverter.cpp b/luni/src/main/native/libcore_icu_NativeConverter.cpp
deleted file mode 100644
index 480c07a..0000000
--- a/luni/src/main/native/libcore_icu_NativeConverter.cpp
+++ /dev/null
@@ -1,701 +0,0 @@
-/**
-*******************************************************************************
-* Copyright (C) 1996-2006, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-*******************************************************************************
-*
-*
-*******************************************************************************
-*/
-/*
- * (C) Copyright IBM Corp. 2000 - All Rights Reserved
- * A JNI wrapper to ICU native converter Interface
- * @author: Ram Viswanadha
- */
-
-#define LOG_TAG "NativeConverter"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <memory>
-#include <vector>
-
-#include <android/log.h>
-#include <nativehelper/JNIHelp.h>
-#include <nativehelper/ScopedLocalRef.h>
-#include <nativehelper/ScopedPrimitiveArray.h>
-#include <nativehelper/ScopedStringChars.h>
-#include <nativehelper/ScopedUtfChars.h>
-#include <nativehelper/jni_macros.h>
-#include <nativehelper/toStringArray.h>
-
-#include "IcuUtilities.h"
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ustrenum.h"
-#include "unicode/ucnv.h"
-#include "unicode/ucnv_cb.h"
-#include "unicode/uniset.h"
-#include "unicode/ustring.h"
-#include "unicode/utypes.h"
-
-#define NativeConverter_REPORT 0
-#define NativeConverter_IGNORE 1
-#define NativeConverter_REPLACE 2
-
-#define MAX_REPLACEMENT_LENGTH 32 // equivalent to UCNV_ERROR_BUFFER_LENGTH
-
-struct DecoderCallbackContext {
- UChar replacementChars[MAX_REPLACEMENT_LENGTH];
- size_t replacementCharCount;
- UConverterToUCallback onUnmappableInput;
- UConverterToUCallback onMalformedInput;
-};
-
-struct EncoderCallbackContext {
- char replacementBytes[MAX_REPLACEMENT_LENGTH];
- size_t replacementByteCount;
- UConverterFromUCallback onUnmappableInput;
- UConverterFromUCallback onMalformedInput;
-};
-
-static UConverter* toUConverter(jlong address) {
- return reinterpret_cast<UConverter*>(static_cast<uintptr_t>(address));
-}
-
-static bool collectStandardNames(JNIEnv* env, const char* canonicalName, const char* standard,
- std::vector<std::string>& result) {
- UErrorCode status = U_ZERO_ERROR;
- icu::UStringEnumeration e(ucnv_openStandardNames(canonicalName, standard, &status));
- if (maybeThrowIcuException(env, "ucnv_openStandardNames", status)) {
- return false;
- }
-
- int32_t count = e.count(status);
- if (maybeThrowIcuException(env, "StringEnumeration::count", status)) {
- return false;
- }
-
- for (int32_t i = 0; i < count; ++i) {
- const icu::UnicodeString* string = e.snext(status);
- if (maybeThrowIcuException(env, "StringEnumeration::snext", status)) {
- return false;
- }
- std::string s;
- string->toUTF8String(s);
- if (s.find_first_of("+,") == std::string::npos) {
- result.push_back(s);
- }
- }
-
- return true;
-}
-
-static const char* getICUCanonicalName(const char* name) {
- UErrorCode error = U_ZERO_ERROR;
- const char* canonicalName = NULL;
- if ((canonicalName = ucnv_getCanonicalName(name, "MIME", &error)) != NULL) {
- return canonicalName;
- } else if ((canonicalName = ucnv_getCanonicalName(name, "IANA", &error)) != NULL) {
- return canonicalName;
- } else if ((canonicalName = ucnv_getCanonicalName(name, "", &error)) != NULL) {
- return canonicalName;
- } else if ((canonicalName = ucnv_getAlias(name, 0, &error)) != NULL) {
- // We have some aliases in the form x-blah .. match those first.
- return canonicalName;
- } else if (strstr(name, "x-") == name) {
- // Check if the converter can be opened with the name given.
- error = U_ZERO_ERROR;
- icu::LocalUConverterPointer cnv(ucnv_open(name + 2, &error));
- if (U_SUCCESS(error)) {
- return name + 2;
- }
- }
- return NULL;
-}
-
-// If a charset listed in the IANA Charset Registry is supported by an implementation
-// of the Java platform then its canonical name must be the name listed in the registry.
-// Many charsets are given more than one name in the registry, in which case the registry
-// identifies one of the names as MIME-preferred. If a charset has more than one registry
-// name then its canonical name must be the MIME-preferred name and the other names in
-// the registry must be valid aliases. If a supported charset is not listed in the IANA
-// registry then its canonical name must begin with one of the strings "X-" or "x-".
-static jstring getJavaCanonicalName(JNIEnv* env, const char* icuCanonicalName) {
- UErrorCode status = U_ZERO_ERROR;
-
- // Check to see if this is a well-known MIME or IANA name.
- const char* cName = NULL;
- if ((cName = ucnv_getStandardName(icuCanonicalName, "MIME", &status)) != NULL) {
- return env->NewStringUTF(cName);
- } else if ((cName = ucnv_getStandardName(icuCanonicalName, "IANA", &status)) != NULL) {
- return env->NewStringUTF(cName);
- }
-
- // Check to see if an alias already exists with "x-" prefix, if yes then
- // make that the canonical name.
- int32_t aliasCount = ucnv_countAliases(icuCanonicalName, &status);
- for (int i = 0; i < aliasCount; ++i) {
- const char* name = ucnv_getAlias(icuCanonicalName, i, &status);
- if (name != NULL && name[0] == 'x' && name[1] == '-') {
- return env->NewStringUTF(name);
- }
- }
-
- // As a last resort, prepend "x-" to any alias and make that the canonical name.
- status = U_ZERO_ERROR;
- const char* name = ucnv_getStandardName(icuCanonicalName, "UTR22", &status);
- if (name == NULL && strchr(icuCanonicalName, ',') != NULL) {
- name = ucnv_getAlias(icuCanonicalName, 1, &status);
- }
- // If there is no UTR22 canonical name then just return the original name.
- if (name == NULL) {
- name = icuCanonicalName;
- }
- std::unique_ptr<char[]> result(new char[2 + strlen(name) + 1]);
- strcpy(&result[0], "x-");
- strcat(&result[0], name);
- return env->NewStringUTF(&result[0]);
-}
-
-// Returns a canonical ICU converter name which may have a version number appended to it, based on
-// the normal canonical name. This is used to determine the actual native converter to use (the
-// normal unversioned name is used to determine the aliases and the Java name).
-static char const * getVersionedIcuCanonicalName(char const * icuCanonicalName) {
- if (strcmp(icuCanonicalName, "UTF-16") == 0) {
- // The ICU UTF-16 converter encodes strings as platform-endian bytes with a BOM. The
- // UTF-16,version=2 one encodes as big-endian with a BOM, as what the Charset javadoc requires.
- return "UTF-16,version=2";
- } else {
- return icuCanonicalName;
- }
-}
-
-static jlong NativeConverter_openConverter(JNIEnv* env, jclass, jstring converterName) {
- ScopedUtfChars converterNameChars(env, converterName);
- if (converterNameChars.c_str() == NULL) {
- // Extra debugging check that we do have an exception if the we could not
- // create a string. See b/62612946.
- if (env->ExceptionCheck()) {
- return 0;
- }
- maybeThrowIcuException(env, "openConverter", U_ILLEGAL_ARGUMENT_ERROR);
- return 0;
- }
- UErrorCode status = U_ZERO_ERROR;
- UConverter* cnv = ucnv_open(converterNameChars.c_str(), &status);
- maybeThrowIcuException(env, "ucnv_open", status);
- if (env->ExceptionCheck()) {
- return 0;
- }
- if (cnv == NULL) {
- // Extra debugging exception in case cnv is null but ICU did not report
- // an error. See b/62612946.
- maybeThrowIcuException(env, "openConverter", U_ILLEGAL_ARGUMENT_ERROR);
- return 0;
- }
- return reinterpret_cast<uintptr_t>(cnv);
-}
-
-static void NativeConverter_closeConverter(JNIEnv*, jclass, jlong address) {
- ucnv_close(toUConverter(address));
-}
-
-static bool shouldCodecThrow(jboolean flush, UErrorCode error) {
- if (flush) {
- return (error != U_BUFFER_OVERFLOW_ERROR && error != U_TRUNCATED_CHAR_FOUND);
- } else {
- return (error != U_BUFFER_OVERFLOW_ERROR && error != U_INVALID_CHAR_FOUND && error != U_ILLEGAL_CHAR_FOUND);
- }
-}
-
-static jint NativeConverter_encode(JNIEnv* env, jclass, jlong address,
- jcharArray source, jint sourceEnd, jbyteArray target, jint targetEnd,
- jintArray data, jboolean flush) {
-
- UConverter* cnv = toUConverter(address);
- if (cnv == NULL) {
- maybeThrowIcuException(env, "toUConverter", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
- ScopedCharArrayRO uSource(env, source);
- if (uSource.get() == NULL) {
- maybeThrowIcuException(env, "uSource", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
- ScopedByteArrayRW uTarget(env, target);
- if (uTarget.get() == NULL) {
- maybeThrowIcuException(env, "uTarget", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
- ScopedIntArrayRW myData(env, data);
- if (myData.get() == NULL) {
- maybeThrowIcuException(env, "myData", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
-
- // Do the conversion.
- jint* sourceOffset = &myData[0];
- jint* targetOffset = &myData[1];
- const jchar* mySource = uSource.get() + *sourceOffset;
- const UChar* mySourceLimit= reinterpret_cast<const UChar*>(uSource.get()) + sourceEnd;
- char* cTarget = reinterpret_cast<char*>(uTarget.get() + *targetOffset);
- const char* cTargetLimit = reinterpret_cast<const char*>(uTarget.get() + targetEnd);
- UErrorCode errorCode = U_ZERO_ERROR;
- ucnv_fromUnicode(cnv, &cTarget, cTargetLimit, reinterpret_cast<const UChar**>(&mySource), mySourceLimit, NULL, (UBool) flush, &errorCode);
- *sourceOffset = (mySource - uSource.get()) - *sourceOffset;
- *targetOffset = (reinterpret_cast<jbyte*>(cTarget) - uTarget.get());
-
- // If there was an error, count the problematic characters.
- if (errorCode == U_ILLEGAL_CHAR_FOUND || errorCode == U_INVALID_CHAR_FOUND ||
- errorCode == U_TRUNCATED_CHAR_FOUND) {
- int8_t invalidUCharCount = 32;
- UChar invalidUChars[32];
- UErrorCode minorErrorCode = U_ZERO_ERROR;
- ucnv_getInvalidUChars(cnv, invalidUChars, &invalidUCharCount, &minorErrorCode);
- if (U_SUCCESS(minorErrorCode)) {
- myData[2] = invalidUCharCount;
- }
- }
-
- // Managed code handles some cases; throw all other errors.
- if (shouldCodecThrow(flush, errorCode)) {
- maybeThrowIcuException(env, "ucnv_fromUnicode", errorCode);
- }
- return errorCode;
-}
-
-static jint NativeConverter_decode(JNIEnv* env, jclass, jlong address,
- jbyteArray source, jint sourceEnd, jcharArray target, jint targetEnd,
- jintArray data, jboolean flush) {
-
- UConverter* cnv = toUConverter(address);
- if (cnv == NULL) {
- maybeThrowIcuException(env, "toUConverter", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
- ScopedByteArrayRO uSource(env, source);
- if (uSource.get() == NULL) {
- maybeThrowIcuException(env, "uSource", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
- ScopedCharArrayRW uTarget(env, target);
- if (uTarget.get() == NULL) {
- maybeThrowIcuException(env, "uTarget", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
- ScopedIntArrayRW myData(env, data);
- if (myData.get() == NULL) {
- maybeThrowIcuException(env, "myData", U_ILLEGAL_ARGUMENT_ERROR);
- return U_ILLEGAL_ARGUMENT_ERROR;
- }
-
- // Do the conversion.
- jint* sourceOffset = &myData[0];
- jint* targetOffset = &myData[1];
- const char* mySource = reinterpret_cast<const char*>(uSource.get() + *sourceOffset);
- const char* mySourceLimit = reinterpret_cast<const char*>(uSource.get() + sourceEnd);
- UChar* cTarget = reinterpret_cast<UChar*>(uTarget.get()) + *targetOffset;
- const UChar* cTargetLimit = reinterpret_cast<UChar*>(uTarget.get()) + targetEnd;
- UErrorCode errorCode = U_ZERO_ERROR;
- ucnv_toUnicode(cnv, &cTarget, cTargetLimit, &mySource, mySourceLimit, NULL, flush, &errorCode);
- *sourceOffset = mySource - reinterpret_cast<const char*>(uSource.get()) - *sourceOffset;
- *targetOffset = cTarget - reinterpret_cast<UChar*>(uTarget.get()) - *targetOffset;
-
- // If there was an error, count the problematic bytes.
- if (errorCode == U_ILLEGAL_CHAR_FOUND || errorCode == U_INVALID_CHAR_FOUND ||
- errorCode == U_TRUNCATED_CHAR_FOUND) {
- int8_t invalidByteCount = 32;
- char invalidBytes[32] = {'\0'};
- UErrorCode minorErrorCode = U_ZERO_ERROR;
- ucnv_getInvalidChars(cnv, invalidBytes, &invalidByteCount, &minorErrorCode);
- if (U_SUCCESS(minorErrorCode)) {
- myData[2] = invalidByteCount;
- }
- }
-
- // Managed code handles some cases; throw all other errors.
- if (shouldCodecThrow(flush, errorCode)) {
- maybeThrowIcuException(env, "ucnv_toUnicode", errorCode);
- }
- return errorCode;
-}
-
-static void NativeConverter_resetByteToChar(JNIEnv*, jclass, jlong address) {
- UConverter* cnv = toUConverter(address);
- if (cnv) {
- ucnv_resetToUnicode(cnv);
- }
-}
-
-static void NativeConverter_resetCharToByte(JNIEnv*, jclass, jlong address) {
- UConverter* cnv = toUConverter(address);
- if (cnv) {
- ucnv_resetFromUnicode(cnv);
- }
-}
-
-static jint NativeConverter_getMaxBytesPerChar(JNIEnv*, jclass, jlong address) {
- UConverter* cnv = toUConverter(address);
- return (cnv != NULL) ? ucnv_getMaxCharSize(cnv) : -1;
-}
-
-static jint NativeConverter_getMinBytesPerChar(JNIEnv*, jclass, jlong address) {
- UConverter* cnv = toUConverter(address);
- return (cnv != NULL) ? ucnv_getMinCharSize(cnv) : -1;
-}
-
-static jfloat NativeConverter_getAveBytesPerChar(JNIEnv*, jclass, jlong address) {
- UConverter* cnv = toUConverter(address);
- return (cnv != NULL) ? ((ucnv_getMaxCharSize(cnv) + ucnv_getMinCharSize(cnv)) / 2.0) : -1;
-}
-
-static jobjectArray NativeConverter_getAvailableCharsetNames(JNIEnv* env, jclass) {
- int32_t num = ucnv_countAvailable();
- jobjectArray result = env->NewObjectArray(num, JniConstants::GetStringClass(env), NULL);
- if (result == NULL) {
- return NULL;
- }
- for (int i = 0; i < num; ++i) {
- const char* name = ucnv_getAvailableName(i);
- ScopedLocalRef<jstring> javaCanonicalName(env, getJavaCanonicalName(env, name));
- if (javaCanonicalName.get() == NULL) {
- return NULL;
- }
- env->SetObjectArrayElement(result, i, javaCanonicalName.get());
- if (env->ExceptionCheck()) {
- return NULL;
- }
- }
- return result;
-}
-
-static void CHARSET_ENCODER_CALLBACK(const void* rawContext, UConverterFromUnicodeArgs* args,
- const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason,
- UErrorCode* status) {
- if (!rawContext) {
- return;
- }
- const EncoderCallbackContext* ctx = reinterpret_cast<const EncoderCallbackContext*>(rawContext);
- switch(reason) {
- case UCNV_UNASSIGNED:
- ctx->onUnmappableInput(ctx, args, codeUnits, length, codePoint, reason, status);
- return;
- case UCNV_ILLEGAL:
- case UCNV_IRREGULAR:
- ctx->onMalformedInput(ctx, args, codeUnits, length, codePoint, reason, status);
- return;
- case UCNV_CLOSE:
- delete ctx;
- return;
- default:
- *status = U_ILLEGAL_ARGUMENT_ERROR;
- return;
- }
-}
-
-static void encoderReplaceCallback(const void* rawContext,
- UConverterFromUnicodeArgs* fromArgs, const UChar*, int32_t, UChar32,
- UConverterCallbackReason, UErrorCode * err) {
- if (rawContext == NULL) {
- return;
- }
- const EncoderCallbackContext* context = reinterpret_cast<const EncoderCallbackContext*>(rawContext);
- *err = U_ZERO_ERROR;
- ucnv_cbFromUWriteBytes(fromArgs, context->replacementBytes, context->replacementByteCount, 0, err);
-}
-
-static UConverterFromUCallback getFromUCallback(int32_t mode) {
- switch(mode) {
- case NativeConverter_IGNORE: return UCNV_FROM_U_CALLBACK_SKIP;
- case NativeConverter_REPLACE: return encoderReplaceCallback;
- case NativeConverter_REPORT: return UCNV_FROM_U_CALLBACK_STOP;
- }
- abort();
-}
-
-static void NativeConverter_setCallbackEncode(JNIEnv* env, jclass, jlong address,
- jint onMalformedInput, jint onUnmappableInput, jbyteArray javaReplacement) {
- UConverter* cnv = toUConverter(address);
- if (cnv == NULL) {
- maybeThrowIcuException(env, "toUConverter", U_ILLEGAL_ARGUMENT_ERROR);
- return;
- }
-
- UConverterFromUCallback oldCallback = NULL;
- const void* oldCallbackContext = NULL;
- ucnv_getFromUCallBack(cnv, &oldCallback, const_cast<const void**>(&oldCallbackContext));
-
- EncoderCallbackContext* callbackContext = const_cast<EncoderCallbackContext*>(
- reinterpret_cast<const EncoderCallbackContext*>(oldCallbackContext));
- // Hold the reference to any new callbackContext we create in a unique_ptr
- // so that the default behavior is to collect it automatically if we exit
- // early.
- std::unique_ptr<EncoderCallbackContext> callbackContextDeleter;
- if (callbackContext == NULL) {
- callbackContext = new EncoderCallbackContext;
- callbackContextDeleter.reset(callbackContext);
- }
-
- callbackContext->onMalformedInput = getFromUCallback(onMalformedInput);
- callbackContext->onUnmappableInput = getFromUCallback(onUnmappableInput);
-
- ScopedByteArrayRO replacementBytes(env, javaReplacement);
- if (replacementBytes.get() == NULL
- || replacementBytes.size() > sizeof(callbackContext->replacementBytes)) {
- maybeThrowIcuException(env, "replacementBytes", U_ILLEGAL_ARGUMENT_ERROR);
- return;
- }
- memcpy(callbackContext->replacementBytes, replacementBytes.get(), replacementBytes.size());
- callbackContext->replacementByteCount = replacementBytes.size();
-
- UErrorCode errorCode = U_ZERO_ERROR;
- ucnv_setFromUCallBack(cnv, CHARSET_ENCODER_CALLBACK, callbackContext, NULL, NULL, &errorCode);
- // Iff callbackContextDeleter holds a reference to a callbackContext we can
- // prevent it being automatically deleted here as responsibility for deletion
- // has passed to the code that closes the NativeConverter.
- callbackContextDeleter.release();
- maybeThrowIcuException(env, "ucnv_setFromUCallBack", errorCode);
-}
-
-static void decoderIgnoreCallback(const void*, UConverterToUnicodeArgs*, const char*, int32_t, UConverterCallbackReason, UErrorCode* err) {
- // The icu4c UCNV_FROM_U_CALLBACK_SKIP callback requires that the context is NULL, which is
- // never true for us.
- *err = U_ZERO_ERROR;
-}
-
-static void decoderReplaceCallback(const void* rawContext,
- UConverterToUnicodeArgs* toArgs, const char*, int32_t, UConverterCallbackReason,
- UErrorCode* err) {
- if (!rawContext) {
- return;
- }
- const DecoderCallbackContext* context = reinterpret_cast<const DecoderCallbackContext*>(rawContext);
- *err = U_ZERO_ERROR;
- ucnv_cbToUWriteUChars(toArgs,context->replacementChars, context->replacementCharCount, 0, err);
-}
-
-static UConverterToUCallback getToUCallback(int32_t mode) {
- switch (mode) {
- case NativeConverter_IGNORE: return decoderIgnoreCallback;
- case NativeConverter_REPLACE: return decoderReplaceCallback;
- case NativeConverter_REPORT: return UCNV_TO_U_CALLBACK_STOP;
- }
- abort();
-}
-
-static void CHARSET_DECODER_CALLBACK(const void* rawContext, UConverterToUnicodeArgs* args,
- const char* codeUnits, int32_t length,
- UConverterCallbackReason reason, UErrorCode* status) {
- if (!rawContext) {
- return;
- }
- const DecoderCallbackContext* ctx = reinterpret_cast<const DecoderCallbackContext*>(rawContext);
- switch(reason) {
- case UCNV_UNASSIGNED:
- ctx->onUnmappableInput(ctx, args, codeUnits, length, reason, status);
- return;
- case UCNV_ILLEGAL:
- case UCNV_IRREGULAR:
- ctx->onMalformedInput(ctx, args, codeUnits, length, reason, status);
- return;
- case UCNV_CLOSE:
- delete ctx;
- return;
- default:
- *status = U_ILLEGAL_ARGUMENT_ERROR;
- return;
- }
-}
-
-static void NativeConverter_setCallbackDecode(JNIEnv* env, jclass, jlong address,
- jint onMalformedInput, jint onUnmappableInput, jstring javaReplacement) {
- UConverter* cnv = toUConverter(address);
- if (cnv == NULL) {
- maybeThrowIcuException(env, "toConverter", U_ILLEGAL_ARGUMENT_ERROR);
- return;
- }
-
- UConverterToUCallback oldCallback;
- const void* oldCallbackContext;
- ucnv_getToUCallBack(cnv, &oldCallback, &oldCallbackContext);
-
- DecoderCallbackContext* callbackContext = const_cast<DecoderCallbackContext*>(
- reinterpret_cast<const DecoderCallbackContext*>(oldCallbackContext));
- // Hold the reference to any new callbackContext we create in a unique_ptr
- // so that the default behavior is to collect it automatically if we exit
- // early.
- std::unique_ptr<DecoderCallbackContext> callbackContextDeleter;
- if (callbackContext == NULL) {
- callbackContext = new DecoderCallbackContext;
- callbackContextDeleter.reset(callbackContext);
- }
-
- callbackContext->onMalformedInput = getToUCallback(onMalformedInput);
- callbackContext->onUnmappableInput = getToUCallback(onUnmappableInput);
-
- ScopedStringChars replacement(env, javaReplacement);
- if (replacement.get() == NULL
- || replacement.size() > sizeof(callbackContext->replacementChars) / sizeof(UChar)) {
- maybeThrowIcuException(env, "replacement", U_ILLEGAL_ARGUMENT_ERROR);
- return;
- }
- u_strncpy(callbackContext->replacementChars, reinterpret_cast<const UChar*>(replacement.get()), replacement.size());
- callbackContext->replacementCharCount = replacement.size();
-
- UErrorCode errorCode = U_ZERO_ERROR;
- ucnv_setToUCallBack(cnv, CHARSET_DECODER_CALLBACK, callbackContext, NULL, NULL, &errorCode);
- // Iff callbackContextDeleter holds a reference to a callbackContext we can
- // prevent it being automatically deleted here as responsibility for deletion
- // has passed to the code that closes the NativeConverter.
- callbackContextDeleter.release();
- maybeThrowIcuException(env, "ucnv_setToUCallBack", errorCode);
-}
-
-static jfloat NativeConverter_getAveCharsPerByte(JNIEnv* env, jclass, jlong handle) {
- return (1 / (jfloat) NativeConverter_getMaxBytesPerChar(env, NULL, handle));
-}
-
-static jbyteArray NativeConverter_getSubstitutionBytes(JNIEnv* env, jclass, jlong address) {
- UConverter* cnv = toUConverter(address);
- if (cnv == NULL) {
- return NULL;
- }
- UErrorCode status = U_ZERO_ERROR;
- char replacementBytes[MAX_REPLACEMENT_LENGTH];
- int8_t len = sizeof(replacementBytes);
- ucnv_getSubstChars(cnv, replacementBytes, &len, &status);
- if (!U_SUCCESS(status)) {
- return env->NewByteArray(0);
- }
- jbyteArray result = env->NewByteArray(len);
- if (result == NULL) {
- return NULL;
- }
- env->SetByteArrayRegion(result, 0, len, reinterpret_cast<jbyte*>(replacementBytes));
- return result;
-}
-
-static jboolean NativeConverter_contains(JNIEnv* env, jclass, jstring name1, jstring name2) {
- ScopedUtfChars name1Chars(env, name1);
- if (name1Chars.c_str() == NULL) {
- return JNI_FALSE;
- }
- ScopedUtfChars name2Chars(env, name2);
- if (name2Chars.c_str() == NULL) {
- return JNI_FALSE;
- }
-
- UErrorCode errorCode = U_ZERO_ERROR;
- icu::LocalUConverterPointer converter1(ucnv_open(name1Chars.c_str(), &errorCode));
- icu::UnicodeSet set1;
- ucnv_getUnicodeSet(&*converter1, set1.toUSet(), UCNV_ROUNDTRIP_SET, &errorCode);
-
- icu::LocalUConverterPointer converter2(ucnv_open(name2Chars.c_str(), &errorCode));
- icu::UnicodeSet set2;
- ucnv_getUnicodeSet(&*converter2, set2.toUSet(), UCNV_ROUNDTRIP_SET, &errorCode);
-
- return U_SUCCESS(errorCode) && set1.containsAll(set2);
-}
-
-static jobject NativeConverter_charsetForName(JNIEnv* env, jclass, jstring charsetName) {
- ScopedUtfChars charsetNameChars(env, charsetName);
- if (charsetNameChars.c_str() == NULL) {
- return NULL;
- }
-
- // Get ICU's canonical name for this charset.
- const char* icuCanonicalName = getICUCanonicalName(charsetNameChars.c_str());
- if (icuCanonicalName == NULL) {
- return NULL;
- }
-
- // Get Java's canonical name for this charset.
- jstring javaCanonicalName = getJavaCanonicalName(env, icuCanonicalName);
- if (env->ExceptionCheck()) {
- return NULL;
- }
-
- // Check that this charset is supported.
- {
- // ICU doesn't offer any "isSupported", so we just open and immediately close.
- UErrorCode error = U_ZERO_ERROR;
- icu::LocalUConverterPointer cnv(ucnv_open(icuCanonicalName, &error));
- if (!U_SUCCESS(error)) {
- return NULL;
- }
- }
-
- // Get the aliases for this charset.
- std::vector<std::string> aliases;
- if (!collectStandardNames(env, icuCanonicalName, "IANA", aliases)) {
- return NULL;
- }
- if (!collectStandardNames(env, icuCanonicalName, "MIME", aliases)) {
- return NULL;
- }
- if (!collectStandardNames(env, icuCanonicalName, "JAVA", aliases)) {
- return NULL;
- }
- if (!collectStandardNames(env, icuCanonicalName, "WINDOWS", aliases)) {
- return NULL;
- }
- jobjectArray javaAliases = toStringArray(env, aliases);
- if (env->ExceptionCheck()) {
- return NULL;
- }
-
- // Construct the CharsetICU object.
- static jmethodID charsetConstructor = env->GetMethodID(JniConstants::GetCharsetICUClass(env), "<init>",
- "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V");
- if (env->ExceptionCheck()) {
- return NULL;
- }
-
- char const * versionedIcuCanonicalName = getVersionedIcuCanonicalName(icuCanonicalName);
- jstring versionedIcuCanonicalNameStr = env->NewStringUTF(versionedIcuCanonicalName);
- if (env->ExceptionCheck()) {
- return NULL;
- }
-
- return env->NewObject(JniConstants::GetCharsetICUClass(env), charsetConstructor,
- javaCanonicalName, versionedIcuCanonicalNameStr, javaAliases);
-}
-
-static void FreeNativeConverter(void *converter) {
- ucnv_close(reinterpret_cast<UConverter*>(converter));
-}
-
-static jlong NativeConverter_getNativeFinalizer(JNIEnv*, jclass) {
- return reinterpret_cast<jlong>(&FreeNativeConverter);
-}
-
-static jlong NativeConverter_getNativeSize(JNIEnv*, jclass) {
- // TODO: Improve estimate.
- return 200;
-}
-
-static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(NativeConverter, charsetForName, "(Ljava/lang/String;)Ljava/nio/charset/Charset;"),
- NATIVE_METHOD(NativeConverter, closeConverter, "(J)V"),
- NATIVE_METHOD(NativeConverter, contains, "(Ljava/lang/String;Ljava/lang/String;)Z"),
- NATIVE_METHOD(NativeConverter, decode, "(J[BI[CI[IZ)I"),
- NATIVE_METHOD(NativeConverter, encode, "(J[CI[BI[IZ)I"),
- NATIVE_METHOD(NativeConverter, getAvailableCharsetNames, "()[Ljava/lang/String;"),
- NATIVE_METHOD(NativeConverter, getAveBytesPerChar, "(J)F"),
- NATIVE_METHOD(NativeConverter, getAveCharsPerByte, "(J)F"),
- NATIVE_METHOD(NativeConverter, getMaxBytesPerChar, "(J)I"),
- NATIVE_METHOD(NativeConverter, getMinBytesPerChar, "(J)I"),
- NATIVE_METHOD(NativeConverter, getSubstitutionBytes, "(J)[B"),
- NATIVE_METHOD(NativeConverter, openConverter, "(Ljava/lang/String;)J"),
- NATIVE_METHOD(NativeConverter, resetByteToChar, "(J)V"),
- NATIVE_METHOD(NativeConverter, resetCharToByte, "(J)V"),
- NATIVE_METHOD(NativeConverter, setCallbackDecode, "(JIILjava/lang/String;)V"),
- NATIVE_METHOD(NativeConverter, setCallbackEncode, "(JII[B)V"),
- NATIVE_METHOD(NativeConverter, getNativeFinalizer, "()J"),
- NATIVE_METHOD(NativeConverter, getNativeSize, "()J")
-};
-void register_libcore_icu_NativeConverter(JNIEnv* env) {
- jniRegisterNativeMethods(env, "libcore/icu/NativeConverter", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/libcore_io_Linux.cpp b/luni/src/main/native/libcore_io_Linux.cpp
index 805b32f..9e44e63 100644
--- a/luni/src/main/native/libcore_io_Linux.cpp
+++ b/luni/src/main/native/libcore_io_Linux.cpp
@@ -1837,6 +1837,21 @@
return doStat(env, javaPath, true);
}
+static jobject Linux_memfd_create(JNIEnv* env, jobject, jstring javaName, jint flags) {
+#if defined(__BIONIC__)
+ ScopedUtfChars name(env, javaName);
+ if (name.c_str() == NULL) {
+ return NULL;
+ }
+
+ int fd = throwIfMinusOne(env, "memfd_create", memfd_create(name.c_str(), flags));
+ return fd != -1 ? jniCreateFileDescriptor(env, fd) : NULL;
+#else
+ UNUSED(env, javaName, flags);
+ return NULL;
+#endif
+}
+
static void Linux_mincore(JNIEnv* env, jobject, jlong address, jlong byteCount, jbyteArray javaVector) {
ScopedByteArrayRW vector(env, javaVector);
if (vector.get() == NULL) {
@@ -2623,6 +2638,7 @@
NATIVE_METHOD(Linux, listxattr, "(Ljava/lang/String;)[Ljava/lang/String;"),
NATIVE_METHOD(Linux, lseek, "(Ljava/io/FileDescriptor;JI)J"),
NATIVE_METHOD(Linux, lstat, "(Ljava/lang/String;)Landroid/system/StructStat;"),
+ NATIVE_METHOD(Linux, memfd_create, "(Ljava/lang/String;I)Ljava/io/FileDescriptor;"),
NATIVE_METHOD(Linux, mincore, "(JJ[B)V"),
NATIVE_METHOD(Linux, mkdir, "(Ljava/lang/String;I)V"),
NATIVE_METHOD(Linux, mkfifo, "(Ljava/lang/String;I)V"),
diff --git a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index 9d23837..6df5bdd 100644
--- a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
@@ -33,7 +33,8 @@
#include "JniConstants.h"
#include "JniException.h"
-#include "unicode/unistr.h"
+#include "unicode/char16ptr.h"
+#include "unicode/ustring.h"
#define BUCKET_COUNT 128
@@ -428,11 +429,11 @@
*
* @returns number of UTF-16 characters which were copied
*/
-static size_t fillBuffer(ParsingContext* parsingContext, const char* utf8, int byteCount) {
+static size_t fillBuffer(ParsingContext* parsingContext, const char* utf8, int byteLength) {
JNIEnv* env = parsingContext->env;
// Grow buffer if necessary (the length in bytes is always >= the length in chars).
- jcharArray javaChars = parsingContext->ensureCapacity(byteCount);
+ jcharArray javaChars = parsingContext->ensureCapacity(byteLength);
if (javaChars == NULL) {
return -1;
}
@@ -443,8 +444,19 @@
return -1;
}
UErrorCode status = U_ZERO_ERROR;
- icu::UnicodeString utf16(icu::UnicodeString::fromUTF8(icu::StringPiece(utf8, byteCount)));
- return utf16.extract(chars.get(), byteCount, status);
+ int32_t length16;
+ // Use inline C++ class provided by ICU
+ icu::Char16Ptr dest(chars.get()); // Convert jchar (aka uint16_t*) to char16_t*
+ // Avoid icu::UnicodeString due to unstable C++ ABI.
+ u_strFromUTF8WithSub(dest.get(), // dest
+ byteLength, // destCapacity
+ &length16, // pDestLength
+ utf8, // src
+ byteLength, // srcLength
+ 0xfffd, // 0xfffd is the standard substitution character for malformed input sequence.
+ NULL, // Don't care about number of substitutions.
+ &status);
+ return length16;
}
/**
diff --git a/luni/src/module/java/module-info.java b/luni/src/module/java/module-info.java
index 8a290d9..6c2bc12 100644
--- a/luni/src/module/java/module-info.java
+++ b/luni/src/module/java/module-info.java
@@ -69,6 +69,8 @@
exports javax.security.auth.x500;
exports javax.security.cert;
exports javax.sql;
+ exports jdk.internal.util;
+ exports jdk.internal.vm.annotation;
exports jdk.net;
exports sun.invoke.util;
exports sun.misc;
diff --git a/luni/src/test/java/libcore/android/system/OsTest.java b/luni/src/test/java/libcore/android/system/OsTest.java
index 8b8aea0..35019db 100644
--- a/luni/src/test/java/libcore/android/system/OsTest.java
+++ b/luni/src/test/java/libcore/android/system/OsTest.java
@@ -87,6 +87,45 @@
}
}
+ public void testFcntlInt_udpSocket() throws Exception {
+ final FileDescriptor fd = Os.socket(AF_INET, SOCK_DGRAM, 0);
+ try {
+ assertEquals(0, (Os.fcntlVoid(fd, F_GETFL) & O_NONBLOCK));
+
+ // Verify that we can set file descriptor flags on sockets
+ Os.fcntlInt(fd, F_SETFL, SOCK_DGRAM | O_NONBLOCK);
+ assertTrue((Os.fcntlVoid(fd, F_GETFL) & O_NONBLOCK) != 0);
+
+ // Check that we can turn it off also.
+ Os.fcntlInt(fd, F_SETFL, SOCK_DGRAM);
+ assertEquals(0, (Os.fcntlVoid(fd, F_GETFL) & O_NONBLOCK));
+ } finally {
+ Os.close(fd);
+ }
+ }
+
+ public void testFcntlInt_invalidCmd() throws Exception {
+ final FileDescriptor fd = Os.socket(AF_INET, SOCK_DGRAM, 0);
+ try {
+ final int unknownCmd = -1;
+ Os.fcntlInt(fd, unknownCmd, 0);
+ fail("Expected failure due to invalid cmd");
+ } catch (ErrnoException expected) {
+ assertEquals(EINVAL, expected.errno);
+ } finally {
+ Os.close(fd);
+ }
+ }
+
+ public void testFcntlInt_nullFd() throws Exception {
+ try {
+ Os.fcntlInt(null, F_SETFL, O_NONBLOCK);
+ fail("Expected failure due to null file descriptor");
+ } catch (ErrnoException expected) {
+ assertEquals(EBADF, expected.errno);
+ }
+ }
+
public void testUnixDomainSockets_in_file_system() throws Exception {
String path = System.getProperty("java.io.tmpdir") + "/test_unix_socket";
new File(path).delete();
@@ -538,10 +577,14 @@
public void test_NetlinkSocket() throws Exception {
FileDescriptor nlSocket = Os.socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
- Os.bind(nlSocket, new NetlinkSocketAddress());
- NetlinkSocketAddress address = (NetlinkSocketAddress) Os.getsockname(nlSocket);
- assertTrue(address.getPortId() > 0);
- assertEquals(0, address.getGroupsMask());
+ try {
+ Os.bind(nlSocket, new NetlinkSocketAddress());
+ // Non-system processes should not be allowed to bind() to NETLINK_ROUTE sockets.
+ // http://b/141455849
+ fail("bind() on NETLINK_ROUTE socket succeeded");
+ } catch (ErrnoException expectedException) {
+ assertEquals(expectedException.errno, EACCES);
+ }
NetlinkSocketAddress nlKernel = new NetlinkSocketAddress();
Os.connect(nlSocket, nlKernel);
@@ -941,7 +984,7 @@
// ENOTSUP, Extended attributes are not supported by the filesystem, or are disabled.
// Since kernel version 4.9 (or some other version after 4.4), *xattr() methods
- // may set errno to EACCESS instead. This behavior change is likely related to
+ // may set errno to EACCES instead. This behavior change is likely related to
// https://patchwork.kernel.org/patch/9294421/ which reimplemented getxattr, setxattr,
// and removexattr on top of generic handlers.
final String path = "/proc/self/stat";
@@ -1470,4 +1513,83 @@
InetAddress inetAddress = Os.inet_pton(AF_INET, srcAddress);
assertNull(inetAddress);
}
+
+ /**
+ * Verifies the {@link OsConstants#MAP_ANONYMOUS}.
+ */
+ public void testMapAnonymous() throws Exception {
+ final long size = 4096;
+ final long address = Os.mmap(0, size, PROT_READ,
+ MAP_PRIVATE | MAP_ANONYMOUS, new FileDescriptor(), 0);
+ assertTrue(address > 0);
+ Os.munmap(address, size);
+ }
+
+ public void testMemfdCreate() throws Exception {
+ FileDescriptor fd = null;
+ try {
+ fd = Os.memfd_create("test_memfd", 0);
+ assertNotNull(fd);
+ assertTrue(fd.valid());
+
+ StructStat stat = Os.fstat(fd);
+ assertEquals(0, stat.st_size);
+
+ final byte[] expected = new byte[] {1, 2, 3, 4};
+ Os.write(fd, expected, 0, expected.length);
+ stat = Os.fstat(fd);
+ assertEquals(expected.length, stat.st_size);
+
+ byte[] actual = new byte[expected.length];
+ // should be seekable
+ Os.lseek(fd, 0, SEEK_SET);
+ Os.read(fd, actual, 0, actual.length);
+ assertArrayEquals(expected, actual);
+ } finally {
+ if (fd != null) {
+ Os.close(fd);
+ fd = null;
+ }
+ }
+ }
+
+ public void testMemfdCreateFlags() throws Exception {
+ FileDescriptor fd = null;
+
+ // test that MFD_CLOEXEC is obeyed
+ try {
+ fd = Os.memfd_create("test_memfd", 0);
+ assertNotNull(fd);
+ assertTrue(fd.valid());
+ int flags = Os.fcntlVoid(fd, F_GETFD);
+ assertTrue("Expected flags to not include " + FD_CLOEXEC + ", actual value: " + flags,
+ 0 == (flags & FD_CLOEXEC));
+ } finally {
+ if (fd != null) {
+ Os.close(fd);
+ fd = null;
+ }
+ }
+ try {
+ fd = Os.memfd_create("test_memfd", MFD_CLOEXEC);
+ assertNotNull(fd);
+ assertTrue(fd.valid());
+ int flags = Os.fcntlVoid(fd, F_GETFD);
+ assertTrue("Expected flags to include " + FD_CLOEXEC + ", actual value: " + flags,
+ 0 != (flags & FD_CLOEXEC));
+ } finally {
+ if (fd != null) {
+ Os.close(fd);
+ fd = null;
+ }
+ }
+ }
+
+ public void testMemfdCreateErrno() throws Exception {
+ expectException(() -> Os.memfd_create(null, 0), NullPointerException.class, null,
+ "memfd_create(null, 0)");
+
+ expectException(() -> Os.memfd_create("test_memfd", 0xffff), ErrnoException.class, EINVAL,
+ "memfd_create(\"test_memfd\", 0xffff)");
+ }
}
diff --git a/luni/src/test/java/libcore/dalvik/system/BaseDexClassLoaderTest.java b/luni/src/test/java/libcore/dalvik/system/BaseDexClassLoaderTest.java
index 84f7f71..1642a11 100644
--- a/luni/src/test/java/libcore/dalvik/system/BaseDexClassLoaderTest.java
+++ b/luni/src/test/java/libcore/dalvik/system/BaseDexClassLoaderTest.java
@@ -20,10 +20,12 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import dalvik.system.BaseDexClassLoader;
import dalvik.system.DelegateLastClassLoader;
import dalvik.system.PathClassLoader;
+import java.lang.reflect.Method;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
@@ -63,6 +65,7 @@
private ClassLoader pcl;
private File jar;
+ private File jar2;
private Reporter reporter;
// For resources that we will load in this test. We're re-using parent.jar and child.jar
@@ -81,7 +84,7 @@
}
@Before
- public void extractTestJar() throws Exception {
+ public void extractTestJars() throws Exception {
// Extract loading-test.jar from the resource.
pcl = BaseDexClassLoaderTest.class.getClassLoader();
jar = File.createTempFile("loading-test", ".jar");
@@ -89,6 +92,11 @@
FileOutputStream out = new FileOutputStream(jar)) {
Streams.copy(in, out);
}
+ jar2 = File.createTempFile("loading-test2", ".jar");
+ try (InputStream in = pcl.getResourceAsStream("dalvik/system/loading-test2.jar");
+ FileOutputStream out = new FileOutputStream(jar2)) {
+ Streams.copy(in, out);
+ }
}
@Before
@@ -103,8 +111,9 @@
}
@After
- public void deleteTestJar() throws Exception {
+ public void deleteTestJars() throws Exception {
assertTrue(jar.delete());
+ assertTrue(jar2.delete());
}
@Test
@@ -337,4 +346,30 @@
assertEquals("child", readResource(delegateLast, "resource.txt"));
}
+
+ @Test
+ public void testAddDexPath() throws Exception {
+ BaseDexClassLoader bdcl = new PathClassLoader(jar.getPath(),
+ ClassLoader.getSystemClassLoader());
+
+ Class test1Class = bdcl.loadClass("test.Test1");
+ Method testMethod = test1Class.getMethod("test", (Class[]) null);
+ String testResult = (String) testMethod.invoke(null, (Object[]) null);
+ assertEquals("blort", testResult);
+
+ // Just for completeness sake, prove that we were able to load
+ // the class only after addDexPath was called.
+ try {
+ bdcl.loadClass("test2.Target2");
+ fail();
+ } catch (ClassNotFoundException expected) {
+ }
+
+ bdcl.addDexPath(jar2.getPath());
+
+ Class target2Class = bdcl.loadClass("test2.Target2");
+ Method frotzMethod = target2Class.getMethod("frotz", (Class[]) null);
+ String frotzResult = (String) frotzMethod.invoke(null, (Object[]) null);
+ assertEquals("frotz", frotzResult);
+ }
}
diff --git a/luni/src/test/java/libcore/dalvik/system/EmulatedStackFrameTest.java b/luni/src/test/java/libcore/dalvik/system/EmulatedStackFrameTest.java
index 6d61300..c17fad7 100644
--- a/luni/src/test/java/libcore/dalvik/system/EmulatedStackFrameTest.java
+++ b/luni/src/test/java/libcore/dalvik/system/EmulatedStackFrameTest.java
@@ -113,6 +113,23 @@
assertEquals("foo", reader.nextReference(String.class));
}
+ public void testReaderWriter_assignableTypes() {
+ EmulatedStackFrame stackFrame = EmulatedStackFrame.create(
+ MethodType.methodType(Object.class, Object.class));
+
+ EmulatedStackFrame.StackFrameWriter writer = new EmulatedStackFrame.StackFrameWriter();
+ writer.attach(stackFrame);
+ writer.putNextReference(Boolean.TRUE, Object.class);
+ writer.makeReturnValueAccessor();
+ writer.putNextReference(Boolean.FALSE, Object.class);
+
+ EmulatedStackFrame.StackFrameReader reader = new EmulatedStackFrame.StackFrameReader();
+ reader.attach(stackFrame);
+ assertEquals(Boolean.TRUE, reader.nextReference(Object.class));
+ reader.makeReturnValueAccessor();
+ assertEquals(Boolean.FALSE, reader.nextReference(Object.class));
+ }
+
public void testReaderWriter_wrongTypes() {
EmulatedStackFrame stackFrame = EmulatedStackFrame.create(
MethodType.methodType(boolean.class, String.class));
diff --git a/luni/src/test/java/libcore/java/lang/StringTest.java b/luni/src/test/java/libcore/java/lang/StringTest.java
index c440ebe..395209a 100644
--- a/luni/src/test/java/libcore/java/lang/StringTest.java
+++ b/luni/src/test/java/libcore/java/lang/StringTest.java
@@ -29,7 +29,6 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
-import java.nio.charset.ModifiedUtf8;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.ArrayList;
diff --git a/luni/src/test/java/libcore/java/lang/ThreadTest.java b/luni/src/test/java/libcore/java/lang/ThreadTest.java
index f1d0db6..4e60891 100644
--- a/luni/src/test/java/libcore/java/lang/ThreadTest.java
+++ b/luni/src/test/java/libcore/java/lang/ThreadTest.java
@@ -16,7 +16,13 @@
package libcore.java.lang;
+import dalvik.system.InMemoryDexClassLoader;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
import java.lang.Thread.UncaughtExceptionHandler;
+import java.nio.ByteBuffer;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.LockSupport;
@@ -28,6 +34,7 @@
import org.mockito.InOrder;
import org.mockito.Mockito;
+import libcore.io.Streams;
import libcore.java.lang.ref.FinalizationTester;
public final class ThreadTest extends TestCase {
@@ -137,6 +144,85 @@
assertSame(Thread.currentThread().getContextClassLoader(), other.getContextClassLoader());
}
+ public void testSetPriority_unstarted() throws Exception {
+ Thread thread = new Thread();
+ checkSetPriority_inBounds_succeeds(thread);
+ checkSetPriority_outOfBounds_fails(thread);
+ }
+
+ public void testSetPriority_starting() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ Thread thread = new Thread("starting thread") {
+ @Override public void run() { try { latch.await(); } catch (Exception e) { } }
+ };
+ // priority set while thread was not started should carry over to started thread
+ int priority = thread.getPriority() + 1;
+ if (priority > Thread.MAX_PRIORITY) {
+ priority = Thread.MIN_PRIORITY;
+ }
+ thread.setPriority(priority);
+ thread.start();
+ assertEquals(priority, thread.getPriority());
+ latch.countDown();
+ thread.join();
+ }
+
+ public void testSetPriority_started() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ Thread startedThread = new Thread("started thread") {
+ @Override public void run() { try { latch.await(); } catch (Exception e) { } }
+ };
+ startedThread.start();
+ checkSetPriority_inBounds_succeeds(startedThread);
+ checkSetPriority_outOfBounds_fails(startedThread);
+ latch.countDown();
+ startedThread.join();
+ }
+
+ public void testSetPriority_joined() throws Exception {
+ Thread joinedThread = new Thread();
+ joinedThread.start();
+ joinedThread.join();
+
+ int originalPriority = joinedThread.getPriority();
+ for (int p = Thread.MIN_PRIORITY; p <= Thread.MAX_PRIORITY; p++) {
+ joinedThread.setPriority(p);
+ // setting the priority of a not-alive Thread should not succeed
+ assertEquals(originalPriority, joinedThread.getPriority());
+ }
+ checkSetPriority_outOfBounds_fails(joinedThread);
+ }
+
+ private static void checkSetPriority_inBounds_succeeds(Thread thread) {
+ int oldPriority = thread.getPriority();
+ try {
+ for (int priority = Thread.MIN_PRIORITY; priority <= Thread.MAX_PRIORITY; priority++) {
+ thread.setPriority(priority);
+ assertEquals(priority, thread.getPriority());
+ }
+ } finally {
+ thread.setPriority(oldPriority);
+ }
+ assertEquals(oldPriority, thread.getPriority());
+ }
+
+ private static void checkSetPriority_outOfBounds_fails(Thread thread) {
+ checkSetPriority_outOfBounds_fails(thread, Thread.MIN_PRIORITY - 1);
+ checkSetPriority_outOfBounds_fails(thread, Thread.MAX_PRIORITY + 1);
+ checkSetPriority_outOfBounds_fails(thread, Integer.MIN_VALUE);
+ checkSetPriority_outOfBounds_fails(thread, Integer.MAX_VALUE);
+ }
+
+ private static void checkSetPriority_outOfBounds_fails(Thread thread, int invalidPriority) {
+ int oldPriority = thread.getPriority();
+ try {
+ thread.setPriority(invalidPriority);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(oldPriority, thread.getPriority()); // priority shouldn't have changed
+ }
+
public void testUncaughtExceptionPreHandler_calledBeforeDefaultHandler() {
UncaughtExceptionHandler initialHandler = Mockito.mock(UncaughtExceptionHandler.class);
UncaughtExceptionHandler defaultHandler = Mockito.mock(UncaughtExceptionHandler.class);
@@ -203,6 +289,84 @@
t1.join();
}
+ /**
+ * Checks that a stacktrace reports the expected debug metadata
+ * (source-filename, line number) hard-coded in a class loaded from
+ * pre-built test resources.
+ */
+ public void testGetStackTrace_debugInfo() throws Exception {
+ StackTraceElement ste = getStackTraceElement("debugInfo");
+
+ // Verify that this StackTraceElement appears as we expect it to
+ // e.g. when an exception is printed.
+ assertEquals("java.lang.ThreadTestHelper.debugInfo(ThreadTestHelper.java:9)",
+ ste.toString());
+
+ // Since we emit debug information for ThreadTestHelper.debugInfo,
+ // the Runtime will symbolicate this frame with the correct file name.
+ assertEquals("ThreadTestHelper.java", ste.getFileName());
+
+ // We explicitly specify this in the test resource.
+ assertEquals(9, ste.getLineNumber());
+ }
+
+ /**
+ * Checks that a stacktrace reports the expected dex PC in place of
+ * a line number when debug info is missing for a method; the method is
+ * declared on a class loaded from pre-built test resources.
+ */
+ public void testGetStackTrace_noDebugInfo() throws Exception {
+ StackTraceElement ste = getStackTraceElement("noDebugInfo");
+
+ // Verify that this StackTraceElement appears as we expect it to
+ // e.g. when an exception is printed.
+ assertEquals("java.lang.ThreadTestHelper.noDebugInfo(Unknown Source:3)", ste.toString());
+
+ // Since we don't have any debug info for this method, the Runtime
+ // doesn't symbolicate this with a file name (even though the
+ // enclosing class may have the file name specified).
+ assertEquals(null, ste.getFileName());
+
+ // In the test resource we emit 3 nops before generating a stack
+ // trace; each nop advances the dex PC by 1 because a nop is a
+ // single code unit wide.
+ assertEquals(3, ste.getLineNumber());
+ }
+
+ /**
+ * Calls the given static method declared on ThreadTestHelper, which
+ * is loaded from precompiled test resources.
+ *
+ * @param methodName either {@quote "debugInfo"} or {@quote "noDebugInfo"}
+ * @return the StackTraceElement corresponding to said method's frame
+ */
+ private static StackTraceElement getStackTraceElement(String methodName) throws Exception {
+ final String className = "java.lang.ThreadTestHelper";
+ byte[] data;
+ try (InputStream is =
+ ThreadTest.class.getClassLoader().getResourceAsStream("core-tests-smali.dex")) {
+ data = Streams.readFullyNoClose(is);
+ }
+ ClassLoader imcl = new InMemoryDexClassLoader(ByteBuffer.wrap(data),
+ ThreadTest.class.getClassLoader());
+ Class<?> helper = imcl.loadClass(className);
+ Method m = helper.getDeclaredMethod(methodName);
+ StackTraceElement[] stes = (StackTraceElement[]) m.invoke(null);
+
+ // The top of the stack trace looks like:
+ // - VMStack.getThreadStackTrace()
+ // - Thread.getStackTrace()
+ // - ThreadTestHelper.createStackTrace()
+ // - ThreadTestHelper.{debugInfo,noDebugInfo}
+ StackTraceElement result = stes[3];
+
+ // Sanity check before we return
+ assertEquals(result.getClassName(), className);
+ assertEquals(result.getMethodName(), methodName);
+ assertFalse(result.isNativeMethod());
+ return result;
+ }
+
public void testGetAllStackTracesIncludesAllGroups() throws Exception {
final AtomicInteger visibleTraces = new AtomicInteger();
ThreadGroup group = new ThreadGroup("1");
diff --git a/luni/src/test/java/libcore/java/lang/ThreadTestHelper.smali b/luni/src/test/java/libcore/java/lang/ThreadTestHelper.smali
new file mode 100644
index 0000000..d55120e
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/ThreadTestHelper.smali
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed 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
+#
+# 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.
+#
+
+# Generated by running the following java through dx/baksmali:
+# package java.lang;
+#
+# public class ThreadTestHelper {
+# static StackTraceElement[] createStackTrace() {
+# return Thread.currentThread().getStackTrace();
+# }
+#
+# static public StackTraceElement[] debugInfo() {
+# return createStackTrace();
+# }
+#
+# static public StackTraceElement[] noDebugInfo() {
+# return createStackTrace();
+# }
+# }
+# Additionally .line / .prologue declarations were removed from noDebugInfo
+# so that no debug info is generated for that method and three nops were
+# introduced so that the stack trace is a little bit more interesting.
+.class public Ljava/lang/ThreadTestHelper;
+.super Ljava/lang/Object;
+.source "ThreadTestHelper.java"
+
+
+# direct methods
+.method public constructor <init>()V
+ .registers 1
+
+ .prologue
+ .line 3
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+
+ return-void
+.end method
+
+.method static createStackTrace()[Ljava/lang/StackTraceElement;
+ .registers 1
+
+ .prologue
+ .line 5
+ invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
+
+ move-result-object v0
+
+ invoke-virtual {v0}, Ljava/lang/Thread;->getStackTrace()[Ljava/lang/StackTraceElement;
+
+ move-result-object v0
+
+ return-object v0
+.end method
+
+.method public static debugInfo()[Ljava/lang/StackTraceElement;
+ .registers 1
+
+ .prologue
+ .line 9
+ invoke-static {}, Ljava/lang/ThreadTestHelper;->createStackTrace()[Ljava/lang/StackTraceElement;
+
+ move-result-object v0
+
+ return-object v0
+.end method
+
+.method public static noDebugInfo()[Ljava/lang/StackTraceElement;
+ .registers 1
+
+ # Removed so this method doesn't have debug info
+ #.prologue
+ #.line 13
+
+ # Added so the stack trace looks more interesting
+ nop
+ nop
+ nop
+ invoke-static {}, Ljava/lang/ThreadTestHelper;->createStackTrace()[Ljava/lang/StackTraceElement;
+
+ move-result-object v0
+
+ return-object v0
+.end method
diff --git a/luni/src/test/java/libcore/java/lang/invoke/ExplicitCastArgumentsTest.java b/luni/src/test/java/libcore/java/lang/invoke/ExplicitCastArgumentsTest.java
new file mode 100644
index 0000000..abc5825
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/invoke/ExplicitCastArgumentsTest.java
@@ -0,0 +1,5724 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.java.lang.invoke;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.WrongMethodTypeException;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class ExplicitCastArgumentsTest {
+ //
+ // Constants for value casts.
+ //
+ private static final Boolean[] BOOLEAN_VALUES = new Boolean[]{ Boolean.TRUE, Boolean.FALSE };
+
+ private static final Byte[] BYTE_VALUES = new Byte[]{
+ Byte.valueOf((byte) 0), Byte.valueOf((byte) 1), Byte.valueOf((byte) 2),
+ Byte.valueOf((byte) -1), Byte.valueOf((byte) -2), Byte.MIN_VALUE, Byte.MAX_VALUE
+ };
+
+ private static final Character[] CHARACTER_VALUES = new Character[]{
+ Character.MIN_VALUE, Character.MAX_VALUE, Character.valueOf('A'), Character.valueOf('B'),
+ };
+
+ private static final Short[] SHORT_VALUES = new Short[]{
+ Short.valueOf((short) 0), Short.valueOf((short) 1), Short.valueOf((short) 130),
+ Short.valueOf((short) -1), Short.valueOf((short) -130), Short.MIN_VALUE, Short.MAX_VALUE
+ };
+
+ private static final Integer[] INTEGER_VALUES = new Integer[]{
+ Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(130), Integer.valueOf(32768),
+ Integer.valueOf(-1), Integer.valueOf(-130), Integer.valueOf(-32769),
+ Integer.MIN_VALUE, Integer.MAX_VALUE
+ };
+
+ private static final Long[] LONG_VALUES = new Long[]{
+ Long.valueOf(0L), Long.valueOf(1L), Long.valueOf(130L), Long.valueOf(32768L),
+ Long.valueOf(0x800000000L), Long.valueOf(0x800000001L),
+ Long.valueOf(-1l), Long.valueOf(-130l), Long.valueOf(-32769l), Long.valueOf(-0x800000000L),
+ Long.valueOf(-0x800000001L), Long.MIN_VALUE, Long.MAX_VALUE
+ };
+
+ private static final Float[] FLOAT_VALUES = new Float[]{
+ Float.valueOf(0.0f), Float.valueOf(0.5f), Float.valueOf(1.0f), Float.valueOf(2.0f),
+ Float.valueOf(3.141f), Float.valueOf(-0.5f), Float.valueOf(-1.0f), Float.valueOf(-2.0f),
+ Float.valueOf(-3.141f), Float.MIN_VALUE, Float.MAX_VALUE
+ };
+
+ private static final Double[] DOUBLE_VALUES = new Double[]{
+ Double.valueOf(0.0), Double.valueOf(0.5), Double.valueOf(1.0), Double.valueOf(2.0),
+ Double.valueOf(3.141), Double.valueOf(-0.5), Double.valueOf(-1.0), Double.valueOf(-2.0),
+ Double.valueOf(-3.141), Double.MIN_VALUE, Double.MAX_VALUE,
+ };
+
+ // Conversions to boolean for explicitCastArgument().
+ private static boolean toBooleanValue(byte v) { return (v & 1) != 0; }
+ private static boolean toBooleanValue(char v) { return toBooleanValue((byte) v); }
+ private static boolean toBooleanValue(short v) { return toBooleanValue((byte) v); }
+ private static boolean toBooleanValue(int v) { return toBooleanValue((byte) v); }
+ private static boolean toBooleanValue(long v) { return toBooleanValue((byte) v); }
+ private static boolean toBooleanValue(float v) { return toBooleanValue((long) v); }
+ private static boolean toBooleanValue(double v) { return toBooleanValue((long) v); }
+
+ // Conversions from boolean for explicitCastArgument().
+ private static byte byteFromBooleanValue(boolean v) { return v ? (byte) 1 : (byte) 0; }
+ private static char charFromBooleanValue(boolean v) { return v ? (char) 1 : (char) 0; }
+ private static short shortFromBooleanValue(boolean v) { return v ? (short) 1 : (short) 0; }
+ private static int intFromBooleanValue(boolean v) { return v ? 1 : 0; }
+ private static long longFromBooleanValue(boolean v) { return v ? 1L : 0L; }
+ private static float floatFromBooleanValue(boolean v) { return v ? 1.0f : 0.0f; }
+ private static double doubleFromBooleanValue(boolean v) { return v ? 1.0 : 0.0; }
+
+ // Helper constructing a MethodHandle of type (identityClass, argClass) for testing
+ // explicit casts applied to the argument of the MethodHandle invocation.
+ private static MethodHandle explicitCastArgumentToIdentity(Class identityClass,
+ Class argClass) {
+ MethodHandle identity = MethodHandles.identity(identityClass);
+ MethodType mt = MethodType.methodType(identityClass, argClass);
+ return MethodHandles.explicitCastArguments(identity, mt);
+ }
+
+ // Helper constructing a MethodHandle of type (argClass, identity) for testing
+ // explicit casts applied to the return value from the MethodHandle invocation.
+ private static MethodHandle explicitCastReturnValueFromIdentity(Class identityClass,
+ Class retClass) {
+ MethodHandle identity = MethodHandles.identity(identityClass);
+ MethodType mt = MethodType.methodType(retClass, identityClass);
+ return MethodHandles.explicitCastArguments(identity, mt);
+ }
+
+ // Helper for constructing a typed null constant with aan explicit cast to a primitive
+ // type.
+ private static MethodHandle nullConstantExplicitCastToPrimitive(Class constantType,
+ Class primitiveType) {
+ return MethodHandles.explicitCastArguments(MethodHandles.constant(constantType, null),
+ MethodType.methodType(primitiveType));
+ }
+
+ // Helper returning void.
+ public static void voidFunction() {
+ }
+
+ // Helper for constructing an explicit cast from void to type return value.
+ private static MethodHandle explicitCastVoidReturnValue(Class toType) throws Throwable {
+ MethodHandle m =
+ MethodHandles.publicLookup().findStatic(ExplicitCastArgumentsTest.class,
+ "voidFunction",
+ MethodType.methodType(void.class));
+ return MethodHandles.explicitCastArguments(m, MethodType.methodType(toType));
+ }
+
+ // Helper classes and interfaces for reference checks.
+ interface ParentInterface {
+ public static String name = "ParentInterface";
+ }
+
+ interface ChildInterface {
+ public static String name = "ChildInterface";
+ }
+
+ class Parent implements ParentInterface {}
+
+ class Child extends Parent implements ChildInterface {}
+
+ // Explicit casting of arguments and return values for reference types.
+ @Test
+ public void explicitCastArgumentParentToChild() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Child.class, Parent.class);
+ try {
+ Child c = (Child) mh.invokeExact(new Parent());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentNullParentToChild() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Child.class, Parent.class);
+ Child c = (Child) mh.invokeExact((Parent) null);
+ assertNull(c);
+ }
+
+ @Test
+ public void explicitCastArgumentChildToParent() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Parent.class, Child.class);
+ Parent p = (Parent) mh.invokeExact(new Child());
+ assertTrue(p instanceof Child);
+ }
+
+ @Test
+ public void explicitCastArgumentNullChildToParent() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Parent.class, Child.class);
+ Parent p = (Parent) mh.invokeExact((Child) null);
+ assertNull(p);
+ }
+
+ @Test
+ public void explicitCastReturnValueNullParentToChild() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Parent.class, Child.class);
+ Child c = (Child) mh.invokeExact((Parent) null);
+ assertNull(c);
+ }
+
+ @Test
+ public void explicitCastReturnValueParentToChild() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Parent.class, Child.class);
+ try {
+ Child c = (Child) mh.invokeExact(new Parent());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueNullChildToParent() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Child.class, Parent.class);
+ Parent p = (Parent) mh.invokeExact((Child) null);
+ assertNull(p);
+ }
+
+ @Test
+ public void explicitCastReturnValueChildToParent() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Child.class, Parent.class);
+ Parent x = (Parent) mh.invokeExact(new Child());
+ assertTrue(x instanceof Child);
+ }
+
+ @Test
+ public void explicitCastArgumentOfInterfaceType_doesNotThrow() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(ParentInterface.class, Parent.class);
+ ParentInterface pi = (ParentInterface) mh.invokeExact(new Parent());
+ assertTrue(pi instanceof ParentInterface);
+ pi = (ParentInterface) mh.invokeExact((Parent) null);
+ assertNull(pi);
+
+ MethodHandle mh1 = explicitCastArgumentToIdentity(ParentInterface.class, Child.class);
+ pi = (ParentInterface) mh1.invokeExact(new Child());
+ assertTrue(pi instanceof ParentInterface);
+ pi = (ParentInterface) mh1.invokeExact((Child) null);
+ assertNull(pi);
+
+ MethodHandle mh2 = explicitCastArgumentToIdentity(ParentInterface.class, Integer.class);
+ pi = (ParentInterface) mh2.invokeExact(Integer.valueOf(3));
+ assertFalse(pi instanceof ParentInterface);
+ pi = (ParentInterface) mh2.invokeExact((Integer) null);
+ assertNull(pi);
+ }
+
+ @Test
+ public void explicitCastReturnValueOfInterfaceType_doesNotThrow() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Parent.class,
+ ParentInterface.class);
+ ParentInterface pi = (ParentInterface) mh.invokeExact(new Parent());
+ assertTrue(pi instanceof ParentInterface);
+ pi = (ParentInterface) mh.invokeExact((Parent) null);
+ assertNull(pi);
+
+ MethodHandle mh1 = explicitCastReturnValueFromIdentity(Child.class,
+ ParentInterface.class);
+ pi = (ParentInterface) mh1.invokeExact(new Child());
+ assertTrue(pi instanceof ParentInterface);
+ pi = (ParentInterface) mh1.invokeExact((Child) null);
+ assertNull(pi);
+
+ MethodHandle mh2 = explicitCastReturnValueFromIdentity(Integer.class,
+ ParentInterface.class);
+ pi = (ParentInterface) mh2.invokeExact(Integer.valueOf(42));
+ assertFalse(pi instanceof ParentInterface);
+ pi = (ParentInterface) mh2.invokeExact((Integer) null);
+ assertNull(pi);
+ }
+
+ @Test
+ public void originalTypeAndNewTypeEqual() throws Throwable {
+ MethodHandle mh = MethodHandles.identity(Integer.class);
+ assertEquals(mh, MethodHandles.explicitCastArguments(mh, mh.type()));
+ assertEquals(mh,
+ MethodHandles.explicitCastArguments(mh,
+ MethodType.methodType(Integer.class,
+ Integer.class)));
+ }
+
+ //
+ // Explicit casting of arguments between the primitive types and their
+ // reference type counterparts.
+ //
+ @Test
+ public void explicitCastArgumentZToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(v, (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(byteFromBooleanValue(v), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(charFromBooleanValue(v), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(shortFromBooleanValue(v), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(intFromBooleanValue(v), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(longFromBooleanValue(v), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(floatFromBooleanValue(v), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(doubleFromBooleanValue(v), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(Boolean.valueOf(v), (Boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentZToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, boolean.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentZToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, boolean.class);
+ try {
+ Character o = (Character) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentZToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, boolean.class);
+ try {
+ Short o = (Short) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentZToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, boolean.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentZToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, boolean.class);
+ try {
+ Long o = (Long) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentZToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, boolean.class);
+ try {
+ Float o = (Float) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentZToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, boolean.class);
+ try {
+ Double o = (Double) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals(v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, byte.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals(Byte.valueOf(v), (Byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, byte.class);
+ try {
+ Character o = (Character) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, byte.class);
+ try {
+ Short o = (Short) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, byte.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, byte.class);
+ try {
+ Long o = (Long) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, byte.class);
+ try {
+ Float o = (Float) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, byte.class);
+ try {
+ Double o = (Double) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals(v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, char.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, char.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals(Character.valueOf(v), (Character) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, char.class);
+ try {
+ Short o = (Short) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, char.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, char.class);
+ try {
+ Long o = (Long) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, char.class);
+ try {
+ Float o = (Float) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, char.class);
+ try {
+ Double o = (Double) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals(v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, short.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, short.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, short.class);
+ try {
+ Character o = (Character) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals(Short.valueOf(v), (Short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentSToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, short.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, short.class);
+ try {
+ Long o = (Long) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, short.class);
+ try {
+ Float o = (Float) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentSToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, short.class);
+ try {
+ Double o = (Double) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals(v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, int.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, int.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, int.class);
+ try {
+ Character o = (Character) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, int.class);
+ try {
+ Short o = (Short) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals(Integer.valueOf(v), (Integer) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, int.class);
+ try {
+ Long o = (Long) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, int.class);
+ try {
+ Float o = (Float) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, int.class);
+ try {
+ Double o = (Double) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals(v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, long.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, long.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, long.class);
+ try {
+ Character o = (Character) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, long.class);
+ try {
+ Short o = (Short) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, long.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals(Long.valueOf(v), (Long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentJToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, long.class);
+ try {
+ Float o = (Float) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentJToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, long.class);
+ try {
+ Double o = (Double) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals(v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, float.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, float.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, float.class);
+ try {
+ Character o = (Character) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, float.class);
+ try {
+ Short o = (Short) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, float.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, float.class);
+ try {
+ Long o = (Long) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals(Float.valueOf(v), (Float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, float.class);
+ try {
+ Double o = (Double) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals(v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, double.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, double.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, double.class);
+ try {
+ Character o = (Character) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, double.class);
+ try {
+ Short o = (Short) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, double.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, double.class);
+ try {
+ Long o = (Long) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, double.class);
+ try {
+ Float o = (Float) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals(Double.valueOf(v), (Double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(v.booleanValue(), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(byteFromBooleanValue(v.booleanValue()), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(charFromBooleanValue(v.booleanValue()), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(shortFromBooleanValue(v.booleanValue()), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(intFromBooleanValue(v.booleanValue()), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(longFromBooleanValue(v.booleanValue()), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(floatFromBooleanValue(v.booleanValue()), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(doubleFromBooleanValue(v.booleanValue()), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(v, (Boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Boolean.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Boolean.class);
+ try {
+ Character o = (Character) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Boolean.class);
+ try {
+ Short o = (Short) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Boolean.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Boolean.class);
+ try {
+ Long o = (Long) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Boolean.class);
+ try {
+ Float o = (Float) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentBooleanToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Boolean.class);
+ try {
+ Double o = (Double) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals(toBooleanValue(v.byteValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals(v.byteValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((char) v.byteValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((short) v.byteValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((int) v.byteValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((long) v.byteValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((float) v.byteValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((double) v.byteValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Byte.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals(v, (Byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentByteToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Byte.class);
+ try {
+ Character o = (Character) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Byte.class);
+ try {
+ Short o = (Short) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Byte.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Byte.class);
+ try {
+ Long o = (Long) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Byte.class);
+ try {
+ Float o = (Float) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentByteToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Byte.class);
+ try {
+ Double o = (Double) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals(toBooleanValue(v.charValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((byte) v.charValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals(v.charValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((short) v.charValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((int) v.charValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((long) v.charValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((float) v.charValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((double) v.charValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Character.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Character.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals(v, (Character) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Character.class);
+ try {
+ Short o = (Short) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Character.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Character.class);
+ try {
+ Long o = (Long) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Character.class);
+ try {
+ Float o = (Float) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentCharacterToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Character.class);
+ try {
+ Double o = (Double) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals(toBooleanValue(v.shortValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((byte) v.shortValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((char) v.shortValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals(v.shortValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((int) v.shortValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((long) v.shortValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((float) v.shortValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((double) v.shortValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Short.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Short.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Short.class);
+ try {
+ Character o = (Character) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals(v, (Short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentShortToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Short.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Short.class);
+ try {
+ Long o = (Long) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Short.class);
+ try {
+ Float o = (Float) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentShortToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Short.class);
+ try {
+ Double o = (Double) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals(toBooleanValue(v.intValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((byte) v.intValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((char) v.intValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((short) v.intValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals(v.intValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((long) v.intValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((float) v.intValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((double) v.intValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Integer.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Integer.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Integer.class);
+ try {
+ Character o = (Character) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Integer.class);
+ try {
+ Short o = (Short) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals(v, (Integer) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Integer.class);
+ try {
+ Long o = (Long) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Integer.class);
+ try {
+ Float o = (Float) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentIntegerToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Integer.class);
+ try {
+ Double o = (Double) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals(toBooleanValue(v.longValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((byte) v.longValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((char) v.longValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((short) v.longValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((int) v.longValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals(v.longValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((float) v.longValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((double) v.longValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Long.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Long.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Long.class);
+ try {
+ Character o = (Character) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Long.class);
+ try {
+ Short o = (Short) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Long.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals(v, (Long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentLongToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Long.class);
+ try {
+ Float o = (Float) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentLongToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Long.class);
+ try {
+ Double o = (Double) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals(toBooleanValue(v.floatValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((byte) v.floatValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((char) v.floatValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((short) v.floatValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((int) v.floatValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((long) v.floatValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals(v.floatValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((double) v.floatValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Float.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Float.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Float.class);
+ try {
+ Character o = (Character) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Float.class);
+ try {
+ Short o = (Short) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Float.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Float.class);
+ try {
+ Long o = (Long) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals(v, (Float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentFloatToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Float.class);
+ try {
+ Double o = (Double) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToZ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(boolean.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals(toBooleanValue(v.doubleValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToB() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(byte.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((byte) v.doubleValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToC() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(char.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((char) v.doubleValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToS() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(short.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((short) v.doubleValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToI() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(int.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((int) v.doubleValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToJ() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(long.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((long) v.doubleValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToF() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(float.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((float) v.doubleValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToD() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(double.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals(v.doubleValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Boolean.class, Double.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToByte() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Byte.class, Double.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Character.class, Double.class);
+ try {
+ Character o = (Character) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToShort() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Short.class, Double.class);
+ try {
+ Short o = (Short) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToInteger() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Integer.class, Double.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToLong() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Long.class, Double.class);
+ try {
+ Long o = (Long) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToFloat() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Float.class, Double.class);
+ try {
+ Float o = (Float) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastArgumentDoubleToDouble() throws Throwable {
+ MethodHandle mh = explicitCastArgumentToIdentity(Double.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals(v, (Double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ //
+ // Explicit casting of return values between the primitive types and their
+ // reference type counterparts.
+ //
+ @Test
+ public void explicitCastReturnValueZToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(v, (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, boolean.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, boolean.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, boolean.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, boolean.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, boolean.class);
+ for (long v : LONG_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, boolean.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, boolean.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals(toBooleanValue(v), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(v.booleanValue(), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, boolean.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals(toBooleanValue(v.byteValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, boolean.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals(toBooleanValue(v.charValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, boolean.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals(toBooleanValue(v.shortValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, boolean.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals(toBooleanValue(v.intValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, boolean.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals(toBooleanValue(v.longValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, boolean.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals(toBooleanValue(v.floatValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToZ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, boolean.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals(toBooleanValue(v.doubleValue()), (boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, byte.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(byteFromBooleanValue(v), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals(v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, byte.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, byte.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, byte.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, byte.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, byte.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, byte.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((byte) v, (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, byte.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(byteFromBooleanValue(v.booleanValue()), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals(v.byteValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, byte.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((byte) v.charValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, byte.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((byte) v.shortValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, byte.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((byte) v.intValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, byte.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((byte) v.longValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, byte.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((byte) v.floatValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToB() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, byte.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((byte) v.doubleValue(), (byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, char.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(charFromBooleanValue(v), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, char.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, char.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals(v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, char.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, char.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, char.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, char.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, char.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((char) v, (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, char.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(charFromBooleanValue(v.booleanValue()), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, char.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((char) v.byteValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, char.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals(v.charValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, char.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((char) v.shortValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, char.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((char) v.intValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, char.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((char) v.longValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, char.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((char) v.floatValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToC() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, char.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((char) v.doubleValue(), (char) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, short.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(shortFromBooleanValue(v), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, short.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, short.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals(v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, short.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, short.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, short.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, short.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((short) v, (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, short.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(shortFromBooleanValue(v.booleanValue()), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, short.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((short) v.byteValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, short.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((short) v.charValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals(v.shortValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, short.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((short) v.intValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, short.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((short) v.longValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, short.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((short) v.floatValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToS() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, short.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((short) v.doubleValue(), (short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, int.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(intFromBooleanValue(v), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, int.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, int.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, int.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, int.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals(v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, int.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, int.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, int.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((int) v, (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, int.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(intFromBooleanValue(v.booleanValue()), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, int.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((int) v.byteValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, int.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((int) v.charValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, int.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((int) v.shortValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, int.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals(v.intValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, int.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((int) v.longValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, int.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((int) v.floatValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToI() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, int.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((int) v.doubleValue(), (int) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, long.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(longFromBooleanValue(v), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, long.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, long.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, long.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, long.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals(v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, long.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, long.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((long) v, (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, long.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(longFromBooleanValue(v.booleanValue()), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, long.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((long) v.byteValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, long.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((long) v.charValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, long.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((long) v.shortValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, long.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((long) v.intValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals(v.longValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, long.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((long) v.floatValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToJ() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, long.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((long) v.doubleValue(), (long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, float.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(floatFromBooleanValue(v), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, float.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, float.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, float.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, float.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, float.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals(v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, float.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals((float) v, (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, float.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(floatFromBooleanValue(v.booleanValue()), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, float.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((float) v.byteValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, float.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((float) v.charValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, float.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((float) v.shortValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, float.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((float) v.intValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, float.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((float) v.longValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals(v.floatValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToF() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, float.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals((float) v.doubleValue(), (float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, double.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(doubleFromBooleanValue(v), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, double.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, double.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, double.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, double.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, double.class);
+ for (long v : LONG_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, double.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals((double) v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals(v, (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, double.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(doubleFromBooleanValue(v.booleanValue()), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, double.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals((double) v.byteValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, double.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals((double) v.charValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, double.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals((double) v.shortValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, double.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals((double) v.intValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, double.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals((double) v.longValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, double.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals((double) v.floatValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToD() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals(v.doubleValue(), (double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueZToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Boolean.class);
+ for (boolean v : BOOLEAN_VALUES) {
+ assertEquals(Boolean.valueOf(v), (Boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Boolean.class);
+ for (Boolean v : BOOLEAN_VALUES) {
+ assertEquals(v, (Boolean) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToBoolean() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Boolean.class);
+ try {
+ Boolean o = (Boolean) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Byte.class);
+ for (byte v : BYTE_VALUES) {
+ assertEquals(Byte.valueOf(v), (Byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Byte.class);
+ for (Byte v : BYTE_VALUES) {
+ assertEquals(v, (Byte) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToByte() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Byte.class);
+ try {
+ Byte o = (Byte) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Character.class);
+ for (char v : CHARACTER_VALUES) {
+ assertEquals(Character.valueOf(v), (Character) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueSToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Character.class);
+ for (Character v : CHARACTER_VALUES) {
+ assertEquals(v, (Character) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToCharacter() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Character.class);
+ try {
+ Character o = (Character) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Short.class);
+ for (short v : SHORT_VALUES) {
+ assertEquals(Short.valueOf(v), (Short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Short.class);
+ for (Short v : SHORT_VALUES) {
+ assertEquals(v, (Short) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToShort() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Short.class);
+ try {
+ Short o = (Short) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Integer.class);
+ for (int v : INTEGER_VALUES) {
+ assertEquals(Integer.valueOf(v), (Integer) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueJToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Integer.class);
+ for (Integer v : INTEGER_VALUES) {
+ assertEquals(v, (Integer) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToInteger() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Integer.class);
+ try {
+ Integer o = (Integer) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Long.class);
+ for (long v : LONG_VALUES) {
+ assertEquals(Long.valueOf(v), (Long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Long.class);
+ for (Long v : LONG_VALUES) {
+ assertEquals(v, (Long) mh.invokeExact(v));
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToLong() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Long.class);
+ try {
+ Long o = (Long) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Float.class);
+ for (float v : FLOAT_VALUES) {
+ assertEquals(Float.valueOf(v), (Float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(DOUBLE_VALUES[0].doubleValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Float.class);
+ for (Float v : FLOAT_VALUES) {
+ assertEquals(v, (Float) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToFloat() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Float.class);
+ try {
+ Float o = (Float) mh.invokeExact(DOUBLE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueZToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(boolean.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(BOOLEAN_VALUES[0].booleanValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueBToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(byte.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(BYTE_VALUES[0].byteValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(char.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(CHARACTER_VALUES[0].charValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueSToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(short.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(SHORT_VALUES[0].shortValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(int.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(INTEGER_VALUES[0].intValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueJToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(long.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(LONG_VALUES[0].longValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(float.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(FLOAT_VALUES[0].floatValue());
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(double.class, Double.class);
+ for (double v : DOUBLE_VALUES) {
+ assertEquals(Double.valueOf(v), (Double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ @Test
+ public void explicitCastReturnValueBooleanToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Boolean.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(BOOLEAN_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueByteToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Byte.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(BYTE_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueCharacterToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Character.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(CHARACTER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueShortToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Short.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(SHORT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueIntegerToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Integer.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(INTEGER_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueLongToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Long.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(LONG_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueFloatToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Float.class, Double.class);
+ try {
+ Double o = (Double) mh.invokeExact(FLOAT_VALUES[0]);
+ fail("Expected CCE");
+ } catch (ClassCastException expected) {}
+ }
+
+ @Test
+ public void explicitCastReturnValueDoubleToDouble() throws Throwable {
+ MethodHandle mh = explicitCastReturnValueFromIdentity(Double.class, Double.class);
+ for (Double v : DOUBLE_VALUES) {
+ assertEquals(v, (Double) mh.invokeExact(v), 0.0);
+ }
+ }
+
+ //
+ // Explicit casting of null valued arguments to primitive type values
+ // (zero/false).
+ //
+ @Test
+ public void nullBooleanArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Boolean.class);
+ assertEquals(false, (boolean) m.invokeExact((Boolean) null));
+ }
+
+ @Test
+ public void nullBooleanArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Boolean.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Boolean) null));
+ }
+
+ @Test
+ public void nullBooleanArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Boolean.class);
+ assertEquals((char) 0, (char) m.invokeExact((Boolean) null));
+ }
+
+ @Test
+ public void nullBooleanArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Boolean.class);
+ assertEquals((short) 0, (short) m.invokeExact((Boolean) null));
+ }
+
+ @Test
+ public void nullBooleanArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Boolean.class);
+ assertEquals((int) 0, (int) m.invokeExact((Boolean) null));
+ }
+
+ @Test
+ public void nullBooleanArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Boolean.class);
+ assertEquals((long) 0, (long) m.invokeExact((Boolean) null));
+ }
+
+ @Test
+ public void nullBooleanArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Boolean.class);
+ assertEquals((float) 0, (float) m.invokeExact((Boolean) null), 0.0);
+ }
+
+ @Test
+ public void nullBooleanArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Boolean.class);
+ assertEquals((double) 0, (double) m.invokeExact((Boolean) null), 0.0);
+ }
+
+ @Test
+ public void nullByteArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Byte.class);
+ assertEquals(false, (boolean) m.invokeExact((Byte) null));
+ }
+
+ @Test
+ public void nullByteArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Byte) null));
+ }
+
+ @Test
+ public void nullByteArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Byte.class);
+ assertEquals((char) 0, (char) m.invokeExact((Byte) null));
+ }
+
+ @Test
+ public void nullByteArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Byte.class);
+ assertEquals((short) 0, (short) m.invokeExact((Byte) null));
+ }
+
+ @Test
+ public void nullByteArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Byte.class);
+ assertEquals((int) 0, (int) m.invokeExact((Byte) null));
+ }
+
+ @Test
+ public void nullByteArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Byte.class);
+ assertEquals((long) 0, (long) m.invokeExact((Byte) null));
+ }
+
+ @Test
+ public void nullByteArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Byte.class);
+ assertEquals((float) 0, (float) m.invokeExact((Byte) null), 0.0);
+ }
+
+ @Test
+ public void nullByteArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Byte.class);
+ assertEquals((double) 0, (double) m.invokeExact((Byte) null), 0.0);
+ }
+
+ @Test
+ public void nullCharacterArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Character.class);
+ assertEquals(false, (boolean) m.invokeExact((Character) null));
+ }
+
+ @Test
+ public void nullCharacterArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Character.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Character) null));
+ }
+
+ @Test
+ public void nullCharacterArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Character.class);
+ assertEquals((char) 0, (char) m.invokeExact((Character) null));
+ }
+
+ @Test
+ public void nullCharacterArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Character.class);
+ assertEquals((short) 0, (short) m.invokeExact((Character) null));
+ }
+
+ @Test
+ public void nullCharacterArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Character.class);
+ assertEquals((int) 0, (int) m.invokeExact((Character) null));
+ }
+
+ @Test
+ public void nullCharacterArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Character.class);
+ assertEquals((long) 0, (long) m.invokeExact((Character) null));
+ }
+
+ @Test
+ public void nullCharacterArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Character.class);
+ assertEquals((float) 0, (float) m.invokeExact((Character) null), 0.0);
+ }
+
+ @Test
+ public void nullCharacterArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Character.class);
+ assertEquals((double) 0, (double) m.invokeExact((Character) null), 0.0);
+ }
+
+ @Test
+ public void nullShortArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Short.class);
+ assertEquals(false, (boolean) m.invokeExact((Short) null));
+ }
+
+ @Test
+ public void nullShortArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Short.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Short) null));
+ }
+
+ @Test
+ public void nullShortArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Short.class);
+ assertEquals((char) 0, (char) m.invokeExact((Short) null));
+ }
+
+ @Test
+ public void nullShortArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Short.class);
+ assertEquals((short) 0, (short) m.invokeExact((Short) null));
+ }
+
+ @Test
+ public void nullShortArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Short.class);
+ assertEquals((int) 0, (int) m.invokeExact((Short) null));
+ }
+
+ @Test
+ public void nullShortArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Short.class);
+ assertEquals((long) 0, (long) m.invokeExact((Short) null));
+ }
+
+ @Test
+ public void nullShortArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Short.class);
+ assertEquals((float) 0, (float) m.invokeExact((Short) null), 0.0);
+ }
+
+ @Test
+ public void nullShortArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Short.class);
+ assertEquals((double) 0, (double) m.invokeExact((Short) null), 0.0);
+ }
+
+ @Test
+ public void nullIntegerArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Integer.class);
+ assertEquals(false, (boolean) m.invokeExact((Integer) null));
+ }
+
+ @Test
+ public void nullIntegerArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Integer.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Integer) null));
+ }
+
+ @Test
+ public void nullIntegerArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Integer.class);
+ assertEquals((char) 0, (char) m.invokeExact((Integer) null));
+ }
+
+ @Test
+ public void nullIntegerArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Integer.class);
+ assertEquals((short) 0, (short) m.invokeExact((Integer) null));
+ }
+
+ @Test
+ public void nullIntegerArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Integer.class);
+ assertEquals((int) 0, (int) m.invokeExact((Integer) null));
+ }
+
+ @Test
+ public void nullIntegerArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Integer.class);
+ assertEquals((long) 0, (long) m.invokeExact((Integer) null));
+ }
+
+ @Test
+ public void nullIntegerArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Integer.class);
+ assertEquals((float) 0, (float) m.invokeExact((Integer) null), 0.0);
+ }
+
+ @Test
+ public void nullIntegerArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Integer.class);
+ assertEquals((double) 0, (double) m.invokeExact((Integer) null), 0.0);
+ }
+
+ @Test
+ public void nullLongArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Long.class);
+ assertEquals(false, (boolean) m.invokeExact((Long) null));
+ }
+
+ @Test
+ public void nullLongArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Long.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Long) null));
+ }
+
+ @Test
+ public void nullLongArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Long.class);
+ assertEquals((char) 0, (char) m.invokeExact((Long) null));
+ }
+
+ @Test
+ public void nullLongArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Long.class);
+ assertEquals((short) 0, (short) m.invokeExact((Long) null));
+ }
+
+ @Test
+ public void nullLongArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Long.class);
+ assertEquals((int) 0, (int) m.invokeExact((Long) null));
+ }
+
+ @Test
+ public void nullLongArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Long.class);
+ assertEquals((long) 0, (long) m.invokeExact((Long) null));
+ }
+
+ @Test
+ public void nullLongArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Long.class);
+ assertEquals((float) 0, (float) m.invokeExact((Long) null), 0.0);
+ }
+
+ @Test
+ public void nullLongArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Long.class);
+ assertEquals((double) 0, (double) m.invokeExact((Long) null), 0.0);
+ }
+
+ @Test
+ public void nullFloatArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Float.class);
+ assertEquals(false, (boolean) m.invokeExact((Float) null));
+ }
+
+ @Test
+ public void nullFloatArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Float.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Float) null));
+ }
+
+ @Test
+ public void nullFloatArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Float.class);
+ assertEquals((char) 0, (char) m.invokeExact((Float) null));
+ }
+
+ @Test
+ public void nullFloatArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Float.class);
+ assertEquals((short) 0, (short) m.invokeExact((Float) null));
+ }
+
+ @Test
+ public void nullFloatArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Float.class);
+ assertEquals((int) 0, (int) m.invokeExact((Float) null));
+ }
+
+ @Test
+ public void nullFloatArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Float.class);
+ assertEquals((long) 0, (long) m.invokeExact((Float) null));
+ }
+
+ @Test
+ public void nullFloatArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Float.class);
+ assertEquals((float) 0, (float) m.invokeExact((Float) null), 0.0);
+ }
+
+ @Test
+ public void nullFloatArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Float.class);
+ assertEquals((double) 0, (double) m.invokeExact((Float) null), 0.0);
+ }
+
+ @Test
+ public void nullDoubleArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Double.class);
+ assertEquals(false, (boolean) m.invokeExact((Double) null));
+ }
+
+ @Test
+ public void nullDoubleArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Double.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Double) null));
+ }
+
+ @Test
+ public void nullDoubleArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Double.class);
+ assertEquals((char) 0, (char) m.invokeExact((Double) null));
+ }
+
+ @Test
+ public void nullDoubleArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Double.class);
+ assertEquals((short) 0, (short) m.invokeExact((Double) null));
+ }
+
+ @Test
+ public void nullDoubleArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Double.class);
+ assertEquals((int) 0, (int) m.invokeExact((Double) null));
+ }
+
+ @Test
+ public void nullDoubleArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Double.class);
+ assertEquals((long) 0, (long) m.invokeExact((Double) null));
+ }
+
+ @Test
+ public void nullDoubleArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Double.class);
+ assertEquals((float) 0, (float) m.invokeExact((Double) null), 0.0);
+ }
+
+ @Test
+ public void nullDoubleArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Double.class);
+ assertEquals((double) 0, (double) m.invokeExact((Double) null), 0.0);
+ }
+
+ @Test
+ public void nullObjectArgumentToZ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(boolean.class, Object.class);
+ assertEquals(false, (boolean) m.invokeExact((Object) null));
+ }
+
+ @Test
+ public void nullObjectArgumentToB() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(byte.class, Object.class);
+ assertEquals((byte) 0, (byte) m.invokeExact((Object) null));
+ }
+
+ @Test
+ public void nullObjectArgumentToC() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(char.class, Object.class);
+ assertEquals((char) 0, (char) m.invokeExact((Object) null));
+ }
+
+ @Test
+ public void nullObjectArgumentToS() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(short.class, Object.class);
+ assertEquals((short) 0, (short) m.invokeExact((Object) null));
+ }
+
+ @Test
+ public void nullObjectArgumentToI() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(int.class, Object.class);
+ assertEquals((int) 0, (int) m.invokeExact((Object) null));
+ }
+
+ @Test
+ public void nullObjectArgumentToJ() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(long.class, Object.class);
+ assertEquals((long) 0, (long) m.invokeExact((Object) null));
+ }
+
+ @Test
+ public void nullObjectArgumentToF() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(float.class, Object.class);
+ assertEquals((float) 0, (float) m.invokeExact((Object) null), 0.0);
+ }
+
+ @Test
+ public void nullObjectArgumentToD() throws Throwable {
+ MethodHandle m = explicitCastArgumentToIdentity(double.class, Object.class);
+ assertEquals((double) 0, (double) m.invokeExact((Object) null), 0.0);
+ }
+
+ //
+ // Explicit casting of null valued return values to primitive type values
+ // (zero/false).
+ //
+ @Test
+ public void returnValueNullBooleanToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullBooleanToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullBooleanToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullBooleanToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullBooleanToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullBooleanToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullBooleanToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullBooleanToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Boolean.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullByteToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullByteToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullByteToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullByteToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullByteToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullByteToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullByteToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullByteToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Byte.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullCharacterToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullCharacterToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullCharacterToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullCharacterToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullCharacterToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullCharacterToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullCharacterToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullCharacterToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Character.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullShortToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullShortToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullShortToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullShortToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullShortToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullShortToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullShortToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullShortToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Short.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullIntegerToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullIntegerToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullIntegerToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullIntegerToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullIntegerToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullIntegerToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullIntegerToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullIntegerToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Integer.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullLongToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullLongToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullLongToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullLongToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullLongToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullLongToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullLongToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullLongToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Long.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullFloatToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullFloatToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullFloatToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullFloatToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullFloatToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullFloatToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullFloatToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullFloatToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Float.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullDoubleToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullDoubleToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullDoubleToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullDoubleToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullDoubleToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullDoubleToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullDoubleToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullDoubleToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Double.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullObjectToZ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, boolean.class);
+ assertEquals(false, (boolean) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullObjectToB() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, byte.class);
+ assertEquals((byte) 0, (byte) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullObjectToC() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, char.class);
+ assertEquals((char) 0, (char) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullObjectToS() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, short.class);
+ assertEquals((short) 0, (short) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullObjectToI() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, int.class);
+ assertEquals((int) 0, (int) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullObjectToJ() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, long.class);
+ assertEquals((long) 0, (long) m.invokeExact());
+ }
+
+ @Test
+ public void returnValueNullObjectToF() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, float.class);
+ assertEquals((float) 0, (float) m.invokeExact(), 0.0);
+ }
+
+ @Test
+ public void returnValueNullObjectToD() throws Throwable
+ {
+ MethodHandle m = nullConstantExplicitCastToPrimitive(Object.class, double.class);
+ assertEquals((double) 0, (double) m.invokeExact(), 0.0);
+ }
+
+ //
+ // Check asType() behaviour of void return value cast to primitives yields
+ // zero/false/null.
+ //
+ @Test
+ public void testVoidReturnToZ() throws Throwable {
+ assertFalse((boolean) explicitCastVoidReturnValue(boolean.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToB() throws Throwable {
+ assertEquals((byte) 0, (byte) explicitCastVoidReturnValue(byte.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToC() throws Throwable {
+ assertEquals((char) 0, (char) explicitCastVoidReturnValue(char.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToS() throws Throwable {
+ assertEquals((short) 0, (short) explicitCastVoidReturnValue(short.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToI() throws Throwable {
+ assertEquals((int) 0, (int) explicitCastVoidReturnValue(int.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToJ() throws Throwable {
+ assertEquals((long) 0, (long) explicitCastVoidReturnValue(long.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToF() throws Throwable {
+ assertEquals((float) 0, (float) explicitCastVoidReturnValue(float.class).invokeExact(), 0.0);
+ }
+
+ @Test
+ public void testVoidReturnToD() throws Throwable {
+ assertEquals((double) 0, (double) explicitCastVoidReturnValue(double.class).invokeExact(), 0.0);
+ }
+
+ @Test
+ public void testVoidReturnToBoolean() throws Throwable {
+ assertNull((Boolean) explicitCastVoidReturnValue(Boolean.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToByte() throws Throwable {
+ assertNull((Byte) explicitCastVoidReturnValue(Byte.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToCharacter() throws Throwable {
+ assertNull((Character) explicitCastVoidReturnValue(Character.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToShort() throws Throwable {
+ assertNull((Short) explicitCastVoidReturnValue(Short.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToInteger() throws Throwable {
+ assertNull((Integer) explicitCastVoidReturnValue(Integer.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToLong() throws Throwable {
+ assertNull((Long) explicitCastVoidReturnValue(Long.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToFloat() throws Throwable {
+ assertNull((Float) explicitCastVoidReturnValue(Float.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToDouble() throws Throwable {
+ assertNull((Double) explicitCastVoidReturnValue(Double.class).invokeExact());
+ }
+
+ @Test
+ public void testVoidReturnToObject() throws Throwable {
+ assertNull((Object) explicitCastVoidReturnValue(Object.class).invokeExact());
+ }
+
+ //
+ // Check asType() behaviour of returning a value cast to void.
+ //
+ @Test
+ public void testReturnZToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(boolean.class, void.class);
+ m.invokeExact((boolean) BOOLEAN_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnBToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(byte.class, void.class);
+ m.invokeExact((byte) BYTE_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnCToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(char.class, void.class);
+ m.invokeExact((char) CHARACTER_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnSToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(short.class, void.class);
+ m.invokeExact((short) SHORT_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnIToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(int.class, void.class);
+ m.invokeExact((int) INTEGER_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnJToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(long.class, void.class);
+ m.invokeExact((long) LONG_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnFToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(float.class, void.class);
+ m.invokeExact((float) FLOAT_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnDToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(double.class, void.class);
+ m.invokeExact((double) DOUBLE_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnBooleanToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Boolean.class, void.class);
+ m.invokeExact((Boolean) BOOLEAN_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnByteToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Byte.class, void.class);
+ m.invokeExact((Byte) BYTE_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnCharacterToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Character.class, void.class);
+ m.invokeExact((Character) CHARACTER_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnShortToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Short.class, void.class);
+ m.invokeExact((Short) SHORT_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnIntegerToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Integer.class, void.class);
+ m.invokeExact((Integer) INTEGER_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnLongToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Long.class, void.class);
+ m.invokeExact((Long) LONG_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnFloatToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Float.class, void.class);
+ m.invokeExact((Float) FLOAT_VALUES[0]);
+ }
+
+ @Test
+ public void testReturnDoubleToVoid() throws Throwable {
+ MethodHandle m = explicitCastReturnValueFromIdentity(Double.class, void.class);
+ m.invokeExact((Double) DOUBLE_VALUES[0]);
+ }
+
+}
diff --git a/luni/src/test/java/libcore/java/math/BigIntegerTest.java b/luni/src/test/java/libcore/java/math/BigIntegerTest.java
index 80041c2..6c1d11e 100644
--- a/luni/src/test/java/libcore/java/math/BigIntegerTest.java
+++ b/luni/src/test/java/libcore/java/math/BigIntegerTest.java
@@ -195,4 +195,35 @@
assertEquals("-9223372036854775808", negV.toString());
assertEquals( "9223372036854775808", posV.toString());
}
+
+ private void try_gcd_variants(BigInteger arg1, BigInteger arg2, BigInteger result)
+ throws Exception {
+ // Test both argument orders, and all 4 combinations of negation.
+ assertEquals(arg1.gcd(arg2), result);
+ assertEquals(arg2.gcd(arg1), result);
+ assertEquals(arg1.negate().gcd(arg2), result);
+ assertEquals(arg2.gcd(arg1.negate()), result);
+ assertEquals(arg1.gcd(arg2.negate()), result);
+ assertEquals(arg2.negate().gcd(arg1), result);
+ assertEquals(arg1.negate().gcd(arg2.negate()), result);
+ assertEquals(arg2.negate().gcd(arg1.negate()), result);
+ }
+
+ /**
+ * Test gcd(), with emphasis on arguments of very different size.
+ */
+ public void test_gcd() throws Exception {
+ BigInteger two = BigInteger.valueOf(2); // BigInteger.TWO added in OpenJDK 9
+ BigInteger three = BigInteger.valueOf(3);
+ try_gcd_variants(BigInteger.TEN, two, two);
+ try_gcd_variants(BigInteger.TEN, BigInteger.TEN, BigInteger.TEN);
+ try_gcd_variants(BigInteger.TEN, BigInteger.ZERO, BigInteger.TEN);
+ try_gcd_variants(BigInteger.ZERO, BigInteger.ZERO, BigInteger.ZERO);
+ BigInteger large = three.shiftLeft(500);
+ try_gcd_variants(large, three, three);
+ try_gcd_variants(large, large, large);
+ try_gcd_variants(large, two, two);
+ try_gcd_variants(large, BigInteger.valueOf(5), BigInteger.ONE);
+ try_gcd_variants(large, BigInteger.ZERO, large);
+ }
}
diff --git a/luni/src/test/java/libcore/java/net/InetAddressTest.java b/luni/src/test/java/libcore/java/net/InetAddressTest.java
index 88f03d4..6bbfe01 100644
--- a/luni/src/test/java/libcore/java/net/InetAddressTest.java
+++ b/luni/src/test/java/libcore/java/net/InetAddressTest.java
@@ -282,10 +282,17 @@
public void test_isReachable_by_ICMP() throws Exception {
InetAddress[] inetAddresses = InetAddress.getAllByName("www.google.com");
for (InetAddress ia : inetAddresses) {
- // ICMP is not reliable, allow 5 attempts before failing.
- assertTrue(ia.isReachableByICMP(5 * 1000 /* ICMP timeout */));
+ // ICMP is not reliable, allow 5 attempts to each IP address before failing.
+ // If any address is reachable then that's sufficient.
+ if (ia.isReachableByICMP(5 * 1000 /* ICMP timeout */)) {
+ return;
+ }
}
+ fail();
+ }
+ @Test
+ public void test_inUnreachable() throws Exception {
// IPv6 discard prefix. RFC 6666.
final InetAddress blackholeAddress = InetAddress.getByName("100::1");
assertFalse(blackholeAddress.isReachable(1000));
diff --git a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
index 51c8b04..0547462 100644
--- a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
+++ b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
@@ -16,8 +16,8 @@
package libcore.java.net;
-import junit.framework.TestCase;
+import android.system.StructIfaddrs;
import java.io.BufferedReader;
import java.io.FileDescriptor;
import java.io.InputStreamReader;
@@ -29,6 +29,7 @@
import java.net.MulticastSocket;
import java.net.NetworkInterface;
import java.net.SocketException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
@@ -37,6 +38,11 @@
import java.util.regex.Pattern;
import libcore.io.IoUtils;
import libcore.io.Libcore;
+import libcore.junit.junit3.TestCaseWithRules;
+import libcore.junit.util.SwitchTargetSdkVersionRule;
+import libcore.junit.util.SwitchTargetSdkVersionRule.TargetSdkVersion;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.IFF_LOOPBACK;
@@ -47,7 +53,10 @@
import static android.system.OsConstants.SOCK_DGRAM;
import static java.net.NetworkInterface.getNetworkInterfaces;
-public class NetworkInterfaceTest extends TestCase {
+public class NetworkInterfaceTest extends TestCaseWithRules {
+ @Rule
+ public TestRule switchTargetSdkVersionRule = SwitchTargetSdkVersionRule.getInstance();
+
// http://code.google.com/p/android/issues/detail?id=13784
private final static int ARPHRD_ETHER = 1; // from if_arp.h
public void testIPv6() throws Exception {
@@ -100,7 +109,6 @@
}
// Ethernet
if (isEthernet(nif.getName())) {
- assertEquals(6, nif.getHardwareAddress().length);
for (InterfaceAddress ia : nif.getInterfaceAddresses()) {
if (ia.getAddress() instanceof Inet4Address) {
assertNotNull(ia.getBroadcast());
@@ -110,6 +118,24 @@
}
}
+ @TargetSdkVersion(29)
+ public void testGetHardwareAddress_compat_returnsHardwareAddress() throws Exception {
+ // Ensure apps with a targetSdk version <= 29 are able to access the MAC address of ethernet
+ // devices.
+ for (NetworkInterface nif : Collections.list(getNetworkInterfaces())) {
+ if (isEthernet(nif.getName())) {
+ assertEquals(6, nif.getHardwareAddress().length);
+ }
+ }
+ }
+
+ public void testGetHardwareAddress_returnsNull() throws Exception {
+ // Hardware addresses should be unavailable to non-system apps.
+ for (NetworkInterface nif : Collections.list(getNetworkInterfaces())) {
+ assertNull(nif.getHardwareAddress());
+ }
+ }
+
public void testLoopback() throws Exception {
NetworkInterface lo = NetworkInterface.getByName("lo");
assertNull(lo.getHardwareAddress());
@@ -201,31 +227,16 @@
} catch(SocketException expected) {}
}
- // b/29243557
- public void testGetNetworkInterfaces() throws Exception {
- // Check that the interfaces we get from #getNetworkInterfaces agrees with IP-LINK(8).
+ public void testGetNetworkInterfaces_matchesIfaddrs() throws Exception {
+ StructIfaddrs[] ifaddrs = Libcore.os.getifaddrs();
+ Set<String> ifaddrsNames = new HashSet<>();
+ Arrays.asList(ifaddrs).forEach(ifa -> ifaddrsNames.add(ifa.ifa_name));
- // Parse output of ip link.
- String[] cmd = { "ip", "link" };
- Process proc = Runtime.getRuntime().exec(cmd);
- BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- Set<String> expectedNiNames = new HashSet<>();
- for (String s; (s = stdInput.readLine()) != null; ) {
- String[] split = s.split(": |@");
- try {
- if (split.length > 2) {
- expectedNiNames.add(split[1]);
- }
- } catch (NumberFormatException e) {
- // Skip this line.
- }
- }
-
- Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
+ List<NetworkInterface> nifs = Collections.list(NetworkInterface.getNetworkInterfaces());
Set<String> actualNiNames = new HashSet<>();
- Collections.list(nifs).forEach(ni -> actualNiNames.add(ni.getName()));
+ nifs.forEach(ni -> actualNiNames.add(ni.getName()));
- assertEquals(expectedNiNames, actualNiNames);
+ assertEquals(ifaddrsNames, actualNiNames);
}
// Calling getSubInterfaces on interfaces with no subinterface should not throw NPE.
diff --git a/luni/src/test/java/libcore/java/net/OldSocketTest.java b/luni/src/test/java/libcore/java/net/OldSocketTest.java
index 8a577fb..644fe52 100644
--- a/luni/src/test/java/libcore/java/net/OldSocketTest.java
+++ b/luni/src/test/java/libcore/java/net/OldSocketTest.java
@@ -20,6 +20,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.net.BindException;
import java.net.ConnectException;
import java.net.Inet4Address;
@@ -37,6 +39,7 @@
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.SocketChannel;
import java.security.Permission;
+import java.util.concurrent.atomic.AtomicReference;
import libcore.junit.util.ResourceLeakageDetector.DisableResourceLeakageDetection;
import tests.support.Support_Configuration;
@@ -1266,39 +1269,37 @@
}
}
- @DisableResourceLeakageDetection(
- why = "Strange threading behavior causes resource leak",
- bug = "31820278")
public void test_connectLjava_net_SocketAddressI_setSOTimeout() throws Exception {
+ final AtomicReference<Exception> exceptionRef = new AtomicReference<>();
+
class SocketConnector extends Thread {
+ private final int timeout;
+ private final Socket theSocket;
+ private final SocketAddress address;
- int timeout = 0;
-
- Socket theSocket = null;
-
- SocketAddress address = null;
-
+ @Override
public void run() {
try {
theSocket.connect(address, timeout);
} catch (Exception e) {
+ exceptionRef.set(e);
}
-
- return;
}
- public SocketConnector(int timeout, Socket theSocket,
- SocketAddress address) {
+ private SocketConnector(int timeout, Socket theSocket, SocketAddress address) {
this.timeout = timeout;
this.theSocket = theSocket;
this.address = address;
}
}
- // now try to set options while we are connecting
- SocketAddress nonReachableAddress = UNREACHABLE_ADDRESS;
- try (Socket theSocket = new Socket()) {
- SocketConnector connector = new SocketConnector(5000, theSocket, nonReachableAddress);
+ // Now try to set options while we are connecting
+ try (final Socket theSocket = new Socket()) {
+ // Force SocketImpl creation to prevent race between connect() and setSoTimeout()
+ // creating it. b/144258500
+ theSocket.getSoTimeout();
+ final SocketConnector connector
+ = new SocketConnector(5000, theSocket, UNREACHABLE_ADDRESS);
connector.start();
theSocket.setSoTimeout(1000);
Thread.sleep(10);
@@ -1308,10 +1309,21 @@
theSocket.setSoTimeout(2000);
assertTrue("Socket option not set during connect: 50 ",
Math.abs(2000 - theSocket.getSoTimeout()) <= 10);
- Thread.sleep(5000);
+ connector.join();
+ Exception e = exceptionRef.get();
+ if (!(e instanceof SocketTimeoutException)) {
+ fail(printStackTraceToString(e));
+ }
}
}
+ private String printStackTraceToString(Throwable throwable) {
+ StringWriter writer = new StringWriter();
+ throwable.printStackTrace(new PrintWriter(writer));
+ return writer.toString();
+ }
+
+
public void test_isInputShutdown() throws IOException {
Socket theSocket = new Socket();
ServerSocket serverSocket = new ServerSocket(0, 5);
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
index a272a37..ddd447a 100644
--- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
@@ -16,6 +16,9 @@
package libcore.java.net;
+import com.android.okhttp.AndroidShimResponseCache;
+import com.android.okhttp.internal.Platform;
+import com.android.okhttp.internal.tls.TrustRootIndex;
import com.google.mockwebserver.Dispatcher;
import com.google.mockwebserver.MockResponse;
import com.google.mockwebserver.MockWebServer;
@@ -23,11 +26,9 @@
import com.google.mockwebserver.RecordedRequest;
import com.google.mockwebserver.SocketPolicy;
-import com.android.okhttp.AndroidShimResponseCache;
-import com.android.okhttp.internal.Platform;
-import com.android.okhttp.internal.tls.TrustRootIndex;
-
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -88,6 +89,7 @@
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
+import libcore.content.type.MimeMap;
import libcore.java.security.TestKeyStore;
import libcore.javax.net.ssl.TestSSLContext;
import libcore.testing.io.TestIoUtils;
@@ -98,23 +100,26 @@
import static com.google.mockwebserver.SocketPolicy.SHUTDOWN_INPUT_AT_END;
import static com.google.mockwebserver.SocketPolicy.SHUTDOWN_OUTPUT_AT_END;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-public final class URLConnectionTest extends TestCase {
+public final class URLConnectionTest {
private MockWebServer server;
private AndroidShimResponseCache cache;
private String hostName;
private List<TestSSLContext> testSSLContextsToClose;
- @Override protected void setUp() throws Exception {
- super.setUp();
+ @Before public void setUp() throws Exception {
server = new MockWebServer();
hostName = server.getHostName();
testSSLContextsToClose = new ArrayList<>();
}
- @Override protected void tearDown() throws Exception {
+ @After public void tearDown() throws Exception {
ResponseCache.setDefault(null);
Authenticator.setDefault(null);
System.clearProperty("proxyHost");
@@ -132,10 +137,9 @@
for (TestSSLContext testSSLContext : testSSLContextsToClose) {
testSSLContext.close();
}
- super.tearDown();
}
- public void testRequestHeaderValidation() throws Exception {
+ @Test public void requestHeaderValidation() throws Exception {
// Android became more strict after M about which characters were allowed in request header
// names and values: previously almost anything was allowed if it didn't contain \0.
@@ -228,7 +232,7 @@
return urlConnection.getRequestProperty("key");
}
- public void testRequestHeaders() throws IOException, InterruptedException {
+ @Test public void requestHeaders() throws IOException, InterruptedException {
server.enqueue(new MockResponse());
server.play();
@@ -291,7 +295,7 @@
}
}
- public void testGetRequestPropertyReturnsLastValue() throws Exception {
+ @Test public void getRequestPropertyReturnsLastValue() throws Exception {
server.play();
HttpURLConnection urlConnection = (HttpURLConnection) server.getUrl("/").openConnection();
urlConnection.addRequestProperty("A", "value1");
@@ -299,7 +303,7 @@
assertEquals("value2", urlConnection.getRequestProperty("A"));
}
- public void testResponseHeaders() throws IOException, InterruptedException {
+ @Test public void responseHeaders() throws IOException, InterruptedException {
server.enqueue(new MockResponse()
.setStatus("HTTP/1.0 200 Fantastic")
.addHeader("A: c")
@@ -334,14 +338,14 @@
assertEquals("e", urlConnection.getHeaderField(2));
}
- public void testGetErrorStreamOnSuccessfulRequest() throws Exception {
+ @Test public void getErrorStreamOnSuccessfulRequest() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
assertNull(connection.getErrorStream());
}
- public void testGetErrorStreamOnUnsuccessfulRequest() throws Exception {
+ @Test public void getErrorStreamOnUnsuccessfulRequest() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404).setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -351,7 +355,7 @@
// Check that if we don't read to the end of a response, the next request on the
// recycled connection doesn't get the unread tail of the first request's response.
// http://code.google.com/p/android/issues/detail?id=2939
- public void test_2939() throws Exception {
+ @Test public void bug2939() throws Exception {
MockResponse response = new MockResponse().setChunkedBody("ABCDE\nFGHIJ\nKLMNO\nPQR", 8);
server.enqueue(response);
@@ -364,12 +368,12 @@
// Check that we recognize a few basic mime types by extension.
// http://code.google.com/p/android/issues/detail?id=10100
- public void test_10100() throws Exception {
+ @Test public void bug10100() throws Exception {
assertEquals("image/jpeg", URLConnection.guessContentTypeFromName("someFile.jpg"));
assertEquals("application/pdf", URLConnection.guessContentTypeFromName("stuff.pdf"));
}
- public void testConnectionsArePooled() throws Exception {
+ @Test public void connectionsArePooled() throws Exception {
MockResponse response = new MockResponse().setBody("ABCDEFGHIJKLMNOPQR");
server.enqueue(response);
@@ -385,7 +389,7 @@
assertEquals(2, server.takeRequest().getSequenceNumber());
}
- public void testChunkedConnectionsArePooled() throws Exception {
+ @Test public void chunkedConnectionsArePooled() throws Exception {
MockResponse response = new MockResponse().setChunkedBody("ABCDEFGHIJKLMNOPQR", 5);
server.enqueue(response);
@@ -405,7 +409,7 @@
* Test that connections are added to the pool as soon as the response has
* been consumed.
*/
- public void testConnectionsArePooledWithoutExplicitDisconnect() throws Exception {
+ @Test public void connectionsArePooledWithoutExplicitDisconnect() throws Exception {
server.enqueue(new MockResponse().setBody("ABC"));
server.enqueue(new MockResponse().setBody("DEF"));
server.play();
@@ -418,11 +422,11 @@
assertEquals(1, server.takeRequest().getSequenceNumber());
}
- public void testServerClosesSocket() throws Exception {
+ @Test public void serverClosesSocket() throws Exception {
testServerClosesSocket(DISCONNECT_AT_END);
}
- public void testServerShutdownInput() throws Exception {
+ @Test public void serverShutdownInput() throws Exception {
testServerClosesSocket(SHUTDOWN_INPUT_AT_END);
}
@@ -440,7 +444,7 @@
assertEquals(0, server.takeRequest().getSequenceNumber());
}
- public void testServerShutdownOutput() throws Exception {
+ @Test public void serverShutdownOutput() throws Exception {
// This test causes MockWebServer to log a "connection failed" stack trace
// Setting the server workerThreads to 1 ensures the responses are generated in the order
@@ -464,27 +468,27 @@
enum WriteKind { BYTE_BY_BYTE, SMALL_BUFFERS, LARGE_BUFFERS }
- public void test_chunkedUpload_byteByByte() throws Exception {
+ @Test public void chunkedUpload_byteByByte() throws Exception {
doUpload(TransferKind.CHUNKED, WriteKind.BYTE_BY_BYTE);
}
- public void test_chunkedUpload_smallBuffers() throws Exception {
+ @Test public void chunkedUpload_smallBuffers() throws Exception {
doUpload(TransferKind.CHUNKED, WriteKind.SMALL_BUFFERS);
}
- public void test_chunkedUpload_largeBuffers() throws Exception {
+ @Test public void chunkedUpload_largeBuffers() throws Exception {
doUpload(TransferKind.CHUNKED, WriteKind.LARGE_BUFFERS);
}
- public void test_fixedLengthUpload_byteByByte() throws Exception {
+ @Test public void fixedLengthUpload_byteByByte() throws Exception {
doUpload(TransferKind.FIXED_LENGTH, WriteKind.BYTE_BY_BYTE);
}
- public void test_fixedLengthUpload_smallBuffers() throws Exception {
+ @Test public void fixedLengthUpload_smallBuffers() throws Exception {
doUpload(TransferKind.FIXED_LENGTH, WriteKind.SMALL_BUFFERS);
}
- public void test_fixedLengthUpload_largeBuffers() throws Exception {
+ @Test public void fixedLengthUpload_largeBuffers() throws Exception {
doUpload(TransferKind.FIXED_LENGTH, WriteKind.LARGE_BUFFERS);
}
@@ -525,7 +529,7 @@
}
}
- public void testGetResponseCodeNoResponseBody() throws Exception {
+ @Test public void getResponseCodeNoResponseBody() throws Exception {
server.enqueue(new MockResponse()
.addHeader("abc: def"));
server.play();
@@ -542,7 +546,11 @@
}
}
- public void testConnectViaHttps() throws IOException, InterruptedException {
+ @Test public void connectViaHttps() throws IOException, InterruptedException {
+ checkConnectViaHttps();
+ }
+
+ private void checkConnectViaHttps() throws IOException, InterruptedException {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
@@ -559,7 +567,7 @@
assertEquals("TLSv1.2", request.getSslProtocol());
}
- public void testConnectViaHttpsReusingConnections() throws IOException, InterruptedException {
+ @Test public void connectViaHttpsReusingConnections() throws IOException, InterruptedException {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
SSLSocketFactory clientSocketFactory = testSSLContext.clientContext.getSocketFactory();
@@ -580,7 +588,7 @@
assertEquals(1, server.takeRequest().getSequenceNumber());
}
- public void testConnectViaHttpsReusingConnectionsDifferentFactories()
+ @Test public void connectViaHttpsReusingConnectionsDifferentFactories()
throws IOException, InterruptedException {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
@@ -607,7 +615,7 @@
*
* http://code.google.com/p/android/issues/detail?id=13178
*/
- public void testConnectViaHttpsToUntrustedServer() throws IOException, InterruptedException {
+ @Test public void connectViaHttpsToUntrustedServer() throws IOException, InterruptedException {
TestSSLContext testSSLContext = TestSSLContext.create(TestKeyStore.getClientCA2(),
TestKeyStore.getServer());
testSSLContextsToClose.add(testSSLContext);
@@ -627,29 +635,29 @@
assertEquals(0, server.getRequestCount());
}
- public void testConnectViaProxy_emptyPath() throws Exception {
+ @Test public void connectViaProxy_emptyPath() throws Exception {
// expected normalization http://android -> http://android/ per b/30107354
checkConnectViaProxy(
ProxyConfig.HTTP_PROXY_SYSTEM_PROPERTY, "http://android.com",
"http://android.com/", "android.com");
}
- public void testConnectViaProxy_complexUrlWithNoPath() throws Exception {
+ @Test public void connectViaProxy_complexUrlWithNoPath() throws Exception {
checkConnectViaProxy(ProxyConfig.HTTP_PROXY_SYSTEM_PROPERTY,
"http://android.com:8080?height=100&width=42",
"http://android.com:8080/?height=100&width=42",
"android.com:8080");
}
- public void testConnectViaProxyUsingProxyArg() throws Exception {
+ @Test public void connectViaProxyUsingProxyArg() throws Exception {
checkConnectViaProxy(ProxyConfig.CREATE_ARG);
}
- public void testConnectViaProxyUsingProxySystemProperty() throws Exception {
+ @Test public void connectViaProxyUsingProxySystemProperty() throws Exception {
checkConnectViaProxy(ProxyConfig.PROXY_SYSTEM_PROPERTY);
}
- public void testConnectViaProxyUsingHttpProxySystemProperty() throws Exception {
+ @Test public void connectViaProxyUsingHttpProxySystemProperty() throws Exception {
checkConnectViaProxy(ProxyConfig.HTTP_PROXY_SYSTEM_PROPERTY);
}
@@ -673,7 +681,7 @@
assertContains(request.getHeaders(), "Host: " + expectedHost);
}
- public void testContentDisagreesWithContentLengthHeader() throws IOException {
+ @Test public void contentDisagreesWithContentLengthHeader() throws IOException {
server.enqueue(new MockResponse()
.setBody("abc\r\nYOU SHOULD NOT SEE THIS")
.clearHeaders()
@@ -683,7 +691,7 @@
assertContent("abc", server.getUrl("/").openConnection());
}
- public void testContentDisagreesWithChunkedHeader() throws IOException {
+ @Test public void contentDisagreesWithChunkedHeader() throws IOException {
MockResponse mockResponse = new MockResponse();
mockResponse.setChunkedBody("abc", 3);
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
@@ -699,16 +707,16 @@
assertContent("abc", server.getUrl("/").openConnection());
}
- public void testConnectViaHttpProxyToHttpsUsingProxyArgWithNoProxy() throws Exception {
- testConnectViaDirectProxyToHttps(ProxyConfig.NO_PROXY);
+ @Test public void connectViaHttpProxyToHttpsUsingProxyArgWithNoProxy() throws Exception {
+ checkConnectViaDirectProxyToHttps(ProxyConfig.NO_PROXY);
}
- public void testConnectViaHttpProxyToHttpsUsingHttpProxySystemProperty() throws Exception {
+ @Test public void connectViaHttpProxyToHttpsUsingHttpProxySystemProperty() throws Exception {
// https should not use http proxy
- testConnectViaDirectProxyToHttps(ProxyConfig.HTTP_PROXY_SYSTEM_PROPERTY);
+ checkConnectViaDirectProxyToHttps(ProxyConfig.HTTP_PROXY_SYSTEM_PROPERTY);
}
- private void testConnectViaDirectProxyToHttps(ProxyConfig proxyConfig) throws Exception {
+ private void checkConnectViaDirectProxyToHttps(ProxyConfig proxyConfig) throws Exception {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
@@ -726,27 +734,27 @@
}
- public void testConnectViaHttpProxyToHttpsUsingProxyArg() throws Exception {
- testConnectViaHttpProxyToHttps(ProxyConfig.CREATE_ARG);
+ @Test public void connectViaHttpProxyToHttpsUsingProxyArg() throws Exception {
+ checkConnectViaHttpProxyToHttps(ProxyConfig.CREATE_ARG);
}
/**
* We weren't honoring all of the appropriate proxy system properties when
* connecting via HTTPS. http://b/3097518
*/
- public void testConnectViaHttpProxyToHttpsUsingProxySystemProperty() throws Exception {
- testConnectViaHttpProxyToHttps(ProxyConfig.PROXY_SYSTEM_PROPERTY);
+ @Test public void connectViaHttpProxyToHttpsUsingProxySystemProperty() throws Exception {
+ checkConnectViaHttpProxyToHttps(ProxyConfig.PROXY_SYSTEM_PROPERTY);
}
- public void testConnectViaHttpProxyToHttpsUsingHttpsProxySystemProperty() throws Exception {
- testConnectViaHttpProxyToHttps(ProxyConfig.HTTPS_PROXY_SYSTEM_PROPERTY);
+ @Test public void connectViaHttpProxyToHttpsUsingHttpsProxySystemProperty() throws Exception {
+ checkConnectViaHttpProxyToHttps(ProxyConfig.HTTPS_PROXY_SYSTEM_PROPERTY);
}
/**
* We were verifying the wrong hostname when connecting to an HTTPS site
* through a proxy. http://b/3097277
*/
- private void testConnectViaHttpProxyToHttps(ProxyConfig proxyConfig) throws Exception {
+ private void checkConnectViaHttpProxyToHttps(ProxyConfig proxyConfig) throws Exception {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
RecordingHostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
@@ -779,7 +787,8 @@
/**
* Tolerate bad https proxy response when using HttpResponseCache. http://b/6754912
*/
- public void testConnectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache() throws Exception {
+ @Test public void connectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache()
+ throws Exception {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
initResponseCache();
@@ -820,7 +829,7 @@
* Test Etag headers are returned correctly when a client-side cache is not installed.
* https://code.google.com/p/android/issues/detail?id=108949
*/
- public void testEtagHeaders_uncached() throws Exception {
+ @Test public void etagHeaders_uncached() throws Exception {
final String etagValue1 = "686897696a7c876b7e";
final String body1 = "Response with etag 1";
final String etagValue2 = "686897696a7c876b7f";
@@ -857,7 +866,7 @@
assertNull(request.getHeader("If-None-Match"));
}
- public void testGetFileNameMap_null() {
+ @Test public void getFileNameMap_null() {
assertThrowsNpe(() -> URLConnection.getFileNameMap().getContentTypeFor(null));
assertThrowsNpe(() -> URLConnection.guessContentTypeFromName(null));
}
@@ -873,22 +882,58 @@
/**
* Checks that paths ending in '/' (directory listings) are identified as HTML.
*/
- public void testGetFileNameMap_directory() {
+ @Test public void getFileNameMap_directory() {
checkFileNameMap("text/html", "/directory/path/");
checkFileNameMap("text/html", "http://example.com/path/");
checkFileNameMap("text/html", "http://example.com/path/#fragment");
}
- public void testGetFileNameMap_simple() {
+ @Test public void getFileNameMap_simple() {
checkFileNameMap("text/plain", "example.txt");
checkFileNameMap("text/plain", "example.com/file.txt");
}
+ @Test public void getFileNameMap_compositeExtension() {
+ checkFileNameMap("text/plain", "example.html.txt"); // html.txt isn't known, but txt is
+ checkFileNameMap("application/x-font-pcf", "filename.pcf.Z"); // pcf.Z is known
+ }
+
+ @Test public void getFileNameMap_compositeExtension_customMimeMap() {
+ MimeMap testMimeMap = MimeMap.builder()
+ .put("text/html", "html")
+ .put("application/gzip", "gz")
+ .put("application/tar+gzip", "tar.gz")
+ .build();
+ MimeMap defaultMimeMap = MimeMap.getDefault();
+ MimeMap.setDefaultSupplier(() -> testMimeMap);
+ try {
+ checkFileNameMap("application/gzip", "filename.gz");
+ checkFileNameMap("application/gzip", "filename.foobar.gz");
+ checkFileNameMap("application/gzip", "filename.html.gz");
+ checkFileNameMap("application/tar+gzip", "filename.tar.gz"); // tar.gz is found
+ } finally {
+ MimeMap.setDefaultSupplier(() -> defaultMimeMap);
+ }
+ }
+
+ /**
+ * Checks that as long as there are no '.' or '/', a file name that matches
+ * a known extension is interpreted as that extension, as if it was preceded by ".".
+ */
+ @Test public void getFileNameMap_plainExtension() {
+ checkFileNameMap("text/plain", "txt");
+ checkFileNameMap("text/plain", "txt#fragment");
+ checkFileNameMap(null, "example.com/txt");
+ checkFileNameMap(null, "example.com/txt#fragment");
+ checkFileNameMap(null, "example/txt");
+ checkFileNameMap(null, "http://example/txt#fragment");
+ }
+
/**
* Checks cases where there's a '.' in the fragment, path or as an earlier path
* of a file name (only the last '.' that is part of the filename should count).
*/
- public void testGetFileNameMap_dotsInOtherPlaces() {
+ @Test public void getFileNameMap_dotsInOtherPlaces() {
// '.' in path
checkFileNameMap("text/html", "example.com/foo.txt/bar.html");
checkFileNameMap("text/plain", "example.com/foo.html/bar.txt");
@@ -904,7 +949,7 @@
checkFileNameMap("text/plain", "/path.html/foo/../readme.html.txt#fragment.html");
}
- public void testGetFileNameMap_multipleHashCharacters() {
+ @Test public void getFileNameMap_multipleHashCharacters() {
// Based on RFC 3986, URLs can only contain a single '#' but android.net.Uri
// considers the fragment to start after the first, rather than the last, '#'.
// We check that FileNameMap cuts off after the first '#', consistent with Uri.
@@ -914,7 +959,7 @@
/**
* Checks that fragments are stripped when determining file extension.
*/
- public void testGetFileNameMap_fragment() {
+ @Test public void getFileNameMap_fragment() {
checkFileNameMap("text/plain", "example.txt#fragment");
checkFileNameMap("text/plain", "example.com/path/example.txt#fragment");
}
@@ -924,7 +969,7 @@
* of file type.
* This matches RI behavior, but it'd be reasonable to change behavior here.
*/
- public void testGetFileNameMap_queryParameter() {
+ @Test public void getFileNameMap_queryParameter() {
checkFileNameMap(null, "example.txt?key=value");
checkFileNameMap(null, "example.txt?key=value#fragment");
}
@@ -943,7 +988,7 @@
* data is unchanged.
* https://code.google.com/p/android/issues/detail?id=108949
*/
- public void testEtagHeaders_cachedWithServerHit() throws Exception {
+ @Test public void etagHeaders_cachedWithServerHit() throws Exception {
final String etagValue = "686897696a7c876b7e";
final String body = "Response with etag";
@@ -986,7 +1031,7 @@
* data has changed.
* https://code.google.com/p/android/issues/detail?id=108949
*/
- public void testEtagHeaders_cachedWithServerMiss() throws Exception {
+ @Test public void etagHeaders_cachedWithServerMiss() throws Exception {
final String etagValue1 = "686897696a7c876b7e";
final String body1 = "Response with etag 1";
final String etagValue2 = "686897696a7c876b7f";
@@ -1033,7 +1078,7 @@
/**
* Test which headers are sent unencrypted to the HTTP proxy.
*/
- public void testProxyConnectIncludesProxyHeadersOnly()
+ @Test public void proxyConnectIncludesProxyHeadersOnly()
throws IOException, InterruptedException {
Authenticator.setDefault(new SimpleAuthenticator());
RecordingHostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
@@ -1087,7 +1132,7 @@
assertEquals(Arrays.asList("verify android.com"), hostnameVerifier.calls);
}
- public void testProxyAuthenticateOnConnect() throws Exception {
+ @Test public void proxyAuthenticateOnConnect() throws Exception {
Authenticator.setDefault(new SimpleAuthenticator());
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), true);
@@ -1123,7 +1168,7 @@
// Don't disconnect after building a tunnel with CONNECT
// http://code.google.com/p/android/issues/detail?id=37221
- public void testProxyWithConnectionClose() throws IOException {
+ @Test public void proxyWithConnectionClose() throws IOException {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), true);
server.enqueue(new MockResponse()
@@ -1142,7 +1187,7 @@
assertContent("this response comes via a proxy", connection);
}
- public void testDisconnectedConnection() throws IOException {
+ @Test public void disconnectedConnection() throws IOException {
server.enqueue(new MockResponse()
.throttleBody(2, 100, TimeUnit.MILLISECONDS)
.setBody("ABCD"));
@@ -1162,7 +1207,7 @@
}
}
- public void testDisconnectFromBackgroundThread_blockedRead_beforeHeader()
+ @Test public void disconnectFromBackgroundThread_blockedRead_beforeHeader()
throws IOException {
QueueDispatcher dispatcher = new QueueDispatcher() {
@Override
@@ -1176,7 +1221,7 @@
checkDisconnectFromBackgroundThread_blockedRead(2000, null /* disconnectMillis */);
}
- public void testDisconnectFromBackgroundThread_blockedRead_beforeBody()
+ @Test public void disconnectFromBackgroundThread_blockedRead_beforeBody()
throws IOException {
server.enqueue(new MockResponse().setHeader("Key", "Value")
.setBody("Response body").setBodyDelayTimeMs(6000));
@@ -1187,7 +1232,7 @@
*
* @throws IOException
*/
- public void testDisconnectFromBackgroundThread_blockedRead_duringBody()
+ @Test public void disconnectFromBackgroundThread_blockedRead_duringBody()
throws IOException {
server.enqueue(new MockResponse().setHeader("Key", "Value")
.setBody("Response body").throttleBody(3, 1333, TimeUnit.MILLISECONDS));
@@ -1262,22 +1307,22 @@
// http://b/33763156
- public void testDisconnectDuringConnect_getInputStream() throws IOException {
+ @Test public void disconnectDuringConnect_getInputStream() throws IOException {
checkDisconnectDuringConnect(HttpURLConnection::getInputStream);
}
// http://b/33763156
- public void testDisconnectDuringConnect_getOutputStream() throws IOException {
+ @Test public void disconnectDuringConnect_getOutputStream() throws IOException {
checkDisconnectDuringConnect(HttpURLConnection::getOutputStream);
}
// http://b/33763156
- public void testDisconnectDuringConnect_getResponseCode() throws IOException {
+ @Test public void disconnectDuringConnect_getResponseCode() throws IOException {
checkDisconnectDuringConnect(HttpURLConnection::getResponseCode);
}
// http://b/33763156
- public void testDisconnectDuringConnect_getResponseMessage() throws IOException {
+ @Test public void disconnectDuringConnect_getResponseMessage() throws IOException {
checkDisconnectDuringConnect(HttpURLConnection::getResponseMessage);
}
@@ -1322,7 +1367,7 @@
}
}
- public void testDisconnectBeforeConnect() throws IOException {
+ @Test public void disconnectBeforeConnect() throws IOException {
server.enqueue(new MockResponse().setBody("A"));
server.play();
@@ -1333,7 +1378,7 @@
assertEquals(200, connection.getResponseCode());
}
- public void testDisconnectAfterOnlyResponseCodeCausesNoCloseGuardWarning() throws IOException {
+ @Test public void disconnectAfterOnlyResponseCodeCausesNoCloseGuardWarning() throws IOException {
server.enqueue(new MockResponse()
.setBody(gzip("ABCABCABC".getBytes("UTF-8")))
.addHeader("Content-Encoding: gzip"));
@@ -1347,7 +1392,7 @@
}
}
- public void testDefaultRequestProperty() throws Exception {
+ @Test public void defaultRequestProperty() throws Exception {
URLConnection.setDefaultRequestProperty("X-testSetDefaultRequestProperty", "A");
assertNull(URLConnection.getDefaultRequestProperty("X-setDefaultRequestProperty"));
}
@@ -1374,15 +1419,15 @@
return readAscii(in, Integer.MAX_VALUE);
}
- public void testMarkAndResetWithContentLengthHeader() throws IOException {
+ @Test public void markAndResetWithContentLengthHeader() throws IOException {
testMarkAndReset(TransferKind.FIXED_LENGTH);
}
- public void testMarkAndResetWithChunkedEncoding() throws IOException {
+ @Test public void markAndResetWithChunkedEncoding() throws IOException {
testMarkAndReset(TransferKind.CHUNKED);
}
- public void testMarkAndResetWithNoLengthHeaders() throws IOException {
+ @Test public void markAndResetWithNoLengthHeaders() throws IOException {
testMarkAndReset(TransferKind.END_OF_STREAM);
}
@@ -1411,7 +1456,7 @@
* code 401. This causes a new HTTP request to be issued for every call into
* the URLConnection.
*/
- public void testUnauthorizedResponseHandling() throws IOException {
+ @Test public void unauthorizedResponseHandling() throws IOException {
MockResponse response = new MockResponse()
.addHeader("WWW-Authenticate: Basic realm=\"protected area\"")
.setResponseCode(401) // UNAUTHORIZED
@@ -1430,7 +1475,7 @@
assertEquals(1, server.getRequestCount());
}
- public void testNonHexChunkSize() throws IOException {
+ @Test public void nonHexChunkSize() throws IOException {
server.enqueue(new MockResponse()
.setBody("5\r\nABCDE\r\nG\r\nFGHIJKLMNOPQRSTU\r\n0\r\n\r\n")
.clearHeaders()
@@ -1445,7 +1490,7 @@
}
}
- public void testMissingChunkBody() throws IOException {
+ @Test public void missingChunkBody() throws IOException {
server.enqueue(new MockResponse()
.setBody("5")
.clearHeaders()
@@ -1466,7 +1511,7 @@
* behavior in not required by the API, so a failure of this test does not
* imply a bug in the implementation.
*/
- public void testGzipEncodingEnabledByDefault() throws IOException, InterruptedException {
+ @Test public void gzipEncodingEnabledByDefault() throws IOException, InterruptedException {
server.enqueue(new MockResponse()
.setBody(gzip("ABCABCABC".getBytes("UTF-8")))
.addHeader("Content-Encoding: gzip"));
@@ -1481,7 +1526,7 @@
assertContains(request.getHeaders(), "Accept-Encoding: gzip");
}
- public void testClientConfiguredGzipContentEncoding() throws Exception {
+ @Test public void clientConfiguredGzipContentEncoding() throws Exception {
byte[] bodyBytes = gzip("ABCDEFGHIJKLMNOPQRSTUVWXYZ".getBytes("UTF-8"));
server.enqueue(new MockResponse()
.setBody(bodyBytes)
@@ -1500,15 +1545,15 @@
assertEquals("gzip", connection.getContentEncoding());
}
- public void testGzipAndConnectionReuseWithFixedLength() throws Exception {
+ @Test public void gzipAndConnectionReuseWithFixedLength() throws Exception {
testClientConfiguredGzipContentEncodingAndConnectionReuse(TransferKind.FIXED_LENGTH);
}
- public void testGzipAndConnectionReuseWithChunkedEncoding() throws Exception {
+ @Test public void gzipAndConnectionReuseWithChunkedEncoding() throws Exception {
testClientConfiguredGzipContentEncodingAndConnectionReuse(TransferKind.CHUNKED);
}
- public void testClientConfiguredCustomContentEncoding() throws Exception {
+ @Test public void clientConfiguredCustomContentEncoding() throws Exception {
server.enqueue(new MockResponse()
.setBody("ABCDE")
.addHeader("Content-Encoding: custom"));
@@ -1553,7 +1598,7 @@
* Test that HEAD requests don't have a body regardless of the response
* headers. http://code.google.com/p/android/issues/detail?id=24672
*/
- public void testHeadAndContentLength() throws Exception {
+ @Test public void headAndContentLength() throws Exception {
server.enqueue(new MockResponse()
.clearHeaders()
.addHeader("Content-Length: 100"));
@@ -1579,7 +1624,7 @@
* the fixed chunk size. Instead, we check that chunking takes place
* and we force the chunk size with flushes.
*/
- public void testSetChunkedStreamingMode() throws IOException, InterruptedException {
+ @Test public void setChunkedStreamingMode() throws IOException, InterruptedException {
server.enqueue(new MockResponse());
server.play();
@@ -1606,11 +1651,11 @@
assertEquals(Arrays.asList(3, 3, 2), request.getChunkSizes());
}
- public void testAuthenticateWithFixedLengthStreaming() throws Exception {
+ @Test public void authenticateWithFixedLengthStreaming() throws Exception {
testAuthenticateWithStreamingPost(StreamingMode.FIXED_LENGTH);
}
- public void testAuthenticateWithChunkedStreaming() throws Exception {
+ @Test public void authenticateWithChunkedStreaming() throws Exception {
testAuthenticateWithStreamingPost(StreamingMode.CHUNKED);
}
@@ -1646,7 +1691,7 @@
assertEquals(Arrays.toString(requestBody), Arrays.toString(request.getBody()));
}
- public void testSetValidRequestMethod() throws Exception {
+ @Test public void setValidRequestMethod() throws Exception {
server.play();
assertValidRequestMethod("GET");
assertValidRequestMethod("DELETE");
@@ -1663,12 +1708,12 @@
assertEquals(requestMethod, connection.getRequestMethod());
}
- public void testSetInvalidRequestMethodLowercase() throws Exception {
+ @Test public void setInvalidRequestMethodLowercase() throws Exception {
server.play();
assertInvalidRequestMethod("get");
}
- public void testSetInvalidRequestMethodConnect() throws Exception {
+ @Test public void setInvalidRequestMethodConnect() throws Exception {
server.play();
assertInvalidRequestMethod("CONNECT");
}
@@ -1682,7 +1727,7 @@
}
}
- public void testCannotSetNegativeFixedLengthStreamingMode() throws Exception {
+ @Test public void cannotSetNegativeFixedLengthStreamingMode() throws Exception {
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
try {
@@ -1692,13 +1737,13 @@
}
}
- public void testCanSetNegativeChunkedStreamingMode() throws Exception {
+ @Test public void canSetNegativeChunkedStreamingMode() throws Exception {
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
connection.setChunkedStreamingMode(-2);
}
- public void testCannotSetFixedLengthStreamingModeAfterConnect() throws Exception {
+ @Test public void cannotSetFixedLengthStreamingModeAfterConnect() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -1710,7 +1755,7 @@
}
}
- public void testCannotSetChunkedStreamingModeAfterConnect() throws Exception {
+ @Test public void cannotSetChunkedStreamingModeAfterConnect() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -1722,7 +1767,7 @@
}
}
- public void testCannotSetFixedLengthStreamingModeAfterChunkedStreamingMode() throws Exception {
+ @Test public void cannotSetFixedLengthStreamingModeAfterChunkedStreamingMode() throws Exception {
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
connection.setChunkedStreamingMode(1);
@@ -1733,7 +1778,8 @@
}
}
- public void testCannotSetChunkedStreamingModeAfterFixedLengthStreamingMode() throws Exception {
+ @Test public void cannotSetChunkedStreamingModeAfterFixedLengthStreamingMode()
+ throws Exception {
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
connection.setFixedLengthStreamingMode(1);
@@ -1744,11 +1790,11 @@
}
}
- public void testSecureFixedLengthStreaming() throws Exception {
+ @Test public void secureFixedLengthStreaming() throws Exception {
testSecureStreamingPost(StreamingMode.FIXED_LENGTH);
}
- public void testSecureChunkedStreaming() throws Exception {
+ @Test public void secureChunkedStreaming() throws Exception {
testSecureStreamingPost(StreamingMode.CHUNKED);
}
@@ -1790,7 +1836,7 @@
FIXED_LENGTH, CHUNKED
}
- public void testAuthenticateWithPost() throws Exception {
+ @Test public void authenticateWithPost() throws Exception {
MockResponse pleaseAuthenticate = new MockResponse()
.setResponseCode(401)
.addHeader("WWW-Authenticate: Basic realm=\"protected area\"")
@@ -1826,7 +1872,7 @@
}
}
- public void testAuthenticateWithGet() throws Exception {
+ @Test public void authenticateWithGet() throws Exception {
MockResponse pleaseAuthenticate = new MockResponse()
.setResponseCode(401)
.addHeader("WWW-Authenticate: Basic realm=\"protected area\"")
@@ -1864,7 +1910,7 @@
}
// bug 11473660
- public void testAuthenticateWithLowerCaseHeadersAndScheme() throws Exception {
+ @Test public void authenticateWithLowerCaseHeadersAndScheme() throws Exception {
MockResponse pleaseAuthenticate = new MockResponse()
.setResponseCode(401)
.addHeader("www-authenticate: basic realm=\"protected area\"")
@@ -1890,7 +1936,7 @@
}
// http://code.google.com/p/android/issues/detail?id=19081
- public void testAuthenticateWithCommaSeparatedAuthenticationMethods() throws Exception {
+ @Test public void authenticateWithCommaSeparatedAuthenticationMethods() throws Exception {
server.enqueue(new MockResponse()
.setResponseCode(401)
.addHeader("WWW-Authenticate: Scheme1 realm=\"a\", Basic realm=\"b\", "
@@ -1911,7 +1957,7 @@
assertEquals("Basic", authenticator.requestingScheme);
}
- public void testAuthenticateWithMultipleAuthenticationHeaders() throws Exception {
+ @Test public void authenticateWithMultipleAuthenticationHeaders() throws Exception {
server.enqueue(new MockResponse()
.setResponseCode(401)
.addHeader("WWW-Authenticate: Scheme1 realm=\"a\"")
@@ -1933,15 +1979,15 @@
assertEquals("Basic", authenticator.requestingScheme);
}
- public void testRedirectedWithChunkedEncoding() throws Exception {
+ @Test public void redirectedWithChunkedEncoding() throws Exception {
testRedirected(TransferKind.CHUNKED, true);
}
- public void testRedirectedWithContentLengthHeader() throws Exception {
+ @Test public void redirectedWithContentLengthHeader() throws Exception {
testRedirected(TransferKind.FIXED_LENGTH, true);
}
- public void testRedirectedWithNoLengthHeaders() throws Exception {
+ @Test public void redirectedWithNoLengthHeaders() throws Exception {
testRedirected(TransferKind.END_OF_STREAM, false);
}
@@ -1966,7 +2012,7 @@
}
}
- public void testRedirectedOnHttps() throws IOException, InterruptedException {
+ @Test public void redirectedOnHttps() throws IOException, InterruptedException {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
server.enqueue(new MockResponse()
@@ -1987,7 +2033,7 @@
assertEquals("Expected connection reuse", 1, retry.getSequenceNumber());
}
- public void testNotRedirectedFromHttpsToHttp() throws IOException, InterruptedException {
+ @Test public void notRedirectedFromHttpsToHttp() throws IOException, InterruptedException {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
server.enqueue(new MockResponse()
@@ -2001,7 +2047,7 @@
assertEquals("This page has moved!", readAscii(connection.getInputStream()));
}
- public void testNotRedirectedFromHttpToHttps() throws IOException, InterruptedException {
+ @Test public void notRedirectedFromHttpToHttps() throws IOException, InterruptedException {
server.enqueue(new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_MOVED_TEMP)
.addHeader("Location: https://anyhost/foo")
@@ -2012,7 +2058,7 @@
assertEquals("This page has moved!", readAscii(connection.getInputStream()));
}
- public void testRedirectToAnotherOriginServer() throws Exception {
+ @Test public void redirectToAnotherOriginServer() throws Exception {
MockWebServer server2 = new MockWebServer();
server2.enqueue(new MockResponse().setBody("This is the 2nd server!"));
server2.play();
@@ -2043,7 +2089,7 @@
// http://b/27590872 - assert we do not throw a runtime exception if a server responds with
// a location that cannot be represented directly by URI.
- public void testRedirectWithInvalidRedirectUrl() throws Exception {
+ @Test public void redirectWithInvalidRedirectUrl() throws Exception {
// The first server hosts a redirect to a second. We need two so that the ProxySelector
// installed is used for the redirect. Otherwise the second request will be handled via the
// existing keep-alive connection.
@@ -2113,7 +2159,7 @@
}
}
- public void testInstanceFollowsRedirects() throws Exception {
+ @Test public void instanceFollowsRedirects() throws Exception {
testInstanceFollowsRedirects("http://www.google.com/");
testInstanceFollowsRedirects("https://www.google.com/");
}
@@ -2127,7 +2173,7 @@
assertFalse(urlConnection.getInstanceFollowRedirects());
}
- public void testFollowRedirects() throws Exception {
+ @Test public void followRedirects() throws Exception {
testFollowRedirects("http://www.google.com/");
testFollowRedirects("https://www.google.com/");
}
@@ -2152,20 +2198,20 @@
}
}
- public void testResponse300MultipleChoiceWithPost() throws Exception {
+ @Test public void response300MultipleChoiceWithPost() throws Exception {
// Chrome doesn't follow the redirect, but Firefox and the RI both do
testResponseRedirectedWithPost(HttpURLConnection.HTTP_MULT_CHOICE);
}
- public void testResponse301MovedPermanentlyWithPost() throws Exception {
+ @Test public void response301MovedPermanentlyWithPost() throws Exception {
testResponseRedirectedWithPost(HttpURLConnection.HTTP_MOVED_PERM);
}
- public void testResponse302MovedTemporarilyWithPost() throws Exception {
+ @Test public void response302MovedTemporarilyWithPost() throws Exception {
testResponseRedirectedWithPost(HttpURLConnection.HTTP_MOVED_TEMP);
}
- public void testResponse303SeeOtherWithPost() throws Exception {
+ @Test public void response303SeeOtherWithPost() throws Exception {
testResponseRedirectedWithPost(HttpURLConnection.HTTP_SEE_OTHER);
}
@@ -2194,7 +2240,7 @@
assertEquals("GET /page2 HTTP/1.1", page2.getRequestLine());
}
- public void testResponse305UseProxy() throws Exception {
+ @Test public void response305UseProxy() throws Exception {
server.play();
server.enqueue(new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_USE_PROXY)
@@ -2211,7 +2257,7 @@
assertEquals(1, server.getRequestCount());
}
- public void testHttpsWithCustomTrustManager() throws Exception {
+ @Test public void httpsWithCustomTrustManager() throws Exception {
RecordingHostnameVerifier hostnameVerifier = new RecordingHostnameVerifier();
RecordingTrustManager trustManager = new RecordingTrustManager();
SSLContext sc = SSLContext.getInstance("TLS");
@@ -2247,7 +2293,7 @@
}
}
- public void testSetSSLSocketFactory_null() throws Exception {
+ @Test public void setSSLSocketFactory_null() throws Exception {
URL url = new URL("https://google.com");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
try {
@@ -2257,7 +2303,7 @@
}
}
- public void testSetDefaultSSLSocketFactory_null() {
+ @Test public void setDefaultSSLSocketFactory_null() {
try {
HttpsURLConnection.setDefaultSSLSocketFactory(null);
fail();
@@ -2270,7 +2316,7 @@
* connection attempt. If a hostname resolves to multiple IPs HttpURLConnection will wait the
* full timeout for each.
*/
- public void testConnectTimeouts() throws IOException {
+ @Test public void connectTimeouts() throws IOException {
// During CTS tests we are limited in what host names we can depend on and unfortunately
// DNS lookups are not pluggable through standard APIs. During manual testing you should be
// able to change this to any name that can be resolved to multiple IPs and it should still
@@ -2317,7 +2363,7 @@
}
}
- public void testReadTimeouts() throws IOException {
+ @Test public void readTimeouts() throws IOException {
/*
* This relies on the fact that MockWebServer doesn't close the
* connection after a response has been sent. This causes the client to
@@ -2344,7 +2390,8 @@
}
}
- public void testSetChunkedEncodingAsRequestProperty() throws IOException, InterruptedException {
+ @Test public void setChunkedEncodingAsRequestProperty()
+ throws IOException, InterruptedException {
server.enqueue(new MockResponse());
server.play();
@@ -2358,7 +2405,7 @@
assertEquals("ABC", new String(request.getBody(), "UTF-8"));
}
- public void testConnectionCloseInRequest() throws IOException, InterruptedException {
+ @Test public void connectionCloseInRequest() throws IOException, InterruptedException {
server.enqueue(new MockResponse()); // server doesn't honor the connection: close header!
server.enqueue(new MockResponse());
server.play();
@@ -2375,7 +2422,7 @@
0, server.takeRequest().getSequenceNumber());
}
- public void testConnectionCloseInResponse() throws IOException, InterruptedException {
+ @Test public void connectionCloseInResponse() throws IOException, InterruptedException {
server.enqueue(new MockResponse().addHeader("Connection: close"));
server.enqueue(new MockResponse());
server.play();
@@ -2391,7 +2438,7 @@
0, server.takeRequest().getSequenceNumber());
}
- public void testConnectionCloseWithRedirect() throws IOException, InterruptedException {
+ @Test public void connectionCloseWithRedirect() throws IOException, InterruptedException {
MockResponse response = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_MOVED_TEMP)
.addHeader("Location: /foo")
@@ -2408,7 +2455,7 @@
0, server.takeRequest().getSequenceNumber());
}
- public void testResponseCodeDisagreesWithHeaders() throws IOException, InterruptedException {
+ @Test public void responseCodeDisagreesWithHeaders() throws IOException, InterruptedException {
server.enqueue(new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_NO_CONTENT)
.setBody("This body is not allowed!"));
@@ -2418,7 +2465,7 @@
assertEquals("This body is not allowed!", readAscii(connection.getInputStream()));
}
- public void testSingleByteReadIsSigned() throws IOException {
+ @Test public void singleByteReadIsSigned() throws IOException {
server.enqueue(new MockResponse().setBody(new byte[] { -2, -1 }));
server.play();
@@ -2429,15 +2476,15 @@
assertEquals(-1, in.read());
}
- public void testFlushAfterStreamTransmittedWithChunkedEncoding() throws IOException {
+ @Test public void flushAfterStreamTransmittedWithChunkedEncoding() throws IOException {
testFlushAfterStreamTransmitted(TransferKind.CHUNKED);
}
- public void testFlushAfterStreamTransmittedWithFixedLength() throws IOException {
+ @Test public void flushAfterStreamTransmittedWithFixedLength() throws IOException {
testFlushAfterStreamTransmitted(TransferKind.FIXED_LENGTH);
}
- public void testFlushAfterStreamTransmittedWithNoLengthHeaders() throws IOException {
+ @Test public void flushAfterStreamTransmittedWithNoLengthHeaders() throws IOException {
testFlushAfterStreamTransmitted(TransferKind.END_OF_STREAM);
}
@@ -2472,7 +2519,7 @@
}
}
- public void testGetHeadersThrows() throws IOException {
+ @Test public void getHeadersThrows() throws IOException {
server.enqueue(new MockResponse().setSocketPolicy(DISCONNECT_AT_START));
server.play();
@@ -2490,7 +2537,7 @@
}
}
- public void testReadTimeoutsOnRecycledConnections() throws Exception {
+ @Test public void readTimeoutsOnRecycledConnections() throws Exception {
server.enqueue(new MockResponse().setBody("ABC"));
server.play();
@@ -2519,7 +2566,7 @@
* After M, Android's HttpURLConnection started canonicalizing hostnames to lower case, IDN
* encoding and being more strict about invalid characters.
*/
- public void testUrlCharacterMapping() throws Exception {
+ @Test public void urlCharacterMapping() throws Exception {
server.setDispatcher(new Dispatcher() {
@Override public MockResponse dispatch(RecordedRequest request)
throws InterruptedException {
@@ -2742,7 +2789,7 @@
backdoorUrlToUri(new URL("http://host.tld/file#" + asFragment + "-x")).toString());
}
- public void testHostWithNul() throws Exception {
+ @Test public void hostWithNul() throws Exception {
URL url = new URL("http://host\u0000/");
try {
url.openStream();
@@ -2753,7 +2800,7 @@
/**
* Don't explode if the cache returns a null body. http://b/3373699
*/
- public void testResponseCacheReturnsNullOutputStream() throws Exception {
+ @Test public void responseCacheReturnsNullOutputStream() throws Exception {
final AtomicBoolean aborted = new AtomicBoolean();
ResponseCache.setDefault(new ResponseCache() {
@Override public CacheResponse get(URI uri, String requestMethod,
@@ -2786,7 +2833,7 @@
/**
* http://code.google.com/p/android/issues/detail?id=14562
*/
- public void testReadAfterLastByte() throws Exception {
+ @Test public void readAfterLastByte() throws Exception {
server.enqueue(new MockResponse()
.setBody("ABC")
.clearHeaders()
@@ -2801,7 +2848,7 @@
assertEquals(-1, in.read()); // throws IOException in Gingerbread
}
- public void testGetContent() throws Exception {
+ @Test public void getContent() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2809,7 +2856,7 @@
assertEquals("A", readAscii(in));
}
- public void testGetContentOfType() throws Exception {
+ @Test public void getContentOfType() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2827,7 +2874,7 @@
connection.disconnect();
}
- public void testGetOutputStreamOnGetFails() throws Exception {
+ @Test public void getOutputStreamOnGetFails() throws Exception {
server.enqueue(new MockResponse());
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2838,7 +2885,7 @@
}
}
- public void testGetOutputAfterGetInputStreamFails() throws Exception {
+ @Test public void getOutputAfterGetInputStreamFails() throws Exception {
server.enqueue(new MockResponse());
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2851,7 +2898,7 @@
}
}
- public void testSetDoOutputOrDoInputAfterConnectFails() throws Exception {
+ @Test public void setDoOutputOrDoInputAfterConnectFails() throws Exception {
server.enqueue(new MockResponse());
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2869,7 +2916,7 @@
connection.disconnect();
}
- public void testLastModified() throws Exception {
+ @Test public void lastModified() throws Exception {
server.enqueue(new MockResponse()
.addHeader("Last-Modified", "Wed, 27 Nov 2013 11:26:00 GMT")
.setBody("Hello"));
@@ -2882,7 +2929,7 @@
assertEquals(1385551560000L, connection.getHeaderFieldDate("Last-Modified", -1));
}
- public void testClientSendsContentLength() throws Exception {
+ @Test public void clientSendsContentLength() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2895,7 +2942,7 @@
assertContains(request.getHeaders(), "Content-Length: 3");
}
- public void testGetContentLengthConnects() throws Exception {
+ @Test public void getContentLengthConnects() throws Exception {
server.enqueue(new MockResponse().setBody("ABC"));
server.play();
HttpURLConnection connection = (HttpURLConnection) server.getUrl("/").openConnection();
@@ -2903,7 +2950,7 @@
connection.disconnect();
}
- public void testGetContentTypeConnects() throws Exception {
+ @Test public void getContentTypeConnects() throws Exception {
server.enqueue(new MockResponse()
.addHeader("Content-Type: text/plain")
.setBody("ABC"));
@@ -2913,7 +2960,7 @@
connection.disconnect();
}
- public void testGetContentEncodingConnects() throws Exception {
+ @Test public void getContentEncodingConnects() throws Exception {
server.enqueue(new MockResponse()
.addHeader("Content-Encoding: identity")
.setBody("ABC"));
@@ -2924,7 +2971,7 @@
}
// http://b/4361656
- public void testUrlContainsQueryButNoPath() throws Exception {
+ @Test public void urlContainsQueryButNoPath() throws Exception {
server.enqueue(new MockResponse().setBody("A"));
server.play();
URL url = new URL("http", server.getHostName(), server.getPort(), "?query");
@@ -2934,19 +2981,19 @@
}
// http://code.google.com/p/android/issues/detail?id=20442
- public void testInputStreamAvailableWithChunkedEncoding() throws Exception {
- testInputStreamAvailable(TransferKind.CHUNKED);
+ @Test public void inputStreamAvailableWithChunkedEncoding() throws Exception {
+ checkInputStreamAvailable(TransferKind.CHUNKED);
}
- public void testInputStreamAvailableWithContentLengthHeader() throws Exception {
- testInputStreamAvailable(TransferKind.FIXED_LENGTH);
+ @Test public void inputStreamAvailableWithContentLengthHeader() throws Exception {
+ checkInputStreamAvailable(TransferKind.FIXED_LENGTH);
}
- public void testInputStreamAvailableWithNoLengthHeaders() throws Exception {
- testInputStreamAvailable(TransferKind.END_OF_STREAM);
+ @Test public void inputStreamAvailableWithNoLengthHeaders() throws Exception {
+ checkInputStreamAvailable(TransferKind.END_OF_STREAM);
}
- private void testInputStreamAvailable(TransferKind transferKind) throws IOException {
+ private void checkInputStreamAvailable(TransferKind transferKind) throws IOException {
String body = "ABCDEFGH";
MockResponse response = new MockResponse();
transferKind.setBody(response, body, 4);
@@ -2963,7 +3010,7 @@
}
// http://code.google.com/p/android/issues/detail?id=28095
- public void testInvalidIpv4Address() throws Exception {
+ @Test public void invalidIpv4Address() throws Exception {
try {
URI uri = new URI("http://1111.111.111.111/index.html");
uri.toURL().openConnection().connect();
@@ -2972,7 +3019,7 @@
}
}
- public void testConnectIpv6() throws Exception {
+ @Test public void connectIpv6() throws Exception {
server.enqueue(new MockResponse().setBody("testConnectIpv6 body"));
server.play();
URL url = new URL("http://[::1]:" + server.getPort() + "/");
@@ -2981,7 +3028,7 @@
}
// http://code.google.com/p/android/issues/detail?id=16895
- public void testUrlWithSpaceInHost() throws Exception {
+ @Test public void urlWithSpaceInHost() throws Exception {
URLConnection urlConnection = new URL("http://and roid.com/").openConnection();
try {
urlConnection.getInputStream();
@@ -2991,7 +3038,7 @@
}
// http://code.google.com/p/android/issues/detail?id=16895
- public void testUrlWithSpaceInHostViaHttpProxy() throws Exception {
+ @Test public void urlWithSpaceInHostViaHttpProxy() throws Exception {
server.enqueue(new MockResponse());
server.play();
URLConnection urlConnection = new URL("http://and roid.com/")
@@ -3032,7 +3079,7 @@
false /* expectedWasFallbackScsvSet */, expectedProtocols);
}
- public void testNoSslFallback_specifiedProtocols() throws Exception {
+ @Test public void noSslFallback_specifiedProtocols() throws Exception {
String[] enabledProtocols = { "TLSv1.2", "TLSv1.1" };
TestSSLContext testSSLContext = createDefaultTestSSLContext();
SSLSocketFactory serverSocketFactory =
@@ -3045,7 +3092,7 @@
enabledProtocols);
}
- public void testNoSslFallback_defaultProtocols() throws Exception {
+ @Test public void noSslFallback_defaultProtocols() throws Exception {
// Will need to be updated if the enabled protocols in Android's SSLSocketFactory change
String[] expectedEnabledProtocols = { "TLSv1.2", "TLSv1.1", "TLSv1" };
@@ -3065,7 +3112,7 @@
assertEquals(expectedWasFallbackScsvSet, socket.wasTlsFallbackScsvSet());
}
- public void testInspectSslBeforeConnect() throws Exception {
+ @Test public void inspectSslBeforeConnect() throws Exception {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
server.enqueue(new MockResponse());
@@ -3100,7 +3147,7 @@
* Test that we can inspect the SSL session after connect().
* http://code.google.com/p/android/issues/detail?id=24431
*/
- public void testInspectSslAfterConnect() throws Exception {
+ @Test public void inspectSslAfterConnect() throws Exception {
TestSSLContext testSSLContext = createDefaultTestSSLContext();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
server.enqueue(new MockResponse());
@@ -3137,10 +3184,10 @@
* the minimal implementation of these methods to get OkHttp's tests to pass, so
* they should never be invoked outside of OkHttp's tests.
*/
- public void testTrustManagerAndTrustRootIndex_unusedForHttpsConnection() throws Exception {
+ @Test public void trustManagerAndTrustRootIndex_unusedForHttpsConnection() throws Exception {
Platform platform = Platform.getAndSetForTest(new PlatformWithoutTrustManager());
try {
- testConnectViaHttps();
+ checkConnectViaHttps();
} finally {
Platform.getAndSetForTest(platform);
}
@@ -3153,7 +3200,7 @@
* be going wrong in order for this test to (unexpectedly) invoke the corresponding
* Platform methods.
*/
- public void testTrustManagerAndTrustRootIndex_unusedForHttpConnection() throws Exception {
+ @Test public void trustManagerAndTrustRootIndex_unusedForHttpConnection() throws Exception {
Platform platform = Platform.getAndSetForTest(new PlatformWithoutTrustManager());
try {
server.enqueue(new MockResponse().setBody("response").setResponseCode(200));
diff --git a/luni/src/test/java/libcore/java/nio/charset/ModifiedUtf8Test.java b/luni/src/test/java/libcore/java/nio/charset/ModifiedUtf8Test.java
deleted file mode 100644
index f7c91ba..0000000
--- a/luni/src/test/java/libcore/java/nio/charset/ModifiedUtf8Test.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 libcore.java.nio.charset;
-
-import junit.framework.TestCase;
-
-import java.io.UTFDataFormatException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.charset.ModifiedUtf8;
-import java.util.Arrays;
-
-/**
- * Tests for {@code ModifiedUtf8}.
- */
-public class ModifiedUtf8Test extends TestCase {
- public void test_decode_singleChar() throws Exception {
- assertEquals("A", ModifiedUtf8.decode(new byte[] { 'A' }, new char[1], 0, 1));
- }
-
- public void test_decode_checkOffsetAndLength() throws Exception {
- assertEquals("BC", ModifiedUtf8.decode(
- new byte[] { 'A', 'B', 'C', 'D' }, new char[2], 1, 2));
- }
-
- public void test_decode_unexpectedEndOfStreamAfterC2_throws() {
- // We need at least one byte after 0xc2.
- try {
- ModifiedUtf8.decode(new byte[]{'B', (byte) 0xc2}, new char[2], 0, 2);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch(UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_decode_unexpectedEndOfStreamAfterE0_throws() {
- // We need at least two bytes after 0xe0.
- try {
- ModifiedUtf8.decode(
- new byte[] { 'B', (byte) 0xe0, (byte) 0xab }, new char[2], 0, 3);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch(UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_decode_endOfStreamAfterC2() throws Exception {
- assertEquals("B\u00a0", ModifiedUtf8.decode(
- new byte[] { 'B', (byte) 0xc2, (byte) 0xa0 },
- new char[2],
- 0,
- 3));
- }
-
- public void test_decode_endOfStreamAfterE0() throws Exception {
- assertEquals("B\u0830", ModifiedUtf8.decode(
- new byte[] { 'B', (byte) 0xe0, (byte) 0xa0, (byte) 0xb0 },
- new char[2],
- 0,
- 4));
- }
-
- public void test_decode_invalidByte_characterUnknown() throws Exception {
- try {
- ModifiedUtf8.decode(new byte[]{'A', (byte) 0xf0}, new char[2], 0, 2);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch (UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_decode_someC2Character() throws Exception {
- assertEquals("A\u00a6", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xc2, (byte) 0xa6 }, new char[2], 0, 3));
- }
-
- public void test_decode_lastC2Character() throws Exception {
- assertEquals("A\u00bf", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xc2, (byte) 0xbf }, new char[2], 0, 3));
- }
-
- public void test_decode_someTwoByteCharacter() throws Exception {
- // Make sure bit masking works
- assertEquals("A\u0606", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xd8, (byte) 0x86 }, new char[3], 0, 3));
- }
-
- public void test_decode_lastTwoByteCharacter() throws Exception {
- assertEquals("A\u07ff", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xdf, (byte) 0xbf }, new char[2], 0, 3));
- }
-
- public void test_decode_firstE0Character() throws Exception {
- assertEquals("A\u0800", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xe0, (byte) 0xa0, (byte) 0x80 },
- new char[2],
- 0,
- 4));
- }
-
- public void test_decode_someThreeBytesCharacter() throws Exception {
- assertEquals("A\u31c6", ModifiedUtf8.decode(
- new byte[]{ 'A', (byte) 0xe3, (byte) 0x87, (byte) 0x86 },
- new char[2],
- 0,
- 4));
- }
-
- public void test_decode_lastThreeBytesCharacter() throws Exception {
- assertEquals("A\uffff", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xef, (byte) 0xbf, (byte) 0xbf },
- new char[2],
- 0,
- 4));
- }
-
- public void test_decode_twoByteCharacterAfterThreeByteCharacter() throws Exception {
- assertEquals("\uffff\u0606A", ModifiedUtf8.decode(
- new byte[] { (byte) 0xef, (byte) 0xbf, (byte) 0xbf, (byte) 0xd8, (byte) 0x86, 'A' },
- new char[3],
- 0,
- 6));
- }
-
- public void test_decode_c080isZero() throws Exception {
- assertEquals("A\u0000A", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0xc0, (byte) 0x80, 'A' }, new char[3], 0, 4));
- }
-
- public void test_decode_00isZero() throws Exception {
- assertEquals("A\u0000A", ModifiedUtf8.decode(
- new byte[] { 'A', (byte) 0, 'A' }, new char[3], 0, 3));
- }
-
- public void test_decode_insufficientOutputSpace_throws() throws Exception{
- try {
- ModifiedUtf8.decode(new byte[] { 'A', (byte) 0, 'A' }, new char[2], 0, 3);
- fail("Should throw " + ArrayIndexOutOfBoundsException.class.getName());
- } catch(ArrayIndexOutOfBoundsException expected) {
- // Expected.
- }
- }
-
- public void test_decode_checkBadSecondByteOfTwo() throws Exception {
- try {
- ModifiedUtf8.decode(new byte[]{(byte) 0xc0, (byte) 0xc0}, new char[2], 0, 2);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch (UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_decode_checkBadSecondByteOfThree() throws Exception{
- try {
- ModifiedUtf8.decode(new byte[]{
- (byte) 0xe0, (byte) 0xc0, (byte) 0x80}, new char[2], 0, 2);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch (UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_decode_checkBadThirdByteOfThree() throws Exception{
- try {
- ModifiedUtf8.decode(new byte[]{
- (byte) 0xe0, (byte) 0x80, (byte) 0xc0}, new char[2], 0, 2);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch (UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_decode_insufficientInput_throws() throws Exception{
- try {
- ModifiedUtf8.decode(new byte[] { 'A', (byte) 0, 'A' }, new char[8], 0, 100);
- fail("Should throw " + ArrayIndexOutOfBoundsException.class.getName());
- } catch(ArrayIndexOutOfBoundsException expected) {
- // Expected.
- }
- }
-
- public void test_decode_extraCharsInArray_ignored() throws Exception {
- assertEquals("A", ModifiedUtf8.decode(new byte[] { 'A' }, new char[] { 'B', 'Z' }, 0, 1));
- }
-
- public void test_countBytes_rightCount() throws Exception {
- assertEquals(0, ModifiedUtf8.countBytes("", false));
- assertEquals(2, ModifiedUtf8.countBytes("\u0000", false));
- assertEquals(1, ModifiedUtf8.countBytes("A", false));
- assertEquals(1, ModifiedUtf8.countBytes("\u007f", false));
- assertEquals(2, ModifiedUtf8.countBytes("\u0080", false));
- assertEquals(2, ModifiedUtf8.countBytes("\u07ff", false));
- assertEquals(3, ModifiedUtf8.countBytes("\u0800", false));
- assertEquals(3, ModifiedUtf8.countBytes("\uffff", false));
- }
-
- public void test_countBytes_checkExceptionThrown() throws Exception {
- // These two mustn't throw...
- ModifiedUtf8.countBytes("", true);
- ModifiedUtf8.countBytes("A", true);
-
- char[] unsignedShortSizedCharArray = new char[2 * Short.MAX_VALUE + 1];
- for (int i = 0; i < unsignedShortSizedCharArray.length; i++) {
- unsignedShortSizedCharArray[i] = 'A';
- }
- String unsignedShortSizedString = String.copyValueOf(unsignedShortSizedCharArray);
-
- char[] sizeLongerThanUnsignedShortCharArray = new char[2 * Short.MAX_VALUE + 2];
- for (int i = 0; i < sizeLongerThanUnsignedShortCharArray.length; i++) {
- sizeLongerThanUnsignedShortCharArray[i] = 'A';
- }
- String sizeLongerThanUnsignedShortString = String.copyValueOf(
- sizeLongerThanUnsignedShortCharArray);
-
- // Mustn't throw.
- ModifiedUtf8.countBytes(unsignedShortSizedString, true);
-
- try {
- // Must throw.
- ModifiedUtf8.countBytes(sizeLongerThanUnsignedShortString, true);
- fail();
- } catch (UTFDataFormatException expected) {
- // Expected.
- }
-
- // Mustn't throw.
- ModifiedUtf8.countBytes(unsignedShortSizedString, false);
- ModifiedUtf8.countBytes(sizeLongerThanUnsignedShortString, false);
- }
-
- public void test_encode() throws Exception {
- assertTrue(Arrays.equals(new byte[]{0, 1, 'A'}, ModifiedUtf8.encode("A")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', 'B', 'C' }, ModifiedUtf8.encode("ABC")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', (byte) 0xc2, (byte) 0xa0 },
- ModifiedUtf8.encode("A\u00a0")));
- assertTrue(Arrays.equals(new byte[] { 0, 4, 'A', (byte) 0xe0, (byte) 0xa0, (byte) 0xb0 },
- ModifiedUtf8.encode("A\u0830")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', (byte) 0xc2, (byte) 0xa6 },
- ModifiedUtf8.encode("A\u00a6")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', (byte) 0xc2, (byte) 0xbf },
- ModifiedUtf8.encode("A\u00bf")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', (byte) 0xd8, (byte) 0x86 },
- ModifiedUtf8.encode("A\u0606")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', (byte) 0xdf, (byte) 0xbf },
- ModifiedUtf8.encode("A\u07ff")));
- assertTrue(Arrays.equals(new byte[] { 0, 4, 'A', (byte) 0xe0, (byte) 0xa0, (byte) 0x80 },
- ModifiedUtf8.encode("A\u0800")));
- assertTrue(Arrays.equals(new byte[] { 0, 4, 'A', (byte) 0xe3, (byte) 0x87, (byte) 0x86 },
- ModifiedUtf8.encode("A\u31c6")));
- assertTrue(Arrays.equals(new byte[] { 0, 4, 'A', (byte) 0xef, (byte) 0xbf, (byte) 0xbf },
- ModifiedUtf8.encode("A\uffff")));
- assertTrue(Arrays.equals(new byte[] { 0, 3, 'A', (byte) 0xc0, (byte) 0x80 },
- ModifiedUtf8.encode("A\u0000")));
- assertTrue(
- Arrays.equals(new byte[] { 0, 8, (byte) 0xe3, (byte) 0x87, (byte) 0x86,
- (byte) 0xd8, (byte) 0x86, (byte) 0xc0, (byte) 0x80, 'A' },
- ModifiedUtf8.encode("\u31c6\u0606\u0000A")));
- }
-
- public void test_encode_throws() throws Exception {
- char[] unsignedShortSizedCharArray = new char[Short.MAX_VALUE * 2 + 1];
- for (int i = 0; i < unsignedShortSizedCharArray.length; i++) {
- unsignedShortSizedCharArray[i] = 'A';
- }
- String unsignedShortSizedString = String.copyValueOf(unsignedShortSizedCharArray);
-
- char[] sizeLongerThanUnsignedShortCharArray = new char[Short.MAX_VALUE * 2 + 2];
- for (int i = 0; i < sizeLongerThanUnsignedShortCharArray.length; i++) {
- sizeLongerThanUnsignedShortCharArray[i] = 'A';
- }
- String sizeLongerThanUnsignedShortString =
- String.copyValueOf(sizeLongerThanUnsignedShortCharArray);
-
- // Mustn't throw.
- ModifiedUtf8.encode(unsignedShortSizedString);
- try {
- // Must throw.
- ModifiedUtf8.encode(sizeLongerThanUnsignedShortString);
- fail("Should throw " + UTFDataFormatException.class.getName());
- } catch (UTFDataFormatException expected) {
- // Expected.
- }
- }
-
- public void test_encode_lengthAtBeginning() throws Exception {
- int testStringLength = 20000;
- char[] charArray = new char[testStringLength];
- for (int i = 0; i < charArray.length; i++) {
- charArray[i] = 'A';
- }
- String testString = String.copyValueOf(charArray);
-
- // Mustn't throw.
- byte[] result = ModifiedUtf8.encode(testString);
- ByteBuffer b = ByteBuffer.wrap(result);
- b.order(ByteOrder.BIG_ENDIAN);
- assertEquals(testStringLength, b.getShort());
- }
-
-}
diff --git a/luni/src/test/java/libcore/java/text/CollatorTest.java b/luni/src/test/java/libcore/java/text/CollatorTest.java
index 75a245e..66ea0d2 100644
--- a/luni/src/test/java/libcore/java/text/CollatorTest.java
+++ b/luni/src/test/java/libcore/java/text/CollatorTest.java
@@ -22,7 +22,11 @@
import java.text.ParseException;
import java.text.RuleBasedCollator;
import java.text.StringCharacterIterator;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Locale;
+import java.util.Set;
public class CollatorTest extends junit.framework.TestCase {
public void test_setStrengthI() throws Exception {
@@ -164,4 +168,15 @@
public void testGetCollationElementIteratorCharacterIterator_de_DE() throws Exception {
assertGetCollationElementIteratorCharacterIterator(new Locale("de", "DE", ""), "\u00e6b", 0, 1, 1, 2);
}
+
+ public void testGetAvailableLocales_icuConsistency() {
+ Locale[] javaLocales = Collator.getAvailableLocales();
+ Locale[] icuLocales = android.icu.text.Collator.getAvailableLocales();
+ Set<Locale> javaSet = new HashSet<>(Arrays.asList(javaLocales));
+ Set<Locale> icuSet = new HashSet<>(Arrays.asList(icuLocales));
+ assertEquals(javaSet, icuSet);
+ // Assert no duplicated entries
+ assertEquals(javaLocales.length, javaSet.size());
+ assertEquals(icuLocales.length, icuSet.size());
+ }
}
diff --git a/luni/src/test/java/libcore/java/util/AbstractListTest.java b/luni/src/test/java/libcore/java/util/AbstractListTest.java
new file mode 100644
index 0000000..e0c4db2
--- /dev/null
+++ b/luni/src/test/java/libcore/java/util/AbstractListTest.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.java.util;
+
+import junit.framework.AssertionFailedError;
+
+import org.junit.Test;
+
+import java.util.AbstractList;
+import java.util.AbstractSequentialList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.RandomAccess;
+import java.util.Spliterator;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Supplier;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class AbstractListTest {
+ @Test public void sublist_outOfBounds() {
+ assertSubListOutOfBounds(new RandomAccessList(/* size */ 0), 0, 1);
+ assertSubListOutOfBounds(new RandomAccessList(/* size */ 10), 0, 11);
+ assertSubListOutOfBounds(new RandomAccessList(/* size */ 10), -1, 10);
+ assertSubListOutOfBounds(new RandomAccessList(/* size */ 10), -1, 11);
+
+ assertSubListOutOfBounds(new SequentialList(/* elements */), 0, 1);
+ assertSubListOutOfBounds(new SequentialList(/* elements */ 10, 20, 30), 0, 4);
+ assertSubListOutOfBounds(new SequentialList(/* elements */ 10, 20, 30), -1, 3);
+
+ // These ones work
+ new RandomAccessList(/* size */ 0).subList(0, 0);
+ new RandomAccessList(/* size */ 10).subList(0, 10);
+ new RandomAccessList(/* size */ 10).subList(2, 5);
+ new SequentialList(/* elements */).subList(0, 0);
+ new SequentialList(/* elements */ 10, 20, 30).subList(0, 3);
+ }
+
+ private static<T> void assertSubListOutOfBounds(List<T> list, int startIndex, int endIndex) {
+ try {
+ list.subList(startIndex, endIndex);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ }
+ }
+
+ /** Checks that list.spliterator() is late-binding. */
+ @Test public void spliterator_lateBinding() {
+ List<Integer> list = new RandomAccessList(50);
+ Spliterator<Integer> spliterator = list.spliterator();
+ Integer newFirstValue = list.get(0) + 3000;
+ list.add(0, newFirstValue); // prepend
+ AtomicReference<Integer> receivedValue = new AtomicReference<>(null);
+ // No ConcurrentModificationException because of late-binding Spliterator
+ boolean didAdvance = spliterator.tryAdvance(value -> receivedValue.set(value));
+ // Expect the values at index 0 from after the add(), not from after the spliterator().
+ assertEquals(newFirstValue, receivedValue.get());
+ assertTrue(didAdvance);
+ }
+
+ @Test public void spliterator_modification_failFast() {
+ List<Integer> list = new RandomAccessList(50);
+ Integer expectedValue = list.get(2);
+ Spliterator<Integer> spliterator = list.spliterator();
+ // We need to perform at least one action on the spliterator because only then does
+ // it initialize its internal expectedModCount.
+ assertTrue(spliterator.tryAdvance(value -> {}));
+ assertTrue(spliterator.tryAdvance(value -> {}));
+ list.add(42); // concurrent modification
+ AtomicReference<Integer> receivedValue = new AtomicReference<>(null);
+ try {
+ spliterator.tryAdvance(value -> receivedValue.set(value));
+ fail();
+ } catch (ConcurrentModificationException expected) {
+ }
+ // I believe it would also be within spec for this to remain unset (null),
+ // but the current implementation checks for concurrent modification only after
+ // delivering the value. We're asserting that so that we notice if the behavior
+ // ever changes in future.
+ assertEquals(expectedValue, receivedValue.get());
+ }
+
+ @Test public void spliteratorOfRandomAccessList_usesOnlyRandomAccess() {
+ checkSpliteratorOfOnlyRandomAccessList_usesOnlyRandomAccess(0);
+ checkSpliteratorOfOnlyRandomAccessList_usesOnlyRandomAccess(1);
+ checkSpliteratorOfOnlyRandomAccessList_usesOnlyRandomAccess(2);
+ checkSpliteratorOfOnlyRandomAccessList_usesOnlyRandomAccess(100);
+ }
+
+ private static void checkSpliteratorOfOnlyRandomAccessList_usesOnlyRandomAccess(int listSize) {
+ checkSpliteratorOfRandomAccessList(listSize,
+ () -> new OnlyRandomAccessList(listSize));
+ int subListSize = listSize / 2;
+ checkSpliteratorOfRandomAccessList(
+ subListSize,
+ () -> new OnlyRandomAccessList(listSize).subList(0, subListSize));
+ }
+
+ /**
+ * Checks basic operations on supplied RandomAccess Lists. If the supplied Lists are
+ * {@link OnlyRandomAccessList} or its sublists, then that has the side-effect of
+ * checking that only random-access operations are attempted.
+ */
+ // We're using a Supplier<List> to keep constructing new Lists because some of the testers
+ // have the side effect of sorting the List.
+ private static void checkSpliteratorOfRandomAccessList(int size,
+ Supplier<List<Integer>> listSupplier) {
+ assertTrue(listSupplier.get() instanceof RandomAccess);
+ assertEquals(size, listSupplier.get().size());
+
+ Supplier<Spliterator<Integer>> spliteratorSupplier = () -> listSupplier.get().spliterator();
+ List<Integer> expectedList = new ArrayList<>();
+ for (int index = 0; index < size; index++) {
+ expectedList.add(RandomAccessList.initialValue(index));
+ }
+
+ SpliteratorTester.runBasicIterationTests(spliteratorSupplier.get(), expectedList);
+ SpliteratorTester.runBasicSplitTests(spliteratorSupplier.get(), expectedList,
+ Comparator.naturalOrder());
+ SpliteratorTester.testSpliteratorNPE(spliteratorSupplier.get());
+
+ assertTrue(spliteratorSupplier.get().hasCharacteristics(
+ Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED));
+
+ SpliteratorTester.runSizedTests(spliteratorSupplier.get(), size /* expected size */);
+ if (spliteratorSupplier.get().trySplit() != null) {
+ SpliteratorTester.runSubSizedTests(spliteratorSupplier.get(), size);
+ } else {
+ assertTrue(size <= 1); // trySplit() should work for lists sized > 1.
+ }
+ }
+
+ static class SequentialList extends AbstractSequentialList<Integer> {
+ private final List<Integer> delegate;
+
+ public SequentialList(Integer... elements) {
+ this.delegate = Collections.unmodifiableList(Arrays.asList(elements));
+ }
+
+ @Override public ListIterator<Integer> listIterator(int index) {
+ return delegate.listIterator(index);
+ }
+
+ @Override public int size() { return delegate.size(); }
+ }
+
+ /**
+ * A simple list that allows random-access {@code get()} and modifications. This
+ * implementation increases {@link AbstractList#modCount} during {@code add()}
+ * and {@code remove()} to provide fail-fast Spliterators.
+ */
+ static class RandomAccessList extends AbstractList<Integer> implements RandomAccess {
+ protected final List<Integer> delegate;
+
+ public RandomAccessList(int size) {
+ this.delegate = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ delegate.add(initialValue(i));
+ }
+ }
+
+ static Integer initialValue(int index) { return 31337 ^ index; }
+
+ @Override public Integer get(int index) { return delegate.get(index); }
+ @Override public int size() { return delegate.size(); }
+ @Override public Integer set(int index, Integer v) { return delegate.set(index, v); }
+ @Override public void add(int index, Integer element) {
+ modCount++;
+ delegate.add(index, element);
+ }
+ @Override public Integer remove(int index) {
+ modCount++;
+ return delegate.remove(index);
+ }
+ }
+
+ /**
+ * A {@link RandomAccessList} that throws if a caller attempts {@link #iterator()
+ * iterative access}.
+ */
+ static class OnlyRandomAccessList extends RandomAccessList {
+ public OnlyRandomAccessList(int size) {
+ super(size);
+ }
+ @Override public Iterator<Integer> iterator() {
+ throw new AssertionFailedError();
+ }
+
+ @Override public ListIterator<Integer> listIterator(int index) {
+ throw new AssertionFailedError();
+ }
+
+ }
+
+}
diff --git a/luni/src/test/java/libcore/java/util/ListOfTest.java b/luni/src/test/java/libcore/java/util/ListOfTest.java
new file mode 100644
index 0000000..04b787f
--- /dev/null
+++ b/luni/src/test/java/libcore/java/util/ListOfTest.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.java.util;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.RandomAccess;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+import libcore.libcore.util.SerializationTester;
+import libcore.util.NonNull;
+
+import static java.util.Arrays.asList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class ListOfTest {
+
+ @Test
+ public void serializationCompatibility_empty() {
+ String golden = "ACED00057372001F6A6176612E7574696C2E436F6C6C656374696F6E7324456D7074794C69"
+ + "73747AB817B43CA79EDE0200007870";
+ new SerializationTester<>(List.<String>of(), golden).test();
+ }
+
+ @Test public void serializationCompatibility_oneElement() {
+ String golden = "ACED0005737200266A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C654C697374FC0F2531B5EC8E100200014C00046C6973747400104C6A6176612F7574696C"
+ + "2F4C6973743B7872002C6A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F64696669"
+ + "61626C65436F6C6C656374696F6E19420080CB5EF71E0200014C0001637400164C6A6176612F7574"
+ + "696C2F436F6C6C656374696F6E3B7870737200136A6176612E7574696C2E41727261794C69737478"
+ + "81D21D99C7619D03000149000473697A657870000000017704000000017400036F6E657871007E00"
+ + "06";
+ new SerializationTester<>(List.of("one"), golden).test();
+ }
+
+ @Test public void serializationCompatibility_manyElements() {
+ String golden = "ACED0005737200266A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C654C697374FC0F2531B5EC8E100200014C00046C6973747400104C6A6176612F7574696C"
+ + "2F4C6973743B7872002C6A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F64696669"
+ + "61626C65436F6C6C656374696F6E19420080CB5EF71E0200014C0001637400164C6A6176612F7574"
+ + "696C2F436F6C6C656374696F6E3B7870737200136A6176612E7574696C2E41727261794C69737478"
+ + "81D21D99C7619D03000149000473697A6578700000000D77040000000D737200116A6176612E6C61"
+ + "6E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C61"
+ + "6E672E4E756D62657286AC951D0B94E08B02000078700000000C7371007E00070000000B7371007E"
+ + "00070000000A7371007E0007000000097371007E0007000000087371007E0007000000077371007E"
+ + "0007000000067371007E0007000000057371007E0007000000047371007E0007000000037371007E"
+ + "0007000000027371007E0007000000017371007E0007000000007871007E0006";
+ new SerializationTester<>(List.of(12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0), golden).test();
+ }
+
+ @Test public void mixedTypes() {
+ List<?> list = List.of("element", 42);
+ assertEquals(asList("element", 42), list);
+
+ assertTrue(list.contains("element"));
+ assertTrue(list.contains(42));
+ assertFalse(list.contains(new Object()));
+ assertFalse(list.contains(31));
+ }
+
+ @Test public void duplicates_allowed() {
+ // duplicates values are allowed for List.of(), but not for Set.of()
+ check_nonEmpty(asList("duplicate", "duplicate"), List.of("duplicate", "duplicate"));
+ }
+
+ @Test public void empty() {
+ assertBehaviorCommonToAllOfInstances(
+ Collections.<String>emptyList(), List.<String>of(), "non-null example String");
+ }
+
+ @Test public void nonEmpty() {
+ check_nonEmpty(asList("one"), List.of("one"));
+ check_nonEmpty(asList("one", "two"), List.of("one", "two"));
+ check_nonEmpty(asList("one", "two", "three"), List.of("one", "two", "three"));
+ check_nonEmpty(asList("one", "two", "three", "four"),
+ List.of("one", "two", "three", "four"));
+ check_nonEmpty(asList("one", "two", "three", "four", "five"),
+ List.of("one", "two", "three", "four", "five"));
+ check_nonEmpty(asList("one", "two", "three", "four", "five", "six"),
+ List.of("one", "two", "three", "four", "five", "six"));
+ check_nonEmpty(asList("one", "two", "three", "four", "five", "six", "seven"),
+ List.of("one", "two", "three", "four", "five", "six", "seven"));
+ check_nonEmpty(asList(1, 2, 3, 4, 5, 6, 7, 8), List.of(1, 2, 3, 4, 5, 6, 7, 8));
+ check_nonEmpty(asList(1, 2, 3, 4, 5, 6, 7, 8, 9), List.of(1, 2, 3, 4, 5, 6, 7, 8, 9));
+ check_nonEmpty(asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+ List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
+ check_nonEmpty(asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
+ List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
+ check_nonEmpty(asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
+ List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
+ check_nonEmpty(asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
+ List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13));
+ }
+
+ @Test public void null_examples() {
+ assertThrowsNpe(() -> List.<String>of((String) null)); // one-arg version
+ assertThrowsNpe(() -> List.<String[]>of((String[]) null)); // null var-args array
+ assertThrowsNpe(() -> List.<String>of(new String[] { "one", null, "three"})); // var-args
+
+ assertThrowsNpe(() -> List.of(null, "two"));
+ assertThrowsNpe(() -> List.of("one", null));
+ assertThrowsNpe(
+ () -> List.of(null, "two", "three", "four", "five", "six", "seven"));
+ assertThrowsNpe(
+ () -> List.of("one", "two", "three", "four", "five", "six", null));
+ }
+
+ @Test public void null_comprehensive() {
+ List<Integer> template = asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
+ for (int i = 0; i < template.size(); i++) {
+ Integer[] l = template.toArray(new Integer[0]);
+ l[i] = null;
+ npe(i <= 0, () -> List.of(l[0]));
+ npe(i <= 1, () -> List.of(l[0], l[1]));
+ npe(i <= 2, () -> List.of(l[0], l[1], l[2]));
+ npe(i <= 3, () -> List.of(l[0], l[1], l[2], l[3]));
+ npe(i <= 4, () -> List.of(l[0], l[1], l[2], l[3], l[4]));
+ npe(i <= 5, () -> List.of(l[0], l[1], l[2], l[3], l[4], l[5]));
+ npe(i <= 6, () -> List.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6]));
+ npe(i <= 7, () -> List.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7]));
+ npe(i <= 8, () -> List.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8]));
+ npe(i <= 9, () -> List.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9]));
+ npe(i <= 10, () -> List.of(
+ l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10]));
+ npe(i <= 11, () -> List.of(
+ l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10], l[11]));
+ npe(i <= 12, () -> List.of(
+ l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10], l[11], l[12])
+ );
+ }
+ }
+
+ /**
+ * Asserts that {@code runnable.run()} throws {@link NullPointerException} if
+ * any only if {@code expectedToThrowNpe}.
+ */
+ private static void npe(boolean expectedToThrowNpe, Runnable runnable) {
+ if (expectedToThrowNpe) {
+ assertThrowsNpe(runnable);
+ } else {
+ runnable.run(); // should not throw
+ }
+ }
+
+ private static<T extends Comparable<T>> void check_nonEmpty(List<T> expected, List<T> actual) {
+ T example = actual.iterator().next();
+ assertBehaviorCommonToAllOfInstances(expected, actual, example);
+ }
+
+ /** Checks assertions that hold for all List.of() instances. */
+ private static<T extends Comparable<T>> void assertBehaviorCommonToAllOfInstances(
+ List<T> expected, List<T> actual, @NonNull T example) {
+ assertNotNull(example);
+ assertEquals(expected, actual);
+ assertEquals(expected.size(), actual.size());
+ assertEquals(expected.hashCode(), actual.hashCode());
+ assertEquals(actual.isEmpty(), actual.isEmpty());
+ assertEquals(actual.size() == 0, actual.isEmpty());
+ SpliteratorTester.runBasicIterationTests(actual.spliterator(), expected);
+ if (expected.isEmpty()) {
+ assertEquals(expected, actual.subList(0, 0));
+ } else {
+ assertEquals(expected.subList(1, expected.size()), actual.subList(1, actual.size()));
+ }
+ assertEquals(expected.contains(example), actual.contains(example));
+ assertFalse(actual.contains("absent-element"));
+ assertFalse(actual.contains(new Object()));
+ assertThrowsNpe(() -> actual.contains(null));
+ assertEquals(expected.toString(), actual.toString());
+
+ assertUnmodifiable(actual, example);
+ assertEquals(actual, reserialize((Serializable) actual));
+ assertTrue(actual instanceof RandomAccess);
+ }
+
+ private static<T extends Comparable<T>> void assertUnmodifiable(List<T> list, T example) {
+ List<T> examples = Collections.singletonList(example);
+ assertThrowsUoe(() -> { list.add(example); } );
+ assertThrowsUoe(() -> { list.addAll(examples); } );
+ assertThrowsUoe(() -> { list.addAll(0, examples); } );
+ // List.of() documentation guarantees that the following operations throw
+ // UnsupportedOperationException, even though some other implementations don't
+ // do that in the case of isEmpty().
+ assertThrowsUoe(() -> { list.clear(); });
+ assertThrowsUoe(() -> { list.remove(example); } );
+ assertThrowsUoe(() -> { list.removeAll(examples); } );
+ assertThrowsUoe(() -> { list.removeIf(Predicate.isEqual(example)); } );
+ assertThrowsUoe(() -> { list.replaceAll(UnaryOperator.identity()); } );
+ assertThrowsUoe(() -> { list.retainAll(examples); } );
+ assertThrowsUoe(() -> { list.sort(Comparator.<T>naturalOrder()); } );
+ }
+
+ private static void assertThrowsUoe(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+ }
+
+ private static void assertThrowsNpe(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ private static <S extends Serializable> S reserialize(S value) {
+ try {
+ return (S) SerializationTester.reserialize(value);
+ } catch (IOException | ClassNotFoundException e) {
+ fail("Unexpected exception: " + e.getMessage());
+ throw new AssertionError(e); // unreachable
+ }
+ }
+}
diff --git a/luni/src/test/java/libcore/java/util/LocaleTest.java b/luni/src/test/java/libcore/java/util/LocaleTest.java
index f9e11a7..6cb9e17 100644
--- a/luni/src/test/java/libcore/java/util/LocaleTest.java
+++ b/luni/src/test/java/libcore/java/util/LocaleTest.java
@@ -22,6 +22,7 @@
import static java.util.Locale.FilteringMode.MAP_EXTENDED_RANGES;
import static java.util.Locale.FilteringMode.REJECT_EXTENDED_RANGES;
+import android.icu.util.ULocale;
import java.io.ObjectInputStream;
import java.text.BreakIterator;
import java.text.Collator;
@@ -30,13 +31,17 @@
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
+import java.util.HashSet;
import java.util.IllformedLocaleException;
import java.util.List;
import java.util.Locale;
import java.util.Locale.LanguageRange;
import java.util.MissingResourceException;
+import java.util.Set;
+import java.util.stream.Collectors;
public class LocaleTest extends junit.framework.TestCase {
@@ -156,7 +161,6 @@
public void test_getDisplayCountry_8870289() throws Exception {
assertEquals("Hong Kong", new Locale("", "HK").getDisplayCountry(Locale.US));
- assertEquals("Macao", new Locale("", "MO").getDisplayCountry(Locale.US));
assertEquals("Palestine", new Locale("", "PS").getDisplayCountry(Locale.US));
assertEquals("Cocos (Keeling) Islands", new Locale("", "CC").getDisplayCountry(Locale.US));
@@ -233,6 +237,19 @@
assertOnce(newLocale, Locale.getAvailableLocales());
}
+ public void testGetAvailableLocales_icuConsistency() {
+ Locale[] javaLocales = Locale.getAvailableLocales();
+ ULocale[] icuLocales = ULocale.getAvailableLocales();
+ Set<Locale> javaSet = new HashSet<>(Arrays.asList(javaLocales));
+ Set<Locale> icuSet = Arrays.stream(icuLocales)
+ .map(uLocale -> uLocale.toLocale())
+ .collect(Collectors.toSet());
+ assertEquals(javaSet, icuSet);
+ // Assert no duplicated entries
+ assertEquals(javaLocales.length, javaSet.size());
+ assertEquals(icuLocales.length, icuSet.size());
+ }
+
private static void assertOnce(Locale element, Locale[] array) {
int count = 0;
for (Locale l : array) {
diff --git a/luni/src/test/java/libcore/java/util/MapOfTest.java b/luni/src/test/java/libcore/java/util/MapOfTest.java
new file mode 100644
index 0000000..68e20a7
--- /dev/null
+++ b/luni/src/test/java/libcore/java/util/MapOfTest.java
@@ -0,0 +1,317 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.java.util;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import libcore.libcore.util.SerializationTester;
+
+import static java.util.Map.entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests {@code Map.of()} overloads and {@code Map.ofEntries(...)}.
+ */
+@RunWith(Parameterized.class)
+public class MapOfTest {
+
+ @Test public void serializationCompatibility_empty() {
+ String golden = "ACED0005737200256A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C654D6170F1A5A8FE74F507420200014C00016D74000F4C6A6176612F7574696C2F4D6170"
+ + "3B7870737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F"
+ + "6164466163746F724900097468726573686F6C6478703F4000000000000177080000000100000000"
+ + "78";
+ new SerializationTester<>(create(), golden).test();
+ }
+
+ @Test public void serializationCompatibility_oneElement() {
+ String golden = "ACED0005737200256A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C654D6170F1A5A8FE74F507420200014C00016D74000F4C6A6176612F7574696C2F4D6170"
+ + "3B7870737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F"
+ + "6164466163746F724900097468726573686F6C6478703F4000000000000177080000000200000001"
+ + "7400036F6E65737200116A6176612E6C616E672E496E746567657212E2A0A4F78187380200014900"
+ + "0576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B020000787000"
+ + "00000178";
+ new SerializationTester<>(create(entry("one", 1)), golden).test();
+ }
+
+ @Test public void serializationCompatibility_manyElements() {
+ String golden = "ACED0005737200256A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C654D6170F1A5A8FE74F507420200014C00016D74000F4C6A6176612F7574696C2F4D6170"
+ + "3B7870737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F"
+ + "6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000A"
+ + "7400046E696E65737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149"
+ + "000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870"
+ + "000000097400037369787371007E000600000006740004666F75727371007E000600000004740003"
+ + "6F6E657371007E000600000001740005736576656E7371007E00060000000774000374656E737100"
+ + "7E00060000000A74000374776F7371007E00060000000274000574687265657371007E0006000000"
+ + "03740004666976657371007E00060000000574000565696768747371007E00060000000878";
+ new SerializationTester<>(
+ create(entry("one", 1), entry("two", 2), entry("three", 3),
+ entry("four", 4), entry("five", 5), entry("six", 6), entry("seven", 7),
+ entry("eight", 8), entry("nine", 9), entry("ten", 10)), golden).test();
+ }
+
+ @Test public void duplicates_sameKey() {
+ Map.Entry[] entries = { entry("duplicateKey", 23), entry("duplicateKey", 42) };
+ assertThrowsIae(() -> creator.create(entries));
+ }
+
+ @Test public void duplicates_sameEntry() {
+ Map.Entry[] entries = { entry("duplicateKey", 42), entry("duplicateKey", 42) };
+ assertThrowsIae(() -> creator.create(entries));
+ }
+
+ @Test public void duplicates_manyElements() {
+ Map.Entry[] entries = {
+ entry("key1", 1),
+ entry("duplicateKey", 23),
+ entry("key2", 2),
+ entry("duplicateKey", 42) };
+ assertThrowsIae(() -> creator.create(entries));
+ }
+
+ @Test public void empty() {
+ assertBehaviorCommonToAllOfInstances("exampleKey", 42);
+ }
+
+ @Test public void nullEntries() {
+ assertThrowsNpe(() -> Map.ofEntries((Map.Entry[]) null));
+ assertThrowsNpe(() -> Map.ofEntries((Map.Entry) null));
+ List<Map.Entry<String, Integer>> sampleEntries = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ sampleEntries.add(entry("key" + i, i));
+ }
+ for (int size = 0; size <= sampleEntries.size(); size++) {
+ for (int nullIndex = 0; nullIndex < size; nullIndex++) {
+ Map.Entry[] entries = sampleEntries.subList(0, size).toArray(
+ (Map.Entry<String, Integer>[]) new Map.Entry[0]);
+ entries[nullIndex] = null;
+ assertThrowsNpe(() -> Map.ofEntries(entries));
+ }
+ }
+ }
+
+ @Test public void oneEntry() {
+ assertBehaviorCommonToAllOfInstances(
+ "exampleKey", 42, entry("key", "value"));
+ }
+
+ @Test public void twoEntries() {
+ assertBehaviorCommonToAllOfInstances(
+ "exampleKey", 42, entry("key1", "value1"), entry("key2", "value2"));
+ }
+
+ @Test public void manyEntries() {
+ List<Map.Entry<String, Integer>> sampleEntries = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ sampleEntries.add(entry("key" + i, i));
+ }
+ for (int size = 0; size <= sampleEntries.size(); size++) {
+ Map.Entry[] entries = sampleEntries.subList(0, size).toArray(
+ (Map.Entry<String, Integer>[]) new Map.Entry[0]);
+ assertBehaviorCommonToAllOfInstances("key0", 42, entries);
+ }
+ }
+
+ @Test public void entry_nullKeyOrValue() {
+ assertThrowsNpe(() -> entry(null, "value"));
+ assertThrowsNpe(() -> entry("key", null));
+ assertThrowsNpe(() -> entry(null, null));
+
+ // This one works
+ entry("key", "value");
+ }
+
+ @Test public void of_nullKeyOrValue() {
+ assertThrowsNpe(() -> Map.of(null, "value"));
+ assertThrowsNpe(() -> Map.of("key", null));
+ assertThrowsNpe(() -> Map.of("k1", "v1", "k2", "v2", null, "v3", "k4", "v4"));
+ assertThrowsNpe(() -> Map.of("k1", "v1", "k2", "v2", "k3", null, "k4", "v4"));
+ }
+
+ @Test public void mixedEntryTypes() {
+ assertBehaviorCommonToAllOfInstances(
+ "onekey", "new value", entry("oneKey", 1), entry(2, "twoValue"));
+ }
+
+ private static<K, V> void assertUnmodifiable(Map<K, V> map, K exampleKey, V exampleValue) {
+ Map<K, V> exampleEntries = Collections.singletonMap(exampleKey, exampleValue);
+ assertThrowsUoe(() -> map.put(exampleKey, exampleValue));
+ assertThrowsUoe(() -> map.putAll(exampleEntries));
+ assertThrowsUoe(() -> map.remove(exampleKey));
+ assertThrowsUoe(() -> map.remove(exampleKey, exampleValue));
+ assertThrowsUoe(() -> map.clear());
+ assertThrowsUoe(() -> map.replace(exampleKey, exampleValue, null));
+ assertThrowsUoe(() -> map.putIfAbsent(exampleKey, exampleValue));
+ assertThrowsUoe(() -> map.entrySet().clear());
+ assertThrowsUoe(() -> map.keySet().clear());
+ assertThrowsUoe(() -> map.values().clear());
+
+ if (!map.isEmpty()) {
+ Map.Entry<K, V> firstEntry = map.entrySet().iterator().next();
+ assertThrowsUoe(() -> firstEntry.setValue(exampleValue));
+ }
+ }
+
+ /** Checks assertions that hold for all Map.of() / Map.ofEntries() instances. */
+ private <K, V> void assertBehaviorCommonToAllOfInstances(K exampleKey, V exampleValue,
+ Map.Entry<K, V>...entries) {
+ Map<K, V> expected = hashMapOf(entries);
+ Map<K, V> actual = creator.create(entries);
+ assertBehaviorCommonToAllOfInstances(expected, actual, exampleKey, exampleValue);
+ }
+
+ private static<K, V> void assertBehaviorCommonToAllOfInstances(Map<K, V> expected,
+ Map<K, V> actual, K exampleKey, V exampleValue) {
+ assertDoesNotSupportNull(actual);
+ assertMapEquals(expected, actual);
+ assertUnmodifiable(actual, exampleKey, exampleValue);
+ }
+
+ private static<K, V> void assertDoesNotSupportNull(Map<K, V> map) {
+ assertThrowsNpe(() -> map.containsKey(null));
+ assertThrowsNpe(() -> map.keySet().contains(null));
+ assertThrowsNpe(() -> map.values().contains(null));
+ }
+
+ private static<K, V> void assertMapEquals(Map<K, V> expected, Map<K, V> actual) {
+ assertEquals(expected, actual);
+ assertEquals(actual, expected);
+ assertEquals(expected.size(), actual.size());
+ assertEquals(expected.entrySet(), actual.entrySet());
+
+ assertSetEquals(expected.entrySet(), actual.entrySet());
+ assertSetEquals(expected.keySet(), actual.keySet());
+ assertCollectionEquals(new HashSet<>(expected.values()), new HashSet<>(actual.values()));
+ }
+
+ private static<T> void assertSetEquals(Set<T> expected, Set<T> actual) {
+ assertCollectionEquals(expected, actual);
+ }
+
+ private static<T> void assertCollectionEquals(Collection<T> expected, Collection<T> actual) {
+ assertEquals(expected, actual);
+ assertEquals(actual, expected);
+ assertEquals(expected.hashCode(), actual.hashCode());
+
+ assertEquals(expected.size(), actual.size());
+ assertTrue(expected.containsAll(actual));
+ assertTrue(actual.containsAll(expected));
+ }
+
+ private final Creator creator;
+
+ public MapOfTest(Creator creator) {
+ this.creator = Objects.requireNonNull(creator);
+ }
+
+ private<K, V> Map<K, V> create(Map.Entry<K, V>... entries) {
+ return creator.create(entries);
+ }
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<Creator> getCreators() {
+ return Arrays.asList(Creator.OF, Creator.OF_ENTRIES);
+ }
+
+ private static<K, V> Map<K, V> hashMapOf(Map.Entry<K, V>... entries) {
+ HashMap<K, V> result = new HashMap<>();
+ for (Map.Entry<K, V> entry : entries) {
+ result.put(entry.getKey(), entry.getValue());
+ }
+ return result;
+ }
+
+ enum Creator {
+ OF {
+ private<K,V> K k(int index, Map.Entry<K, V>... entries) {
+ return entries[index].getKey();
+ }
+ private<K,V> V v(int index, Map.Entry<K, V>... entries) {
+ return entries[index].getValue();
+ }
+
+ @Override
+ <K, V> Map<K, V> create(Map.Entry<K, V>... e) {
+ switch (e.length) {
+ case 0: return Map.of();
+ case 1: return Map.of(k(0, e), v(0, e));
+ case 2: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e));
+ case 3: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e));
+ case 4: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e));
+ case 5: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e), k(4, e), v(4, e));
+ case 6: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e), k(4, e), v(4, e), k(5, e), v(5, e));
+ case 7: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e), k(4, e), v(4, e), k(5, e), v(5, e), k(6, e), v(6, e));
+ case 8: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e), k(4, e), v(4, e), k(5, e), v(5, e), k(6, e), v(6, e), k(7, e), v(7, e));
+ case 9: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e), k(4, e), v(4, e), k(5, e), v(5, e), k(6, e), v(6, e), k(7, e), v(7, e), k(8, e), v(8, e));
+ case 10: return Map.of(k(0, e), v(0, e), k(1, e), v(1, e), k(2, e), v(2, e), k(3, e), v(3, e), k(4, e), v(4, e), k(5, e), v(5, e), k(6, e), v(6, e), k(7, e), v(7, e), k(8, e), v(8, e), k(9, e), v(9, e));
+ default:
+ fail(this + " requires 0 to 10 entries");
+ throw new AssertionError("unreachable");
+ }
+
+ }
+ },
+ OF_ENTRIES {
+ @Override
+ <K, V> Map<K, V> create(Map.Entry<K, V>... entries) {
+ return Map.ofEntries(entries);
+ }
+ }
+ ;
+ abstract <K,V> Map<K, V> create(Map.Entry<K,V>... entries);
+ }
+
+ private static void assertThrowsIae(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ private static void assertThrowsUoe(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+ }
+
+ private static void assertThrowsNpe(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (NullPointerException expected) {
+ }
+ }
+}
diff --git a/luni/src/test/java/libcore/java/util/ObjectsTest.java b/luni/src/test/java/libcore/java/util/ObjectsTest.java
index 735f6c5..6e118e9 100644
--- a/luni/src/test/java/libcore/java/util/ObjectsTest.java
+++ b/luni/src/test/java/libcore/java/util/ObjectsTest.java
@@ -25,6 +25,111 @@
public String toString() { return "hello"; }
}
+ public void test_checkFromIndexSize_valid() {
+ Objects.checkFromIndexSize(/* fromIndex */ 0, /* size */ 0, /* length */ 10);
+ Objects.checkFromIndexSize(/* fromIndex */ 10, /* size */ 0, /* length */ 10);
+ Objects.checkFromIndexSize(/* fromIndex */ 5, /* size */ 1, /* length */ 10);
+ Objects.checkFromIndexSize(/* fromIndex */ 0, /* size */ 10, /* length */ 10);
+ Objects.checkFromIndexSize(/* fromIndex */ 1, /* size */ 9, /* length */ 10);
+ Objects.checkFromIndexSize(/* fromIndex */ 0, /* size */ 9, /* length */ 10);
+ }
+
+ public void test_checkFromIndexSize_negativeSize() {
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ -1, /* size */ 10, /* length */ 100);
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ 5, /* size */ -1, /* length */ 100);
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ 0, /* size */ -1, /* length */ 100);
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ 0, /* size */ -1, /* length */ -1);
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ 0, /* size */ 0, /* length */ -1);
+ }
+
+ public void test_checkFromIndexSize_beyondEnd() {
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ 0, /* size */ 10, /* length */ 9);
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ 1, /* size */ 10, /* length */ 10);
+
+ // Invalid, but fromIndex + size overflows and is < length.
+ assertFromIndexSizeOutOfBounds(/* fromIndex */ Integer.MAX_VALUE - 10, /* size */ 11,
+ /* length */ Integer.MAX_VALUE);
+ }
+
+ private static void assertFromIndexSizeOutOfBounds(int fromIndex, int size, int length) {
+ try {
+ Objects.checkFromIndexSize(fromIndex, size, length);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ }
+ }
+
+ public void test_checkFromToIndex_valid() {
+ Objects.checkFromToIndex(/* fromIndex */ 0, /* toIndex */ 0, /* length */ 10);
+ Objects.checkFromToIndex(/* fromIndex */ 10, /* toIndex */ 10, /* length */ 10);
+ Objects.checkFromToIndex(/* fromIndex */ 5, /* toIndex */ 6, /* length */ 10);
+ Objects.checkFromToIndex(/* fromIndex */ 0, /* toIndex */ 10, /* length */ 10);
+ Objects.checkFromToIndex(/* fromIndex */ 1, /* toIndex */ 10, /* length */ 10);
+ Objects.checkFromToIndex(/* fromIndex */ 0, /* toIndex */ 0, /* length */ 10);
+ }
+
+ public void test_checkFromToIndex_negativeSize() {
+ assertFromToIndexOutOfBounds(/* fromIndex */ -1, /* toIndex */ 9, /* length */ 100);
+ assertFromToIndexOutOfBounds(/* fromIndex */ 5, /* toIndex */ 4, /* length */ 100);
+ assertFromToIndexOutOfBounds(/* fromIndex */ 0, /* toIndex */ -1, /* length */ 100);
+ assertFromToIndexOutOfBounds(/* fromIndex */ 0, /* toIndex */ -1, /* length */ -1);
+ assertFromToIndexOutOfBounds(/* fromIndex */ 0, /* toIndex */ 0, /* length */ -1);
+ }
+
+ public void test_checkFromToIndex_beyondEnd() {
+ assertFromToIndexOutOfBounds(/* fromIndex */ 0, /* toIndex */ 10, /* length */ 9);
+ assertFromToIndexOutOfBounds(/* fromIndex */ 1, /* toIndex */ 11, /* length */ 10);
+ assertFromToIndexOutOfBounds(/* fromIndex */ Integer.MAX_VALUE - 10,
+ /* toIndex */ Integer.MIN_VALUE, /* length */ Integer.MAX_VALUE);
+ }
+
+ private static void assertFromToIndexOutOfBounds(int fromIndex, int toIndex, int length) {
+ try {
+ Objects.checkFromToIndex(fromIndex, toIndex, length);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ }
+ }
+
+ public void test_checkIndex_empty() {
+ assertIndexOutOfBounds(0, 0);
+ assertIndexOutOfBounds(1, 0);
+ assertIndexOutOfBounds(-1, 0);
+ assertIndexOutOfBounds(100, 0);
+ assertIndexOutOfBounds(-100, 0);
+ assertIndexOutOfBounds(Integer.MAX_VALUE, 0);
+ assertIndexOutOfBounds(Integer.MAX_VALUE, 0);
+ }
+
+ public void test_checkIndex_size1() {
+ Objects.checkIndex(0, 1);
+ assertIndexOutOfBounds(1, 1);
+ assertIndexOutOfBounds(-1, 1);
+ assertIndexOutOfBounds(100, 1);
+ assertIndexOutOfBounds(-100, 1);
+ assertIndexOutOfBounds(Integer.MAX_VALUE, 1);
+ assertIndexOutOfBounds(Integer.MAX_VALUE, 1);
+ }
+
+ public void test_checkIndex_largeSize() {
+ Objects.checkIndex(0, 100);
+ Objects.checkIndex(99, 100);
+ Objects.checkIndex(100, Integer.MAX_VALUE);
+ Objects.checkIndex(Integer.MAX_VALUE - 1, Integer.MAX_VALUE);
+ assertIndexOutOfBounds(-1, 100);
+ assertIndexOutOfBounds(100, 100);
+ assertIndexOutOfBounds(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ assertIndexOutOfBounds(-1, Integer.MAX_VALUE);
+ }
+
+ private static void assertIndexOutOfBounds(int index, int length) {
+ try {
+ Objects.checkIndex(index, length);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ }
+ }
+
public void test_compare() throws Exception {
assertEquals(0, Objects.compare(null, null, String.CASE_INSENSITIVE_ORDER));
assertEquals(0, Objects.compare("a", "A", String.CASE_INSENSITIVE_ORDER));
@@ -121,6 +226,10 @@
} catch (NullPointerException expected) {
}
+ // This does not currently throw. The presence of this test ensures that any
+ // future behavior change is deliberate.
+ assertEquals(h, Objects.requireNonNull(h, (Supplier<String>) null));
+
// The message returned by the supplier is null.
try {
Objects.requireNonNull(null, () -> null);
@@ -130,6 +239,35 @@
}
}
+ public void test_requireNonNullElse() {
+ assertEquals("obj", Objects.requireNonNullElse("obj", "default"));
+ assertEquals("default", Objects.requireNonNullElse(null, "default"));
+ assertEquals("obj", Objects.requireNonNullElse("obj", null));
+ assertThrowsNpe(() -> Objects.requireNonNullElse(null, null));
+ }
+
+ public void test_requireNonNullElseGet_obj() {
+ assertEquals("obj", Objects.requireNonNullElseGet("obj", () -> "default"));
+ // null supplier / supplier that returns null is tolerated when obj != null.
+ assertEquals("obj", Objects.requireNonNullElseGet("obj", () -> null));
+ assertEquals("obj", Objects.requireNonNullElseGet("obj", null));
+ }
+
+ public void test_requireNonNullElseGet_nullObj() {
+ assertEquals("default", Objects.requireNonNullElseGet(null, () -> "default"));
+ // null supplier and supplier of null both throw.
+ assertThrowsNpe(() -> Objects.requireNonNullElseGet(null, (Supplier<?>) () -> null));
+ assertThrowsNpe(() -> Objects.requireNonNullElse(null, null));
+ }
+
+ private static void assertThrowsNpe(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (NullPointerException expected) {
+ }
+ }
+
public void test_toString_Object() throws Exception {
assertEquals("hello", Objects.toString(new Hello()));
assertEquals("null", Objects.toString(null));
diff --git a/luni/src/test/java/libcore/java/util/SetOfTest.java b/luni/src/test/java/libcore/java/util/SetOfTest.java
new file mode 100644
index 0000000..86dfc74
--- /dev/null
+++ b/luni/src/test/java/libcore/java/util/SetOfTest.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.java.util;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Predicate;
+import libcore.libcore.util.SerializationTester;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class SetOfTest {
+
+ @Test public void of_serializationCompatibility_empty() {
+ String golden = "ACED00057372001E6A6176612E7574696C2E436F6C6C656374696F6E7324456D7074795365"
+ + "7415F5721DB403CB280200007870";
+ new SerializationTester<>(Set.<String>of(), golden).test();
+ }
+
+ @Test public void of_serializationCompatibility_oneElement() {
+ String golden = "ACED0005737200256A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C65536574801D92D18F9B80550200007872002C6A6176612E7574696C2E436F6C6C656374"
+ + "696F6E7324556E6D6F6469666961626C65436F6C6C656374696F6E19420080CB5EF71E0200014C00"
+ + "01637400164C6A6176612F7574696C2F436F6C6C656374696F6E3B7870737200116A6176612E7574"
+ + "696C2E48617368536574BA44859596B8B7340300007870770C000000023F40000000000001740003"
+ + "6F6E6578";
+ new SerializationTester<>(Set.of("one"), golden).test();
+ }
+
+ @Test public void of_serializationCompatibility_manyElements() {
+ String golden = "ACED0005737200256A6176612E7574696C2E436F6C6C656374696F6E7324556E6D6F646966"
+ + "6961626C65536574801D92D18F9B80550200007872002C6A6176612E7574696C2E436F6C6C656374"
+ + "696F6E7324556E6D6F6469666961626C65436F6C6C656374696F6E19420080CB5EF71E0200014C00"
+ + "01637400164C6A6176612F7574696C2F436F6C6C656374696F6E3B7870737200116A6176612E7574"
+ + "696C2E48617368536574BA44859596B8B7340300007870770C000000203F4000000000000D737200"
+ + "116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200"
+ + "106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000007371007E0006"
+ + "000000017371007E0006000000027371007E0006000000037371007E0006000000047371007E0006"
+ + "000000057371007E0006000000067371007E0006000000077371007E0006000000087371007E0006"
+ + "000000097371007E00060000000A7371007E00060000000B7371007E00060000000C78";
+ new SerializationTester<>(Set.of(12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0), golden).test();
+ }
+
+ @Test public void mixedTypes() {
+ Set<?> list = Set.of("element", 42);
+ assertEquals(asSet("element", 42), list);
+
+ assertTrue(list.contains("element"));
+ assertTrue(list.contains(42));
+ assertFalse(list.contains(new Object()));
+ assertFalse(list.contains(31));
+ }
+
+ @Test public void duplicate() {
+ assertThrowsIae(() -> { Set.of("duplicate", "duplicate"); });
+ assertThrowsIae(() -> { Set.of("duplicate", "duplicate", "duplicate"); });
+ assertThrowsIae(() -> { Set.of("a", "duplicate", "duplicate"); });
+ assertThrowsIae(() -> {
+ Set.of("a", "duplicate", "b", "c", "d", "e", "f", "g", "duplicate");
+ });
+ assertThrowsIae(() -> { Set.of("a", "duplicate", "b", "c", "d", "e", "f", "g",
+ "duplicate", "h", "i", "j", "k", "l"); });
+ }
+
+ /**
+ * Checks that when there is both a duplicate and null, the exception that is thrown
+ * depends on which occurs first.
+ */
+ @Test public void duplicateAndNull() {
+ assertThrowsNpe(() -> { Set.of("duplicate", null, "duplicate"); }); // null first
+ assertThrowsIae(() -> { Set.of("duplicate", "duplicate", null); }); // duplicate first
+ }
+
+ @Test public void empty() {
+ check_commonBehavior(Collections.<String>emptySet(), Set.<String>of(), "non-null example");
+ }
+
+ @Test public void nonEmpty() {
+ check_nonEmpty(asSet("one"), Set.of("one"));
+ check_nonEmpty(asSet("one", "two"), Set.of("one", "two"));
+ check_nonEmpty(asSet("one", "two", "three"), Set.of("one", "two", "three"));
+ check_nonEmpty(asSet("one", "two", "three", "four"),
+ Set.of("one", "two", "three", "four"));
+ check_nonEmpty(asSet("one", "two", "three", "four", "five"),
+ Set.of("one", "two", "three", "four", "five"));
+ check_nonEmpty(asSet("one", "two", "three", "four", "five", "six"),
+ Set.of("one", "two", "three", "four", "five", "six"));
+ check_nonEmpty(asSet("one", "two", "three", "four", "five", "six", "seven"),
+ Set.of("one", "two", "three", "four", "five", "six", "seven"));
+ check_nonEmpty(asSet(1, 2, 3, 4, 5, 6, 7, 8), Set.of(1, 2, 3, 4, 5, 6, 7, 8));
+ check_nonEmpty(asSet(1, 2, 3, 4, 5, 6, 7, 8, 9), Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9));
+ check_nonEmpty(asSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+ Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
+ check_nonEmpty(asSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
+ Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
+ check_nonEmpty(asSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
+ Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
+ check_nonEmpty(asSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
+ Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13));
+ }
+
+ @Test public void null_examples() {
+ assertThrowsNpe(() -> List.<String>of((String) null)); // one-arg version
+ assertThrowsNpe(() -> List.<String[]>of((String[]) null)); // null var-args array
+ assertThrowsNpe(() -> List.<String>of(new String[] { "one", null, "three"})); // var-args
+
+ assertThrowsNpe(() -> Set.of(null, "two"));
+ assertThrowsNpe(() -> Set.of("one", null));
+ assertThrowsNpe(
+ () -> Set.of(null, "two", "three", "four", "five", "six", "seven"));
+ assertThrowsNpe(
+ () -> Set.of("one", "two", "three", "four", "five", "six", null));
+ }
+
+ @Test public void null_comprehensive() {
+ Set<Integer> template = asSet(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
+ for (int i = 0; i < template.size(); i++) {
+ Integer[] l = template.toArray(new Integer[0]);
+ l[i] = null;
+ npe(i <= 0, () -> Set.of(l[0]));
+ npe(i <= 1, () -> Set.of(l[0], l[1]));
+ npe(i <= 2, () -> Set.of(l[0], l[1], l[2]));
+ npe(i <= 3, () -> Set.of(l[0], l[1], l[2], l[3]));
+ npe(i <= 4, () -> Set.of(l[0], l[1], l[2], l[3], l[4]));
+ npe(i <= 5, () -> Set.of(l[0], l[1], l[2], l[3], l[4], l[5]));
+ npe(i <= 6, () -> Set.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6]));
+ npe(i <= 7, () -> Set.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7]));
+ npe(i <= 8, () -> Set.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8]));
+ npe(i <= 9, () -> Set.of(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9]));
+ npe(i <= 10, () -> Set.of(
+ l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10]));
+ npe(i <= 11, () -> Set.of(
+ l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10], l[11]));
+ npe(i <= 12, () -> Set.of(
+ l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10], l[11], l[12])
+ );
+ }
+ }
+
+ /**
+ * Asserts that {@code runnable.run()} throws {@link NullPointerException} if
+ * any only if {@code expectedToThrowNpe}.
+ */
+ private static void npe(boolean expectedToThrowNpe, Runnable runnable) {
+ if (expectedToThrowNpe) {
+ assertThrowsNpe(runnable);
+ } else {
+ runnable.run(); // should not throw
+ }
+ }
+
+ private static<T extends Comparable<T>> void check_nonEmpty(Set<T> expected, Set<T> actual) {
+ T example = actual.iterator().next();
+ check_commonBehavior(expected, actual, example);
+ }
+
+ /** Checks assertions that hold for all Set.of() instances. */
+ private static<T extends Comparable<T>> void check_commonBehavior(
+ Set<T> expected, Set<T> actual, T nonNullExample) {
+ assertNotNull(nonNullExample);
+ assertEquals(expected, actual);
+ assertEquals(expected.size(), actual.size());
+ assertEquals(expected.hashCode(), actual.hashCode());
+ assertEquals(actual.isEmpty(), actual.isEmpty());
+ assertEquals(actual.size() == 0, actual.isEmpty());
+ assertEquals(expected.contains(nonNullExample), actual.contains(nonNullExample));
+ assertFalse(actual.contains("absent-element"));
+ assertFalse(actual.contains(new Object()));
+ assertThrowsNpe(() -> actual.contains(null));
+
+ assertUnmodifiable(actual, nonNullExample);
+ assertEquals(actual, reserialize((Serializable) actual));
+ }
+
+ private static<T extends Comparable<T>> void assertUnmodifiable(Set<T> set, T example) {
+ Set<T> examples = Collections.singleton(example);
+ assertTrue(throwsUoe(() -> { set.add(example); } ));
+ assertTrue(throwsUoe(() -> { set.addAll(examples); } ));
+ // List.of() documentation guarantees that the following operations throw
+ // UnsupportedOperationException, even though some other implementations don't
+ // do that in the case of isEmpty().
+ assertTrue(throwsUoe(() -> { set.clear(); }));
+ assertTrue(throwsUoe(() -> { set.remove(example); } ));
+ assertTrue(throwsUoe(() -> { set.removeAll(examples); } ));
+ assertTrue(throwsUoe(() -> { set.removeIf(Predicate.isEqual(example)); } ));
+ assertTrue(throwsUoe(() -> { set.retainAll(examples); } ));
+ }
+
+ private static boolean throwsUoe(Runnable runnable) {
+ try {
+ runnable.run();
+ return false;
+ } catch (UnsupportedOperationException tolerated) {
+ return true;
+ }
+ }
+
+ private static void assertThrowsIae(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ private static void assertThrowsNpe(Runnable runnable) {
+ try {
+ runnable.run();
+ fail();
+ } catch (NullPointerException expected) {
+ }
+ }
+
+ private static <S extends Serializable> S reserialize(S value) {
+ try {
+ return (S) SerializationTester.reserialize(value);
+ } catch (IOException | ClassNotFoundException e) {
+ fail("Unexpected exception: " + e.getMessage());
+ throw new AssertionError(e); // unreachable
+ }
+ }
+
+ private static<T> Set<T> asSet(T... values) {
+ return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(values)));
+ }
+
+}
diff --git a/luni/src/test/java/libcore/java/util/zip/DeflateRegressionTest.java b/luni/src/test/java/libcore/java/util/zip/DeflateRegressionTest.java
deleted file mode 100644
index d3b38a0..0000000
--- a/luni/src/test/java/libcore/java/util/zip/DeflateRegressionTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed 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
- *
- * 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 libcore.java.util.zip;
-
-import com.google.archivepatcher.shared.DefaultDeflateCompatibilityWindow;
-import com.google.archivepatcher.shared.JreDeflateParameters;
-
-import org.junit.Test;
-
-import static org.junit.Assert.fail;
-
-import java.util.Map;
-
-/**
- * A regression test for Deflate and the underlying native libraries. If any of these tests fail
- * it suggests that tools such as Google Play Store that rely on deterministic binary output from
- * Deflate; those tools may behave inefficiently if the output changes.
- */
-public class DeflateRegressionTest {
-
- /*
- * If this test fails then it implies a change that could regress Android user performance.
- * Please check that the platform version of Deflate is still used by affected tools and notify
- * them. See also http://b/27637914.
- */
- @Test
- public void deterministicOutput() throws Exception {
- DefaultDeflateCompatibilityWindow compatibilityWindow
- = new DefaultDeflateCompatibilityWindow();
- if (!compatibilityWindow.isCompatible()) {
- Map<JreDeflateParameters, String>
- incompatibleValues = compatibilityWindow.getIncompatibleValues();
- fail("Incompatible values found: " + incompatibleValues);
- }
- }
-}
diff --git a/luni/src/test/java/libcore/libcore/content/type/MimeMapTest.java b/luni/src/test/java/libcore/libcore/content/type/MimeMapTest.java
index f7bb140..764bad2 100644
--- a/luni/src/test/java/libcore/libcore/content/type/MimeMapTest.java
+++ b/luni/src/test/java/libcore/libcore/content/type/MimeMapTest.java
@@ -241,7 +241,7 @@
// null or "" are not allowed for either MIME type or extension
assertPutThrowsNpe(null, "ext");
assertPutThrowsIae("", "ext");
- assertPutThrowsNpe("mime/type", null);
+ assertPutThrowsNpe("mime/type", (String) null);
assertPutThrowsIae("mime/type", "");
assertPutThrowsNpe("mime/type", "ext", null);
diff --git a/luni/src/test/java/libcore/libcore/icu/ICUTest.java b/luni/src/test/java/libcore/libcore/icu/ICUTest.java
index a7b4e4b..30e3081 100644
--- a/luni/src/test/java/libcore/libcore/icu/ICUTest.java
+++ b/luni/src/test/java/libcore/libcore/icu/ICUTest.java
@@ -220,4 +220,25 @@
assertTrue(c.compare("AF", "af") < 0);
}
+ public void testSetDefault() {
+ String current = ICU.getDefaultLocale();
+
+ try {
+ assertGetDefault("", "");
+ assertGetDefault("und", "");
+ assertGetDefault("en-US", "en_US");
+ assertGetDefault("uz-CYRL-UZ", "uz_Cyrl_UZ");
+ assertGetDefault("ca-ES-PREEURO", "ca_ES_PREEURO");
+ assertGetDefault("es-ES-PREEURO-u-ca-japanese", "es_ES_PREEURO@calendar=japanese");
+ assertGetDefault("es-ES-PREEURO-u-ca-Japanese", "es_ES_PREEURO@calendar=japanese");
+ } finally {
+ ICU.setDefaultLocale(current);
+ }
+ }
+
+ private static void assertGetDefault(String inputLangaugeTag, String expectedLanguageTag) {
+ ICU.setDefaultLocale(inputLangaugeTag);
+ assertEquals(expectedLanguageTag, ICU.getDefaultLocale());
+ }
+
}
diff --git a/luni/src/test/java/libcore/libcore/icu/TimeZoneIntegrationTest.java b/luni/src/test/java/libcore/libcore/icu/TimeZoneIntegrationTest.java
index 3470eb8..f24d8b1 100644
--- a/luni/src/test/java/libcore/libcore/icu/TimeZoneIntegrationTest.java
+++ b/luni/src/test/java/libcore/libcore/icu/TimeZoneIntegrationTest.java
@@ -22,6 +22,8 @@
import android.icu.util.VersionInfo;
import android.system.Os;
+import com.android.icu.util.Icu4cMetadata;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -37,11 +39,10 @@
import java.util.function.Function;
import java.util.stream.Collectors;
-import libcore.icu.ICU;
import libcore.timezone.TimeZoneDataFiles;
import libcore.timezone.TimeZoneFinder;
import libcore.timezone.TzDataSetVersion;
-import libcore.timezone.ZoneInfoDB;
+import libcore.timezone.ZoneInfoDb;
import libcore.util.CoreLibraryDebug;
import libcore.util.DebugInfo;
@@ -182,9 +183,9 @@
*/
@Test
public void testTimeZoneDataVersion() {
- String icu4cTzVersion = ICU.getTZDataVersion();
+ String icu4cTzVersion = Icu4cMetadata.getTzdbVersion();
- String zoneInfoTzVersion = ZoneInfoDB.getInstance().getVersion();
+ String zoneInfoTzVersion = ZoneInfoDb.getInstance().getVersion();
assertEquals(icu4cTzVersion, zoneInfoTzVersion);
String icu4jTzVersion = android.icu.util.TimeZone.getTZDataVersion();
@@ -246,9 +247,9 @@
TzDataSetVersion actualVersion = TzDataSetVersion.readFromFile(new File(versionFile));
assertEquals(
TzDataSetVersion.currentFormatMajorVersion(),
- actualVersion.formatMajorVersion);
+ actualVersion.getFormatMajorVersion());
int minDeviceMinorVersion = TzDataSetVersion.currentFormatMinorVersion();
- assertTrue(actualVersion.formatMinorVersion >= minDeviceMinorVersion);
+ assertTrue(actualVersion.getFormatMinorVersion() >= minDeviceMinorVersion);
}
/**
@@ -290,7 +291,7 @@
"core_library.timezone.source.system_status"));
assertFileExists(
TimeZoneDataFiles.getSystemTzFile(TzDataSetVersion.DEFAULT_FILE_NAME));
- assertFileExists(TimeZoneDataFiles.getSystemTzFile(ZoneInfoDB.TZDATA_FILE_NAME));
+ assertFileExists(TimeZoneDataFiles.getSystemTzFile(ZoneInfoDb.TZDATA_FILE_NAME));
// The following files once existed in /system but have been removed as part of APEX work.
assertFileDoesNotExist(
TimeZoneDataFiles.getSystemTzFile(TimeZoneFinder.TZLOOKUP_FILE_NAME));
@@ -308,7 +309,7 @@
Function<String, String> pathCreationFunction) {
List<String> relativePaths = Arrays.asList(
TzDataSetVersion.DEFAULT_FILE_NAME,
- ZoneInfoDB.TZDATA_FILE_NAME,
+ ZoneInfoDb.TZDATA_FILE_NAME,
TimeZoneFinder.TZLOOKUP_FILE_NAME);
return relativePaths.stream().map(pathCreationFunction).collect(Collectors.toList());
}
@@ -335,7 +336,7 @@
*/
@Test
public void testTimeZoneIdLookup() {
- String[] zoneInfoDbAvailableIds = ZoneInfoDB.getInstance().getAvailableIDs();
+ String[] zoneInfoDbAvailableIds = ZoneInfoDb.getInstance().getAvailableIDs();
// ICU has a known set of IDs. We want ANY because we don't want to filter to ICU's
// canonical IDs only.
diff --git a/luni/src/test/java/libcore/libcore/io/BlockGuardOsTest.java b/luni/src/test/java/libcore/libcore/io/BlockGuardOsTest.java
index 17f031b..218678e 100644
--- a/luni/src/test/java/libcore/libcore/io/BlockGuardOsTest.java
+++ b/luni/src/test/java/libcore/libcore/io/BlockGuardOsTest.java
@@ -226,6 +226,7 @@
"kill(int,int)",
"listen(java.io.FileDescriptor,int)",
"listxattr(java.lang.String)",
+ "memfd_create(java.lang.String,int)",
"mincore(long,long,byte[])",
"mlock(long,long)",
"mmap(long,long,int,int,java.io.FileDescriptor,long)",
diff --git a/luni/src/test/java/libcore/libcore/timezone/CountryTimeZonesTest.java b/luni/src/test/java/libcore/libcore/timezone/CountryTimeZonesTest.java
index 1b9aad0..cf32896 100644
--- a/luni/src/test/java/libcore/libcore/timezone/CountryTimeZonesTest.java
+++ b/luni/src/test/java/libcore/libcore/timezone/CountryTimeZonesTest.java
@@ -153,51 +153,44 @@
final Boolean isDst = true;
final Boolean notDst = false;
final Boolean unkIsDst = null;
- final Integer goodDstOffset = HOUR_MILLIS; // Every DST used here is one hour ahead.
- final Integer badDstOffset = HOUR_MILLIS + 1;
- final Integer unkDstOffset = null;
final TimeZone noBias = null;
final OffsetResult noMatch = null;
Object[][] testCases = new Object[][] {
- // totalOffsetMillis, isDst, dstOffsetMillis, whenMillis, bias, expectedMatch
+ // totalOffsetMillis, isDst, whenMillis, bias, expectedMatch
// The parameters match the zone: total offset and time.
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, noBias, lonMatch },
- { LON_NO_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_NO_DST, noBias, lonMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, noBias, lonMatch },
+ { LON_NO_DST_TOTAL_OFFSET, unkIsDst, WHEN_NO_DST, noBias, lonMatch },
// The parameters match the zone: total offset, isDst and time.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, noBias, lonMatch },
- { LON_DST_TOTAL_OFFSET, isDst, goodDstOffset, WHEN_DST, noBias, lonMatch },
- { LON_NO_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_NO_DST, noBias, lonMatch },
-
- // Lookup failures: bad DST offset.
- { LON_DST_TOTAL_OFFSET, isDst, badDstOffset, WHEN_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, noBias, lonMatch },
+ { LON_NO_DST_TOTAL_OFFSET, notDst, WHEN_NO_DST, noBias, lonMatch },
// Some lookup failure cases where the total offset, isDst and time do not match the
// zone.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { LON_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { LON_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, notDst, WHEN_NO_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, isDst, WHEN_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, notDst, WHEN_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, notDst, WHEN_DST, noBias, noMatch },
// Some bias cases below.
// The bias is irrelevant here: it matches what would be returned anyway.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, LON_TZ, lonMatch },
- { LON_NO_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_NO_DST, LON_TZ, lonMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, LON_TZ, lonMatch },
+ { LON_NO_DST_TOTAL_OFFSET, notDst, WHEN_NO_DST, LON_TZ, lonMatch },
// A sample of a non-matching case with bias.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, LON_TZ, noMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, LON_TZ, noMatch },
// The bias should be ignored: it doesn't match any of the country's zones.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, NY_TZ, lonMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, NY_TZ, lonMatch },
// The bias should still be ignored even though it matches the offset information
// given it doesn't match any of the country's zones.
- { NY_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, NY_TZ, noMatch },
+ { NY_DST_TOTAL_OFFSET, isDst, WHEN_DST, NY_TZ, noMatch },
};
executeLookupByOffsetWithBiasTestCases(countryTimeZones, testCases);
}
@@ -215,9 +208,6 @@
final Boolean isDst = true;
final Boolean notDst = false;
final Boolean unkIsDst = null;
- final Integer unkDstOffset = null;
- final Integer goodDstOffset = HOUR_MILLIS; // Every DST used here is one hour ahead.
- final Integer badDstOffset = HOUR_MILLIS + 1;
final TimeZone noBias = null;
final OffsetResult noMatch = null;
@@ -225,51 +215,43 @@
// totalOffsetMillis, isDst, dstOffsetMillis, whenMillis, bias, expectedMatch
// The parameters match the zone: total offset and time.
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, noBias, lonMatch },
- { LON_NO_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_NO_DST, noBias, lonMatch },
- { NY_NO_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_NO_DST, noBias, nyMatch },
- { NY_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, noBias, nyMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, noBias, lonMatch },
+ { LON_NO_DST_TOTAL_OFFSET, unkIsDst, WHEN_NO_DST, noBias, lonMatch },
+ { NY_NO_DST_TOTAL_OFFSET, unkIsDst, WHEN_NO_DST, noBias, nyMatch },
+ { NY_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, noBias, nyMatch },
// The parameters match the zone: total offset, isDst and time.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, noBias, lonMatch },
- { LON_NO_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_NO_DST, noBias, lonMatch },
- { NY_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, noBias, nyMatch },
- { NY_NO_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_NO_DST, noBias, nyMatch },
-
- // The parameters match the zone: total offset, isDst, DST offset and time.
- { LON_DST_TOTAL_OFFSET, isDst, goodDstOffset, WHEN_DST, noBias, lonMatch },
- { NY_DST_TOTAL_OFFSET, isDst, goodDstOffset, WHEN_DST, noBias, nyMatch },
-
- // Lookup failures: bad DST offset.
- { LON_DST_TOTAL_OFFSET, isDst, badDstOffset, WHEN_DST, noBias, noMatch },
- { NY_DST_TOTAL_OFFSET, isDst, badDstOffset, WHEN_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, noBias, lonMatch },
+ { LON_NO_DST_TOTAL_OFFSET, notDst, WHEN_NO_DST, noBias, lonMatch },
+ { NY_DST_TOTAL_OFFSET, isDst, WHEN_DST, noBias, nyMatch },
+ { NY_NO_DST_TOTAL_OFFSET, notDst, WHEN_NO_DST, noBias, nyMatch },
// Some lookup failure cases where the total offset, isDst and time do not match the
// zone. This is a sample, not complete.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { LON_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, noBias, noMatch },
- { LON_NO_DST_TOTAL_OFFSET, notDst, unkDstOffset, WHEN_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_NO_DST, noBias, noMatch },
+ { LON_DST_TOTAL_OFFSET, notDst, WHEN_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, isDst, WHEN_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, noBias, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, notDst, WHEN_DST, noBias, noMatch },
// Some bias cases below.
// The bias is irrelevant here: it matches what would be returned anyway.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, LON_TZ, lonMatch },
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, LON_TZ, lonMatch },
- { LON_NO_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_NO_DST, LON_TZ, lonMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, LON_TZ, lonMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, LON_TZ, lonMatch },
+ { LON_NO_DST_TOTAL_OFFSET, unkIsDst, WHEN_NO_DST, LON_TZ, lonMatch },
// A sample of non-matching cases with bias.
- { LON_NO_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, LON_TZ, noMatch },
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_NO_DST, LON_TZ, noMatch },
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_NO_DST, LON_TZ, noMatch },
+ { LON_NO_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, LON_TZ, noMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_NO_DST, LON_TZ, noMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_NO_DST, LON_TZ, noMatch },
// The bias should be ignored: it matches a zone, but the offset is wrong so
// should not be considered a match.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, NY_TZ, lonMatch },
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, NY_TZ, lonMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, NY_TZ, lonMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, NY_TZ, lonMatch },
};
executeLookupByOffsetWithBiasTestCases(countryTimeZones, testCases);
}
@@ -288,9 +270,6 @@
final Boolean isDst = true;
final Boolean notDst = false;
final Boolean unkIsDst = null;
- final Integer unkDstOffset = null;
- final Integer goodDstOffset = HOUR_MILLIS; // Every DST used here is one hour ahead.
- final Integer badDstOffset = HOUR_MILLIS + 1;
final TimeZone noBias = null;
final OffsetResult noMatch = null;
@@ -308,49 +287,42 @@
// totalOffsetMillis, isDst, dstOffsetMillis, whenMillis, bias, expectedMatch
// The parameters match one zone: total offset and time.
- { dstTotalOffset, unkIsDst, unkDstOffset, WHEN_DST, noBias, lonOnlyMatch },
- { dstTotalOffset, unkIsDst, unkDstOffset, WHEN_DST, noBias, lonOnlyMatch },
+ { dstTotalOffset, unkIsDst, WHEN_DST, noBias, lonOnlyMatch },
+ { dstTotalOffset, unkIsDst, WHEN_DST, noBias, lonOnlyMatch },
// The parameters match several zones: total offset and time.
- { noDstTotalOffset, unkIsDst, unkDstOffset, WHEN_NO_DST, noBias, reykBestMatch },
- { noDstTotalOffset, unkIsDst, unkDstOffset, WHEN_DST, noBias, reykBestMatch },
+ { noDstTotalOffset, unkIsDst, WHEN_NO_DST, noBias, reykBestMatch },
+ { noDstTotalOffset, unkIsDst, WHEN_DST, noBias, reykBestMatch },
// The parameters match one zone: total offset, isDst and time.
- { dstTotalOffset, isDst, unkDstOffset, WHEN_DST, noBias, lonOnlyMatch },
- { dstTotalOffset, isDst, unkDstOffset, WHEN_DST, noBias, lonOnlyMatch },
+ { dstTotalOffset, isDst, WHEN_DST, noBias, lonOnlyMatch },
+ { dstTotalOffset, isDst, WHEN_DST, noBias, lonOnlyMatch },
- // The parameters match one zone: total offset, isDst, DST offset and time.
- { dstTotalOffset, isDst, goodDstOffset, WHEN_DST, noBias, lonOnlyMatch },
-
- // The parameters match several zones: total offset, isDst and time.
- { noDstTotalOffset, notDst, unkDstOffset, WHEN_NO_DST, noBias, reykBestMatch },
- { noDstTotalOffset, notDst, unkDstOffset, WHEN_DST, noBias, reykBestMatch },
-
- // Lookup failures: bad DST offset.
- { dstTotalOffset, isDst, badDstOffset, WHEN_DST, noBias, noMatch },
+ { noDstTotalOffset, notDst, WHEN_NO_DST, noBias, reykBestMatch },
+ { noDstTotalOffset, notDst, WHEN_DST, noBias, reykBestMatch },
// Some lookup failure cases where the total offset, isDst and time do not match any
// zone.
- { dstTotalOffset, isDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { dstTotalOffset, unkIsDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { noDstTotalOffset, isDst, unkDstOffset, WHEN_NO_DST, noBias, noMatch },
- { noDstTotalOffset, isDst, unkDstOffset, WHEN_DST, noBias, noMatch },
+ { dstTotalOffset, isDst, WHEN_NO_DST, noBias, noMatch },
+ { dstTotalOffset, unkIsDst, WHEN_NO_DST, noBias, noMatch },
+ { noDstTotalOffset, isDst, WHEN_NO_DST, noBias, noMatch },
+ { noDstTotalOffset, isDst, WHEN_DST, noBias, noMatch },
// Some bias cases below.
// Multiple zones match but Reykjavik is the bias.
- { noDstTotalOffset, notDst, unkDstOffset, WHEN_NO_DST, REYK_TZ, reykBestMatch },
+ { noDstTotalOffset, notDst, WHEN_NO_DST, REYK_TZ, reykBestMatch },
// Multiple zones match but London is the bias.
- { noDstTotalOffset, notDst, unkDstOffset, WHEN_NO_DST, LON_TZ, lonBestMatch },
+ { noDstTotalOffset, notDst, WHEN_NO_DST, LON_TZ, lonBestMatch },
// Multiple zones match but UTC is the bias.
- { noDstTotalOffset, notDst, unkDstOffset, WHEN_NO_DST, UTC_TZ, utcBestMatch },
+ { noDstTotalOffset, notDst, WHEN_NO_DST, UTC_TZ, utcBestMatch },
// The bias should be ignored: it matches a zone, but the offset is wrong so
// should not be considered a match.
- { LON_DST_TOTAL_OFFSET, isDst, unkDstOffset, WHEN_DST, REYK_TZ, lonOnlyMatch },
- { LON_DST_TOTAL_OFFSET, unkIsDst, unkDstOffset, WHEN_DST, REYK_TZ, lonOnlyMatch },
+ { LON_DST_TOTAL_OFFSET, isDst, WHEN_DST, REYK_TZ, lonOnlyMatch },
+ { LON_DST_TOTAL_OFFSET, unkIsDst, WHEN_DST, REYK_TZ, lonOnlyMatch },
};
executeLookupByOffsetWithBiasTestCases(countryTimeZones, testCases);
}
@@ -363,24 +335,28 @@
Object[] testCase = testCases[i];
int totalOffsetMillis = (int) testCase[0];
Boolean isDst = (Boolean) testCase[1];
- Integer dstOffsetMillis = (Integer) testCase[2];
- long whenMillis = (Long) testCase[3];
- TimeZone bias = (TimeZone) testCase[4];
- OffsetResult expectedMatch = (OffsetResult) testCase[5];
+ long whenMillis = (Long) testCase[2];
+ TimeZone bias = (TimeZone) testCase[3];
+ OffsetResult expectedMatch = (OffsetResult) testCase[4];
- OffsetResult actualMatch = countryTimeZones.lookupByOffsetWithBias(
- totalOffsetMillis, isDst, dstOffsetMillis, whenMillis, bias);
+ OffsetResult actualMatch;
+ if (isDst == null) {
+ actualMatch = countryTimeZones.lookupByOffsetWithBias(
+ whenMillis, bias, totalOffsetMillis);
+ } else {
+ actualMatch = countryTimeZones.lookupByOffsetWithBias(
+ whenMillis, bias, totalOffsetMillis, isDst);
+ }
if (!offsetResultEquals(expectedMatch, actualMatch)) {
Function<TimeZone, String> timeZoneFormatter =
x -> x == null ? "null" : x.getID();
Function<OffsetResult, String> offsetResultFormatter =
x -> x == null ? "null"
- : "{" + x.mTimeZone.getID() + ", " + x.mOneMatch + "}";
+ : "{" + x.getTimeZone().getID() + ", " + x.isOnlyMatch() + "}";
failures.add("Fail: case=" + i
+ ", totalOffsetMillis=" + totalOffsetMillis
+ ", isDst=" + isDst
- + ", dstOffsetMillis=" + dstOffsetMillis
+ ", whenMillis=" + whenMillis
+ ", bias=" + timeZoneFormatter.apply(bias)
+ ", expectedMatch=" + offsetResultFormatter.apply(expectedMatch)
@@ -504,7 +480,11 @@
public void timeZoneMapping_getTimeZone_badZoneId() {
TimeZoneMapping timeZoneMapping =
TimeZoneMapping.createForTests("DOES_NOT_EXIST", true, 1234L);
- assertNull(timeZoneMapping.getTimeZone());
+ try {
+ timeZoneMapping.getTimeZone();
+ fail();
+ } catch (RuntimeException expected) {
+ }
}
@Test
@@ -540,8 +520,8 @@
private static boolean offsetResultEquals(OffsetResult expected, OffsetResult actual) {
return expected == actual
|| (expected != null && actual != null
- && Objects.equals(expected.mTimeZone.getID(), actual.mTimeZone.getID())
- && expected.mOneMatch == actual.mOneMatch);
+ && Objects.equals(expected.getTimeZone().getID(), actual.getTimeZone().getID())
+ && expected.isOnlyMatch() == actual.isOnlyMatch());
}
/**
diff --git a/luni/src/test/java/libcore/libcore/timezone/TelephonyLookupTest.java b/luni/src/test/java/libcore/libcore/timezone/TelephonyLookupTest.java
new file mode 100644
index 0000000..8b4d867
--- /dev/null
+++ b/luni/src/test/java/libcore/libcore/timezone/TelephonyLookupTest.java
@@ -0,0 +1,367 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.libcore.timezone;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import libcore.timezone.TelephonyLookup;
+import libcore.timezone.TelephonyNetwork;
+import libcore.timezone.TelephonyNetworkFinder;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+public class TelephonyLookupTest {
+
+ private Path testDir;
+
+ @Before
+ public void setUp() throws Exception {
+ testDir = Files.createTempDirectory("TelephonyLookupTest");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Delete the testDir and all contents.
+ Files.walkFileTree(testDir, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+ throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc)
+ throws IOException {
+ Files.delete(dir);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+
+ @Test
+ public void createInstanceWithFallback() throws Exception {
+ String validXml1 = "<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n";
+ TelephonyNetwork expectedTelephonyNetwork1 =
+ TelephonyNetwork.create("123", "456", "gb");
+
+ String validXml2 = "<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"234\" mnc=\"567\" country=\"fr\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n";
+ TelephonyNetwork expectedTelephonyNetwork2 =
+ TelephonyNetwork.create("234", "567", "fr");
+
+ String invalidXml = "<foo></foo>\n";
+ checkValidateThrowsParserException(invalidXml);
+
+ String validFile1 = createFile(validXml1);
+ String validFile2 = createFile(validXml2);
+ String invalidFile = createFile(invalidXml);
+ String missingFile = createMissingFile();
+
+ TelephonyLookup file1ThenFile2 =
+ TelephonyLookup.createInstanceWithFallback(validFile1, validFile2);
+ assertEquals(list(expectedTelephonyNetwork1),
+ file1ThenFile2.getTelephonyNetworkFinder().getAll());
+
+ TelephonyLookup missingFileThenFile1 =
+ TelephonyLookup.createInstanceWithFallback(missingFile, validFile1);
+ assertEquals(list(expectedTelephonyNetwork1),
+ missingFileThenFile1.getTelephonyNetworkFinder().getAll());
+
+ TelephonyLookup file2ThenFile1 =
+ TelephonyLookup.createInstanceWithFallback(validFile2, validFile1);
+ assertEquals(list(expectedTelephonyNetwork2),
+ file2ThenFile1.getTelephonyNetworkFinder().getAll());
+
+ // We assume the file has been validated so an invalid file is not checked ahead of time.
+ // We will find out when we look something up.
+ TelephonyLookup invalidThenValid =
+ TelephonyLookup.createInstanceWithFallback(invalidFile, validFile1);
+ assertNull(invalidThenValid.getTelephonyNetworkFinder());
+
+ // This is not a normal case: It would imply a device shipped without a file anywhere!
+ TelephonyLookup missingFiles =
+ TelephonyLookup.createInstanceWithFallback(missingFile, missingFile);
+ assertEmpty(missingFiles.getTelephonyNetworkFinder().getAll());
+ }
+
+ @Test
+ public void xmlParsing_emptyFile() throws Exception {
+ checkValidateThrowsParserException("");
+ }
+
+ @Test
+ public void xmlParsing_unexpectedRootElement() throws Exception {
+ checkValidateThrowsParserException("<foo></foo>\n");
+ }
+
+ @Test
+ public void xmlParsing_missingNetworks() throws Exception {
+ checkValidateThrowsParserException("<telephony_lookup></telephony_lookup>\n");
+ }
+
+ @Test
+ public void xmlParsing_emptyNetworksOk() throws Exception {
+ {
+ TelephonyLookup telephonyLookup =
+ validate("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ TelephonyNetworkFinder telephonyNetworkFinder = telephonyLookup
+ .getTelephonyNetworkFinder();
+ assertEquals(list(), telephonyNetworkFinder.getAll());
+ }
+ {
+ TelephonyLookup telephonyLookup =
+ validate("<telephony_lookup>\n"
+ + " <networks/>\n"
+ + "</telephony_lookup>\n");
+ TelephonyNetworkFinder telephonyNetworkFinder = telephonyLookup
+ .getTelephonyNetworkFinder();
+ assertEquals(list(), telephonyNetworkFinder.getAll());
+ }
+ }
+
+ @Test
+ public void xmlParsing_unexpectedComments() throws Exception {
+ TelephonyNetwork expectedTelephonyNetwork =
+ TelephonyNetwork.create("123", "456", "gb");
+
+ TelephonyLookup telephonyLookup = validate("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <!-- This is a comment -->"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ assertEquals(list(expectedTelephonyNetwork), telephonyLookup.getTelephonyNetworkFinder().getAll());
+ }
+
+ @Test
+ public void xmlParsing_unexpectedElementsIgnored() throws Exception {
+ TelephonyNetwork expectedTelephonyNetwork =
+ TelephonyNetwork.create("123", "456", "gb");
+ List<TelephonyNetwork> expectedNetworks = list(expectedTelephonyNetwork);
+
+ String unexpectedElement = "<unexpected-element>\n<a /></unexpected-element>\n";
+
+ // These tests are important because they ensure we can extend the format in future with
+ // more information but could continue using the same file on older devices.
+ TelephonyLookup telephonyLookup = validate("<telephony_lookup>\n"
+ + " " + unexpectedElement
+ + " <networks>\n"
+ + " " + unexpectedElement
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " " + unexpectedElement
+ + " </networks>\n"
+ + " " + unexpectedElement
+ + "</telephony_lookup>\n");
+ assertEquals(expectedNetworks, telephonyLookup.getTelephonyNetworkFinder().getAll());
+
+ telephonyLookup = validate("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\">\n"
+ + " " + unexpectedElement
+ + " </network>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ assertEquals(expectedNetworks, telephonyLookup.getTelephonyNetworkFinder().getAll());
+
+ expectedNetworks = list(expectedTelephonyNetwork,
+ TelephonyNetwork.create("234", "567", "fr"));
+ telephonyLookup = validate("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " " + unexpectedElement
+ + " <network mcc=\"234\" mnc=\"567\" country=\"fr\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ assertEquals(expectedNetworks, telephonyLookup.getTelephonyNetworkFinder().getAll());
+ }
+
+ @Test
+ public void xmlParsing_unexpectedTextIgnored() throws Exception {
+ TelephonyNetwork expectedTelephonyNetwork =
+ TelephonyNetwork.create("123", "456", "gb");
+ List<TelephonyNetwork> expectedNetworks = list(expectedTelephonyNetwork);
+
+ String unexpectedText = "unexpected-text";
+ TelephonyLookup telephonyLookup = validate("<telephony_lookup>\n"
+ + " " + unexpectedText
+ + " <networks>\n"
+ + " " + unexpectedText
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " " + unexpectedText
+ + " </networks>\n"
+ + " " + unexpectedText
+ + "</telephony_lookup>\n");
+ assertEquals(expectedNetworks, telephonyLookup.getTelephonyNetworkFinder().getAll());
+
+ telephonyLookup = validate("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\">\n"
+ + " " + unexpectedText
+ + " </network>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ assertEquals(expectedNetworks, telephonyLookup.getTelephonyNetworkFinder().getAll());
+ }
+
+ @Test
+ public void xmlParsing_truncatedInput() throws Exception {
+ checkValidateThrowsParserException("<telephony_lookup>\n");
+
+ checkValidateThrowsParserException("<telephony_lookup>\n"
+ + " <networks>\n");
+
+ checkValidateThrowsParserException("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n");
+
+ checkValidateThrowsParserException("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " </networks>\n");
+ }
+
+ @Test
+ public void validateDuplicateMccMnc() {
+ checkValidateThrowsParserException("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" countryCode=\"gb\"/>\n"
+ + " <network mcc=\"123\" mnc=\"456\" countryCode=\"fr\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ }
+
+ @Test
+ public void validateCountryCodeLowerCase() {
+ checkValidateThrowsParserException("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" countryCode=\"GB\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ }
+
+
+ @Test
+ public void getTelephonyNetworkFinder() throws Exception {
+ TelephonyLookup telephonyLookup = TelephonyLookup.createInstanceForTests(
+ "<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\" country=\"gb\"/>\n"
+ + " <network mcc=\"234\" mnc=\"567\" country=\"fr\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+
+ TelephonyNetworkFinder telephonyNetworkFinder = telephonyLookup.getTelephonyNetworkFinder();
+ TelephonyNetwork expectedNetwork1 = TelephonyNetwork.create("123", "456", "gb");
+ TelephonyNetwork expectedNetwork2 = TelephonyNetwork.create("234", "567", "fr");
+ assertEquals(list(expectedNetwork1, expectedNetwork2), telephonyNetworkFinder.getAll());
+ assertEquals(expectedNetwork1, telephonyNetworkFinder.findNetworkByMccMnc("123", "456"));
+ assertEquals(expectedNetwork2, telephonyNetworkFinder.findNetworkByMccMnc("234", "567"));
+ assertNull(telephonyNetworkFinder.findNetworkByMccMnc("999", "999"));
+ }
+
+ @Test
+ public void xmlParsing_missingMccAttribute() throws Exception {
+ checkValidateThrowsParserException("<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mnc=\"456\" country=\"gb\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ }
+
+ @Test
+ public void xmlParsing_missingMncAttribute() throws Exception {
+ TelephonyLookup telephonyLookup = TelephonyLookup.createInstanceForTests(
+ "<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" country=\"gb\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ assertNull(telephonyLookup.getTelephonyNetworkFinder());
+ }
+
+ @Test
+ public void xmlParsing_missingCountryCodeAttribute() throws Exception {
+ TelephonyLookup telephonyLookup = TelephonyLookup.createInstanceForTests(
+ "<telephony_lookup>\n"
+ + " <networks>\n"
+ + " <network mcc=\"123\" mnc=\"456\"/>\n"
+ + " </networks>\n"
+ + "</telephony_lookup>\n");
+ assertNull(telephonyLookup.getTelephonyNetworkFinder());
+ }
+
+ private static void checkValidateThrowsParserException(String xml) {
+ try {
+ validate(xml);
+ fail();
+ } catch (IOException expected) {
+ }
+ }
+
+ private static TelephonyLookup validate(String xml) throws IOException {
+ TelephonyLookup telephonyLookup = TelephonyLookup.createInstanceForTests(xml);
+ telephonyLookup.validate();
+ return telephonyLookup;
+ }
+
+ private static void assertEmpty(Collection<?> collection) {
+ assertTrue("Expected empty:" + collection, collection.isEmpty());
+ }
+
+ private static <X> List<X> list(X... values) {
+ return Arrays.asList(values);
+ }
+
+ private String createFile(String fileContent) throws IOException {
+ Path filePath = Files.createTempFile(testDir, null, null);
+ Files.write(filePath, fileContent.getBytes(StandardCharsets.UTF_8));
+ return filePath.toString();
+ }
+
+ private String createMissingFile() throws IOException {
+ Path filePath = Files.createTempFile(testDir, null, null);
+ Files.delete(filePath);
+ return filePath.toString();
+ }
+}
diff --git a/luni/src/test/java/libcore/libcore/timezone/TelephonyNetworkFinderTest.java b/luni/src/test/java/libcore/libcore/timezone/TelephonyNetworkFinderTest.java
new file mode 100644
index 0000000..44dfc81
--- /dev/null
+++ b/luni/src/test/java/libcore/libcore/timezone/TelephonyNetworkFinderTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.libcore.timezone;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import libcore.timezone.TelephonyNetwork;
+import libcore.timezone.TelephonyNetworkFinder;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class TelephonyNetworkFinderTest {
+
+ @Test
+ public void testCreateAndLookups() {
+ TelephonyNetwork network = TelephonyNetwork.create("123", "456", "gb");
+ List<TelephonyNetwork> networkList = list(network);
+ TelephonyNetworkFinder finder = TelephonyNetworkFinder.create(networkList);
+ assertEquals(network, finder.findNetworkByMccMnc("123", "456"));
+ assertNull(finder.findNetworkByMccMnc("XXX", "XXX"));
+ assertNull(finder.findNetworkByMccMnc("123", "XXX"));
+ assertNull(finder.findNetworkByMccMnc("456", "123"));
+ assertNull(finder.findNetworkByMccMnc("111", "222"));
+ assertEquals(networkList, finder.getAll());
+ }
+
+ private static <X> List<X> list(X... values) {
+ return Arrays.asList(values);
+ }
+}
diff --git a/luni/src/test/java/libcore/libcore/timezone/TimeZoneDataFilesTest.java b/luni/src/test/java/libcore/libcore/timezone/TimeZoneDataFilesTest.java
index 282b18e..a74ba30 100644
--- a/luni/src/test/java/libcore/libcore/timezone/TimeZoneDataFilesTest.java
+++ b/luni/src/test/java/libcore/libcore/timezone/TimeZoneDataFilesTest.java
@@ -28,10 +28,12 @@
private static final String ANDROID_TZDATA_ROOT_ENV = "ANDROID_TZDATA_ROOT";
private static final String ANDROID_I18N_ROOT_ENV = "ANDROID_I18N_ROOT";
+ private static final String ANDROID_DATA_ENV = "ANDROID_DATA";
@Test
public void expectedEnvironmentVariables() {
// These environment variables are required to locate data files used by libcore / ICU.
+ assertNotNull(System.getenv(ANDROID_DATA_ENV));
assertNotNull(System.getenv(ANDROID_TZDATA_ROOT_ENV));
assertNotNull(System.getenv(ANDROID_I18N_ROOT_ENV));
}
@@ -41,6 +43,7 @@
String[] paths = TimeZoneDataFiles.getTimeZoneFilePaths("foo");
assertEquals(2, paths.length);
+ assertTrue(paths[0].startsWith(System.getenv(ANDROID_DATA_ENV)));
assertTrue(paths[0].contains("/misc/zoneinfo/current/"));
assertTrue(paths[0].endsWith("/foo"));
@@ -58,6 +61,7 @@
assertEquals(3, paths.length);
String dataDirPath = paths[0];
+ assertTrue(dataDirPath.startsWith(System.getenv(ANDROID_DATA_ENV)));
assertTrue(dataDirPath + " invalid", dataDirPath.contains("/misc/zoneinfo/current/icu"));
String tzdataModulePath = paths[1];
diff --git a/luni/src/test/java/libcore/libcore/timezone/TimeZoneFinderTest.java b/luni/src/test/java/libcore/libcore/timezone/TimeZoneFinderTest.java
index 261a605..ef07371 100644
--- a/luni/src/test/java/libcore/libcore/timezone/TimeZoneFinderTest.java
+++ b/luni/src/test/java/libcore/libcore/timezone/TimeZoneFinderTest.java
@@ -124,7 +124,7 @@
assertNull(invalidThenValid.getIanaVersion());
assertNull(invalidThenValid.lookupCountryTimeZones("gb"));
- // This is not a normal case: It would imply a define shipped without a file in /system!
+ // This is not a normal case: It would imply a device shipped without a file anywhere!
TimeZoneFinder missingFiles =
TimeZoneFinder.createInstanceWithFallback(missingFile, missingFile);
assertNull(missingFiles.getIanaVersion());
@@ -432,7 +432,7 @@
+ " </countryzones>\n"
+ "</timezones>\n");
CountryTimeZones countryTimeZones = finder.lookupCountryTimeZones("gb");
- assertTrue(countryTimeZones.getDefaultTimeZoneBoost());
+ assertTrue(countryTimeZones.isDefaultTimeZoneBoosted());
}
@Test
diff --git a/luni/src/test/java/libcore/libcore/timezone/TzDataSetVersionTest.java b/luni/src/test/java/libcore/libcore/timezone/TzDataSetVersionTest.java
index 75e079b..a653301 100644
--- a/luni/src/test/java/libcore/libcore/timezone/TzDataSetVersionTest.java
+++ b/luni/src/test/java/libcore/libcore/timezone/TzDataSetVersionTest.java
@@ -55,10 +55,10 @@
public void testConstructor() throws Exception {
TzDataSetVersion distroVersion = new TzDataSetVersion(1, 2, VALID_RULES_VERSION, 3);
- assertEquals(1, distroVersion.formatMajorVersion);
- assertEquals(2, distroVersion.formatMinorVersion);
- assertEquals(VALID_RULES_VERSION, distroVersion.rulesVersion);
- assertEquals(3, distroVersion.revision);
+ assertEquals(1, distroVersion.getFormatMajorVersion());
+ assertEquals(2, distroVersion.getFormatMinorVersion());
+ assertEquals(VALID_RULES_VERSION, distroVersion.getRulesVersion());
+ assertEquals(3, distroVersion.getRevision());
}
public void testToFromBytesRoundTrip() throws Exception {
diff --git a/luni/src/test/java/libcore/libcore/timezone/ZoneInfoDBTest.java b/luni/src/test/java/libcore/libcore/timezone/ZoneInfoDbTest.java
similarity index 85%
rename from luni/src/test/java/libcore/libcore/timezone/ZoneInfoDBTest.java
rename to luni/src/test/java/libcore/libcore/timezone/ZoneInfoDbTest.java
index 966df56..48eb286 100644
--- a/luni/src/test/java/libcore/libcore/timezone/ZoneInfoDBTest.java
+++ b/luni/src/test/java/libcore/libcore/timezone/ZoneInfoDbTest.java
@@ -23,22 +23,22 @@
import libcore.timezone.TimeZoneDataFiles;
import libcore.timezone.testing.ZoneInfoTestHelper;
import libcore.util.ZoneInfo;
-import libcore.timezone.ZoneInfoDB;
+import libcore.timezone.ZoneInfoDb;
-import static libcore.timezone.ZoneInfoDB.TzData.SIZEOF_INDEX_ENTRY;
+import static libcore.timezone.ZoneInfoDb.SIZEOF_INDEX_ENTRY;
-public class ZoneInfoDBTest extends junit.framework.TestCase {
+public class ZoneInfoDbTest extends junit.framework.TestCase {
// The base tzdata file, always present on a device.
private static final String TZDATA_FILE =
- TimeZoneDataFiles.getTimeZoneModuleTzFile(ZoneInfoDB.TZDATA_FILE_NAME);
+ TimeZoneDataFiles.getTimeZoneModuleTzFile(ZoneInfoDb.TZDATA_FILE_NAME);
// An empty override file should fall back to the default file.
public void testLoadTzDataWithFallback_emptyOverrideFile() throws Exception {
String emptyFilePath = makeEmptyFile().getPath();
- try (ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzData(TZDATA_FILE);
- ZoneInfoDB.TzData dataWithEmptyOverride =
- ZoneInfoDB.TzData.loadTzDataWithFallback(emptyFilePath, TZDATA_FILE)) {
+ try (ZoneInfoDb data = ZoneInfoDb.loadTzData(TZDATA_FILE);
+ ZoneInfoDb dataWithEmptyOverride =
+ ZoneInfoDb.loadTzDataWithFallback(emptyFilePath, TZDATA_FILE)) {
assertEquals(data.getVersion(), dataWithEmptyOverride.getVersion());
assertEquals(data.getAvailableIDs().length, dataWithEmptyOverride.getAvailableIDs().length);
}
@@ -47,9 +47,9 @@
// A corrupt override file should fall back to the default file.
public void testLoadTzDataWithFallback_corruptOverrideFile() throws Exception {
String corruptFilePath = makeCorruptFile().getPath();
- try (ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzData(TZDATA_FILE);
- ZoneInfoDB.TzData dataWithCorruptOverride =
- ZoneInfoDB.TzData.loadTzDataWithFallback(corruptFilePath, TZDATA_FILE)) {
+ try (ZoneInfoDb data = ZoneInfoDb.loadTzData(TZDATA_FILE);
+ ZoneInfoDb dataWithCorruptOverride =
+ ZoneInfoDb.loadTzDataWithFallback(corruptFilePath, TZDATA_FILE)) {
assertEquals(data.getVersion(), dataWithCorruptOverride.getVersion());
assertEquals(data.getAvailableIDs().length, dataWithCorruptOverride.getAvailableIDs().length);
}
@@ -58,7 +58,7 @@
// Given no tzdata files we can use, we should fall back to built-in "GMT".
public void testLoadTzDataWithFallback_noGoodFile() throws Exception {
String emptyFilePath = makeEmptyFile().getPath();
- try (ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzDataWithFallback(emptyFilePath)) {
+ try (ZoneInfoDb data = ZoneInfoDb.loadTzDataWithFallback(emptyFilePath)) {
assertEquals("missing", data.getVersion());
assertEquals(1, data.getAvailableIDs().length);
assertEquals("GMT", data.getAvailableIDs()[0]);
@@ -80,9 +80,9 @@
content[10] = 'z';
File goodFile = makeTemporaryFile(content);
- try (ZoneInfoDB.TzData dataWithOverride =
- ZoneInfoDB.TzData.loadTzDataWithFallback(goodFile.getPath(), TZDATA_FILE);
- ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzData(TZDATA_FILE)) {
+ try (ZoneInfoDb dataWithOverride =
+ ZoneInfoDb.loadTzDataWithFallback(goodFile.getPath(), TZDATA_FILE);
+ ZoneInfoDb data = ZoneInfoDb.loadTzData(TZDATA_FILE)) {
assertEquals("9999z", dataWithOverride.getVersion());
assertEquals(data.getAvailableIDs().length, dataWithOverride.getAvailableIDs().length);
@@ -106,7 +106,7 @@
byte[] data = new ZoneInfoTestHelper.TzDataBuilder().initializeToValid().build();
File testFile = makeTemporaryFile(data);
try {
- assertNotNull(ZoneInfoDB.TzData.loadTzData(testFile.getPath()));
+ assertNotNull(ZoneInfoDb.loadTzData(testFile.getPath()));
} finally {
testFile.delete();
}
@@ -149,7 +149,7 @@
// Sections must be in the correct order: section sizing is calculated using them.
int indexOffset = 10;
builder.setIndexOffsetOverride(indexOffset);
- int dataOffset = indexOffset + ZoneInfoDB.TzData.SIZEOF_INDEX_ENTRY - 1;
+ int dataOffset = indexOffset + ZoneInfoDb.SIZEOF_INDEX_ENTRY - 1;
builder.setDataOffsetOverride(dataOffset);
builder.setZoneTabOffsetOverride(dataOffset + 40);
@@ -207,7 +207,7 @@
private static void checkInvalidDataDetected(byte[] data) throws Exception {
File testFile = makeTemporaryFile(data);
try {
- assertNull(ZoneInfoDB.TzData.loadTzData(testFile.getPath()));
+ assertNull(ZoneInfoDb.loadTzData(testFile.getPath()));
} finally {
testFile.delete();
}
@@ -215,7 +215,7 @@
// Confirms any caching that exists correctly handles TimeZone mutability.
public void testMakeTimeZone_timeZoneMutability() throws Exception {
- try (ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzData(TZDATA_FILE)) {
+ try (ZoneInfoDb data = ZoneInfoDb.loadTzData(TZDATA_FILE)) {
String tzId = "Europe/London";
ZoneInfo first = data.makeTimeZone(tzId);
ZoneInfo second = data.makeTimeZone(tzId);
@@ -233,14 +233,14 @@
}
public void testMakeTimeZone_notFound() throws Exception {
- try (ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzData(TZDATA_FILE)) {
+ try (ZoneInfoDb data = ZoneInfoDb.loadTzData(TZDATA_FILE)) {
assertNull(data.makeTimeZone("THIS_TZ_DOES_NOT_EXIST"));
assertFalse(data.hasTimeZone("THIS_TZ_DOES_NOT_EXIST"));
}
}
public void testMakeTimeZone_found() throws Exception {
- try (ZoneInfoDB.TzData data = ZoneInfoDB.TzData.loadTzData(TZDATA_FILE)) {
+ try (ZoneInfoDb data = ZoneInfoDb.loadTzData(TZDATA_FILE)) {
assertNotNull(data.makeTimeZone("Europe/London"));
assertTrue(data.hasTimeZone("Europe/London"));
}
diff --git a/luni/src/test/java/libcore/libcore/util/FP16Test.java b/luni/src/test/java/libcore/libcore/util/FP16Test.java
new file mode 100644
index 0000000..916df92
--- /dev/null
+++ b/luni/src/test/java/libcore/libcore/util/FP16Test.java
@@ -0,0 +1,400 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.libcore.util;
+
+import static libcore.util.FP16.*;
+import libcore.util.FP16;
+
+import junit.framework.TestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class FP16Test extends TestCase {
+
+ public void testSingleToHalf() {
+ // Zeroes, NaN and infinities
+ assertEquals(POSITIVE_ZERO, toHalf(0.0f));
+ assertEquals(NEGATIVE_ZERO, toHalf(-0.0f));
+ assertEquals(NaN, toHalf(Float.NaN));
+ assertEquals(POSITIVE_INFINITY, toHalf(Float.POSITIVE_INFINITY));
+ assertEquals(NEGATIVE_INFINITY, toHalf(Float.NEGATIVE_INFINITY));
+ // Known values
+ assertEquals((short) 0x3c01, toHalf(1.0009765625f));
+ assertEquals((short) 0xc000, toHalf(-2.0f));
+ assertEquals((short) 0x0400, toHalf(6.10352e-5f));
+ assertEquals((short) 0x7bff, toHalf(65504.0f));
+ assertEquals((short) 0x3555, toHalf(1.0f / 3.0f));
+ // Subnormals
+ assertEquals((short) 0x03ff, toHalf(6.09756e-5f));
+ assertEquals(MIN_VALUE, toHalf(5.96046e-8f));
+ assertEquals((short) 0x83ff, toHalf(-6.09756e-5f));
+ assertEquals((short) 0x8001, toHalf(-5.96046e-8f));
+ // Subnormals (flushed to +/-0)
+ assertEquals(POSITIVE_ZERO, toHalf(5.96046e-9f));
+ assertEquals(NEGATIVE_ZERO, toHalf(-5.96046e-9f));
+ // Test for values that overflow the mantissa bits into exp bits
+ assertEquals((short) 0x1000, toHalf(Float.intBitsToFloat(0x39fff000)));
+ assertEquals((short) 0x0400, toHalf(Float.intBitsToFloat(0x387fe000)));
+ // Floats with absolute value above +/-65519 are rounded to +/-inf
+ // when using round-to-even
+ assertEquals((short) 0x7bff, toHalf(65519.0f));
+ assertEquals((short) 0x7bff, toHalf(65519.9f));
+ assertEquals(POSITIVE_INFINITY, toHalf(65520.0f));
+ assertEquals(NEGATIVE_INFINITY, toHalf(-65520.0f));
+ // Check if numbers are rounded to nearest even when they
+ // cannot be accurately represented by Half
+ assertEquals((short) 0x6800, toHalf(2049.0f));
+ assertEquals((short) 0x6c00, toHalf(4098.0f));
+ assertEquals((short) 0x7000, toHalf(8196.0f));
+ assertEquals((short) 0x7400, toHalf(16392.0f));
+ assertEquals((short) 0x7800, toHalf(32784.0f));
+ }
+
+ public void testHalfToSingle() {
+ // Zeroes, NaN and infinities
+ assertEquals(0.0f, toFloat(toHalf(0.0f)), 0.0f);
+ assertEquals(-0.0f, toFloat(toHalf(-0.0f)), 0.0f);
+ assertEquals(Float.NaN, toFloat(toHalf(Float.NaN)), 0.0f);
+ assertEquals(Float.POSITIVE_INFINITY, toFloat(toHalf(Float.POSITIVE_INFINITY)), 0.0f);
+ assertEquals(Float.NEGATIVE_INFINITY, toFloat(toHalf(Float.NEGATIVE_INFINITY)), 0.0f);
+ // Known values
+ assertEquals(1.0009765625f, toFloat(toHalf(1.0009765625f)), 0.0f);
+ assertEquals(-2.0f, toFloat(toHalf(-2.0f)), 0.0f);
+ assertEquals(6.1035156e-5f, toFloat(toHalf(6.10352e-5f)), 0.0f); // Inexact
+ assertEquals(65504.0f, toFloat(toHalf(65504.0f)), 0.0f);
+ assertEquals(0.33325195f, toFloat(toHalf(1.0f / 3.0f)), 0.0f); // Inexact
+ // Denormals (flushed to +/-0)
+ assertEquals(6.097555e-5f, toFloat(toHalf(6.09756e-5f)), 0.0f);
+ assertEquals(5.9604645e-8f, toFloat(toHalf(5.96046e-8f)), 0.0f);
+ assertEquals(-6.097555e-5f, toFloat(toHalf(-6.09756e-5f)), 0.0f);
+ assertEquals(-5.9604645e-8f, toFloat(toHalf(-5.96046e-8f)), 0.0f);
+ }
+
+ public void testHexString() {
+ assertEquals("NaN", toHexString(NaN));
+ assertEquals("Infinity", toHexString(POSITIVE_INFINITY));
+ assertEquals("-Infinity", toHexString(NEGATIVE_INFINITY));
+ assertEquals("0x0.0p0", toHexString(POSITIVE_ZERO));
+ assertEquals("-0x0.0p0", toHexString(NEGATIVE_ZERO));
+ assertEquals("0x1.0p0", toHexString(toHalf(1.0f)));
+ assertEquals("-0x1.0p0", toHexString(toHalf(-1.0f)));
+ assertEquals("0x1.0p1", toHexString(toHalf(2.0f)));
+ assertEquals("0x1.0p8", toHexString(toHalf(256.0f)));
+ assertEquals("0x1.0p-1", toHexString(toHalf(0.5f)));
+ assertEquals("0x1.0p-2", toHexString(toHalf(0.25f)));
+ assertEquals("0x1.3ffp15", toHexString(MAX_VALUE));
+ assertEquals("0x0.1p-14", toHexString(MIN_VALUE));
+ assertEquals("0x1.0p-14", toHexString(MIN_NORMAL));
+ assertEquals("-0x1.3ffp15", toHexString(LOWEST_VALUE));
+ }
+
+ public void testIsInfinite() {
+ assertTrue(FP16.isInfinite(POSITIVE_INFINITY));
+ assertTrue(FP16.isInfinite(NEGATIVE_INFINITY));
+ assertFalse(FP16.isInfinite(POSITIVE_ZERO));
+ assertFalse(FP16.isInfinite(NEGATIVE_ZERO));
+ assertFalse(FP16.isInfinite(NaN));
+ assertFalse(FP16.isInfinite(MAX_VALUE));
+ assertFalse(FP16.isInfinite(LOWEST_VALUE));
+ assertFalse(FP16.isInfinite(toHalf(-128.3f)));
+ assertFalse(FP16.isInfinite(toHalf(128.3f)));
+ }
+
+ public void testIsNaN() {
+ assertFalse(FP16.isNaN(POSITIVE_INFINITY));
+ assertFalse(FP16.isNaN(NEGATIVE_INFINITY));
+ assertFalse(FP16.isNaN(POSITIVE_ZERO));
+ assertFalse(FP16.isNaN(NEGATIVE_ZERO));
+ assertTrue(FP16.isNaN(NaN));
+ assertTrue(FP16.isNaN((short) 0x7c01));
+ assertTrue(FP16.isNaN((short) 0x7c18));
+ assertTrue(FP16.isNaN((short) 0xfc01));
+ assertTrue(FP16.isNaN((short) 0xfc98));
+ assertFalse(FP16.isNaN(MAX_VALUE));
+ assertFalse(FP16.isNaN(LOWEST_VALUE));
+ assertFalse(FP16.isNaN(toHalf(-128.3f)));
+ assertFalse(FP16.isNaN(toHalf(128.3f)));
+ }
+
+ public void testIsNormalized() {
+ assertFalse(FP16.isNormalized(POSITIVE_INFINITY));
+ assertFalse(FP16.isNormalized(NEGATIVE_INFINITY));
+ assertFalse(FP16.isNormalized(POSITIVE_ZERO));
+ assertFalse(FP16.isNormalized(NEGATIVE_ZERO));
+ assertFalse(FP16.isNormalized(NaN));
+ assertTrue(FP16.isNormalized(MAX_VALUE));
+ assertTrue(FP16.isNormalized(MIN_NORMAL));
+ assertTrue(FP16.isNormalized(LOWEST_VALUE));
+ assertTrue(FP16.isNormalized(toHalf(-128.3f)));
+ assertTrue(FP16.isNormalized(toHalf(128.3f)));
+ assertTrue(FP16.isNormalized(toHalf(0.3456f)));
+ assertFalse(FP16.isNormalized(MIN_VALUE));
+ assertFalse(FP16.isNormalized((short) 0x3ff));
+ assertFalse(FP16.isNormalized((short) 0x200));
+ assertFalse(FP16.isNormalized((short) 0x100));
+ }
+
+ public void testCeil() {
+ assertEquals(POSITIVE_INFINITY, FP16.ceil(POSITIVE_INFINITY));
+ assertEquals(NEGATIVE_INFINITY, FP16.ceil(NEGATIVE_INFINITY));
+ assertEquals(POSITIVE_ZERO, FP16.ceil(POSITIVE_ZERO));
+ assertEquals(NEGATIVE_ZERO, FP16.ceil(NEGATIVE_ZERO));
+ assertEquals(NaN, FP16.ceil(NaN));
+ assertEquals(LOWEST_VALUE, FP16.ceil(LOWEST_VALUE));
+ assertEquals(1.0f, toFloat(FP16.ceil(MIN_NORMAL)), 0.0f);
+ assertEquals(1.0f, toFloat(FP16.ceil((short) 0x3ff)), 0.0f);
+ assertEquals(1.0f, toFloat(FP16.ceil(toHalf(0.2f))), 0.0f);
+ assertEquals(NEGATIVE_ZERO, FP16.ceil(toHalf(-0.2f)));
+ assertEquals(1.0f, toFloat(FP16.ceil(toHalf(0.7f))), 0.0f);
+ assertEquals(NEGATIVE_ZERO, FP16.ceil(toHalf(-0.7f)));
+ assertEquals(125.0f, toFloat(FP16.ceil(toHalf(124.7f))), 0.0f);
+ assertEquals(-124.0f, toFloat(FP16.ceil(toHalf(-124.7f))), 0.0f);
+ assertEquals(125.0f, toFloat(FP16.ceil(toHalf(124.2f))), 0.0f);
+ assertEquals(-124.0f, toFloat(FP16.ceil(toHalf(-124.2f))), 0.0f);
+ // ceil for NaN values
+ // These tests check whether the current ceil implementation achieves
+ // bit level compatibility with the hardware implementation (ARM64)
+ assertEquals((short) 0x7e01, FP16.ceil((short) 0x7c01));
+ assertEquals((short) 0x7f00, FP16.ceil((short) 0x7d00));
+ assertEquals((short) 0xfe01, FP16.ceil((short) 0xfc01));
+ assertEquals((short) 0xff00, FP16.ceil((short) 0xfd00));
+ }
+
+ public void testEquals() {
+ assertTrue(FP16.equals(POSITIVE_INFINITY, POSITIVE_INFINITY));
+ assertTrue(FP16.equals(NEGATIVE_INFINITY, NEGATIVE_INFINITY));
+ assertTrue(FP16.equals(POSITIVE_ZERO, POSITIVE_ZERO));
+ assertTrue(FP16.equals(NEGATIVE_ZERO, NEGATIVE_ZERO));
+ assertTrue(FP16.equals(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertFalse(FP16.equals(NaN, toHalf(12.4f)));
+ assertFalse(FP16.equals(toHalf(12.4f), NaN));
+ assertFalse(FP16.equals(NaN, NaN));
+ assertTrue(FP16.equals(toHalf(12.4f), toHalf(12.4f)));
+ assertTrue(FP16.equals(toHalf(-12.4f), toHalf(-12.4f)));
+ assertFalse(FP16.equals(toHalf(12.4f), toHalf(0.7f)));
+ }
+
+ public void testFloor() {
+ assertEquals(POSITIVE_INFINITY, FP16.floor(POSITIVE_INFINITY));
+ assertEquals(NEGATIVE_INFINITY, FP16.floor(NEGATIVE_INFINITY));
+ assertEquals(POSITIVE_ZERO, FP16.floor(POSITIVE_ZERO));
+ assertEquals(NEGATIVE_ZERO, FP16.floor(NEGATIVE_ZERO));
+ assertEquals(NaN, FP16.floor(NaN));
+ assertEquals(LOWEST_VALUE, FP16.floor(LOWEST_VALUE));
+ assertEquals(POSITIVE_ZERO, FP16.floor(MIN_NORMAL));
+ assertEquals(POSITIVE_ZERO, FP16.floor((short) 0x3ff));
+ assertEquals(POSITIVE_ZERO, FP16.floor(toHalf(0.2f)));
+ assertEquals(-1.0f, toFloat(FP16.floor(toHalf(-0.2f))), 0.0f);
+ assertEquals(-1.0f, toFloat(FP16.floor(toHalf(-0.7f))), 0.0f);
+ assertEquals(POSITIVE_ZERO, FP16.floor(toHalf(0.7f)));
+ assertEquals(124.0f, toFloat(FP16.floor(toHalf(124.7f))), 0.0f);
+ assertEquals(-125.0f, toFloat(FP16.floor(toHalf(-124.7f))), 0.0f);
+ assertEquals(124.0f, toFloat(FP16.floor(toHalf(124.2f))), 0.0f);
+ assertEquals(-125.0f, toFloat(FP16.floor(toHalf(-124.2f))), 0.0f);
+ // floor for NaN values
+ assertEquals((short) 0x7e01, FP16.floor((short) 0x7c01));
+ assertEquals((short) 0x7f00, FP16.floor((short) 0x7d00));
+ assertEquals((short) 0xfe01, FP16.floor((short) 0xfc01));
+ assertEquals((short) 0xff00, FP16.floor((short) 0xfd00));
+ }
+
+ public void testRint() {
+ assertEquals(POSITIVE_INFINITY, FP16.rint(POSITIVE_INFINITY));
+ assertEquals(NEGATIVE_INFINITY, FP16.rint(NEGATIVE_INFINITY));
+ assertEquals(POSITIVE_ZERO, FP16.rint(POSITIVE_ZERO));
+ assertEquals(NEGATIVE_ZERO, FP16.rint(NEGATIVE_ZERO));
+ assertEquals(NaN, FP16.rint(NaN));
+ assertEquals(LOWEST_VALUE, FP16.rint(LOWEST_VALUE));
+ assertEquals(POSITIVE_ZERO, FP16.rint(MIN_VALUE));
+ assertEquals(POSITIVE_ZERO, FP16.rint((short) 0x200));
+ assertEquals(POSITIVE_ZERO, FP16.rint((short) 0x3ff));
+ assertEquals(POSITIVE_ZERO, FP16.rint(toHalf(0.2f)));
+ assertEquals(NEGATIVE_ZERO, FP16.rint(toHalf(-0.2f)));
+ assertEquals(1.0f, toFloat(FP16.rint(toHalf(0.7f))), 0.0f);
+ assertEquals(-1.0f, toFloat(FP16.rint(toHalf(-0.7f))), 0.0f);
+ assertEquals(0.0f, toFloat(FP16.rint(toHalf(0.5f))), 0.0f);
+ assertEquals(-0.0f, toFloat(FP16.rint(toHalf(-0.5f))), 0.0f);
+ assertEquals(2.0f, toFloat(FP16.rint(toHalf(1.5f))), 0.0f);
+ assertEquals(-2.0f, toFloat(FP16.rint(toHalf(-1.5f))), 0.0f);
+ assertEquals(1022.0f, toFloat(FP16.rint(toHalf(1022.5f))), 0.0f);
+ assertEquals(-1022.0f, toFloat(FP16.rint(toHalf(-1022.5f))), 0.0f);
+ assertEquals(125.0f, toFloat(FP16.rint(toHalf(124.7f))), 0.0f);
+ assertEquals(-125.0f, toFloat(FP16.rint(toHalf(-124.7f))), 0.0f);
+ assertEquals(124.0f, toFloat(FP16.rint(toHalf(124.2f))), 0.0f);
+ assertEquals(-124.0f, toFloat(FP16.rint(toHalf(-124.2f))), 0.0f);
+ // round for NaN values
+ // These tests check whether the current rint implementation achieves
+ // bit level compatibility with the hardware implementation (ARM64)
+ assertEquals((short) 0x7e01, FP16.rint((short) 0x7c01));
+ assertEquals((short) 0x7f00, FP16.rint((short) 0x7d00));
+ assertEquals((short) 0xfe01, FP16.rint((short) 0xfc01));
+ assertEquals((short) 0xff00, FP16.rint((short) 0xfd00));
+ }
+
+ public void testTrunc() {
+ assertEquals(POSITIVE_INFINITY, FP16.trunc(POSITIVE_INFINITY));
+ assertEquals(NEGATIVE_INFINITY, FP16.trunc(NEGATIVE_INFINITY));
+ assertEquals(POSITIVE_ZERO, FP16.trunc(POSITIVE_ZERO));
+ assertEquals(NEGATIVE_ZERO, FP16.trunc(NEGATIVE_ZERO));
+ assertEquals(NaN, FP16.trunc(NaN));
+ assertEquals(LOWEST_VALUE, FP16.trunc(LOWEST_VALUE));
+ assertEquals(POSITIVE_ZERO, FP16.trunc(toHalf(0.2f)));
+ assertEquals(NEGATIVE_ZERO, FP16.trunc(toHalf(-0.2f)));
+ assertEquals(0.0f, toFloat(FP16.trunc(toHalf(0.7f))), 0.0f);
+ assertEquals(-0.0f, toFloat(FP16.trunc(toHalf(-0.7f))), 0.0f);
+ assertEquals(124.0f, toFloat(FP16.trunc(toHalf(124.7f))), 0.0f);
+ assertEquals(-124.0f, toFloat(FP16.trunc(toHalf(-124.7f))), 0.0f);
+ assertEquals(124.0f, toFloat(FP16.trunc(toHalf(124.2f))), 0.0f);
+ assertEquals(-124.0f, toFloat(FP16.trunc(toHalf(-124.2f))), 0.0f);
+ }
+
+ public void testLess() {
+ assertTrue(FP16.less(NEGATIVE_INFINITY, POSITIVE_INFINITY));
+ assertTrue(FP16.less(MAX_VALUE, POSITIVE_INFINITY));
+ assertFalse(FP16.less(POSITIVE_INFINITY, MAX_VALUE));
+ assertFalse(FP16.less(LOWEST_VALUE, NEGATIVE_INFINITY));
+ assertTrue(FP16.less(NEGATIVE_INFINITY, LOWEST_VALUE));
+ assertFalse(FP16.less(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertFalse(FP16.less(NEGATIVE_ZERO, POSITIVE_ZERO));
+ assertFalse(FP16.less(NaN, toHalf(12.3f)));
+ assertFalse(FP16.less(toHalf(12.3f), NaN));
+ assertTrue(FP16.less(MIN_VALUE, MIN_NORMAL));
+ assertFalse(FP16.less(MIN_NORMAL, MIN_VALUE));
+ assertTrue(FP16.less(toHalf(12.3f), toHalf(12.4f)));
+ assertFalse(FP16.less(toHalf(12.4f), toHalf(12.3f)));
+ assertFalse(FP16.less(toHalf(-12.3f), toHalf(-12.4f)));
+ assertTrue(FP16.less(toHalf(-12.4f), toHalf(-12.3f)));
+ assertTrue(FP16.less(MIN_VALUE, (short) 0x3ff));
+ }
+
+ public void testLessEquals() {
+ assertTrue(FP16.lessEquals(NEGATIVE_INFINITY, POSITIVE_INFINITY));
+ assertTrue(FP16.lessEquals(MAX_VALUE, POSITIVE_INFINITY));
+ assertFalse(FP16.lessEquals(POSITIVE_INFINITY, MAX_VALUE));
+ assertFalse(FP16.lessEquals(LOWEST_VALUE, NEGATIVE_INFINITY));
+ assertTrue(FP16.lessEquals(NEGATIVE_INFINITY, LOWEST_VALUE));
+ assertTrue(FP16.lessEquals(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertTrue(FP16.lessEquals(NEGATIVE_ZERO, POSITIVE_ZERO));
+ assertFalse(FP16.lessEquals(NaN, toHalf(12.3f)));
+ assertFalse(FP16.lessEquals(toHalf(12.3f), NaN));
+ assertTrue(FP16.lessEquals(MIN_VALUE, MIN_NORMAL));
+ assertFalse(FP16.lessEquals(MIN_NORMAL, MIN_VALUE));
+ assertTrue(FP16.lessEquals(toHalf(12.3f), toHalf(12.4f)));
+ assertFalse(FP16.lessEquals(toHalf(12.4f), toHalf(12.3f)));
+ assertFalse(FP16.lessEquals(toHalf(-12.3f), toHalf(-12.4f)));
+ assertTrue(FP16.lessEquals(toHalf(-12.4f), toHalf(-12.3f)));
+ assertTrue(FP16.lessEquals(MIN_VALUE, (short) 0x3ff));
+ assertTrue(FP16.lessEquals(NEGATIVE_INFINITY, NEGATIVE_INFINITY));
+ assertTrue(FP16.lessEquals(POSITIVE_INFINITY, POSITIVE_INFINITY));
+ assertTrue(FP16.lessEquals(toHalf(12.12356f), toHalf(12.12356f)));
+ assertTrue(FP16.lessEquals(toHalf(-12.12356f), toHalf(-12.12356f)));
+ }
+
+ public void testGreater() {
+ assertTrue(FP16.greater(POSITIVE_INFINITY, NEGATIVE_INFINITY));
+ assertTrue(FP16.greater(POSITIVE_INFINITY, MAX_VALUE));
+ assertFalse(FP16.greater(MAX_VALUE, POSITIVE_INFINITY));
+ assertFalse(FP16.greater(NEGATIVE_INFINITY, LOWEST_VALUE));
+ assertTrue(FP16.greater(LOWEST_VALUE, NEGATIVE_INFINITY));
+ assertFalse(FP16.greater(NEGATIVE_ZERO, POSITIVE_ZERO));
+ assertFalse(FP16.greater(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertFalse(FP16.greater(toHalf(12.3f), NaN));
+ assertFalse(FP16.greater(NaN, toHalf(12.3f)));
+ assertTrue(FP16.greater(MIN_NORMAL, MIN_VALUE));
+ assertFalse(FP16.greater(MIN_VALUE, MIN_NORMAL));
+ assertTrue(FP16.greater(toHalf(12.4f), toHalf(12.3f)));
+ assertFalse(FP16.greater(toHalf(12.3f), toHalf(12.4f)));
+ assertFalse(FP16.greater(toHalf(-12.4f), toHalf(-12.3f)));
+ assertTrue(FP16.greater(toHalf(-12.3f), toHalf(-12.4f)));
+ assertTrue(FP16.greater((short) 0x3ff, MIN_VALUE));
+ }
+
+ public void testGreaterEquals() {
+ assertTrue(FP16.greaterEquals(POSITIVE_INFINITY, NEGATIVE_INFINITY));
+ assertTrue(FP16.greaterEquals(POSITIVE_INFINITY, MAX_VALUE));
+ assertFalse(FP16.greaterEquals(MAX_VALUE, POSITIVE_INFINITY));
+ assertFalse(FP16.greaterEquals(NEGATIVE_INFINITY, LOWEST_VALUE));
+ assertTrue(FP16.greaterEquals(LOWEST_VALUE, NEGATIVE_INFINITY));
+ assertTrue(FP16.greaterEquals(NEGATIVE_ZERO, POSITIVE_ZERO));
+ assertTrue(FP16.greaterEquals(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertFalse(FP16.greaterEquals(toHalf(12.3f), NaN));
+ assertFalse(FP16.greaterEquals(NaN, toHalf(12.3f)));
+ assertTrue(FP16.greaterEquals(MIN_NORMAL, MIN_VALUE));
+ assertFalse(FP16.greaterEquals(MIN_VALUE, MIN_NORMAL));
+ assertTrue(FP16.greaterEquals(toHalf(12.4f), toHalf(12.3f)));
+ assertFalse(FP16.greaterEquals(toHalf(12.3f), toHalf(12.4f)));
+ assertFalse(FP16.greaterEquals(toHalf(-12.4f), toHalf(-12.3f)));
+ assertTrue(FP16.greaterEquals(toHalf(-12.3f), toHalf(-12.4f)));
+ assertTrue(FP16.greaterEquals((short) 0x3ff, MIN_VALUE));
+ assertTrue(FP16.greaterEquals(NEGATIVE_INFINITY, NEGATIVE_INFINITY));
+ assertTrue(FP16.greaterEquals(POSITIVE_INFINITY, POSITIVE_INFINITY));
+ assertTrue(FP16.greaterEquals(toHalf(12.12356f), toHalf(12.12356f)));
+ assertTrue(FP16.greaterEquals(toHalf(-12.12356f), toHalf(-12.12356f)));
+ }
+
+ public void testMin() {
+ assertEquals(NEGATIVE_INFINITY, FP16.min(POSITIVE_INFINITY, NEGATIVE_INFINITY));
+ assertEquals(NEGATIVE_ZERO, FP16.min(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertEquals(NaN, FP16.min(NaN, LOWEST_VALUE));
+ assertEquals(NaN, FP16.min(LOWEST_VALUE, NaN));
+ assertEquals(NEGATIVE_INFINITY, FP16.min(NEGATIVE_INFINITY, LOWEST_VALUE));
+ assertEquals(MAX_VALUE, FP16.min(POSITIVE_INFINITY, MAX_VALUE));
+ assertEquals(MIN_VALUE, FP16.min(MIN_VALUE, MIN_NORMAL));
+ assertEquals(POSITIVE_ZERO, FP16.min(MIN_VALUE, POSITIVE_ZERO));
+ assertEquals(POSITIVE_ZERO, FP16.min(MIN_NORMAL, POSITIVE_ZERO));
+ assertEquals(toHalf(-3.456f), FP16.min(toHalf(-3.456f), toHalf(-3.453f)));
+ assertEquals(toHalf(3.453f), FP16.min(toHalf(3.456f), toHalf(3.453f)));
+ }
+
+ public void testMax() {
+ assertEquals(POSITIVE_INFINITY, FP16.max(POSITIVE_INFINITY, NEGATIVE_INFINITY));
+ assertEquals(POSITIVE_ZERO, FP16.max(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertEquals(NaN, FP16.max(NaN, MAX_VALUE));
+ assertEquals(NaN, FP16.max(MAX_VALUE, NaN));
+ assertEquals(LOWEST_VALUE, FP16.max(NEGATIVE_INFINITY, LOWEST_VALUE));
+ assertEquals(POSITIVE_INFINITY, FP16.max(POSITIVE_INFINITY, MAX_VALUE));
+ assertEquals(MIN_NORMAL, FP16.max(MIN_VALUE, MIN_NORMAL));
+ assertEquals(MIN_VALUE, FP16.max(MIN_VALUE, POSITIVE_ZERO));
+ assertEquals(MIN_NORMAL, FP16.max(MIN_NORMAL, POSITIVE_ZERO));
+ assertEquals(toHalf(-3.453f), FP16.max(toHalf(-3.456f), toHalf(-3.453f)));
+ assertEquals(toHalf(3.456f), FP16.max(toHalf(3.456f), toHalf(3.453f)));
+ }
+
+ public void testCompare() {
+ assertEquals(0, FP16.compare(NaN, NaN));
+ assertEquals(0, FP16.compare(NaN, (short) 0xfc98));
+ assertEquals(1, FP16.compare(NaN, POSITIVE_INFINITY));
+ assertEquals(-1, FP16.compare(POSITIVE_INFINITY, NaN));
+
+ assertEquals(0, FP16.compare(POSITIVE_INFINITY, POSITIVE_INFINITY));
+ assertEquals(0, FP16.compare(NEGATIVE_INFINITY, NEGATIVE_INFINITY));
+ assertEquals(1, FP16.compare(POSITIVE_INFINITY, NEGATIVE_INFINITY));
+ assertEquals(-1, FP16.compare(NEGATIVE_INFINITY, POSITIVE_INFINITY));
+
+ assertEquals(0, FP16.compare(POSITIVE_ZERO, POSITIVE_ZERO));
+ assertEquals(0, FP16.compare(NEGATIVE_ZERO, NEGATIVE_ZERO));
+ assertEquals(1, FP16.compare(POSITIVE_ZERO, NEGATIVE_ZERO));
+ assertEquals(-1, FP16.compare(NEGATIVE_ZERO, POSITIVE_ZERO));
+
+ assertEquals(0, FP16.compare(toHalf(12.462f), toHalf(12.462f)));
+ assertEquals(0, FP16.compare(toHalf(-12.462f), toHalf(-12.462f)));
+ assertEquals(1, FP16.compare(toHalf(12.462f), toHalf(-12.462f)));
+ assertEquals(-1, FP16.compare(toHalf(-12.462f), toHalf(12.462f)));
+ }
+}
diff --git a/luni/src/test/java/libcore/libcore/util/ZoneInfoTest.java b/luni/src/test/java/libcore/libcore/util/ZoneInfoTest.java
index fba0b47..8b9715f 100644
--- a/luni/src/test/java/libcore/libcore/util/ZoneInfoTest.java
+++ b/luni/src/test/java/libcore/libcore/util/ZoneInfoTest.java
@@ -26,7 +26,7 @@
import java.util.Arrays;
import java.util.Date;
import libcore.io.BufferIterator;
-import libcore.timezone.ZoneInfoDB;
+import libcore.timezone.ZoneInfoDb;
import libcore.timezone.testing.ZoneInfoTestHelper;
import libcore.util.ZoneInfo;
@@ -470,7 +470,7 @@
* creates the {@link ZoneInfo} instances does not prevent any of the time zones being loaded.
*/
public void testReadTimeZone_All() throws Exception {
- ZoneInfoDB.TzData instance = ZoneInfoDB.getInstance();
+ ZoneInfoDb instance = ZoneInfoDb.getInstance();
String[] availableIDs = instance.getAvailableIDs();
Arrays.sort(availableIDs);
for (String id : availableIDs) {
diff --git a/metrictests/memory/README b/metrictests/memory/README
index 77574ef..e0b083b 100644
--- a/metrictests/memory/README
+++ b/metrictests/memory/README
@@ -27,7 +27,7 @@
then dumps another heap. You can run it manually as follows:
make LibcoreHeapDumper
- adb install -g -r ${ANDROID_PRODUCT_OUT}/data/app/LibcoreHeapDumper/LibcoreHeapDumper.apk
+ adb install -g -r ${ANDROID_PRODUCT_OUT}/testcases/LibcoreHeapDumper/arm64/LibcoreHeapDumper.apk
DEVICE_EXTERNAL_STORAGE=$(adb shell 'echo -n ${EXTERNAL_STORAGE}')
# Pick a suitable name here:
diff --git a/metrictests/memory/apps/AndroidManifest.xml b/metrictests/memory/apps/AndroidManifest.xml
index a8856aa..aca7177 100644
--- a/metrictests/memory/apps/AndroidManifest.xml
+++ b/metrictests/memory/apps/AndroidManifest.xml
@@ -18,7 +18,9 @@
package="libcore.heapdumper">
<uses-sdk android:minSdkVersion="19" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<instrumentation
android:name="libcore.heapdumper.HeapDumpInstrumentation"
@@ -30,6 +32,7 @@
<application
android:allowBackup="false"
+ android:requestLegacyExternalStorage="true"
android:label="@string/libcore_heap_dumper_title">
</application>
</manifest>
diff --git a/metrictests/memory/apps/src/libcore/heapdumper/Actions.java b/metrictests/memory/apps/src/libcore/heapdumper/Actions.java
index e8b56f1..e5ef4ba 100644
--- a/metrictests/memory/apps/src/libcore/heapdumper/Actions.java
+++ b/metrictests/memory/apps/src/libcore/heapdumper/Actions.java
@@ -19,6 +19,8 @@
import java.text.Collator;
import java.util.Arrays;
import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* An enumeration of actions for which we'd like to measure the effect on the post-GC heap.
@@ -65,6 +67,33 @@
}
},
+ REGEX {
+ @Override
+ public void run() {
+ final String sequence = "foo 123 bar baz";
+ Pattern p = Pattern.compile("foo (\\d+) bar (\\w+)");
+ Matcher m = p.matcher(sequence);
+
+ boolean found = m.find();
+ boolean matches = m.matches();
+ int groups = m.groupCount();
+ String first = m.group(1);
+ String second = m.group(2);
+ boolean hitEnd = m.hitEnd();
+
+ // Set region to prefix of the original sequence
+ m.region(0, "foo 123".length());
+ boolean matchesPrefix = m.lookingAt();
+ boolean requireEnd = m.requireEnd();
+
+ m.useTransparentBounds(true);
+ boolean matchesPrefixTransparentBounds = m.lookingAt();
+
+ m.useAnchoringBounds(true);
+ boolean matchesPrefixAnchoringBounds = m.lookingAt();
+ }
+ }
+
;
private static void useCollatorForLocale(Locale locale) {
diff --git a/metrictests/memory/host/Android.bp b/metrictests/memory/host/Android.bp
index a70afc6..beed9e1 100644
--- a/metrictests/memory/host/Android.bp
+++ b/metrictests/memory/host/Android.bp
@@ -15,7 +15,7 @@
java_test_host {
name: "libcore-memory-metrics-tests",
srcs: ["src/**/*.java"],
- libs: [
+ static_libs: [
"tradefed",
"ahat",
],
diff --git a/metrictests/memory/host/src/libcore/heapmetrics/LibcoreHeapMetricsTest.java b/metrictests/memory/host/src/libcore/heapmetrics/LibcoreHeapMetricsTest.java
index 5340d90..2231614 100644
--- a/metrictests/memory/host/src/libcore/heapmetrics/LibcoreHeapMetricsTest.java
+++ b/metrictests/memory/host/src/libcore/heapmetrics/LibcoreHeapMetricsTest.java
@@ -103,6 +103,12 @@
recordBeforeAndAfterAppHeapMetrics(result.getBeforeDump(), result.getAfterDump());
}
+ @Test
+ public void measureRegexes() throws Exception {
+ MetricsRunner.Result result = metricsRunner.runAllInstrumentations("REGEX");
+ recordBeforeAndAfterAppHeapMetrics(result.getBeforeDump(), result.getAfterDump());
+ }
+
private void recordHeapMetrics(AhatSnapshot dump, String metricPrefix, String heapName) {
AhatHeap heap = dump.getHeap(heapName);
recordSizeMetric(metricPrefix, heap.getSize());
diff --git a/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java b/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java
index c3f9e0d..e96bc72 100644
--- a/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java
+++ b/metrictests/memory/host/src/libcore/heapmetrics/MetricsRunner.java
@@ -30,8 +30,7 @@
import java.io.File;
import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.Instant;
/**
* Helper class that runs the metric instrumentations on a test device.
@@ -243,10 +242,14 @@
}
}
+ /**
+ * Returns the ISO 8601 form of the current time in UTC, for use as a timestamp in filenames.
+ * (Note that using UTC avoids an issue where the timezone indicator includes a + sign for the
+ * offset, which triggers an issue with URL encoding in tradefed, which causes the calls to
+ * {@code testDevice.pullFile()} to fail. See b/149018916.)
+ */
private static String getCurrentTimeIso8601() {
- SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
- Date now = new Date();
- return iso8601Format.format(now);
+ return Instant.now().toString();
}
/**
diff --git a/mmodules/core_platform_api/Android.bp b/mmodules/core_platform_api/Android.bp
index adf7d28..f2a042b 100644
--- a/mmodules/core_platform_api/Android.bp
+++ b/mmodules/core_platform_api/Android.bp
@@ -33,7 +33,8 @@
],
installable: false,
- args: "--hide-annotation libcore.api.Hide " +
+ args: "--hide HiddenSuperclass " +
+ "--hide-annotation libcore.api.Hide " +
"--show-single-annotation libcore.api.CorePlatformApi " +
"--skip-annotation-instance-methods=false ",
merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
@@ -84,6 +85,7 @@
java_system_modules {
name: "art-module-platform-api-stubs-system-modules",
visibility: [
+ "//art/build/sdk",
"//external/conscrypt",
"//external/icu/android_icu4j",
"//external/wycheproof",
diff --git a/mmodules/core_platform_api/api/platform/current-api.txt b/mmodules/core_platform_api/api/platform/current-api.txt
index 3fa53e0..707e3a3 100644
--- a/mmodules/core_platform_api/api/platform/current-api.txt
+++ b/mmodules/core_platform_api/api/platform/current-api.txt
@@ -3,8 +3,8 @@
public final class Compatibility {
method public static void clearOverrides();
- method public static boolean isChangeEnabled(@android.compat.annotation.ChangeId long);
- method public static void reportChange(@android.compat.annotation.ChangeId long);
+ method public static boolean isChangeEnabled(long);
+ method public static void reportChange(long);
method public static void setCallbacks(android.compat.Compatibility.Callbacks);
method public static void setOverrides(android.compat.Compatibility.ChangeConfig);
}
@@ -28,29 +28,15 @@
}
-package android.compat.annotation {
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.PARAMETER}) public @interface ChangeId {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD}) public @interface Disabled {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD}) public @interface EnabledAfter {
- method public abstract int targetSdkVersion();
- }
-
-}
-
package android.system {
public class Int32Ref {
ctor public Int32Ref(int);
- field @dalvik.annotation.compat.UnsupportedAppUsage public int value;
+ field public int value;
}
public final class NetlinkSocketAddress extends java.net.SocketAddress {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public NetlinkSocketAddress(int, int);
+ ctor public NetlinkSocketAddress(int, int);
method public int getGroupsMask();
method public int getPortId();
}
@@ -58,7 +44,6 @@
public final class Os {
method public static android.system.StructCapUserData[] capget(android.system.StructCapUserHeader) throws android.system.ErrnoException;
method public static void capset(android.system.StructCapUserHeader, android.system.StructCapUserData[]) throws android.system.ErrnoException;
- method public static int fcntlInt(java.io.FileDescriptor, int, int) throws android.system.ErrnoException;
method public static int getpgid(int) throws android.system.ErrnoException;
method public static android.system.StructRlimit getrlimit(int) throws android.system.ErrnoException;
method public static int getsockoptInt(java.io.FileDescriptor, int, int) throws android.system.ErrnoException;
@@ -69,32 +54,31 @@
method public static void setpgid(int, int) throws android.system.ErrnoException;
method public static void setregid(int, int) throws android.system.ErrnoException;
method public static void setreuid(int, int) throws android.system.ErrnoException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void setsockoptIfreq(java.io.FileDescriptor, int, int, String) throws android.system.ErrnoException;
+ method public static void setsockoptIfreq(java.io.FileDescriptor, int, int, String) throws android.system.ErrnoException;
method public static void setsockoptLinger(java.io.FileDescriptor, int, int, android.system.StructLinger) throws android.system.ErrnoException;
method public static long splice(java.io.FileDescriptor, android.system.Int64Ref, java.io.FileDescriptor, android.system.Int64Ref, long, int) throws android.system.ErrnoException;
method public static void unlink(String) throws android.system.ErrnoException;
}
public final class OsConstants {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static int CAP_TO_INDEX(int);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static int CAP_TO_MASK(int);
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int ARPHRD_LOOPBACK;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int ENONET;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int EUSERS;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int MAP_POPULATE;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int NETLINK_NETFILTER;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int O_DIRECT;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int PR_CAP_AMBIENT;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int PR_CAP_AMBIENT_RAISE;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int RLIMIT_NOFILE;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int RTMGRP_IPV4_IFADDR;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int SPLICE_F_MORE;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int SPLICE_F_MOVE;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int TIOCOUTQ;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int UDP_ENCAP;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int UDP_ENCAP_ESPINUDP;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int XATTR_CREATE;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int _LINUX_CAPABILITY_VERSION_3;
+ method public static int CAP_TO_INDEX(int);
+ method public static int CAP_TO_MASK(int);
+ field public static final int ARPHRD_LOOPBACK;
+ field public static final int ENONET;
+ field public static final int EUSERS;
+ field public static final int MAP_POPULATE;
+ field public static final int O_DIRECT;
+ field public static final int PR_CAP_AMBIENT;
+ field public static final int PR_CAP_AMBIENT_RAISE;
+ field public static final int RLIMIT_NOFILE;
+ field public static final int RTMGRP_IPV4_IFADDR;
+ field public static final int SPLICE_F_MORE;
+ field public static final int SPLICE_F_MOVE;
+ field public static final int TIOCOUTQ;
+ field public static final int UDP_ENCAP;
+ field public static final int UDP_ENCAP_ESPINUDP;
+ field public static final int XATTR_CREATE;
+ field public static final int _LINUX_CAPABILITY_VERSION_3;
}
public final class PacketSocketAddress extends java.net.SocketAddress {
@@ -176,18 +160,18 @@
}
public class ASN1EncodableVector {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public ASN1EncodableVector();
- method @dalvik.annotation.compat.UnsupportedAppUsage public void add(com.android.org.bouncycastle.asn1.ASN1Encodable);
+ ctor public ASN1EncodableVector();
+ method public void add(com.android.org.bouncycastle.asn1.ASN1Encodable);
}
public class ASN1InputStream extends java.io.FilterInputStream {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public ASN1InputStream(java.io.InputStream);
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public ASN1InputStream(byte[]);
- method @dalvik.annotation.compat.UnsupportedAppUsage public com.android.org.bouncycastle.asn1.ASN1Primitive readObject() throws java.io.IOException;
+ ctor public ASN1InputStream(java.io.InputStream);
+ ctor public ASN1InputStream(byte[]);
+ method public com.android.org.bouncycastle.asn1.ASN1Primitive readObject() throws java.io.IOException;
}
public class ASN1Integer extends com.android.org.bouncycastle.asn1.ASN1Primitive {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public ASN1Integer(java.math.BigInteger);
+ ctor public ASN1Integer(java.math.BigInteger);
}
public abstract class ASN1Null extends com.android.org.bouncycastle.asn1.ASN1Primitive {
@@ -224,24 +208,24 @@
}
public class DERBitString extends com.android.org.bouncycastle.asn1.ASN1BitString {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public DERBitString(byte[]);
+ ctor public DERBitString(byte[]);
}
@Deprecated public class DERInteger extends com.android.org.bouncycastle.asn1.ASN1Integer {
- ctor @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public DERInteger(long);
+ ctor @Deprecated public DERInteger(long);
}
public class DERNull extends com.android.org.bouncycastle.asn1.ASN1Null {
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final com.android.org.bouncycastle.asn1.DERNull INSTANCE;
+ field public static final com.android.org.bouncycastle.asn1.DERNull INSTANCE;
}
public class DEROctetString extends com.android.org.bouncycastle.asn1.ASN1OctetString {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public DEROctetString(byte[]);
+ ctor public DEROctetString(byte[]);
}
public class DERSequence extends com.android.org.bouncycastle.asn1.ASN1Sequence {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public DERSequence();
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public DERSequence(com.android.org.bouncycastle.asn1.ASN1EncodableVector);
+ ctor public DERSequence();
+ ctor public DERSequence(com.android.org.bouncycastle.asn1.ASN1EncodableVector);
}
public class DERTaggedObject extends com.android.org.bouncycastle.asn1.ASN1TaggedObject {
@@ -258,7 +242,7 @@
package com.android.org.bouncycastle.asn1.pkcs {
public interface PKCSObjectIdentifiers {
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier sha256WithRSAEncryption;
+ field public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier sha256WithRSAEncryption;
field public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier sha512WithRSAEncryption;
}
@@ -289,8 +273,8 @@
package com.android.org.bouncycastle.asn1.x509 {
public class AlgorithmIdentifier extends com.android.org.bouncycastle.asn1.ASN1Object {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public AlgorithmIdentifier(com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier);
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public AlgorithmIdentifier(com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier, com.android.org.bouncycastle.asn1.ASN1Encodable);
+ ctor public AlgorithmIdentifier(com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier);
+ ctor public AlgorithmIdentifier(com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier, com.android.org.bouncycastle.asn1.ASN1Encodable);
method public com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier getAlgorithm();
}
@@ -300,7 +284,7 @@
}
public class Certificate extends com.android.org.bouncycastle.asn1.ASN1Object {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static com.android.org.bouncycastle.asn1.x509.Certificate getInstance(Object);
+ method public static com.android.org.bouncycastle.asn1.x509.Certificate getInstance(Object);
}
public class GeneralName extends com.android.org.bouncycastle.asn1.ASN1Object {
@@ -313,35 +297,35 @@
}
public class SubjectPublicKeyInfo extends com.android.org.bouncycastle.asn1.ASN1Object {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo getInstance(Object);
+ method public static com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo getInstance(Object);
}
public class TBSCertificate extends com.android.org.bouncycastle.asn1.ASN1Object {
}
public class Time extends com.android.org.bouncycastle.asn1.ASN1Object {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public Time(java.util.Date);
+ ctor public Time(java.util.Date);
}
public class V3TBSCertificateGenerator {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public V3TBSCertificateGenerator();
- method @dalvik.annotation.compat.UnsupportedAppUsage public com.android.org.bouncycastle.asn1.x509.TBSCertificate generateTBSCertificate();
- method @dalvik.annotation.compat.UnsupportedAppUsage public void setEndDate(com.android.org.bouncycastle.asn1.x509.Time);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setIssuer(com.android.org.bouncycastle.asn1.x509.X509Name);
- method @dalvik.annotation.compat.UnsupportedAppUsage public void setSerialNumber(com.android.org.bouncycastle.asn1.ASN1Integer);
- method @dalvik.annotation.compat.UnsupportedAppUsage public void setSignature(com.android.org.bouncycastle.asn1.x509.AlgorithmIdentifier);
- method @dalvik.annotation.compat.UnsupportedAppUsage public void setStartDate(com.android.org.bouncycastle.asn1.x509.Time);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setSubject(com.android.org.bouncycastle.asn1.x509.X509Name);
- method @dalvik.annotation.compat.UnsupportedAppUsage public void setSubjectPublicKeyInfo(com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo);
+ ctor public V3TBSCertificateGenerator();
+ method public com.android.org.bouncycastle.asn1.x509.TBSCertificate generateTBSCertificate();
+ method public void setEndDate(com.android.org.bouncycastle.asn1.x509.Time);
+ method @Deprecated public void setIssuer(com.android.org.bouncycastle.asn1.x509.X509Name);
+ method public void setSerialNumber(com.android.org.bouncycastle.asn1.ASN1Integer);
+ method public void setSignature(com.android.org.bouncycastle.asn1.x509.AlgorithmIdentifier);
+ method public void setStartDate(com.android.org.bouncycastle.asn1.x509.Time);
+ method @Deprecated public void setSubject(com.android.org.bouncycastle.asn1.x509.X509Name);
+ method public void setSubjectPublicKeyInfo(com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo);
}
@Deprecated public class X509Name extends com.android.org.bouncycastle.asn1.ASN1Object {
- ctor @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public X509Name(String);
+ ctor @Deprecated public X509Name(String);
method @Deprecated public static com.android.org.bouncycastle.asn1.x509.X509Name getInstance(Object);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public java.util.Vector getOIDs();
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public java.util.Vector getValues();
+ method @Deprecated public java.util.Vector getOIDs();
+ method @Deprecated public java.util.Vector getValues();
method @Deprecated public String toString(boolean, java.util.Hashtable);
- field @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier CN;
+ field @Deprecated public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier CN;
field @Deprecated public static final java.util.Hashtable DefaultSymbols;
field @Deprecated public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier O;
field @Deprecated public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier OU;
@@ -352,7 +336,7 @@
package com.android.org.bouncycastle.asn1.x9 {
public interface X9ObjectIdentifiers {
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier ecdsa_with_SHA256;
+ field public static final com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier ecdsa_with_SHA256;
}
}
@@ -420,7 +404,7 @@
package com.android.org.bouncycastle.jce {
@Deprecated public class X509Principal extends com.android.org.bouncycastle.asn1.x509.X509Name implements java.security.Principal {
- ctor @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public X509Principal(byte[]) throws java.io.IOException;
+ ctor @Deprecated public X509Principal(byte[]) throws java.io.IOException;
ctor @Deprecated public X509Principal(java.util.Vector, java.util.Hashtable);
method public byte[] getEncoded();
}
@@ -430,11 +414,11 @@
package com.android.org.bouncycastle.jce.provider {
public final class BouncyCastleProvider extends java.security.Provider {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public BouncyCastleProvider();
+ ctor public BouncyCastleProvider();
}
@Deprecated public class X509CertificateObject extends java.security.cert.X509Certificate {
- ctor @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public X509CertificateObject(com.android.org.bouncycastle.asn1.x509.Certificate) throws java.security.cert.CertificateParsingException;
+ ctor @Deprecated public X509CertificateObject(com.android.org.bouncycastle.asn1.x509.Certificate) throws java.security.cert.CertificateParsingException;
}
}
@@ -489,15 +473,15 @@
}
@Deprecated public class X509V3CertificateGenerator {
- ctor @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public X509V3CertificateGenerator();
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public java.security.cert.X509Certificate generate(java.security.PrivateKey) throws java.security.cert.CertificateEncodingException, java.lang.IllegalStateException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, java.security.SignatureException;
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setIssuerDN(javax.security.auth.x500.X500Principal);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setNotAfter(java.util.Date);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setNotBefore(java.util.Date);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setPublicKey(java.security.PublicKey) throws java.lang.IllegalArgumentException;
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setSerialNumber(java.math.BigInteger);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setSignatureAlgorithm(String);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void setSubjectDN(javax.security.auth.x500.X500Principal);
+ ctor @Deprecated public X509V3CertificateGenerator();
+ method @Deprecated public java.security.cert.X509Certificate generate(java.security.PrivateKey) throws java.security.cert.CertificateEncodingException, java.lang.IllegalStateException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, java.security.SignatureException;
+ method @Deprecated public void setIssuerDN(javax.security.auth.x500.X500Principal);
+ method @Deprecated public void setNotAfter(java.util.Date);
+ method @Deprecated public void setNotBefore(java.util.Date);
+ method @Deprecated public void setPublicKey(java.security.PublicKey) throws java.lang.IllegalArgumentException;
+ method @Deprecated public void setSerialNumber(java.math.BigInteger);
+ method @Deprecated public void setSignatureAlgorithm(String);
+ method @Deprecated public void setSubjectDN(javax.security.auth.x500.X500Principal);
}
}
@@ -517,16 +501,10 @@
package dalvik.annotation.compat {
- @java.lang.annotation.Repeatable(UnsupportedAppUsage.Container.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.TYPE}) public @interface UnsupportedAppUsage {
- method public abstract String expectedSignature() default "";
- method public abstract String implicitMember() default "";
- method public abstract int maxTargetSdk() default java.lang.Integer.MAX_VALUE;
- method public abstract String publicAlternatives() default "";
- method public abstract long trackingBug() default 0;
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface UnsupportedAppUsage.Container {
- method public abstract dalvik.annotation.compat.UnsupportedAppUsage[] value();
+ public class VersionCodes {
+ field public static final int O = 26; // 0x1a
+ field public static final int P = 28; // 0x1c
+ field public static final int Q = 29; // 0x1d
}
}
@@ -550,9 +528,9 @@
}
public class BaseDexClassLoader extends java.lang.ClassLoader {
- method @dalvik.annotation.compat.UnsupportedAppUsage public void addDexPath(String);
+ method public void addDexPath(String);
method public void addNativePath(java.util.Collection<java.lang.String>);
- method @dalvik.annotation.compat.UnsupportedAppUsage public String getLdLibraryPath();
+ method public String getLdLibraryPath();
method public static void setReporter(dalvik.system.BaseDexClassLoader.Reporter);
}
@@ -561,17 +539,17 @@
}
public final class BlockGuard {
- method @NonNull @dalvik.annotation.compat.UnsupportedAppUsage public static dalvik.system.BlockGuard.Policy getThreadPolicy();
+ method @NonNull public static dalvik.system.BlockGuard.Policy getThreadPolicy();
method @NonNull public static dalvik.system.BlockGuard.VmPolicy getVmPolicy();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void setThreadPolicy(@NonNull dalvik.system.BlockGuard.Policy);
+ method public static void setThreadPolicy(@NonNull dalvik.system.BlockGuard.Policy);
method public static void setVmPolicy(@NonNull dalvik.system.BlockGuard.VmPolicy);
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final dalvik.system.BlockGuard.Policy LAX_POLICY;
+ field public static final dalvik.system.BlockGuard.Policy LAX_POLICY;
field public static final dalvik.system.BlockGuard.VmPolicy LAX_VM_POLICY;
}
public static interface BlockGuard.Policy {
method public int getPolicyMask();
- method @dalvik.annotation.compat.UnsupportedAppUsage public void onReadFromDisk();
+ method public void onReadFromDisk();
method public void onUnbufferedIO();
method public void onWriteToDisk();
}
@@ -581,17 +559,17 @@
}
public final class CloseGuard {
- method @dalvik.annotation.compat.UnsupportedAppUsage public void close();
- method @dalvik.annotation.compat.UnsupportedAppUsage(trackingBug=111170242) public static dalvik.system.CloseGuard get();
+ method public void close();
+ method public static dalvik.system.CloseGuard get();
method public static dalvik.system.CloseGuard.Reporter getReporter();
- method @dalvik.annotation.compat.UnsupportedAppUsage(trackingBug=111170242) public void open(String);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void setEnabled(boolean);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void setReporter(dalvik.system.CloseGuard.Reporter);
- method @dalvik.annotation.compat.UnsupportedAppUsage(trackingBug=111170242) public void warnIfOpen();
+ method public void open(String);
+ method public static void setEnabled(boolean);
+ method public static void setReporter(dalvik.system.CloseGuard.Reporter);
+ method public void warnIfOpen();
}
public static interface CloseGuard.Reporter {
- method @dalvik.annotation.compat.UnsupportedAppUsage public void report(String, Throwable);
+ method public void report(String, Throwable);
}
public interface DalvikLogHandler {
@@ -635,22 +613,28 @@
}
public final class RuntimeHooks {
+ method @Nullable public static dalvik.system.ThreadPrioritySetter getThreadPrioritySetter();
+ method public static void setThreadPrioritySetter(@NonNull dalvik.system.ThreadPrioritySetter);
method public static void setTimeZoneIdSupplier(java.util.function.Supplier<java.lang.String>);
method public static void setUncaughtExceptionPreHandler(java.lang.Thread.UncaughtExceptionHandler);
}
public abstract class SocketTagger {
ctor public SocketTagger();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static dalvik.system.SocketTagger get();
+ method public static dalvik.system.SocketTagger get();
method public static void set(dalvik.system.SocketTagger);
method public abstract void tag(java.io.FileDescriptor) throws java.net.SocketException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public final void tag(java.net.Socket) throws java.net.SocketException;
+ method public final void tag(java.net.Socket) throws java.net.SocketException;
method public final void tag(java.net.DatagramSocket) throws java.net.SocketException;
method public abstract void untag(java.io.FileDescriptor) throws java.net.SocketException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public final void untag(java.net.Socket) throws java.net.SocketException;
+ method public final void untag(java.net.Socket) throws java.net.SocketException;
method public final void untag(java.net.DatagramSocket) throws java.net.SocketException;
}
+ @java.lang.FunctionalInterface public interface ThreadPrioritySetter {
+ method public void setPriority(int, int);
+ }
+
public final class VMDebug {
method public static void attachAgent(String, ClassLoader) throws java.io.IOException;
method public static boolean cacheRegisterMap(String);
@@ -659,14 +643,14 @@
method public static void dumpHprofData(String) throws java.io.IOException;
method public static void dumpHprofData(String, java.io.FileDescriptor) throws java.io.IOException;
method public static void dumpHprofDataDdms();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void dumpReferenceTables();
+ method public static void dumpReferenceTables();
method public static int getAllocCount(int);
method @dalvik.annotation.optimization.FastNative public static int getLoadedClassCount();
method public static int getMethodTracingMode();
method public static String getRuntimeStat(String);
method public static java.util.Map<java.lang.String,java.lang.String> getRuntimeStats();
method public static String[] getVmFeatureList();
- method @dalvik.annotation.compat.UnsupportedAppUsage @dalvik.annotation.optimization.FastNative public static boolean isDebuggerConnected();
+ method @dalvik.annotation.optimization.FastNative public static boolean isDebuggerConnected();
method @dalvik.annotation.optimization.FastNative public static boolean isDebuggingEnabled();
method @dalvik.annotation.optimization.FastNative public static long lastDebuggerActivity();
method @dalvik.annotation.optimization.FastNative public static void printLoadedClasses(int);
@@ -696,48 +680,51 @@
}
public final class VMRuntime {
- method @dalvik.annotation.compat.UnsupportedAppUsage @dalvik.annotation.optimization.FastNative public long addressOf(Object);
+ method @dalvik.annotation.optimization.FastNative public long addressOf(Object);
method public static void bootCompleted();
method public void clampGrowthLimit();
- method @dalvik.annotation.compat.UnsupportedAppUsage public void clearGrowthLimit();
+ method public void clearGrowthLimit();
method public static boolean didPruneDalvikCache();
method public void disableJitCompilation();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String getCurrentInstructionSet();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String getInstructionSet(String);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static dalvik.system.VMRuntime getRuntime();
+ method public static String getCurrentInstructionSet();
+ method public static String getInstructionSet(String);
+ method public static dalvik.system.VMRuntime getRuntime();
method public float getTargetHeapUtilization();
method public int getTargetSdkVersion();
method @dalvik.annotation.optimization.FastNative public static boolean hasBootImageSpaces();
- method @dalvik.annotation.compat.UnsupportedAppUsage @dalvik.annotation.optimization.FastNative public boolean is64Bit();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static boolean is64BitAbi(String);
+ method @dalvik.annotation.optimization.FastNative public boolean is64Bit();
+ method public static boolean is64BitAbi(String);
method public static boolean is64BitInstructionSet(String);
method public static boolean isBootClassPathOnDisk(String);
method @dalvik.annotation.optimization.FastNative public boolean isCheckJniEnabled();
method @dalvik.annotation.optimization.FastNative public boolean isNativeDebuggable();
- method @dalvik.annotation.compat.UnsupportedAppUsage @dalvik.annotation.optimization.FastNative public Object newNonMovableArray(Class<?>, int);
+ method public static boolean isValidClassLoaderContext(String);
+ method @dalvik.annotation.optimization.FastNative public Object newNonMovableArray(Class<?>, int);
method @dalvik.annotation.optimization.FastNative public Object newUnpaddedArray(Class<?>, int);
method public void notifyStartupCompleted();
method public void preloadDexCaches();
method public static void registerAppInfo(String, String[]);
- method @dalvik.annotation.compat.UnsupportedAppUsage public void registerNativeAllocation(long);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void registerNativeAllocation(int);
- method @dalvik.annotation.compat.UnsupportedAppUsage public void registerNativeFree(long);
- method @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage public void registerNativeFree(int);
+ method public void registerNativeAllocation(long);
+ method @Deprecated public void registerNativeAllocation(int);
+ method public void registerNativeFree(long);
+ method @Deprecated public void registerNativeFree(int);
method public static void registerSensitiveThread();
method public void requestConcurrentGC();
+ method public static void resetJitCounters();
method public static void setDedupeHiddenApiWarnings(boolean);
+ method public void setDisabledCompatChanges(long[]);
method public void setHiddenApiAccessLogSamplingRate(int);
method public void setHiddenApiExemptions(String[]);
method public static void setHiddenApiUsageLogger(dalvik.system.VMRuntime.HiddenApiUsageLogger);
method public static void setNonSdkApiUsageConsumer(java.util.function.Consumer<java.lang.String>);
method public static void setProcessDataDirectory(String);
method public static void setProcessPackageName(String);
- method @dalvik.annotation.compat.UnsupportedAppUsage public float setTargetHeapUtilization(float);
- method @dalvik.annotation.compat.UnsupportedAppUsage(maxTargetSdk=0, publicAlternatives="Use the {@code targetSdkVersion}" + " attribute in the {@code uses-sdk} manifest tag instead.") public void setTargetSdkVersion(int);
+ method public float setTargetHeapUtilization(float);
+ method public void setTargetSdkVersion(int);
method public void startJitCompilation();
method public void updateProcessState(int);
- method @dalvik.annotation.compat.UnsupportedAppUsage public String vmInstructionSet();
- method @dalvik.annotation.compat.UnsupportedAppUsage public String vmLibrary();
+ method public String vmInstructionSet();
+ method public String vmLibrary();
field public static final int SDK_VERSION_CUR_DEVELOPMENT = 10000; // 0x2710
}
@@ -753,19 +740,13 @@
method @dalvik.annotation.optimization.FastNative public static dalvik.system.AnnotatedStackTraceElement[] getAnnotatedThreadStackTrace(Thread);
}
- public class VersionCodes {
- field public static final int O = 26; // 0x1a
- field public static final int P = 28; // 0x1c
- field public static final int Q = 29; // 0x1d
- }
-
public final class ZygoteHooks {
method public static void gcAndFinalize();
method public static void onBeginPreload();
method public static void onEndPreload();
method public static void postForkChild(int, boolean, boolean, String);
method public static void postForkCommon();
- method public static void postForkSystemServer();
+ method public static void postForkSystemServer(int);
method public static void preFork();
method public static void startZygoteNoThreadCreation();
method public static void stopZygoteNoThreadCreation();
@@ -870,9 +851,9 @@
}
public final class NioUtils {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void freeDirectBuffer(java.nio.ByteBuffer);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static byte[] unsafeArray(java.nio.ByteBuffer);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static int unsafeArrayOffset(java.nio.ByteBuffer);
+ method public static void freeDirectBuffer(java.nio.ByteBuffer);
+ method public static byte[] unsafeArray(java.nio.ByteBuffer);
+ method public static int unsafeArrayOffset(java.nio.ByteBuffer);
}
}
@@ -938,6 +919,14 @@
}
+package javax.net.ssl {
+
+ public abstract class HttpsURLConnection extends java.net.HttpURLConnection {
+ method public static javax.net.ssl.HostnameVerifier getStrictHostnameVerifier();
+ }
+
+}
+
package libcore.content.type {
public final class MimeMap {
@@ -963,42 +952,40 @@
package libcore.icu {
public final class DateIntervalFormat {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String formatDateRange(long, long, int, String);
+ method public static String formatDateRange(long, long, int, String);
}
public final class ICU {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static java.util.Locale addLikelySubtags(java.util.Locale);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String getBestDateTimePattern(String, java.util.Locale);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static char[] getDateFormatOrder(String);
- method public static String getTZDataVersion();
+ method public static String getBestDateTimePattern(String, java.util.Locale);
+ method public static char[] getDateFormatOrder(String);
}
public final class LocaleData {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static libcore.icu.LocaleData get(java.util.Locale);
+ method public static libcore.icu.LocaleData get(java.util.Locale);
method public String getDateFormat(int);
field public String[] amPm;
- field @dalvik.annotation.compat.UnsupportedAppUsage public Integer firstDayOfWeek;
+ field public Integer firstDayOfWeek;
field public String[] longMonthNames;
field public String[] longStandAloneMonthNames;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String[] longStandAloneWeekdayNames;
+ field public String[] longStandAloneWeekdayNames;
field public String[] longWeekdayNames;
field public String narrowAm;
field public String narrowPm;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String[] shortMonthNames;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String[] shortStandAloneMonthNames;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String[] shortStandAloneWeekdayNames;
+ field public String[] shortMonthNames;
+ field public String[] shortStandAloneMonthNames;
+ field public String[] shortStandAloneWeekdayNames;
field public String[] shortWeekdayNames;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String timeFormat_Hm;
+ field public String timeFormat_Hm;
field public String timeFormat_Hms;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String timeFormat_hm;
+ field public String timeFormat_hm;
field public String timeFormat_hms;
field public String[] tinyMonthNames;
field public String[] tinyStandAloneMonthNames;
field public String[] tinyStandAloneWeekdayNames;
field public String[] tinyWeekdayNames;
- field @dalvik.annotation.compat.UnsupportedAppUsage public String today;
+ field public String today;
field public String yesterday;
- field @dalvik.annotation.compat.UnsupportedAppUsage public char zeroDigit;
+ field public char zeroDigit;
}
public final class RelativeDateTimeFormatter {
@@ -1020,13 +1007,13 @@
package libcore.io {
public class ForwardingOs implements libcore.io.Os {
- ctor @dalvik.annotation.compat.UnsupportedAppUsage protected ForwardingOs(libcore.io.Os);
- method @dalvik.annotation.compat.UnsupportedAppUsage public boolean access(String, int) throws android.system.ErrnoException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public java.io.FileDescriptor open(String, int, int) throws android.system.ErrnoException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public void remove(String) throws android.system.ErrnoException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public void rename(String, String) throws android.system.ErrnoException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public android.system.StructStat stat(String) throws android.system.ErrnoException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public void unlink(String) throws android.system.ErrnoException;
+ ctor protected ForwardingOs(libcore.io.Os);
+ method public boolean access(String, int) throws android.system.ErrnoException;
+ method public java.io.FileDescriptor open(String, int, int) throws android.system.ErrnoException;
+ method public void remove(String) throws android.system.ErrnoException;
+ method public void rename(String, String) throws android.system.ErrnoException;
+ method public android.system.StructStat stat(String) throws android.system.ErrnoException;
+ method public void unlink(String) throws android.system.ErrnoException;
}
public final class IoBridge {
@@ -1043,13 +1030,13 @@
public final class IoUtils {
method public static int acquireRawFd(@NonNull java.io.FileDescriptor);
method public static void close(java.io.FileDescriptor) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void closeQuietly(AutoCloseable);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void closeQuietly(java.io.FileDescriptor);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void closeQuietly(java.net.Socket);
+ method public static void closeQuietly(AutoCloseable);
+ method public static void closeQuietly(java.io.FileDescriptor);
+ method public static void closeQuietly(java.net.Socket);
method @Deprecated public static void deleteContents(java.io.File) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static byte[] readFileAsByteArray(String) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static String readFileAsString(String) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void setBlocking(java.io.FileDescriptor, boolean) throws java.io.IOException;
+ method public static byte[] readFileAsByteArray(String) throws java.io.IOException;
+ method public static String readFileAsString(String) throws java.io.IOException;
+ method public static void setBlocking(java.io.FileDescriptor, boolean) throws java.io.IOException;
method public static void setFdOwner(@NonNull java.io.FileDescriptor, @NonNull Object);
}
@@ -1068,14 +1055,14 @@
}
public final class Streams {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static int copy(java.io.InputStream, java.io.OutputStream) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void readFully(java.io.InputStream, byte[]) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static byte[] readFully(java.io.InputStream) throws java.io.IOException;
+ method public static int copy(java.io.InputStream, java.io.OutputStream) throws java.io.IOException;
+ method public static void readFully(java.io.InputStream, byte[]) throws java.io.IOException;
+ method public static byte[] readFully(java.io.InputStream) throws java.io.IOException;
method public static String readFully(java.io.Reader) throws java.io.IOException;
method public static byte[] readFullyNoClose(java.io.InputStream) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static int readSingleByte(java.io.InputStream) throws java.io.IOException;
+ method public static int readSingleByte(java.io.InputStream) throws java.io.IOException;
method public static long skipByReading(java.io.InputStream, long) throws java.io.IOException;
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void writeSingleByte(java.io.OutputStream, int) throws java.io.IOException;
+ method public static void writeSingleByte(java.io.OutputStream, int) throws java.io.IOException;
}
}
@@ -1091,7 +1078,7 @@
ctor public NetworkSecurityPolicy();
method public static libcore.net.NetworkSecurityPolicy getInstance();
method public abstract boolean isCertificateTransparencyVerificationRequired(String);
- method @dalvik.annotation.compat.UnsupportedAppUsage public abstract boolean isCleartextTrafficPermitted();
+ method public abstract boolean isCleartextTrafficPermitted();
method public abstract boolean isCleartextTrafficPermitted(String);
method public static void setInstance(libcore.net.NetworkSecurityPolicy);
}
@@ -1101,7 +1088,7 @@
package libcore.net.event {
public class NetworkEventDispatcher {
- method @dalvik.annotation.compat.UnsupportedAppUsage public static libcore.net.event.NetworkEventDispatcher getInstance();
+ method public static libcore.net.event.NetworkEventDispatcher getInstance();
method public void onNetworkConfigurationChanged();
}
@@ -1112,26 +1099,27 @@
public final class CountryTimeZones {
method public String getCountryIso();
method public android.icu.util.TimeZone getDefaultTimeZone();
- method public boolean getDefaultTimeZoneBoost();
method public String getDefaultTimeZoneId();
method public java.util.List<libcore.timezone.CountryTimeZones.TimeZoneMapping> getEffectiveTimeZoneMappingsAt(long);
method public java.util.List<libcore.timezone.CountryTimeZones.TimeZoneMapping> getTimeZoneMappings();
method public boolean hasUtcZone(long);
+ method public boolean isDefaultTimeZoneBoosted();
method public boolean isForCountryCode(String);
- method public libcore.timezone.CountryTimeZones.OffsetResult lookupByOffsetWithBias(int, Boolean, Integer, long, android.icu.util.TimeZone);
+ method public libcore.timezone.CountryTimeZones.OffsetResult lookupByOffsetWithBias(long, android.icu.util.TimeZone, int, boolean);
+ method public libcore.timezone.CountryTimeZones.OffsetResult lookupByOffsetWithBias(long, android.icu.util.TimeZone, int);
}
public static final class CountryTimeZones.OffsetResult {
- field public final boolean mOneMatch;
- field public final android.icu.util.TimeZone mTimeZone;
+ method public android.icu.util.TimeZone getTimeZone();
+ method public boolean isOnlyMatch();
}
public static final class CountryTimeZones.TimeZoneMapping {
method public static libcore.timezone.CountryTimeZones.TimeZoneMapping createForTests(String, boolean, Long);
+ method public Long getNotUsedAfter();
method public android.icu.util.TimeZone getTimeZone();
- field public final Long notUsedAfter;
- field public final boolean showInPicker;
- field public final String timeZoneId;
+ method public String getTimeZoneId();
+ method public boolean isShownInPicker();
}
public final class CountryZonesFinder {
@@ -1140,6 +1128,23 @@
method public java.util.List<libcore.timezone.CountryTimeZones> lookupCountryTimeZonesForZoneId(String);
}
+ public final class TelephonyLookup {
+ method public static libcore.timezone.TelephonyLookup createInstance(String) throws java.io.IOException;
+ method public static libcore.timezone.TelephonyLookup getInstance();
+ method public libcore.timezone.TelephonyNetworkFinder getTelephonyNetworkFinder();
+ method public void validate() throws java.io.IOException;
+ }
+
+ public final class TelephonyNetwork {
+ method public String getCountryIsoCode();
+ method public String getMcc();
+ method public String getMnc();
+ }
+
+ public final class TelephonyNetworkFinder {
+ method public libcore.timezone.TelephonyNetwork findNetworkByMccMnc(String, String);
+ }
+
public final class TimeZoneDataFiles {
method public static String getDataTimeZoneFile(String);
method public static String getDataTimeZoneRootDir();
@@ -1155,15 +1160,19 @@
method public void validate() throws java.io.IOException;
}
- public class TzDataSetVersion {
+ public final class TzDataSetVersion {
ctor public TzDataSetVersion(int, int, String, int) throws libcore.timezone.TzDataSetVersion.TzDataSetException;
method public static int currentFormatMajorVersion();
method public static int currentFormatMinorVersion();
+ method public int getFormatMajorVersion();
+ method public int getFormatMinorVersion();
+ method public int getRevision();
+ method public String getRulesVersion();
method public static boolean isCompatibleWithThisDevice(libcore.timezone.TzDataSetVersion);
method public static libcore.timezone.TzDataSetVersion readFromFile(java.io.File) throws java.io.IOException, libcore.timezone.TzDataSetVersion.TzDataSetException;
+ method public static libcore.timezone.TzDataSetVersion readTimeZoneModuleVersion() throws java.io.IOException, libcore.timezone.TzDataSetVersion.TzDataSetException;
method public byte[] toBytes();
field public static final String DEFAULT_FILE_NAME = "tz_version";
- field public final String rulesVersion;
}
public static class TzDataSetVersion.TzDataSetException extends java.lang.Exception {
@@ -1171,14 +1180,11 @@
ctor public TzDataSetVersion.TzDataSetException(String, Throwable);
}
- public final class ZoneInfoDB {
- method public static libcore.timezone.ZoneInfoDB.TzData getInstance();
- }
-
- public static class ZoneInfoDB.TzData implements java.lang.AutoCloseable {
+ public final class ZoneInfoDb implements java.lang.AutoCloseable {
+ method public static libcore.timezone.ZoneInfoDb getInstance();
method public String getVersion();
method public boolean hasTimeZone(String) throws java.io.IOException;
- method public static libcore.timezone.ZoneInfoDB.TzData loadTzData(String);
+ method public static libcore.timezone.ZoneInfoDb loadTzData(String);
method public libcore.util.ZoneInfo makeTimeZone(String) throws java.io.IOException;
method public void validate() throws java.io.IOException;
}
@@ -1210,11 +1216,11 @@
public final class EmptyArray {
field public static final boolean[] BOOLEAN;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final byte[] BYTE;
+ field public static final byte[] BYTE;
field public static final float[] FLOAT;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final int[] INT;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final long[] LONG;
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final Object[] OBJECT;
+ field public static final int[] INT;
+ field public static final long[] LONG;
+ field public static final Object[] OBJECT;
field public static final String[] STRING;
}
@@ -1352,7 +1358,7 @@
public class Chunk {
ctor public Chunk(int, byte[], int, int);
- ctor @dalvik.annotation.compat.UnsupportedAppUsage public Chunk(int, java.nio.ByteBuffer);
+ ctor public Chunk(int, java.nio.ByteBuffer);
field public int type;
}
@@ -1367,21 +1373,21 @@
method public static void putString(java.nio.ByteBuffer, String);
method public static int type(String);
method public static java.nio.ByteBuffer wrapChunk(org.apache.harmony.dalvik.ddmc.Chunk);
- field @dalvik.annotation.compat.UnsupportedAppUsage public static final java.nio.ByteOrder CHUNK_ORDER;
+ field public static final java.nio.ByteOrder CHUNK_ORDER;
}
public class DdmServer {
method public static void registerHandler(int, org.apache.harmony.dalvik.ddmc.ChunkHandler);
method public static void registrationComplete();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static void sendChunk(org.apache.harmony.dalvik.ddmc.Chunk);
+ method public static void sendChunk(org.apache.harmony.dalvik.ddmc.Chunk);
}
public class DdmVmInternal {
method public static void enableRecentAllocations(boolean);
method @dalvik.annotation.optimization.FastNative public static boolean getRecentAllocationStatus();
method @dalvik.annotation.optimization.FastNative public static byte[] getRecentAllocations();
- method @dalvik.annotation.compat.UnsupportedAppUsage public static StackTraceElement[] getStackTraceById(int);
- method @dalvik.annotation.compat.UnsupportedAppUsage public static byte[] getThreadStats();
+ method public static StackTraceElement[] getStackTraceById(int);
+ method public static byte[] getThreadStats();
method @dalvik.annotation.optimization.FastNative public static boolean heapInfoNotify(int);
method public static boolean heapSegmentNotify(int, int, boolean);
method public static void threadNotify(boolean);
@@ -1392,7 +1398,7 @@
package org.json {
public class JSONObject {
- method @dalvik.annotation.compat.UnsupportedAppUsage public java.util.Set<java.lang.String> keySet();
+ method public java.util.Set<java.lang.String> keySet();
}
}
diff --git a/mmodules/intracoreapi/Android.bp b/mmodules/intracoreapi/Android.bp
index f8454bb..c2a3de3 100644
--- a/mmodules/intracoreapi/Android.bp
+++ b/mmodules/intracoreapi/Android.bp
@@ -71,6 +71,7 @@
java_system_modules {
name: "art-module-intra-core-api-stubs-system-modules",
visibility: [
+ "//art/build/sdk",
"//external/bouncycastle",
"//external/conscrypt",
"//external/icu/android_icu4j",
diff --git a/mmodules/intracoreapi/api/intra/current-api.txt b/mmodules/intracoreapi/api/intra/current-api.txt
index fb613db..5137a10 100644
--- a/mmodules/intracoreapi/api/intra/current-api.txt
+++ b/mmodules/intracoreapi/api/intra/current-api.txt
@@ -2,8 +2,8 @@
package android.compat {
@libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public final class Compatibility {
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static boolean isChangeEnabled(@android.compat.annotation.ChangeId long);
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static void reportChange(@android.compat.annotation.ChangeId long);
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static boolean isChangeEnabled(long);
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static void reportChange(long);
}
@libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final class Compatibility.ChangeConfig {
@@ -19,32 +19,12 @@
}
-package android.compat.annotation {
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.PARAMETER}) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public @interface ChangeId {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD}) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public @interface Disabled {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD}) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public @interface EnabledAfter {
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract int targetSdkVersion();
- }
-
-}
-
package dalvik.annotation.compat {
- @java.lang.annotation.Repeatable(UnsupportedAppUsage.Container.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.TYPE}) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public @interface UnsupportedAppUsage {
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract String expectedSignature() default "";
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract String implicitMember() default "";
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract int maxTargetSdk() default java.lang.Integer.MAX_VALUE;
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract String publicAlternatives() default "";
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract long trackingBug() default 0;
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static @interface UnsupportedAppUsage.Container {
- method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract dalvik.annotation.compat.UnsupportedAppUsage[] value();
+ @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public class VersionCodes {
+ field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int O = 26; // 0x1a
+ field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int P = 28; // 0x1c
+ field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int Q = 29; // 0x1d
}
}
@@ -59,24 +39,18 @@
package dalvik.system {
@libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public final class BlockGuard {
- method @NonNull @dalvik.annotation.compat.UnsupportedAppUsage @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static dalvik.system.BlockGuard.Policy getThreadPolicy();
+ method @NonNull @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static dalvik.system.BlockGuard.Policy getThreadPolicy();
}
@libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static interface BlockGuard.Policy {
- method @dalvik.annotation.compat.UnsupportedAppUsage @libcore.api.IntraCoreApi public void onNetwork();
+ method @libcore.api.IntraCoreApi public void onNetwork();
}
@libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public final class CloseGuard {
- method @dalvik.annotation.compat.UnsupportedAppUsage @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void close();
- method @dalvik.annotation.compat.UnsupportedAppUsage(trackingBug=111170242) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static dalvik.system.CloseGuard get();
- method @dalvik.annotation.compat.UnsupportedAppUsage(trackingBug=111170242) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void open(String);
- method @dalvik.annotation.compat.UnsupportedAppUsage(trackingBug=111170242) @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void warnIfOpen();
- }
-
- @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public class VersionCodes {
- field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int O = 26; // 0x1a
- field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int P = 28; // 0x1c
- field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int Q = 29; // 0x1d
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void close();
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static dalvik.system.CloseGuard get();
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void open(String);
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void warnIfOpen();
}
}
@@ -89,6 +63,22 @@
}
+package java.nio.charset {
+
+ public abstract class Charset implements java.lang.Comparable<java.nio.charset.Charset> {
+ ctor @libcore.api.IntraCoreApi protected Charset(String, String[]);
+ }
+
+ public abstract class CharsetDecoder {
+ ctor protected CharsetDecoder(java.nio.charset.Charset, float, float);
+ }
+
+ public abstract class CharsetEncoder {
+ ctor protected CharsetEncoder(java.nio.charset.Charset, float, float, byte[], boolean);
+ }
+
+}
+
package java.security.spec {
public class ECParameterSpec implements java.security.spec.AlgorithmParameterSpec {
@@ -108,10 +98,10 @@
}
-package libcore.icu {
+package libcore.io {
- @libcore.api.IntraCoreApi @libcore.api.CorePlatformApi public final class ICU {
- method @libcore.api.IntraCoreApi public static String getIcuVersion();
+ @libcore.api.IntraCoreApi public final class AsynchronousCloseMonitor {
+ method @libcore.api.IntraCoreApi public static void signalBlockedThreads(java.io.FileDescriptor);
}
}
@@ -133,10 +123,10 @@
method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public Runnable registerNativeAllocation(Object, long);
}
- @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE_USE}) @libcore.api.IntraCoreApi public @interface NonNull {
+ @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE}) @libcore.api.IntraCoreApi public @interface NonNull {
}
- @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE_USE}) @libcore.api.IntraCoreApi public @interface Nullable {
+ @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE}) @libcore.api.IntraCoreApi public @interface Nullable {
}
}
diff --git a/mmodules/intracoreapi/api/intra/last-api.txt b/mmodules/intracoreapi/api/intra/last-api.txt
index e69de29..a62bfb6 100644
--- a/mmodules/intracoreapi/api/intra/last-api.txt
+++ b/mmodules/intracoreapi/api/intra/last-api.txt
@@ -0,0 +1,88 @@
+// Signature format: 2.0
+package dalvik.annotation.compat {
+
+ @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public class VersionCodes {
+ field @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static final int Q = 29; // 0x1d
+ }
+
+}
+
+package dalvik.system {
+
+ @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public final class BlockGuard {
+ method @NonNull @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static dalvik.system.BlockGuard.Policy getThreadPolicy();
+ }
+
+ @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static interface BlockGuard.Policy {
+ method @libcore.api.IntraCoreApi public void onNetwork();
+ }
+
+ @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public final class CloseGuard {
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void close();
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static dalvik.system.CloseGuard get();
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void open(String);
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public void warnIfOpen();
+ }
+
+}
+
+package java.net {
+
+ public class Socket implements java.io.Closeable {
+ method public java.io.FileDescriptor getFileDescriptor$();
+ }
+
+}
+
+package java.security.spec {
+
+ public class ECParameterSpec implements java.security.spec.AlgorithmParameterSpec {
+ method public String getCurveName();
+ method public void setCurveName(String);
+ }
+
+}
+
+package libcore.api {
+
+ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.ANNOTATION_TYPE}) @libcore.api.IntraCoreApi public @interface CorePlatformApi {
+ }
+
+ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.ANNOTATION_TYPE}) @libcore.api.IntraCoreApi public @interface IntraCoreApi {
+ }
+
+}
+
+package libcore.io {
+
+ @libcore.api.IntraCoreApi public final class AsynchronousCloseMonitor {
+ method @libcore.api.IntraCoreApi public static void signalBlockedThreads(java.io.FileDescriptor);
+ }
+
+}
+
+package libcore.net {
+
+ @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract class NetworkSecurityPolicy {
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public static libcore.net.NetworkSecurityPolicy getInstance();
+ method @libcore.api.CorePlatformApi @libcore.api.IntraCoreApi public abstract boolean isCertificateTransparencyVerificationRequired(String);
+ }
+
+}
+
+package libcore.util {
+
+ @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE}) @libcore.api.IntraCoreApi public @interface NonNull {
+ }
+
+}
+
+package sun.security.x509 {
+
+ public class AlgorithmId implements java.io.Serializable {
+ method public static sun.security.x509.AlgorithmId get(String) throws java.security.NoSuchAlgorithmException;
+ method public String getName();
+ }
+
+}
+
diff --git a/non_openjdk_java_files.bp b/non_openjdk_java_files.bp
index 4f7a33d..e3c8c16 100644
--- a/non_openjdk_java_files.bp
+++ b/non_openjdk_java_files.bp
@@ -49,6 +49,7 @@
"dalvik/src/main/java/dalvik/system/RuntimeHooks.java",
"dalvik/src/main/java/dalvik/system/SocketTagger.java",
"dalvik/src/main/java/dalvik/system/TemporaryDirectory.java",
+ "dalvik/src/main/java/dalvik/system/ThreadPrioritySetter.java",
"dalvik/src/main/java/dalvik/system/VMDebug.java",
"dalvik/src/main/java/dalvik/system/ZygoteHooks.java",
"dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java",
@@ -112,8 +113,7 @@
filegroup {
name: "hidden_api_surface_annotation_files",
srcs: [
- "dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java",
- "dalvik/src/main/java/dalvik/system/VersionCodes.java",
+ "dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java",
],
}
@@ -131,9 +131,6 @@
name: "non_openjdk_javadoc_luni_files",
srcs: [
"luni/src/main/java/android/compat/Compatibility.java",
- "luni/src/main/java/android/compat/annotation/ChangeId.java",
- "luni/src/main/java/android/compat/annotation/Disabled.java",
- "luni/src/main/java/android/compat/annotation/EnabledAfter.java",
"luni/src/main/java/android/system/ErrnoException.java",
"luni/src/main/java/android/system/GaiException.java",
"luni/src/main/java/android/system/IcmpHeaders.java",
@@ -176,10 +173,6 @@
"luni/src/main/java/java/net/DefaultFileNameMap.java",
"luni/src/main/java/java/nio/NIOAccess.java",
"luni/src/main/java/java/nio/NioUtils.java",
- "luni/src/main/java/java/nio/charset/CharsetDecoderICU.java",
- "luni/src/main/java/java/nio/charset/CharsetEncoderICU.java",
- "luni/src/main/java/java/nio/charset/CharsetICU.java",
- "luni/src/main/java/java/nio/charset/ModifiedUtf8.java",
"luni/src/main/java/javax/xml/XMLConstants.java",
"luni/src/main/java/javax/xml/datatype/DatatypeConfigurationException.java",
"luni/src/main/java/javax/xml/datatype/DatatypeConstants.java",
@@ -245,6 +238,7 @@
"luni/src/main/java/libcore/icu/RelativeDateTimeFormatter.java",
"luni/src/main/java/libcore/icu/TimeZoneNames.java",
"luni/src/main/java/libcore/internal/StringPool.java",
+ "luni/src/main/java/libcore/io/AsynchronousCloseMonitor.java",
"luni/src/main/java/libcore/io/ForwardingOs.java",
"luni/src/main/java/libcore/io/IoBridge.java",
"luni/src/main/java/libcore/io/IoUtils.java",
@@ -257,10 +251,14 @@
"luni/src/main/java/libcore/net/event/NetworkEventDispatcher.java",
"luni/src/main/java/libcore/timezone/CountryTimeZones.java",
"luni/src/main/java/libcore/timezone/CountryZonesFinder.java",
+ "luni/src/main/java/libcore/timezone/TelephonyLookup.java",
+ "luni/src/main/java/libcore/timezone/TelephonyNetwork.java",
+ "luni/src/main/java/libcore/timezone/TelephonyNetworkFinder.java",
"luni/src/main/java/libcore/timezone/TimeZoneDataFiles.java",
"luni/src/main/java/libcore/timezone/TimeZoneFinder.java",
"luni/src/main/java/libcore/timezone/TzDataSetVersion.java",
- "luni/src/main/java/libcore/timezone/ZoneInfoDB.java",
+ "luni/src/main/java/libcore/timezone/XmlUtils.java",
+ "luni/src/main/java/libcore/timezone/ZoneInfoDb.java",
"luni/src/main/java/libcore/util/ArrayUtils.java",
"luni/src/main/java/libcore/util/BasicLruCache.java",
"luni/src/main/java/libcore/util/CoreLibraryDebug.java",
@@ -378,9 +376,7 @@
"luni/src/main/java/libcore/icu/CollationKeyICU.java",
"luni/src/main/java/libcore/icu/DateTimeFormat.java",
"luni/src/main/java/libcore/icu/DateUtilsBridge.java",
- "luni/src/main/java/libcore/icu/NativeConverter.java",
"luni/src/main/java/libcore/internal/Java9LanguageFeatures.java",
- "luni/src/main/java/libcore/io/AsynchronousCloseMonitor.java",
"luni/src/main/java/libcore/io/ClassPathURLStreamHandler.java",
"luni/src/main/java/libcore/io/BlockGuardOs.java",
"luni/src/main/java/libcore/io/BufferIterator.java",
@@ -405,8 +401,6 @@
"luni/src/main/java/libcore/reflect/WildcardTypeImpl.java",
"luni/src/main/java/libcore/util/CharsetUtils.java",
"luni/src/main/java/libcore/util/CollectionUtils.java",
- "luni/src/main/java/libcore/util/NonNull.java",
- "luni/src/main/java/libcore/util/Nullable.java",
"luni/src/main/java/libcore/util/NullFromTypeParam.java",
"luni/src/main/java/libcore/util/Objects.java",
"luni/src/main/java/org/apache/harmony/xml/ExpatAttributes.java",
@@ -452,6 +446,7 @@
srcs: [
"luni/src/main/java/libcore/api/CorePlatformApi.java",
"luni/src/main/java/libcore/api/IntraCoreApi.java",
+ "luni/src/main/java/libcore/timezone/TimeZoneDataFiles.java",
"luni/src/main/java/libcore/timezone/TzDataSetVersion.java",
],
}
diff --git a/ojluni/annotations/hiddenapi/com/sun/nio/file/ExtendedWatchEventModifier.java b/ojluni/annotations/hiddenapi/com/sun/nio/file/ExtendedWatchEventModifier.java
index d3d1fd7..9abd97c 100644
--- a/ojluni/annotations/hiddenapi/com/sun/nio/file/ExtendedWatchEventModifier.java
+++ b/ojluni/annotations/hiddenapi/com/sun/nio/file/ExtendedWatchEventModifier.java
@@ -27,7 +27,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public enum ExtendedWatchEventModifier implements java.nio.file.WatchEvent.Modifier {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
FILE_TREE;
private ExtendedWatchEventModifier() {
diff --git a/ojluni/annotations/hiddenapi/java/io/Console.java b/ojluni/annotations/hiddenapi/java/io/Console.java
index 9a93310..24039a1 100644
--- a/ojluni/annotations/hiddenapi/java/io/Console.java
+++ b/ojluni/annotations/hiddenapi/java/io/Console.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Console implements java.io.Flushable {
diff --git a/ojluni/annotations/hiddenapi/java/io/File.java b/ojluni/annotations/hiddenapi/java/io/File.java
index 7b93218..bdcce88 100644
--- a/ojluni/annotations/hiddenapi/java/io/File.java
+++ b/ojluni/annotations/hiddenapi/java/io/File.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class File implements java.io.Serializable, java.lang.Comparable<java.io.File> {
diff --git a/ojluni/annotations/hiddenapi/java/io/FileDescriptor.java b/ojluni/annotations/hiddenapi/java/io/FileDescriptor.java
index 7872403..6e9e74d 100644
--- a/ojluni/annotations/hiddenapi/java/io/FileDescriptor.java
+++ b/ojluni/annotations/hiddenapi/java/io/FileDescriptor.java
@@ -25,7 +25,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class FileDescriptor {
diff --git a/ojluni/annotations/hiddenapi/java/io/FileInputStream.java b/ojluni/annotations/hiddenapi/java/io/FileInputStream.java
index 3de1617..1999d13 100644
--- a/ojluni/annotations/hiddenapi/java/io/FileInputStream.java
+++ b/ojluni/annotations/hiddenapi/java/io/FileInputStream.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class FileInputStream extends java.io.InputStream {
diff --git a/ojluni/annotations/hiddenapi/java/io/FileOutputStream.java b/ojluni/annotations/hiddenapi/java/io/FileOutputStream.java
index b918f6a..5e35fc0 100644
--- a/ojluni/annotations/hiddenapi/java/io/FileOutputStream.java
+++ b/ojluni/annotations/hiddenapi/java/io/FileOutputStream.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class FileOutputStream extends java.io.OutputStream {
diff --git a/ojluni/annotations/hiddenapi/java/io/FileSystem.java b/ojluni/annotations/hiddenapi/java/io/FileSystem.java
index 4999b3c..e522846 100644
--- a/ojluni/annotations/hiddenapi/java/io/FileSystem.java
+++ b/ojluni/annotations/hiddenapi/java/io/FileSystem.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
abstract class FileSystem {
diff --git a/ojluni/annotations/hiddenapi/java/io/ObjectInputStream.java b/ojluni/annotations/hiddenapi/java/io/ObjectInputStream.java
index 90dcfea..562d846 100644
--- a/ojluni/annotations/hiddenapi/java/io/ObjectInputStream.java
+++ b/ojluni/annotations/hiddenapi/java/io/ObjectInputStream.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ObjectInputStream extends java.io.InputStream
diff --git a/ojluni/annotations/hiddenapi/java/io/ObjectOutputStream.java b/ojluni/annotations/hiddenapi/java/io/ObjectOutputStream.java
index f3e462d..1e429a4 100644
--- a/ojluni/annotations/hiddenapi/java/io/ObjectOutputStream.java
+++ b/ojluni/annotations/hiddenapi/java/io/ObjectOutputStream.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ObjectOutputStream extends java.io.OutputStream
diff --git a/ojluni/annotations/hiddenapi/java/io/ObjectStreamClass.java b/ojluni/annotations/hiddenapi/java/io/ObjectStreamClass.java
index d617d32..658d601 100644
--- a/ojluni/annotations/hiddenapi/java/io/ObjectStreamClass.java
+++ b/ojluni/annotations/hiddenapi/java/io/ObjectStreamClass.java
@@ -25,7 +25,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ObjectStreamClass implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/io/ObjectStreamField.java b/ojluni/annotations/hiddenapi/java/io/ObjectStreamField.java
index b3b7c34..36ba799 100644
--- a/ojluni/annotations/hiddenapi/java/io/ObjectStreamField.java
+++ b/ojluni/annotations/hiddenapi/java/io/ObjectStreamField.java
@@ -25,7 +25,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ObjectStreamField implements java.lang.Comparable<java.lang.Object> {
diff --git a/ojluni/annotations/hiddenapi/java/io/RandomAccessFile.java b/ojluni/annotations/hiddenapi/java/io/RandomAccessFile.java
index 32d36ab..5bc7d69 100644
--- a/ojluni/annotations/hiddenapi/java/io/RandomAccessFile.java
+++ b/ojluni/annotations/hiddenapi/java/io/RandomAccessFile.java
@@ -26,7 +26,7 @@
package java.io;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class RandomAccessFile implements java.io.DataOutput, java.io.DataInput, java.io.Closeable {
diff --git a/ojluni/annotations/hiddenapi/java/lang/AbstractStringBuilder.java b/ojluni/annotations/hiddenapi/java/lang/AbstractStringBuilder.java
index 42a5b55..4ec2383 100644
--- a/ojluni/annotations/hiddenapi/java/lang/AbstractStringBuilder.java
+++ b/ojluni/annotations/hiddenapi/java/lang/AbstractStringBuilder.java
@@ -25,7 +25,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
abstract class AbstractStringBuilder implements java.lang.Appendable, java.lang.CharSequence {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Boolean.java b/ojluni/annotations/hiddenapi/java/lang/Boolean.java
index 14f0255..5f82352 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Boolean.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Boolean.java
@@ -25,8 +25,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Boolean
diff --git a/ojluni/annotations/hiddenapi/java/lang/Byte.java b/ojluni/annotations/hiddenapi/java/lang/Byte.java
index 6938eb7..612108b 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Byte.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Byte.java
@@ -25,8 +25,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Byte extends java.lang.Number implements java.lang.Comparable<java.lang.Byte> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Character.java b/ojluni/annotations/hiddenapi/java/lang/Character.java
index 6ac842d..207008e 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Character.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Character.java
@@ -25,8 +25,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Character
diff --git a/ojluni/annotations/hiddenapi/java/lang/Class.java b/ojluni/annotations/hiddenapi/java/lang/Class.java
index 12a69d7..a9c1515 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Class.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Class.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Class<T>
diff --git a/ojluni/annotations/hiddenapi/java/lang/ClassLoader.java b/ojluni/annotations/hiddenapi/java/lang/ClassLoader.java
index 6af0cb8..b9c371e 100644
--- a/ojluni/annotations/hiddenapi/java/lang/ClassLoader.java
+++ b/ojluni/annotations/hiddenapi/java/lang/ClassLoader.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class ClassLoader {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Double.java b/ojluni/annotations/hiddenapi/java/lang/Double.java
index 187b7b4..1daeeb9 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Double.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Double.java
@@ -25,8 +25,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Double extends java.lang.Number
diff --git a/ojluni/annotations/hiddenapi/java/lang/Enum.java b/ojluni/annotations/hiddenapi/java/lang/Enum.java
index 369e58e..8cd1b6d 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Enum.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Enum.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Enum<E extends java.lang.Enum<E>>
diff --git a/ojluni/annotations/hiddenapi/java/lang/Float.java b/ojluni/annotations/hiddenapi/java/lang/Float.java
index 1081764..98f0b09 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Float.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Float.java
@@ -25,8 +25,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Float extends java.lang.Number implements java.lang.Comparable<java.lang.Float> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Integer.java b/ojluni/annotations/hiddenapi/java/lang/Integer.java
index adb8c9c..388878e 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Integer.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Integer.java
@@ -26,8 +26,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Integer extends java.lang.Number
diff --git a/ojluni/annotations/hiddenapi/java/lang/Long.java b/ojluni/annotations/hiddenapi/java/lang/Long.java
index 2f32b27..e3041cc 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Long.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Long.java
@@ -26,8 +26,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Long extends java.lang.Number implements java.lang.Comparable<java.lang.Long> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Object.java b/ojluni/annotations/hiddenapi/java/lang/Object.java
index 5289874..7b26bf5 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Object.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Object.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Object {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Runtime.java b/ojluni/annotations/hiddenapi/java/lang/Runtime.java
index ca8c56c..798967f 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Runtime.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Runtime.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Runtime {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Short.java b/ojluni/annotations/hiddenapi/java/lang/Short.java
index f1f0641..05f18ce 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Short.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Short.java
@@ -25,8 +25,8 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Short extends java.lang.Number implements java.lang.Comparable<java.lang.Short> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/StackTraceElement.java b/ojluni/annotations/hiddenapi/java/lang/StackTraceElement.java
index a396013..010d949 100644
--- a/ojluni/annotations/hiddenapi/java/lang/StackTraceElement.java
+++ b/ojluni/annotations/hiddenapi/java/lang/StackTraceElement.java
@@ -25,7 +25,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class StackTraceElement implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/lang/String.java b/ojluni/annotations/hiddenapi/java/lang/String.java
index 51fdfb7..a7b137a 100644
--- a/ojluni/annotations/hiddenapi/java/lang/String.java
+++ b/ojluni/annotations/hiddenapi/java/lang/String.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class String
diff --git a/ojluni/annotations/hiddenapi/java/lang/System.java b/ojluni/annotations/hiddenapi/java/lang/System.java
index a401efd..407473b 100644
--- a/ojluni/annotations/hiddenapi/java/lang/System.java
+++ b/ojluni/annotations/hiddenapi/java/lang/System.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class System {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Thread.java b/ojluni/annotations/hiddenapi/java/lang/Thread.java
index f1b314d..36ca327 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Thread.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Thread.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Thread implements java.lang.Runnable {
diff --git a/ojluni/annotations/hiddenapi/java/lang/ThreadGroup.java b/ojluni/annotations/hiddenapi/java/lang/ThreadGroup.java
index ee9feb0..bc69033 100644
--- a/ojluni/annotations/hiddenapi/java/lang/ThreadGroup.java
+++ b/ojluni/annotations/hiddenapi/java/lang/ThreadGroup.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ThreadGroup implements java.lang.Thread.UncaughtExceptionHandler {
diff --git a/ojluni/annotations/hiddenapi/java/lang/ThreadLocal.java b/ojluni/annotations/hiddenapi/java/lang/ThreadLocal.java
index 5772a6d..ca5927b 100644
--- a/ojluni/annotations/hiddenapi/java/lang/ThreadLocal.java
+++ b/ojluni/annotations/hiddenapi/java/lang/ThreadLocal.java
@@ -25,7 +25,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ThreadLocal<T> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/Throwable.java b/ojluni/annotations/hiddenapi/java/lang/Throwable.java
index 0bc7d12..00a3b2c 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Throwable.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Throwable.java
@@ -26,7 +26,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Throwable implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/lang/UNIXProcess.java b/ojluni/annotations/hiddenapi/java/lang/UNIXProcess.java
index 75c3aa8..974ca3e 100644
--- a/ojluni/annotations/hiddenapi/java/lang/UNIXProcess.java
+++ b/ojluni/annotations/hiddenapi/java/lang/UNIXProcess.java
@@ -104,7 +104,7 @@
private boolean hasExited;
- @dalvik.annotation.compat.UnsupportedAppUsage private final int pid;
+ @android.compat.annotation.UnsupportedAppUsage private final int pid;
{
pid = 0;
diff --git a/ojluni/annotations/hiddenapi/java/lang/Void.java b/ojluni/annotations/hiddenapi/java/lang/Void.java
index e082300..35118c4 100644
--- a/ojluni/annotations/hiddenapi/java/lang/Void.java
+++ b/ojluni/annotations/hiddenapi/java/lang/Void.java
@@ -25,7 +25,7 @@
package java.lang;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Void {
diff --git a/ojluni/annotations/hiddenapi/java/lang/invoke/MethodHandles.java b/ojluni/annotations/hiddenapi/java/lang/invoke/MethodHandles.java
index dcb5f11..d89c2a1 100644
--- a/ojluni/annotations/hiddenapi/java/lang/invoke/MethodHandles.java
+++ b/ojluni/annotations/hiddenapi/java/lang/invoke/MethodHandles.java
@@ -25,7 +25,7 @@
package java.lang.invoke;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class MethodHandles {
diff --git a/ojluni/annotations/hiddenapi/java/lang/invoke/SerializedLambda.java b/ojluni/annotations/hiddenapi/java/lang/invoke/SerializedLambda.java
index b63d0de..fd92ce4 100644
--- a/ojluni/annotations/hiddenapi/java/lang/invoke/SerializedLambda.java
+++ b/ojluni/annotations/hiddenapi/java/lang/invoke/SerializedLambda.java
@@ -24,7 +24,7 @@
*/
package java.lang.invoke;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
import java.io.Serializable;
public final class SerializedLambda implements Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/lang/ref/Reference.java b/ojluni/annotations/hiddenapi/java/lang/ref/Reference.java
index f2239ea..74359c1 100644
--- a/ojluni/annotations/hiddenapi/java/lang/ref/Reference.java
+++ b/ojluni/annotations/hiddenapi/java/lang/ref/Reference.java
@@ -26,7 +26,7 @@
package java.lang.ref;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Reference<T> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/ref/ReferenceQueue.java b/ojluni/annotations/hiddenapi/java/lang/ref/ReferenceQueue.java
index 423b830..e123068 100644
--- a/ojluni/annotations/hiddenapi/java/lang/ref/ReferenceQueue.java
+++ b/ojluni/annotations/hiddenapi/java/lang/ref/ReferenceQueue.java
@@ -26,7 +26,7 @@
package java.lang.ref;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ReferenceQueue<T> {
diff --git a/ojluni/annotations/hiddenapi/java/lang/reflect/AccessibleObject.java b/ojluni/annotations/hiddenapi/java/lang/reflect/AccessibleObject.java
index b105a24..0a70608 100644
--- a/ojluni/annotations/hiddenapi/java/lang/reflect/AccessibleObject.java
+++ b/ojluni/annotations/hiddenapi/java/lang/reflect/AccessibleObject.java
@@ -26,7 +26,7 @@
package java.lang.reflect;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class AccessibleObject implements java.lang.reflect.AnnotatedElement {
diff --git a/ojluni/annotations/hiddenapi/java/lang/reflect/Constructor.java b/ojluni/annotations/hiddenapi/java/lang/reflect/Constructor.java
index 79d24e3..5accc6a 100644
--- a/ojluni/annotations/hiddenapi/java/lang/reflect/Constructor.java
+++ b/ojluni/annotations/hiddenapi/java/lang/reflect/Constructor.java
@@ -26,7 +26,7 @@
package java.lang.reflect;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Constructor<T> extends java.lang.reflect.Executable {
diff --git a/ojluni/annotations/hiddenapi/java/lang/reflect/Executable.java b/ojluni/annotations/hiddenapi/java/lang/reflect/Executable.java
index e40b1b1..198e79f 100644
--- a/ojluni/annotations/hiddenapi/java/lang/reflect/Executable.java
+++ b/ojluni/annotations/hiddenapi/java/lang/reflect/Executable.java
@@ -25,7 +25,7 @@
package java.lang.reflect;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Executable extends java.lang.reflect.AccessibleObject
diff --git a/ojluni/annotations/hiddenapi/java/lang/reflect/Field.java b/ojluni/annotations/hiddenapi/java/lang/reflect/Field.java
index 2048f74..7e9b0b4 100644
--- a/ojluni/annotations/hiddenapi/java/lang/reflect/Field.java
+++ b/ojluni/annotations/hiddenapi/java/lang/reflect/Field.java
@@ -26,7 +26,7 @@
package java.lang.reflect;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Field extends java.lang.reflect.AccessibleObject
diff --git a/ojluni/annotations/hiddenapi/java/lang/reflect/Parameter.java b/ojluni/annotations/hiddenapi/java/lang/reflect/Parameter.java
index 40ccf9e..9982658 100644
--- a/ojluni/annotations/hiddenapi/java/lang/reflect/Parameter.java
+++ b/ojluni/annotations/hiddenapi/java/lang/reflect/Parameter.java
@@ -25,7 +25,7 @@
package java.lang.reflect;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Parameter implements java.lang.reflect.AnnotatedElement {
diff --git a/ojluni/annotations/hiddenapi/java/lang/reflect/Proxy.java b/ojluni/annotations/hiddenapi/java/lang/reflect/Proxy.java
index e65bf19..593de12 100644
--- a/ojluni/annotations/hiddenapi/java/lang/reflect/Proxy.java
+++ b/ojluni/annotations/hiddenapi/java/lang/reflect/Proxy.java
@@ -26,7 +26,7 @@
package java.lang.reflect;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Proxy implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/net/Authenticator.java b/ojluni/annotations/hiddenapi/java/net/Authenticator.java
index 2765044..3ac0089 100644
--- a/ojluni/annotations/hiddenapi/java/net/Authenticator.java
+++ b/ojluni/annotations/hiddenapi/java/net/Authenticator.java
@@ -25,7 +25,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Authenticator {
diff --git a/ojluni/annotations/hiddenapi/java/net/DatagramSocket.java b/ojluni/annotations/hiddenapi/java/net/DatagramSocket.java
index fd804c7..db3446a 100644
--- a/ojluni/annotations/hiddenapi/java/net/DatagramSocket.java
+++ b/ojluni/annotations/hiddenapi/java/net/DatagramSocket.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class DatagramSocket implements java.io.Closeable {
diff --git a/ojluni/annotations/hiddenapi/java/net/HttpCookie.java b/ojluni/annotations/hiddenapi/java/net/HttpCookie.java
index 938f59e..97189e4 100644
--- a/ojluni/annotations/hiddenapi/java/net/HttpCookie.java
+++ b/ojluni/annotations/hiddenapi/java/net/HttpCookie.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class HttpCookie implements java.lang.Cloneable {
diff --git a/ojluni/annotations/hiddenapi/java/net/Inet4Address.java b/ojluni/annotations/hiddenapi/java/net/Inet4Address.java
index 16395ea..b8f60cb 100644
--- a/ojluni/annotations/hiddenapi/java/net/Inet4Address.java
+++ b/ojluni/annotations/hiddenapi/java/net/Inet4Address.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Inet4Address extends java.net.InetAddress {
diff --git a/ojluni/annotations/hiddenapi/java/net/Inet6Address.java b/ojluni/annotations/hiddenapi/java/net/Inet6Address.java
index f46fa58..fc48ebc 100644
--- a/ojluni/annotations/hiddenapi/java/net/Inet6Address.java
+++ b/ojluni/annotations/hiddenapi/java/net/Inet6Address.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Inet6Address extends java.net.InetAddress {
diff --git a/ojluni/annotations/hiddenapi/java/net/Inet6AddressImpl.java b/ojluni/annotations/hiddenapi/java/net/Inet6AddressImpl.java
index 964bdda..dd25edf 100644
--- a/ojluni/annotations/hiddenapi/java/net/Inet6AddressImpl.java
+++ b/ojluni/annotations/hiddenapi/java/net/Inet6AddressImpl.java
@@ -81,7 +81,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static final java.net.AddressCache addressCache;
static {
diff --git a/ojluni/annotations/hiddenapi/java/net/InetAddress.java b/ojluni/annotations/hiddenapi/java/net/InetAddress.java
index e1a1deb..2be05b7 100644
--- a/ojluni/annotations/hiddenapi/java/net/InetAddress.java
+++ b/ojluni/annotations/hiddenapi/java/net/InetAddress.java
@@ -26,8 +26,8 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class InetAddress implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/net/InetSocketAddress.java b/ojluni/annotations/hiddenapi/java/net/InetSocketAddress.java
index 0a54f95..7522e0e 100644
--- a/ojluni/annotations/hiddenapi/java/net/InetSocketAddress.java
+++ b/ojluni/annotations/hiddenapi/java/net/InetSocketAddress.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class InetSocketAddress extends java.net.SocketAddress {
diff --git a/ojluni/annotations/hiddenapi/java/net/InterfaceAddress.java b/ojluni/annotations/hiddenapi/java/net/InterfaceAddress.java
index 7287847..84d3537 100644
--- a/ojluni/annotations/hiddenapi/java/net/InterfaceAddress.java
+++ b/ojluni/annotations/hiddenapi/java/net/InterfaceAddress.java
@@ -25,7 +25,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class InterfaceAddress {
diff --git a/ojluni/annotations/hiddenapi/java/net/PlainSocketImpl.java b/ojluni/annotations/hiddenapi/java/net/PlainSocketImpl.java
index 806a428..4d7b6be 100644
--- a/ojluni/annotations/hiddenapi/java/net/PlainSocketImpl.java
+++ b/ojluni/annotations/hiddenapi/java/net/PlainSocketImpl.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
class PlainSocketImpl extends java.net.AbstractPlainSocketImpl {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
PlainSocketImpl() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/java/net/Proxy.java b/ojluni/annotations/hiddenapi/java/net/Proxy.java
index 4df3fa4..ff91f35 100644
--- a/ojluni/annotations/hiddenapi/java/net/Proxy.java
+++ b/ojluni/annotations/hiddenapi/java/net/Proxy.java
@@ -25,7 +25,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Proxy {
diff --git a/ojluni/annotations/hiddenapi/java/net/ServerSocket.java b/ojluni/annotations/hiddenapi/java/net/ServerSocket.java
index eabb247..ad0788a 100644
--- a/ojluni/annotations/hiddenapi/java/net/ServerSocket.java
+++ b/ojluni/annotations/hiddenapi/java/net/ServerSocket.java
@@ -25,7 +25,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ServerSocket implements java.io.Closeable {
diff --git a/ojluni/annotations/hiddenapi/java/net/Socket.java b/ojluni/annotations/hiddenapi/java/net/Socket.java
index 2ad18ff..495d134 100644
--- a/ojluni/annotations/hiddenapi/java/net/Socket.java
+++ b/ojluni/annotations/hiddenapi/java/net/Socket.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Socket implements java.io.Closeable {
diff --git a/ojluni/annotations/hiddenapi/java/net/SocketException.java b/ojluni/annotations/hiddenapi/java/net/SocketException.java
index 03e48e9..3775798 100644
--- a/ojluni/annotations/hiddenapi/java/net/SocketException.java
+++ b/ojluni/annotations/hiddenapi/java/net/SocketException.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class SocketException extends java.io.IOException {
diff --git a/ojluni/annotations/hiddenapi/java/net/SocketImpl.java b/ojluni/annotations/hiddenapi/java/net/SocketImpl.java
index be5c4f8..9b9461a 100644
--- a/ojluni/annotations/hiddenapi/java/net/SocketImpl.java
+++ b/ojluni/annotations/hiddenapi/java/net/SocketImpl.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class SocketImpl implements java.net.SocketOptions {
diff --git a/ojluni/annotations/hiddenapi/java/net/SocksSocketImpl.java b/ojluni/annotations/hiddenapi/java/net/SocksSocketImpl.java
index 6e0f66c..001d441 100644
--- a/ojluni/annotations/hiddenapi/java/net/SocksSocketImpl.java
+++ b/ojluni/annotations/hiddenapi/java/net/SocksSocketImpl.java
@@ -25,7 +25,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
class SocksSocketImpl extends java.net.PlainSocketImpl implements java.net.SocksConsts {
diff --git a/ojluni/annotations/hiddenapi/java/net/URI.java b/ojluni/annotations/hiddenapi/java/net/URI.java
index 2287ab8..ec7e242 100644
--- a/ojluni/annotations/hiddenapi/java/net/URI.java
+++ b/ojluni/annotations/hiddenapi/java/net/URI.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class URI implements java.lang.Comparable<java.net.URI>, java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/net/URL.java b/ojluni/annotations/hiddenapi/java/net/URL.java
index 905413c..9ba6358 100644
--- a/ojluni/annotations/hiddenapi/java/net/URL.java
+++ b/ojluni/annotations/hiddenapi/java/net/URL.java
@@ -26,7 +26,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class URL implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/net/URLClassLoader.java b/ojluni/annotations/hiddenapi/java/net/URLClassLoader.java
index 105b0c7..c9a040d 100644
--- a/ojluni/annotations/hiddenapi/java/net/URLClassLoader.java
+++ b/ojluni/annotations/hiddenapi/java/net/URLClassLoader.java
@@ -25,7 +25,7 @@
package java.net;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class URLClassLoader extends java.security.SecureClassLoader implements java.io.Closeable {
diff --git a/ojluni/annotations/hiddenapi/java/nio/Buffer.java b/ojluni/annotations/hiddenapi/java/nio/Buffer.java
index cbcd8c1..fa8b31b 100644
--- a/ojluni/annotations/hiddenapi/java/nio/Buffer.java
+++ b/ojluni/annotations/hiddenapi/java/nio/Buffer.java
@@ -26,7 +26,7 @@
package java.nio;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Buffer {
diff --git a/ojluni/annotations/hiddenapi/java/nio/ByteBuffer.java b/ojluni/annotations/hiddenapi/java/nio/ByteBuffer.java
index 65b6d58..32f53a4 100644
--- a/ojluni/annotations/hiddenapi/java/nio/ByteBuffer.java
+++ b/ojluni/annotations/hiddenapi/java/nio/ByteBuffer.java
@@ -28,7 +28,7 @@
package java.nio;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class ByteBuffer extends java.nio.Buffer
diff --git a/ojluni/annotations/hiddenapi/java/nio/CharBuffer.java b/ojluni/annotations/hiddenapi/java/nio/CharBuffer.java
index 891e8c3..b447bb6 100644
--- a/ojluni/annotations/hiddenapi/java/nio/CharBuffer.java
+++ b/ojluni/annotations/hiddenapi/java/nio/CharBuffer.java
@@ -28,7 +28,7 @@
package java.nio;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class CharBuffer extends java.nio.Buffer
diff --git a/ojluni/annotations/hiddenapi/java/nio/DirectByteBuffer.java b/ojluni/annotations/hiddenapi/java/nio/DirectByteBuffer.java
index 1d5e04f..b6ca5fb 100644
--- a/ojluni/annotations/hiddenapi/java/nio/DirectByteBuffer.java
+++ b/ojluni/annotations/hiddenapi/java/nio/DirectByteBuffer.java
@@ -26,7 +26,7 @@
package java.nio;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class DirectByteBuffer extends java.nio.MappedByteBuffer implements sun.nio.ch.DirectBuffer {
diff --git a/ojluni/annotations/hiddenapi/java/nio/charset/Charset.java b/ojluni/annotations/hiddenapi/java/nio/charset/Charset.java
index daaa265..fb86662 100644
--- a/ojluni/annotations/hiddenapi/java/nio/charset/Charset.java
+++ b/ojluni/annotations/hiddenapi/java/nio/charset/Charset.java
@@ -26,7 +26,7 @@
package java.nio.charset;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Charset implements java.lang.Comparable<java.nio.charset.Charset> {
diff --git a/ojluni/annotations/hiddenapi/java/nio/charset/CharsetEncoder.java b/ojluni/annotations/hiddenapi/java/nio/charset/CharsetEncoder.java
index f053cae..0e0fd2d 100644
--- a/ojluni/annotations/hiddenapi/java/nio/charset/CharsetEncoder.java
+++ b/ojluni/annotations/hiddenapi/java/nio/charset/CharsetEncoder.java
@@ -28,7 +28,7 @@
package java.nio.charset;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class CharsetEncoder {
diff --git a/ojluni/annotations/hiddenapi/java/nio/file/FileTreeWalker.java b/ojluni/annotations/hiddenapi/java/nio/file/FileTreeWalker.java
index d3e6a42..0f9ae1e 100644
--- a/ojluni/annotations/hiddenapi/java/nio/file/FileTreeWalker.java
+++ b/ojluni/annotations/hiddenapi/java/nio/file/FileTreeWalker.java
@@ -72,20 +72,20 @@
private boolean closed;
- @dalvik.annotation.compat.UnsupportedAppUsage private final boolean followLinks;
+ @android.compat.annotation.UnsupportedAppUsage private final boolean followLinks;
{
followLinks = false;
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private final java.nio.file.LinkOption[] linkOptions;
{
linkOptions = new java.nio.file.LinkOption[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage private final int maxDepth;
+ @android.compat.annotation.UnsupportedAppUsage private final int maxDepth;
{
maxDepth = 0;
diff --git a/ojluni/annotations/hiddenapi/java/security/KeyPairGenerator.java b/ojluni/annotations/hiddenapi/java/security/KeyPairGenerator.java
index 2dba7cd..e5ceb2a 100644
--- a/ojluni/annotations/hiddenapi/java/security/KeyPairGenerator.java
+++ b/ojluni/annotations/hiddenapi/java/security/KeyPairGenerator.java
@@ -25,7 +25,7 @@
package java.security;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class KeyPairGenerator extends java.security.KeyPairGeneratorSpi {
diff --git a/ojluni/annotations/hiddenapi/java/security/KeyStore.java b/ojluni/annotations/hiddenapi/java/security/KeyStore.java
index ae64169..6bf29a1 100644
--- a/ojluni/annotations/hiddenapi/java/security/KeyStore.java
+++ b/ojluni/annotations/hiddenapi/java/security/KeyStore.java
@@ -25,7 +25,7 @@
package java.security;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class KeyStore {
diff --git a/ojluni/annotations/hiddenapi/java/security/Signature.java b/ojluni/annotations/hiddenapi/java/security/Signature.java
index a249f65..f9d4ab7 100644
--- a/ojluni/annotations/hiddenapi/java/security/Signature.java
+++ b/ojluni/annotations/hiddenapi/java/security/Signature.java
@@ -26,7 +26,7 @@
package java.security;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Signature extends java.security.SignatureSpi {
diff --git a/ojluni/annotations/hiddenapi/java/security/spec/ECParameterSpec.java b/ojluni/annotations/hiddenapi/java/security/spec/ECParameterSpec.java
index db13a4b8..3166787 100644
--- a/ojluni/annotations/hiddenapi/java/security/spec/ECParameterSpec.java
+++ b/ojluni/annotations/hiddenapi/java/security/spec/ECParameterSpec.java
@@ -26,7 +26,7 @@
package java.security.spec;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ECParameterSpec implements java.security.spec.AlgorithmParameterSpec {
diff --git a/ojluni/annotations/hiddenapi/java/text/Collator.java b/ojluni/annotations/hiddenapi/java/text/Collator.java
index 82aa868..befb9b9 100644
--- a/ojluni/annotations/hiddenapi/java/text/Collator.java
+++ b/ojluni/annotations/hiddenapi/java/text/Collator.java
@@ -39,7 +39,7 @@
package java.text;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Collator
diff --git a/ojluni/annotations/hiddenapi/java/text/DateFormat.java b/ojluni/annotations/hiddenapi/java/text/DateFormat.java
index 7a1973f..2b8ed78 100644
--- a/ojluni/annotations/hiddenapi/java/text/DateFormat.java
+++ b/ojluni/annotations/hiddenapi/java/text/DateFormat.java
@@ -39,7 +39,7 @@
package java.text;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class DateFormat extends java.text.Format {
diff --git a/ojluni/annotations/hiddenapi/java/text/DecimalFormatSymbols.java b/ojluni/annotations/hiddenapi/java/text/DecimalFormatSymbols.java
index 52395a9..1b0a68c 100644
--- a/ojluni/annotations/hiddenapi/java/text/DecimalFormatSymbols.java
+++ b/ojluni/annotations/hiddenapi/java/text/DecimalFormatSymbols.java
@@ -39,7 +39,7 @@
package java.text;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class DecimalFormatSymbols implements java.lang.Cloneable, java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/text/NumberFormat.java b/ojluni/annotations/hiddenapi/java/text/NumberFormat.java
index a570716..232c94f 100644
--- a/ojluni/annotations/hiddenapi/java/text/NumberFormat.java
+++ b/ojluni/annotations/hiddenapi/java/text/NumberFormat.java
@@ -39,7 +39,7 @@
package java.text;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class NumberFormat extends java.text.Format {
diff --git a/ojluni/annotations/hiddenapi/java/time/Duration.java b/ojluni/annotations/hiddenapi/java/time/Duration.java
index 3090adb..ca99832 100644
--- a/ojluni/annotations/hiddenapi/java/time/Duration.java
+++ b/ojluni/annotations/hiddenapi/java/time/Duration.java
@@ -62,7 +62,7 @@
package java.time;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Duration
diff --git a/ojluni/annotations/hiddenapi/java/time/OffsetDateTime.java b/ojluni/annotations/hiddenapi/java/time/OffsetDateTime.java
index f95f12f..d4822c4 100644
--- a/ojluni/annotations/hiddenapi/java/time/OffsetDateTime.java
+++ b/ojluni/annotations/hiddenapi/java/time/OffsetDateTime.java
@@ -62,7 +62,7 @@
package java.time;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class OffsetDateTime
diff --git a/ojluni/annotations/hiddenapi/java/time/ZoneId.java b/ojluni/annotations/hiddenapi/java/time/ZoneId.java
index f3ae76a..ef4a7aa 100644
--- a/ojluni/annotations/hiddenapi/java/time/ZoneId.java
+++ b/ojluni/annotations/hiddenapi/java/time/ZoneId.java
@@ -62,7 +62,7 @@
package java.time;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class ZoneId implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/util/ArrayDeque.java b/ojluni/annotations/hiddenapi/java/util/ArrayDeque.java
index 59315d8..65c684a 100644
--- a/ojluni/annotations/hiddenapi/java/util/ArrayDeque.java
+++ b/ojluni/annotations/hiddenapi/java/util/ArrayDeque.java
@@ -34,7 +34,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ArrayDeque<E> extends java.util.AbstractCollection<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/ArrayList.java b/ojluni/annotations/hiddenapi/java/util/ArrayList.java
index 1131ab9..3d90fa5 100644
--- a/ojluni/annotations/hiddenapi/java/util/ArrayList.java
+++ b/ojluni/annotations/hiddenapi/java/util/ArrayList.java
@@ -26,7 +26,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ArrayList<E> extends java.util.AbstractList<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/Arrays.java b/ojluni/annotations/hiddenapi/java/util/Arrays.java
index c763a2d..040c8b0 100644
--- a/ojluni/annotations/hiddenapi/java/util/Arrays.java
+++ b/ojluni/annotations/hiddenapi/java/util/Arrays.java
@@ -26,7 +26,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Arrays {
diff --git a/ojluni/annotations/hiddenapi/java/util/Calendar.java b/ojluni/annotations/hiddenapi/java/util/Calendar.java
index 99a76f7..274f801 100644
--- a/ojluni/annotations/hiddenapi/java/util/Calendar.java
+++ b/ojluni/annotations/hiddenapi/java/util/Calendar.java
@@ -39,7 +39,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Calendar
diff --git a/ojluni/annotations/hiddenapi/java/util/Collections.java b/ojluni/annotations/hiddenapi/java/util/Collections.java
index 010ba3d..d7445f0 100644
--- a/ojluni/annotations/hiddenapi/java/util/Collections.java
+++ b/ojluni/annotations/hiddenapi/java/util/Collections.java
@@ -26,7 +26,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Collections {
diff --git a/ojluni/annotations/hiddenapi/java/util/EnumMap.java b/ojluni/annotations/hiddenapi/java/util/EnumMap.java
index 81cd885..5b0c31f 100644
--- a/ojluni/annotations/hiddenapi/java/util/EnumMap.java
+++ b/ojluni/annotations/hiddenapi/java/util/EnumMap.java
@@ -26,7 +26,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class EnumMap<K extends java.lang.Enum<K>, V> extends java.util.AbstractMap<K, V>
diff --git a/ojluni/annotations/hiddenapi/java/util/EnumSet.java b/ojluni/annotations/hiddenapi/java/util/EnumSet.java
index f8edb19..6c920b0 100644
--- a/ojluni/annotations/hiddenapi/java/util/EnumSet.java
+++ b/ojluni/annotations/hiddenapi/java/util/EnumSet.java
@@ -26,7 +26,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class EnumSet<E extends java.lang.Enum<E>> extends java.util.AbstractSet<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/HashMap.java b/ojluni/annotations/hiddenapi/java/util/HashMap.java
index af1c342..b13c25c 100644
--- a/ojluni/annotations/hiddenapi/java/util/HashMap.java
+++ b/ojluni/annotations/hiddenapi/java/util/HashMap.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class HashMap<K, V> extends java.util.AbstractMap<K, V>
diff --git a/ojluni/annotations/hiddenapi/java/util/HashSet.java b/ojluni/annotations/hiddenapi/java/util/HashSet.java
index a006121..896c1aa 100644
--- a/ojluni/annotations/hiddenapi/java/util/HashSet.java
+++ b/ojluni/annotations/hiddenapi/java/util/HashSet.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class HashSet<E> extends java.util.AbstractSet<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/LinkedHashMap.java b/ojluni/annotations/hiddenapi/java/util/LinkedHashMap.java
index 8294334..99d649b 100644
--- a/ojluni/annotations/hiddenapi/java/util/LinkedHashMap.java
+++ b/ojluni/annotations/hiddenapi/java/util/LinkedHashMap.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class LinkedHashMap<K, V> extends java.util.HashMap<K, V> implements java.util.Map<K, V> {
diff --git a/ojluni/annotations/hiddenapi/java/util/LinkedList.java b/ojluni/annotations/hiddenapi/java/util/LinkedList.java
index c7eb048..58cbb5f 100644
--- a/ojluni/annotations/hiddenapi/java/util/LinkedList.java
+++ b/ojluni/annotations/hiddenapi/java/util/LinkedList.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class LinkedList<E> extends java.util.AbstractSequentialList<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/Locale.java b/ojluni/annotations/hiddenapi/java/util/Locale.java
index 3f6a54f..73d2dfa 100644
--- a/ojluni/annotations/hiddenapi/java/util/Locale.java
+++ b/ojluni/annotations/hiddenapi/java/util/Locale.java
@@ -41,7 +41,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Locale implements java.lang.Cloneable, java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/util/PriorityQueue.java b/ojluni/annotations/hiddenapi/java/util/PriorityQueue.java
index b8d2a18..09c9d86 100644
--- a/ojluni/annotations/hiddenapi/java/util/PriorityQueue.java
+++ b/ojluni/annotations/hiddenapi/java/util/PriorityQueue.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class PriorityQueue<E> extends java.util.AbstractQueue<E> implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/util/Properties.java b/ojluni/annotations/hiddenapi/java/util/Properties.java
index 3aee2d1..397fa75 100644
--- a/ojluni/annotations/hiddenapi/java/util/Properties.java
+++ b/ojluni/annotations/hiddenapi/java/util/Properties.java
@@ -26,7 +26,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Properties extends java.util.Hashtable<java.lang.Object, java.lang.Object> {
diff --git a/ojluni/annotations/hiddenapi/java/util/Random.java b/ojluni/annotations/hiddenapi/java/util/Random.java
index ce80aa1..930688a 100644
--- a/ojluni/annotations/hiddenapi/java/util/Random.java
+++ b/ojluni/annotations/hiddenapi/java/util/Random.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Random implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/util/TimerTask.java b/ojluni/annotations/hiddenapi/java/util/TimerTask.java
index 8a5c6d5..65c845c 100644
--- a/ojluni/annotations/hiddenapi/java/util/TimerTask.java
+++ b/ojluni/annotations/hiddenapi/java/util/TimerTask.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class TimerTask implements java.lang.Runnable {
diff --git a/ojluni/annotations/hiddenapi/java/util/UUID.java b/ojluni/annotations/hiddenapi/java/util/UUID.java
index 0585e5de..353f2b6 100644
--- a/ojluni/annotations/hiddenapi/java/util/UUID.java
+++ b/ojluni/annotations/hiddenapi/java/util/UUID.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class UUID implements java.io.Serializable, java.lang.Comparable<java.util.UUID> {
diff --git a/ojluni/annotations/hiddenapi/java/util/Vector.java b/ojluni/annotations/hiddenapi/java/util/Vector.java
index 394a097..91a6aa7 100644
--- a/ojluni/annotations/hiddenapi/java/util/Vector.java
+++ b/ojluni/annotations/hiddenapi/java/util/Vector.java
@@ -25,7 +25,7 @@
package java.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Vector<E> extends java.util.AbstractList<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArrayList.java b/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArrayList.java
index 7d526a7..5a19180 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArrayList.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArrayList.java
@@ -34,7 +34,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CopyOnWriteArrayList<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArraySet.java b/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArraySet.java
index 98c53b0..2450ff4 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArraySet.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/CopyOnWriteArraySet.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CopyOnWriteArraySet<E> extends java.util.AbstractSet<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/Executors.java b/ojluni/annotations/hiddenapi/java/util/concurrent/Executors.java
index 1fbd62c..cd64ac8 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/Executors.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/Executors.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Executors {
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/FutureTask.java b/ojluni/annotations/hiddenapi/java/util/concurrent/FutureTask.java
index 2274611..24746d4 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/FutureTask.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/FutureTask.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class FutureTask<V> implements java.util.concurrent.RunnableFuture<V> {
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingDeque.java b/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingDeque.java
index de84037..391ba63 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingDeque.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingDeque.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class LinkedBlockingDeque<E> extends java.util.AbstractQueue<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingQueue.java b/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingQueue.java
index f7aec5c..683a8f1 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingQueue.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/LinkedBlockingQueue.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class LinkedBlockingQueue<E> extends java.util.AbstractQueue<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/PriorityBlockingQueue.java b/ojluni/annotations/hiddenapi/java/util/concurrent/PriorityBlockingQueue.java
index 0577e8c..35bc3c0 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/PriorityBlockingQueue.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/PriorityBlockingQueue.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class PriorityBlockingQueue<E> extends java.util.AbstractQueue<E>
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/ThreadPoolExecutor.java b/ojluni/annotations/hiddenapi/java/util/concurrent/ThreadPoolExecutor.java
index e89f678..0d27711 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/ThreadPoolExecutor.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/ThreadPoolExecutor.java
@@ -35,7 +35,7 @@
package java.util.concurrent;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ThreadPoolExecutor extends java.util.concurrent.AbstractExecutorService {
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/atomic/AtomicInteger.java b/ojluni/annotations/hiddenapi/java/util/concurrent/atomic/AtomicInteger.java
index a5718ac..ed7ef76 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/atomic/AtomicInteger.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/atomic/AtomicInteger.java
@@ -35,7 +35,7 @@
package java.util.concurrent.atomic;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class AtomicInteger extends java.lang.Number implements java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/util/concurrent/locks/ReentrantLock.java b/ojluni/annotations/hiddenapi/java/util/concurrent/locks/ReentrantLock.java
index 1ad6e8d..8921208 100644
--- a/ojluni/annotations/hiddenapi/java/util/concurrent/locks/ReentrantLock.java
+++ b/ojluni/annotations/hiddenapi/java/util/concurrent/locks/ReentrantLock.java
@@ -35,7 +35,7 @@
package java.util.concurrent.locks;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ReentrantLock implements java.util.concurrent.locks.Lock, java.io.Serializable {
diff --git a/ojluni/annotations/hiddenapi/java/util/jar/JarFile.java b/ojluni/annotations/hiddenapi/java/util/jar/JarFile.java
index 1c97964..3c7d7bb 100644
--- a/ojluni/annotations/hiddenapi/java/util/jar/JarFile.java
+++ b/ojluni/annotations/hiddenapi/java/util/jar/JarFile.java
@@ -26,7 +26,7 @@
package java.util.jar;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class JarFile extends java.util.zip.ZipFile {
diff --git a/ojluni/annotations/hiddenapi/java/util/logging/Handler.java b/ojluni/annotations/hiddenapi/java/util/logging/Handler.java
index 2d04f15..7243f48 100644
--- a/ojluni/annotations/hiddenapi/java/util/logging/Handler.java
+++ b/ojluni/annotations/hiddenapi/java/util/logging/Handler.java
@@ -25,7 +25,7 @@
package java.util.logging;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Handler {
diff --git a/ojluni/annotations/hiddenapi/java/util/logging/LogManager.java b/ojluni/annotations/hiddenapi/java/util/logging/LogManager.java
index a140100..8900a5a 100644
--- a/ojluni/annotations/hiddenapi/java/util/logging/LogManager.java
+++ b/ojluni/annotations/hiddenapi/java/util/logging/LogManager.java
@@ -26,7 +26,7 @@
package java.util.logging;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class LogManager {
diff --git a/ojluni/annotations/hiddenapi/java/util/logging/Logger.java b/ojluni/annotations/hiddenapi/java/util/logging/Logger.java
index f504c96..1c14d54 100644
--- a/ojluni/annotations/hiddenapi/java/util/logging/Logger.java
+++ b/ojluni/annotations/hiddenapi/java/util/logging/Logger.java
@@ -25,7 +25,7 @@
package java.util.logging;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Logger {
diff --git a/ojluni/annotations/hiddenapi/java/util/regex/Matcher.java b/ojluni/annotations/hiddenapi/java/util/regex/Matcher.java
index 18d6d95..686f1bd 100644
--- a/ojluni/annotations/hiddenapi/java/util/regex/Matcher.java
+++ b/ojluni/annotations/hiddenapi/java/util/regex/Matcher.java
@@ -26,7 +26,7 @@
package java.util.regex;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Matcher implements java.util.regex.MatchResult {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/Adler32.java b/ojluni/annotations/hiddenapi/java/util/zip/Adler32.java
index f78844f..e22aec4 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/Adler32.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/Adler32.java
@@ -25,7 +25,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Adler32 implements java.util.zip.Checksum {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/CRC32.java b/ojluni/annotations/hiddenapi/java/util/zip/CRC32.java
index 0e25349..6766fa1 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/CRC32.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/CRC32.java
@@ -25,7 +25,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CRC32 implements java.util.zip.Checksum {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/Deflater.java b/ojluni/annotations/hiddenapi/java/util/zip/Deflater.java
index f8f419d..0dbe2a5 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/Deflater.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/Deflater.java
@@ -25,7 +25,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Deflater {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/Inflater.java b/ojluni/annotations/hiddenapi/java/util/zip/Inflater.java
index c4194d2..e5a5dcc 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/Inflater.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/Inflater.java
@@ -26,7 +26,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Inflater {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/ZipEntry.java b/ojluni/annotations/hiddenapi/java/util/zip/ZipEntry.java
index 87ca0f5..91440c2 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/ZipEntry.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/ZipEntry.java
@@ -26,7 +26,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ZipEntry implements java.util.zip.ZipConstants, java.lang.Cloneable {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/ZipFile.java b/ojluni/annotations/hiddenapi/java/util/zip/ZipFile.java
index 371659a..b2c72a7 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/ZipFile.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/ZipFile.java
@@ -26,7 +26,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ZipFile implements java.util.zip.ZipConstants, java.io.Closeable {
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/ZipInputStream.java b/ojluni/annotations/hiddenapi/java/util/zip/ZipInputStream.java
index 90947b7..18c1b2e 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/ZipInputStream.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/ZipInputStream.java
@@ -26,7 +26,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ZipInputStream extends java.util.zip.InflaterInputStream
diff --git a/ojluni/annotations/hiddenapi/java/util/zip/ZipOutputStream.java b/ojluni/annotations/hiddenapi/java/util/zip/ZipOutputStream.java
index 943fefa..fd4276a 100644
--- a/ojluni/annotations/hiddenapi/java/util/zip/ZipOutputStream.java
+++ b/ojluni/annotations/hiddenapi/java/util/zip/ZipOutputStream.java
@@ -26,7 +26,7 @@
package java.util.zip;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ZipOutputStream extends java.util.zip.DeflaterOutputStream
diff --git a/ojluni/annotations/hiddenapi/javax/net/ssl/SSLServerSocketFactory.java b/ojluni/annotations/hiddenapi/javax/net/ssl/SSLServerSocketFactory.java
index 61c720b..e947a88 100644
--- a/ojluni/annotations/hiddenapi/javax/net/ssl/SSLServerSocketFactory.java
+++ b/ojluni/annotations/hiddenapi/javax/net/ssl/SSLServerSocketFactory.java
@@ -26,8 +26,8 @@
package javax.net.ssl;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class SSLServerSocketFactory extends javax.net.ServerSocketFactory {
diff --git a/ojluni/annotations/hiddenapi/javax/net/ssl/SSLSocketFactory.java b/ojluni/annotations/hiddenapi/javax/net/ssl/SSLSocketFactory.java
index 70a11bd..b945122 100644
--- a/ojluni/annotations/hiddenapi/javax/net/ssl/SSLSocketFactory.java
+++ b/ojluni/annotations/hiddenapi/javax/net/ssl/SSLSocketFactory.java
@@ -26,8 +26,8 @@
package javax.net.ssl;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class SSLSocketFactory extends javax.net.SocketFactory {
diff --git a/ojluni/annotations/hiddenapi/sun/misc/ASCIICaseInsensitiveComparator.java b/ojluni/annotations/hiddenapi/sun/misc/ASCIICaseInsensitiveComparator.java
index b632c1e..2df53e2 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/ASCIICaseInsensitiveComparator.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/ASCIICaseInsensitiveComparator.java
@@ -36,7 +36,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static int lowerCaseHashCode(java.lang.String s) {
throw new RuntimeException("Stub!");
}
@@ -57,7 +57,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final java.util.Comparator<java.lang.String> CASE_INSENSITIVE_ORDER;
static {
diff --git a/ojluni/annotations/hiddenapi/sun/misc/BASE64Decoder.java b/ojluni/annotations/hiddenapi/sun/misc/BASE64Decoder.java
index 2ce6dc8..65b4682 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/BASE64Decoder.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/BASE64Decoder.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class BASE64Decoder extends sun.misc.CharacterDecoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public BASE64Decoder() {
throw new RuntimeException("Stub!");
}
@@ -55,7 +55,7 @@
pem_array = new char[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage private static final byte[] pem_convert_array;
+ @android.compat.annotation.UnsupportedAppUsage private static final byte[] pem_convert_array;
static {
pem_convert_array = new byte[0];
diff --git a/ojluni/annotations/hiddenapi/sun/misc/BASE64Encoder.java b/ojluni/annotations/hiddenapi/sun/misc/BASE64Encoder.java
index 8a9ef70..146b543 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/BASE64Encoder.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/BASE64Encoder.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class BASE64Encoder extends sun.misc.CharacterEncoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public BASE64Encoder() {
throw new RuntimeException("Stub!");
}
@@ -46,7 +46,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private static final char[] pem_array;
+ @android.compat.annotation.UnsupportedAppUsage private static final char[] pem_array;
static {
pem_array = new char[0];
diff --git a/ojluni/annotations/hiddenapi/sun/misc/CEFormatException.java b/ojluni/annotations/hiddenapi/sun/misc/CEFormatException.java
index d351479..d52e699 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/CEFormatException.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/CEFormatException.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CEFormatException extends java.io.IOException {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CEFormatException(java.lang.String s) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/CEStreamExhausted.java b/ojluni/annotations/hiddenapi/sun/misc/CEStreamExhausted.java
index e696c67..e78d20e 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/CEStreamExhausted.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/CEStreamExhausted.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CEStreamExhausted extends java.io.IOException {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CEStreamExhausted() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/CharacterDecoder.java b/ojluni/annotations/hiddenapi/sun/misc/CharacterDecoder.java
index de6f942..1b769fa 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/CharacterDecoder.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/CharacterDecoder.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class CharacterDecoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CharacterDecoder() {
throw new RuntimeException("Stub!");
}
@@ -78,7 +78,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] decodeBuffer(java.lang.String inputString) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/CharacterEncoder.java b/ojluni/annotations/hiddenapi/sun/misc/CharacterEncoder.java
index bbbf3f7..b254846 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/CharacterEncoder.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/CharacterEncoder.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class CharacterEncoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CharacterEncoder() {
throw new RuntimeException("Stub!");
}
@@ -38,7 +38,7 @@
protected abstract int bytesPerLine();
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
protected void encodeBufferPrefix(java.io.OutputStream aStream) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -73,7 +73,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String encode(byte[] aBuffer) {
throw new RuntimeException("Stub!");
}
@@ -101,7 +101,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String encodeBuffer(byte[] aBuffer) {
throw new RuntimeException("Stub!");
}
@@ -115,6 +115,6 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
protected java.io.PrintStream pStream;
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/Cleaner.java b/ojluni/annotations/hiddenapi/sun/misc/Cleaner.java
index eb21393..cdbc658 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/Cleaner.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/Cleaner.java
@@ -25,7 +25,7 @@
package sun.misc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Cleaner extends java.lang.ref.PhantomReference<java.lang.Object> {
diff --git a/ojluni/annotations/hiddenapi/sun/misc/FloatingDecimal.java b/ojluni/annotations/hiddenapi/sun/misc/FloatingDecimal.java
index 0c210ac..fd8c668 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/FloatingDecimal.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/FloatingDecimal.java
@@ -86,17 +86,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
static java.lang.String stripLeadingZeros(java.lang.String s) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
static int getHexDigit(java.lang.String s, int position) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private static boolean $assertionsDisabled;
+ @android.compat.annotation.UnsupportedAppUsage private static boolean $assertionsDisabled;
static final sun.misc.FloatingDecimal.ASCIIToBinaryConverter A2BC_NEGATIVE_INFINITY;
diff --git a/ojluni/annotations/hiddenapi/sun/misc/FormattedFloatingDecimal.java b/ojluni/annotations/hiddenapi/sun/misc/FormattedFloatingDecimal.java
index b6766cf..a752931 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/FormattedFloatingDecimal.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/FormattedFloatingDecimal.java
@@ -79,7 +79,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private static boolean $assertionsDisabled;
+ @android.compat.annotation.UnsupportedAppUsage private static boolean $assertionsDisabled;
private int decExponentRounded;
@@ -95,11 +95,11 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public static enum Form {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
SCIENTIFIC,
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
COMPATIBLE,
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
DECIMAL_FLOAT,
GENERAL;
diff --git a/ojluni/annotations/hiddenapi/sun/misc/FpUtils.java b/ojluni/annotations/hiddenapi/sun/misc/FpUtils.java
index 38347bd..16bb5b0 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/FpUtils.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/FpUtils.java
@@ -43,7 +43,7 @@
}
@Deprecated
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static double rawCopySign(double magnitude, double sign) {
throw new RuntimeException("Stub!");
}
@@ -165,5 +165,5 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private static boolean $assertionsDisabled;
+ @android.compat.annotation.UnsupportedAppUsage private static boolean $assertionsDisabled;
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/HexDumpEncoder.java b/ojluni/annotations/hiddenapi/sun/misc/HexDumpEncoder.java
index f278c74..c92af9a 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/HexDumpEncoder.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/HexDumpEncoder.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class HexDumpEncoder extends sun.misc.CharacterEncoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public HexDumpEncoder() {
throw new RuntimeException("Stub!");
}
@@ -62,11 +62,11 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private int currentByte;
+ @android.compat.annotation.UnsupportedAppUsage private int currentByte;
- @dalvik.annotation.compat.UnsupportedAppUsage private int offset;
+ @android.compat.annotation.UnsupportedAppUsage private int offset;
- @dalvik.annotation.compat.UnsupportedAppUsage private byte[] thisLine;
+ @android.compat.annotation.UnsupportedAppUsage private byte[] thisLine;
- @dalvik.annotation.compat.UnsupportedAppUsage private int thisLineLength;
+ @android.compat.annotation.UnsupportedAppUsage private int thisLineLength;
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/IOUtils.java b/ojluni/annotations/hiddenapi/sun/misc/IOUtils.java
index 90f7909..251261b 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/IOUtils.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/IOUtils.java
@@ -34,7 +34,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static byte[] readFully(java.io.InputStream is, int length, boolean readAll)
throws java.io.IOException {
throw new RuntimeException("Stub!");
diff --git a/ojluni/annotations/hiddenapi/sun/misc/JarIndex.java b/ojluni/annotations/hiddenapi/sun/misc/JarIndex.java
index 06187e1..a93d1de 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/JarIndex.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/JarIndex.java
@@ -41,7 +41,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public JarIndex(java.lang.String[] files) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -83,7 +83,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void write(java.io.OutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/MessageUtils.java b/ojluni/annotations/hiddenapi/sun/misc/MessageUtils.java
index bd61419..9fe08e4 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/MessageUtils.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/MessageUtils.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class MessageUtils {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public MessageUtils() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/MetaIndex.java b/ojluni/annotations/hiddenapi/sun/misc/MetaIndex.java
index b3ae0cc..4c38d41 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/MetaIndex.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/MetaIndex.java
@@ -33,12 +33,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.misc.MetaIndex forJar(java.io.File jar) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static synchronized void registerDirectory(java.io.File dir) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/misc/URLClassPath.java b/ojluni/annotations/hiddenapi/sun/misc/URLClassPath.java
index 7ca8bd9..561a21c 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/URLClassPath.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/URLClassPath.java
@@ -26,7 +26,7 @@
package sun.misc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class URLClassPath {
diff --git a/ojluni/annotations/hiddenapi/sun/misc/Unsafe.java b/ojluni/annotations/hiddenapi/sun/misc/Unsafe.java
index 54308e4..c6dad00 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/Unsafe.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/Unsafe.java
@@ -25,8 +25,9 @@
package sun.misc;
-import dalvik.annotation.compat.UnsupportedAppUsage;
-import dalvik.system.VersionCodes;
+import android.compat.annotation.UnsupportedAppUsage;
+
+import dalvik.annotation.compat.VersionCodes;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Unsafe {
diff --git a/ojluni/annotations/hiddenapi/sun/misc/VM.java b/ojluni/annotations/hiddenapi/sun/misc/VM.java
index 979818c..a043c57 100644
--- a/ojluni/annotations/hiddenapi/sun/misc/VM.java
+++ b/ojluni/annotations/hiddenapi/sun/misc/VM.java
@@ -83,7 +83,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static long maxDirectMemory() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/net/ftp/FtpClient.java b/ojluni/annotations/hiddenapi/sun/net/ftp/FtpClient.java
index c60accd..0a54520 100644
--- a/ojluni/annotations/hiddenapi/sun/net/ftp/FtpClient.java
+++ b/ojluni/annotations/hiddenapi/sun/net/ftp/FtpClient.java
@@ -31,7 +31,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class FtpClient implements java.io.Closeable {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
protected FtpClient() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/net/util/IPAddressUtil.java b/ojluni/annotations/hiddenapi/sun/net/util/IPAddressUtil.java
index 710e3a8..0134b09 100644
--- a/ojluni/annotations/hiddenapi/sun/net/util/IPAddressUtil.java
+++ b/ojluni/annotations/hiddenapi/sun/net/util/IPAddressUtil.java
@@ -40,12 +40,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static boolean isIPv4LiteralAddress(java.lang.String src) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static boolean isIPv6LiteralAddress(java.lang.String src) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/net/www/MessageHeader.java b/ojluni/annotations/hiddenapi/sun/net/www/MessageHeader.java
index c63d115..4afd134 100644
--- a/ojluni/annotations/hiddenapi/sun/net/www/MessageHeader.java
+++ b/ojluni/annotations/hiddenapi/sun/net/www/MessageHeader.java
@@ -35,12 +35,12 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class MessageHeader {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public MessageHeader() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public MessageHeader(java.io.InputStream is) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -53,7 +53,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public synchronized java.lang.String findValue(java.lang.String k) {
throw new RuntimeException("Stub!");
}
@@ -99,17 +99,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public synchronized void print(java.io.PrintStream p) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public synchronized void add(java.lang.String k, java.lang.String v) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public synchronized void prepend(java.lang.String k, java.lang.String v) {
throw new RuntimeException("Stub!");
}
@@ -126,7 +126,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public synchronized void set(java.lang.String k, java.lang.String v) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/net/www/ParseUtil.java b/ojluni/annotations/hiddenapi/sun/net/www/ParseUtil.java
index d439a1f..3acc9ee 100644
--- a/ojluni/annotations/hiddenapi/sun/net/www/ParseUtil.java
+++ b/ojluni/annotations/hiddenapi/sun/net/www/ParseUtil.java
@@ -37,7 +37,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.String encodePath(java.lang.String path, boolean flag) {
throw new RuntimeException("Stub!");
}
@@ -50,7 +50,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.String decode(java.lang.String s) {
throw new RuntimeException("Stub!");
}
@@ -59,7 +59,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.net.URL fileToEncodedURL(java.io.File file)
throws java.net.MalformedURLException {
throw new RuntimeException("Stub!");
diff --git a/ojluni/annotations/hiddenapi/sun/net/www/URLConnection.java b/ojluni/annotations/hiddenapi/sun/net/www/URLConnection.java
index 7669272..12b1d72 100644
--- a/ojluni/annotations/hiddenapi/sun/net/www/URLConnection.java
+++ b/ojluni/annotations/hiddenapi/sun/net/www/URLConnection.java
@@ -25,12 +25,10 @@
package sun.net.www;
-import java.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class URLConnection extends java.net.URLConnection {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public URLConnection(java.net.URL u) {
super(null);
throw new RuntimeException("Stub!");
@@ -40,7 +38,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void setProperties(sun.net.www.MessageHeader properties) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/nio/ch/DirectBuffer.java b/ojluni/annotations/hiddenapi/sun/nio/ch/DirectBuffer.java
index e755c28..87a2447 100644
--- a/ojluni/annotations/hiddenapi/sun/nio/ch/DirectBuffer.java
+++ b/ojluni/annotations/hiddenapi/sun/nio/ch/DirectBuffer.java
@@ -25,7 +25,7 @@
package sun.nio.ch;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public interface DirectBuffer {
diff --git a/ojluni/annotations/hiddenapi/sun/nio/ch/FileChannelImpl.java b/ojluni/annotations/hiddenapi/sun/nio/ch/FileChannelImpl.java
index ca3f145..7ab1dc2 100644
--- a/ojluni/annotations/hiddenapi/sun/nio/ch/FileChannelImpl.java
+++ b/ojluni/annotations/hiddenapi/sun/nio/ch/FileChannelImpl.java
@@ -207,7 +207,7 @@
private native long map0(int prot, long position, long length) throws java.io.IOException;
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static native int unmap0(long address, long length);
private native long transferTo0(
diff --git a/ojluni/annotations/hiddenapi/sun/nio/ch/SelectorImpl.java b/ojluni/annotations/hiddenapi/sun/nio/ch/SelectorImpl.java
index 294cdee..41c9dd3 100644
--- a/ojluni/annotations/hiddenapi/sun/nio/ch/SelectorImpl.java
+++ b/ojluni/annotations/hiddenapi/sun/nio/ch/SelectorImpl.java
@@ -94,9 +94,9 @@
private java.util.Set<java.nio.channels.SelectionKey> publicKeys;
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private java.util.Set<java.nio.channels.SelectionKey> publicSelectedKeys;
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
protected java.util.Set<java.nio.channels.SelectionKey> selectedKeys;
}
diff --git a/ojluni/annotations/hiddenapi/sun/nio/cs/HistoricallyNamedCharset.java b/ojluni/annotations/hiddenapi/sun/nio/cs/HistoricallyNamedCharset.java
index ed066b4..b0c71f4 100644
--- a/ojluni/annotations/hiddenapi/sun/nio/cs/HistoricallyNamedCharset.java
+++ b/ojluni/annotations/hiddenapi/sun/nio/cs/HistoricallyNamedCharset.java
@@ -28,6 +28,6 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public interface HistoricallyNamedCharset {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String historicalName();
}
diff --git a/ojluni/annotations/hiddenapi/sun/nio/cs/ThreadLocalCoders.java b/ojluni/annotations/hiddenapi/sun/nio/cs/ThreadLocalCoders.java
index ef03631..3357f41 100644
--- a/ojluni/annotations/hiddenapi/sun/nio/cs/ThreadLocalCoders.java
+++ b/ojluni/annotations/hiddenapi/sun/nio/cs/ThreadLocalCoders.java
@@ -25,8 +25,6 @@
package sun.nio.cs;
-import java.nio.charset.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ThreadLocalCoders {
@@ -34,7 +32,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.nio.charset.CharsetDecoder decoderFor(java.lang.Object name) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/nio/fs/BasicFileAttributesHolder.java b/ojluni/annotations/hiddenapi/sun/nio/fs/BasicFileAttributesHolder.java
index 78cf143..3d6c0e8 100644
--- a/ojluni/annotations/hiddenapi/sun/nio/fs/BasicFileAttributesHolder.java
+++ b/ojluni/annotations/hiddenapi/sun/nio/fs/BasicFileAttributesHolder.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public interface BasicFileAttributesHolder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.nio.file.attribute.BasicFileAttributes get();
public void invalidate();
diff --git a/ojluni/annotations/hiddenapi/sun/reflect/Reflection.java b/ojluni/annotations/hiddenapi/sun/reflect/Reflection.java
index ab0fb2a..120ecb1 100644
--- a/ojluni/annotations/hiddenapi/sun/reflect/Reflection.java
+++ b/ojluni/annotations/hiddenapi/sun/reflect/Reflection.java
@@ -38,7 +38,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static void ensureMemberAccess(
java.lang.Class<?> currentClass,
java.lang.Class<?> memberClass,
@@ -68,7 +68,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
static boolean isSubclassOf(java.lang.Class<?> queryClass, java.lang.Class<?> ofClass) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/reflect/misc/ReflectUtil.java b/ojluni/annotations/hiddenapi/sun/reflect/misc/ReflectUtil.java
index 3200def..014d613 100644
--- a/ojluni/annotations/hiddenapi/sun/reflect/misc/ReflectUtil.java
+++ b/ojluni/annotations/hiddenapi/sun/reflect/misc/ReflectUtil.java
@@ -53,22 +53,22 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static boolean isSubclassOf(java.lang.Class<?> queryClass, java.lang.Class<?> ofClass) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static void checkPackageAccess(java.lang.Class<?> clazz) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static void checkPackageAccess(java.lang.String name) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static boolean isPackageAccessible(java.lang.Class<?> clazz) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/action/GetBooleanAction.java b/ojluni/annotations/hiddenapi/sun/security/action/GetBooleanAction.java
index 36355d7..a9e37e4 100644
--- a/ojluni/annotations/hiddenapi/sun/security/action/GetBooleanAction.java
+++ b/ojluni/annotations/hiddenapi/sun/security/action/GetBooleanAction.java
@@ -28,7 +28,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class GetBooleanAction implements java.security.PrivilegedAction<java.lang.Boolean> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GetBooleanAction(java.lang.String theProp) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/action/GetIntegerAction.java b/ojluni/annotations/hiddenapi/sun/security/action/GetIntegerAction.java
index a0bc736..223563c 100644
--- a/ojluni/annotations/hiddenapi/sun/security/action/GetIntegerAction.java
+++ b/ojluni/annotations/hiddenapi/sun/security/action/GetIntegerAction.java
@@ -32,7 +32,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GetIntegerAction(java.lang.String theProp, int defaultVal) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/action/GetPropertyAction.java b/ojluni/annotations/hiddenapi/sun/security/action/GetPropertyAction.java
index b83e1cd..ee83f58 100644
--- a/ojluni/annotations/hiddenapi/sun/security/action/GetPropertyAction.java
+++ b/ojluni/annotations/hiddenapi/sun/security/action/GetPropertyAction.java
@@ -28,12 +28,12 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class GetPropertyAction implements java.security.PrivilegedAction<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GetPropertyAction(java.lang.String theProp) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GetPropertyAction(java.lang.String theProp, java.lang.String defaultVal) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/jca/GetInstance.java b/ojluni/annotations/hiddenapi/sun/security/jca/GetInstance.java
index e046dae..92756f9 100644
--- a/ojluni/annotations/hiddenapi/sun/security/jca/GetInstance.java
+++ b/ojluni/annotations/hiddenapi/sun/security/jca/GetInstance.java
@@ -75,7 +75,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.jca.GetInstance.Instance getInstance(
java.lang.String type,
java.lang.Class<?> clazz,
@@ -94,7 +94,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.jca.GetInstance.Instance getInstance(
java.lang.String type,
java.lang.Class<?> clazz,
@@ -114,7 +114,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.jca.GetInstance.Instance getInstance(
java.lang.String type,
java.lang.Class<?> clazz,
@@ -156,13 +156,13 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage public final java.lang.Object impl;
+ @android.compat.annotation.UnsupportedAppUsage public final java.lang.Object impl;
{
impl = null;
}
- @dalvik.annotation.compat.UnsupportedAppUsage public final java.security.Provider provider;
+ @android.compat.annotation.UnsupportedAppUsage public final java.security.Provider provider;
{
provider = null;
diff --git a/ojluni/annotations/hiddenapi/sun/security/jca/JCAUtil.java b/ojluni/annotations/hiddenapi/sun/security/jca/JCAUtil.java
index 26d767f..ca703f2 100644
--- a/ojluni/annotations/hiddenapi/sun/security/jca/JCAUtil.java
+++ b/ojluni/annotations/hiddenapi/sun/security/jca/JCAUtil.java
@@ -39,7 +39,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.security.SecureRandom getSecureRandom() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/jca/ProviderConfig.java b/ojluni/annotations/hiddenapi/sun/security/jca/ProviderConfig.java
index 60ed61e..f6abd8b 100644
--- a/ojluni/annotations/hiddenapi/sun/security/jca/ProviderConfig.java
+++ b/ojluni/annotations/hiddenapi/sun/security/jca/ProviderConfig.java
@@ -47,7 +47,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private boolean hasArgument() {
throw new RuntimeException("Stub!");
}
@@ -56,7 +56,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void disableLoad() {
throw new RuntimeException("Stub!");
}
@@ -94,7 +94,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private static final java.lang.Class[] CL_STRING;
+ @android.compat.annotation.UnsupportedAppUsage private static final java.lang.Class[] CL_STRING;
static {
CL_STRING = new java.lang.Class[0];
@@ -107,7 +107,7 @@
private static final java.lang.String P11_SOL_NAME = "sun.security.pkcs11.SunPKCS11";
- @dalvik.annotation.compat.UnsupportedAppUsage private final java.lang.String argument;
+ @android.compat.annotation.UnsupportedAppUsage private final java.lang.String argument;
{
argument = null;
diff --git a/ojluni/annotations/hiddenapi/sun/security/jca/ProviderList.java b/ojluni/annotations/hiddenapi/sun/security/jca/ProviderList.java
index 7cd3d4e..e823f317 100644
--- a/ojluni/annotations/hiddenapi/sun/security/jca/ProviderList.java
+++ b/ojluni/annotations/hiddenapi/sun/security/jca/ProviderList.java
@@ -106,7 +106,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.security.Provider.Service getService(java.lang.String type, java.lang.String name) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/jca/Providers.java b/ojluni/annotations/hiddenapi/sun/security/jca/Providers.java
index da37d94..4e116fc 100644
--- a/ojluni/annotations/hiddenapi/sun/security/jca/Providers.java
+++ b/ojluni/annotations/hiddenapi/sun/security/jca/Providers.java
@@ -38,17 +38,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.Object startJarVerification() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static void stopJarVerification(java.lang.Object obj) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.jca.ProviderList getProviderList() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/ContentInfo.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/ContentInfo.java
index 98a0a85..4340ab5 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/ContentInfo.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/ContentInfo.java
@@ -31,13 +31,13 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ContentInfo {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public ContentInfo(
sun.security.util.ObjectIdentifier contentType, sun.security.util.DerValue content) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public ContentInfo(byte[] bytes) {
throw new RuntimeException("Stub!");
}
@@ -60,12 +60,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getData() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(sun.security.util.DerOutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -78,7 +78,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.util.ObjectIdentifier DATA_OID;
public static sun.security.util.ObjectIdentifier DIGESTED_DATA_OID;
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS7.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS7.java
index 0292827..48a4c3c 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS7.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS7.java
@@ -44,12 +44,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS7(byte[] bytes) throws sun.security.pkcs.ParsingException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS7(
sun.security.x509.AlgorithmId[] digestAlgorithmIds,
sun.security.pkcs.ContentInfo contentInfo,
@@ -59,7 +59,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS7(
sun.security.x509.AlgorithmId[] digestAlgorithmIds,
sun.security.pkcs.ContentInfo contentInfo,
@@ -93,7 +93,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encodeSignedData(java.io.OutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -102,7 +102,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.pkcs.SignerInfo verify(sun.security.pkcs.SignerInfo info, byte[] bytes)
throws java.security.NoSuchAlgorithmException, java.security.SignatureException {
throw new RuntimeException("Stub!");
@@ -115,7 +115,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.pkcs.SignerInfo[] verify(byte[] bytes)
throws java.security.NoSuchAlgorithmException, java.security.SignatureException {
throw new RuntimeException("Stub!");
@@ -134,12 +134,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.pkcs.ContentInfo getContentInfo() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.security.cert.X509Certificate[] getCertificates() {
throw new RuntimeException("Stub!");
}
@@ -148,7 +148,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.pkcs.SignerInfo[] getSignerInfos() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS8Key.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS8Key.java
index fa84ed9..e8bb5a1 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS8Key.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS8Key.java
@@ -32,7 +32,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class PKCS8Key implements java.security.PrivateKey {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS8Key() {
throw new RuntimeException("Stub!");
}
@@ -115,11 +115,11 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage protected sun.security.x509.AlgorithmId algid;
+ @android.compat.annotation.UnsupportedAppUsage protected sun.security.x509.AlgorithmId algid;
- @dalvik.annotation.compat.UnsupportedAppUsage protected byte[] encodedKey;
+ @android.compat.annotation.UnsupportedAppUsage protected byte[] encodedKey;
- @dalvik.annotation.compat.UnsupportedAppUsage protected byte[] key;
+ @android.compat.annotation.UnsupportedAppUsage protected byte[] key;
private static final long serialVersionUID = -3836890099307167124L; // 0xcac0a0c88c95426cL
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attribute.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attribute.java
index 40718c2..4413f4e 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attribute.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attribute.java
@@ -29,19 +29,19 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class PKCS9Attribute implements sun.security.util.DerEncoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS9Attribute(sun.security.util.ObjectIdentifier oid, java.lang.Object value)
throws java.lang.IllegalArgumentException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS9Attribute(java.lang.String name, java.lang.Object value)
throws java.lang.IllegalArgumentException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS9Attribute(sun.security.util.DerValue derVal) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -51,7 +51,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void derEncode(java.io.OutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -60,7 +60,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Object getValue() {
throw new RuntimeException("Stub!");
}
@@ -69,7 +69,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.ObjectIdentifier getOID() {
throw new RuntimeException("Stub!");
}
@@ -116,7 +116,7 @@
public static final java.lang.String CHALLENGE_PASSWORD_STR = "ChallengePassword";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier CONTENT_TYPE_OID;
static {
@@ -133,7 +133,7 @@
public static final java.lang.String COUNTERSIGNATURE_STR = "Countersignature";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier EMAIL_ADDRESS_OID;
static {
@@ -167,7 +167,7 @@
public static final java.lang.String ISSUER_SERIALNUMBER_STR = "IssuerAndSerialNumber";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier MESSAGE_DIGEST_OID;
static {
@@ -220,7 +220,7 @@
public static final java.lang.String SIGNING_CERTIFICATE_STR = "SigningCertificate";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier SIGNING_TIME_OID;
static {
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attributes.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attributes.java
index ac9faba..a5e9019 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attributes.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/PKCS9Attributes.java
@@ -36,18 +36,18 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS9Attributes(sun.security.util.DerInputStream in) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS9Attributes(sun.security.util.DerInputStream in, boolean ignoreUnsupportedAttributes)
throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public PKCS9Attributes(sun.security.pkcs.PKCS9Attribute[] attribs)
throws java.io.IOException, java.lang.IllegalArgumentException {
throw new RuntimeException("Stub!");
@@ -57,7 +57,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(byte tag, java.io.OutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -66,7 +66,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getDerEncoding() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -75,7 +75,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.pkcs.PKCS9Attribute getAttribute(java.lang.String name) {
throw new RuntimeException("Stub!");
}
@@ -84,7 +84,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Object getAttributeValue(sun.security.util.ObjectIdentifier oid)
throws java.io.IOException {
throw new RuntimeException("Stub!");
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/ParsingException.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/ParsingException.java
index 7b10115..1f012cb 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/ParsingException.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/ParsingException.java
@@ -37,7 +37,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public ParsingException(java.lang.String s) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/pkcs/SignerInfo.java b/ojluni/annotations/hiddenapi/sun/security/pkcs/SignerInfo.java
index 03ebf6f..162b420 100644
--- a/ojluni/annotations/hiddenapi/sun/security/pkcs/SignerInfo.java
+++ b/ojluni/annotations/hiddenapi/sun/security/pkcs/SignerInfo.java
@@ -34,7 +34,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public SignerInfo(
sun.security.x509.X500Name issuerName,
java.math.BigInteger serial,
@@ -44,7 +44,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public SignerInfo(
sun.security.x509.X500Name issuerName,
java.math.BigInteger serial,
@@ -74,13 +74,13 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.security.cert.X509Certificate getCertificate(sun.security.pkcs.PKCS7 block)
throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.util.ArrayList<java.security.cert.X509Certificate> getCertificateChain(
sun.security.pkcs.PKCS7 block) throws java.io.IOException {
throw new RuntimeException("Stub!");
@@ -115,7 +115,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.AlgorithmId getDigestAlgorithmId() {
throw new RuntimeException("Stub!");
}
@@ -124,12 +124,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.AlgorithmId getDigestEncryptionAlgorithmId() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getEncryptedDigest() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/provider/X509Factory.java b/ojluni/annotations/hiddenapi/sun/security/provider/X509Factory.java
index 499dddc..5f23765 100644
--- a/ojluni/annotations/hiddenapi/sun/security/provider/X509Factory.java
+++ b/ojluni/annotations/hiddenapi/sun/security/provider/X509Factory.java
@@ -25,8 +25,6 @@
package sun.security.provider;
-import java.security.cert.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509Factory {
@@ -34,25 +32,25 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static synchronized sun.security.x509.X509CertImpl intern(
java.security.cert.X509Certificate c) throws java.security.cert.CertificateException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static synchronized sun.security.x509.X509CRLImpl intern(java.security.cert.X509CRL c)
throws java.security.cert.CRLException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static synchronized <K, V> V getFromCache(
sun.security.util.Cache<K, V> cache, byte[] encoding) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static synchronized <V> void addToCache(
sun.security.util.Cache<java.lang.Object, V> cache, byte[] encoding, V value) {
throw new RuntimeException("Stub!");
@@ -60,7 +58,7 @@
private static final int ENC_MAX_LENGTH = 4194304; // 0x400000
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static final sun.security.util.Cache<java.lang.Object, sun.security.x509.X509CertImpl>
certCache;
@@ -68,7 +66,7 @@
certCache = null;
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static final sun.security.util.Cache<java.lang.Object, sun.security.x509.X509CRLImpl>
crlCache;
diff --git a/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertPath.java b/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertPath.java
index f3d432a..71cc57f 100644
--- a/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertPath.java
+++ b/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertPath.java
@@ -25,25 +25,23 @@
package sun.security.provider.certpath;
-import java.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509CertPath extends java.security.cert.CertPath {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertPath(java.util.List<? extends java.security.cert.Certificate> certs)
throws java.security.cert.CertificateException {
super(null);
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertPath(java.io.InputStream is) throws java.security.cert.CertificateException {
super(null);
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertPath(java.io.InputStream is, java.lang.String encoding)
throws java.security.cert.CertificateException {
super(null);
@@ -81,7 +79,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.util.Iterator<java.lang.String> getEncodingsStatic() {
throw new RuntimeException("Stub!");
}
@@ -100,7 +98,7 @@
private static final java.lang.String PKIPATH_ENCODING = "PkiPath";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private java.util.List<java.security.cert.X509Certificate> certs;
private static final java.util.Collection<java.lang.String> encodingList;
diff --git a/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertificatePair.java b/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertificatePair.java
index 3d5b410..fa9fb60 100644
--- a/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertificatePair.java
+++ b/ojluni/annotations/hiddenapi/sun/security/provider/certpath/X509CertificatePair.java
@@ -43,7 +43,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static synchronized void clearCache() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/timestamp/TimestampToken.java b/ojluni/annotations/hiddenapi/sun/security/timestamp/TimestampToken.java
index 241935e..1c2d115 100644
--- a/ojluni/annotations/hiddenapi/sun/security/timestamp/TimestampToken.java
+++ b/ojluni/annotations/hiddenapi/sun/security/timestamp/TimestampToken.java
@@ -28,27 +28,27 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class TimestampToken {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public TimestampToken(byte[] timestampTokenInfo) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.util.Date getDate() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.AlgorithmId getHashAlgorithm() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getHashedMessage() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.math.BigInteger getNonce() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/BitArray.java b/ojluni/annotations/hiddenapi/sun/security/util/BitArray.java
index 2eb98fe..a27ab65 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/BitArray.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/BitArray.java
@@ -32,7 +32,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public BitArray(int length, byte[] a) throws java.lang.IllegalArgumentException {
throw new RuntimeException("Stub!");
}
@@ -65,7 +65,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] toByteArray() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/Cache.java b/ojluni/annotations/hiddenapi/sun/security/util/Cache.java
index f5077e1..1520e12 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/Cache.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/Cache.java
@@ -31,20 +31,20 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public abstract class Cache<K, V> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
protected Cache() {
throw new RuntimeException("Stub!");
}
public abstract int size();
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract void clear();
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract void put(K key, V value);
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract V get(java.lang.Object key);
public abstract void remove(java.lang.Object key);
@@ -63,7 +63,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static <K, V> sun.security.util.Cache<K, V> newHardMemoryCache(int size) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/Debug.java b/ojluni/annotations/hiddenapi/sun/security/util/Debug.java
index e511d0d..5421d20 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/Debug.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/Debug.java
@@ -33,7 +33,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.util.Debug getInstance(java.lang.String option) {
throw new RuntimeException("Stub!");
}
@@ -47,17 +47,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void println(java.lang.String message) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void println() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.String toHexString(java.math.BigInteger b) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/DerIndefLenConverter.java b/ojluni/annotations/hiddenapi/sun/security/util/DerIndefLenConverter.java
index af6e282..6ac25a9 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/DerIndefLenConverter.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/DerIndefLenConverter.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
class DerIndefLenConverter {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
DerIndefLenConverter() {
throw new RuntimeException("Stub!");
}
@@ -42,27 +42,27 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
static boolean isIndefinite(int lengthByte) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void parseTag() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void writeTag() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private int parseLength() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void writeLengthAndValue() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -79,7 +79,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void parseValue(int curLen) {
throw new RuntimeException("Stub!");
}
@@ -88,7 +88,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
byte[] convert(byte[] indefData) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -105,21 +105,21 @@
private static final int TAG_MASK = 31; // 0x1f
- @dalvik.annotation.compat.UnsupportedAppUsage private byte[] data;
+ @android.compat.annotation.UnsupportedAppUsage private byte[] data;
- @dalvik.annotation.compat.UnsupportedAppUsage private int dataPos;
+ @android.compat.annotation.UnsupportedAppUsage private int dataPos;
- @dalvik.annotation.compat.UnsupportedAppUsage private int dataSize;
+ @android.compat.annotation.UnsupportedAppUsage private int dataSize;
private int index;
private java.util.ArrayList<java.lang.Object> ndefsList;
- @dalvik.annotation.compat.UnsupportedAppUsage private byte[] newData;
+ @android.compat.annotation.UnsupportedAppUsage private byte[] newData;
private int newDataPos;
- @dalvik.annotation.compat.UnsupportedAppUsage private int numOfTotalLenBytes = 0; // 0x0
+ @android.compat.annotation.UnsupportedAppUsage private int numOfTotalLenBytes = 0; // 0x0
private int unresolved = 0; // 0x0
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/DerInputStream.java b/ojluni/annotations/hiddenapi/sun/security/util/DerInputStream.java
index a8348e3..fefcd08 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/DerInputStream.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/DerInputStream.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class DerInputStream {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerInputStream(byte[] data) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -52,7 +52,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.DerInputStream subStream(int len, boolean do_skip)
throws java.io.IOException {
throw new RuntimeException("Stub!");
@@ -62,12 +62,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int getInteger() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.math.BigInteger getBigInteger() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -80,7 +80,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getBitString() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -89,7 +89,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getOctetString() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -102,7 +102,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.ObjectIdentifier getOID() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -112,17 +112,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.DerValue[] getSequence(int startLen) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.DerValue[] getSet(int startLen) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.DerValue[] getSet(int startLen, boolean implicit)
throws java.io.IOException {
throw new RuntimeException("Stub!");
@@ -143,12 +143,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.DerValue getDerValue() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getUTF8String() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -179,7 +179,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.util.Date getUTCTime() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -192,7 +192,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int peekByte() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -209,22 +209,22 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void mark(int value) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void reset() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int available() {
throw new RuntimeException("Stub!");
}
sun.security.util.DerInputBuffer buffer;
- @dalvik.annotation.compat.UnsupportedAppUsage public byte tag;
+ @android.compat.annotation.UnsupportedAppUsage public byte tag;
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/DerOutputStream.java b/ojluni/annotations/hiddenapi/sun/security/util/DerOutputStream.java
index 77e5e05..772018d 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/DerOutputStream.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/DerOutputStream.java
@@ -30,22 +30,22 @@
public class DerOutputStream extends java.io.ByteArrayOutputStream
implements sun.security.util.DerEncoder {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerOutputStream(int size) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerOutputStream() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void write(byte tag, byte[] buf) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void write(byte tag, sun.security.util.DerOutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -55,12 +55,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putDerValue(sun.security.util.DerValue val) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putBoolean(boolean val) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -69,7 +69,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putInteger(java.math.BigInteger i) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -78,7 +78,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putInteger(int i) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -87,7 +87,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putBitString(byte[] bits) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -101,22 +101,22 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putOctetString(byte[] octets) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putNull() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putOID(sun.security.util.ObjectIdentifier oid) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putSequence(sun.security.util.DerValue[] seq) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -125,7 +125,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putOrderedSetOf(byte tag, sun.security.util.DerEncoder[] set)
throws java.io.IOException {
throw new RuntimeException("Stub!");
@@ -142,12 +142,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putUTF8String(java.lang.String s) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putPrintableString(java.lang.String s) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -156,7 +156,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putIA5String(java.lang.String s) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -174,7 +174,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void putUTCTime(java.util.Date d) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/DerValue.java b/ojluni/annotations/hiddenapi/sun/security/util/DerValue.java
index d034f44..42825d3 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/DerValue.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/DerValue.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class DerValue {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerValue(java.lang.String value) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -39,7 +39,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerValue(byte tag, byte[] data) {
throw new RuntimeException("Stub!");
}
@@ -49,17 +49,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerValue(byte[] buf) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerValue(byte[] buf, int offset, int len) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public DerValue(java.io.InputStream in) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -72,12 +72,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean isContextSpecific() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean isContextSpecific(byte cntxtTag) {
throw new RuntimeException("Stub!");
}
@@ -86,7 +86,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean isConstructed() {
throw new RuntimeException("Stub!");
}
@@ -105,12 +105,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(sun.security.util.DerOutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public final sun.security.util.DerInputStream getData() {
throw new RuntimeException("Stub!");
}
@@ -123,7 +123,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.ObjectIdentifier getOID() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -132,7 +132,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getOctetString() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -141,12 +141,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.math.BigInteger getBigInteger() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.math.BigInteger getPositiveBigInteger() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -155,17 +155,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getBitString() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.BitArray getUnalignedBitString() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getAsString() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -179,7 +179,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getDataBytes() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -236,12 +236,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] toByteArray() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.DerInputStream toDerInputStream() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -250,17 +250,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static boolean isPrintableStringChar(char ch) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static byte createTag(byte tagClass, boolean form, byte val) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void resetTag(byte tag) {
throw new RuntimeException("Stub!");
}
@@ -277,9 +277,9 @@
public static final byte TAG_UNIVERSAL = 0; // 0x0
- @dalvik.annotation.compat.UnsupportedAppUsage protected sun.security.util.DerInputBuffer buffer;
+ @android.compat.annotation.UnsupportedAppUsage protected sun.security.util.DerInputBuffer buffer;
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public final sun.security.util.DerInputStream data;
{
@@ -290,7 +290,7 @@
private byte[] originalEncodedForm;
- @dalvik.annotation.compat.UnsupportedAppUsage public byte tag;
+ @android.compat.annotation.UnsupportedAppUsage public byte tag;
public static final byte tag_BMPString = 30; // 0x1e
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/ManifestDigester.java b/ojluni/annotations/hiddenapi/sun/security/util/ManifestDigester.java
index ff473fb..b8d89f8 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/ManifestDigester.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/ManifestDigester.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class ManifestDigester {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public ManifestDigester(byte[] bytes) {
throw new RuntimeException("Stub!");
}
@@ -43,12 +43,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.ManifestDigester.Entry get(java.lang.String name, boolean oldStyle) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] manifestDigest(java.security.MessageDigest md) {
throw new RuntimeException("Stub!");
}
@@ -66,7 +66,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] digest(java.security.MessageDigest md) {
throw new RuntimeException("Stub!");
}
@@ -76,7 +76,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] digestWorkaround(java.security.MessageDigest md) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/MemoryCache.java b/ojluni/annotations/hiddenapi/sun/security/util/MemoryCache.java
index 0bea0a2..5a7d646 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/MemoryCache.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/MemoryCache.java
@@ -16,7 +16,7 @@
package sun.security.util;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
class MemoryCache<K, V> extends sun.security.util.Cache<K, V> {
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/ObjectIdentifier.java b/ojluni/annotations/hiddenapi/sun/security/util/ObjectIdentifier.java
index 1c17bed..7b536f4 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/ObjectIdentifier.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/ObjectIdentifier.java
@@ -30,12 +30,12 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class ObjectIdentifier implements java.io.Serializable {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public ObjectIdentifier(java.lang.String oid) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public ObjectIdentifier(int[] values) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -61,7 +61,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.util.ObjectIdentifier newInternal(int[] values) {
throw new RuntimeException("Stub!");
}
@@ -71,7 +71,7 @@
}
@Deprecated
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean equals(sun.security.util.ObjectIdentifier other) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/PropertyExpander.java b/ojluni/annotations/hiddenapi/sun/security/util/PropertyExpander.java
index f763de7..9a86630 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/PropertyExpander.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/PropertyExpander.java
@@ -33,7 +33,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.String expand(java.lang.String value)
throws sun.security.util.PropertyExpander.ExpandException {
throw new RuntimeException("Stub!");
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/ResourcesMgr.java b/ojluni/annotations/hiddenapi/sun/security/util/ResourcesMgr.java
index eef01dc..0a66cae 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/ResourcesMgr.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/ResourcesMgr.java
@@ -32,7 +32,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.String getString(java.lang.String s) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/SecurityConstants.java b/ojluni/annotations/hiddenapi/sun/security/util/SecurityConstants.java
index 33d67c6..4a89da6 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/SecurityConstants.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/SecurityConstants.java
@@ -51,7 +51,7 @@
CREATE_ACC_PERMISSION = null;
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final java.lang.RuntimePermission CREATE_CLASSLOADER_PERMISSION;
static {
@@ -68,7 +68,7 @@
public static final java.lang.String FILE_WRITE_ACTION = "write";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final java.lang.RuntimePermission GET_CLASSLOADER_PERMISSION;
static {
@@ -123,14 +123,14 @@
LOCAL_LISTEN_PERMISSION = null;
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final java.lang.RuntimePermission MODIFY_THREADGROUP_PERMISSION;
static {
MODIFY_THREADGROUP_PERMISSION = null;
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final java.lang.RuntimePermission MODIFY_THREAD_PERMISSION;
static {
diff --git a/ojluni/annotations/hiddenapi/sun/security/util/SignatureFileVerifier.java b/ojluni/annotations/hiddenapi/sun/security/util/SignatureFileVerifier.java
index bce34ad..0d9c770 100644
--- a/ojluni/annotations/hiddenapi/sun/security/util/SignatureFileVerifier.java
+++ b/ojluni/annotations/hiddenapi/sun/security/util/SignatureFileVerifier.java
@@ -50,7 +50,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static boolean isBlockOrSF(java.lang.String s) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/AVA.java b/ojluni/annotations/hiddenapi/sun/security/x509/AVA.java
index e2e18ca..d4018bf 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/AVA.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/AVA.java
@@ -26,7 +26,7 @@
package sun.security.x509;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class AVA implements sun.security.util.DerEncoder {
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/AVAComparator.java b/ojluni/annotations/hiddenapi/sun/security/x509/AVAComparator.java
index 21494c3..3643d60 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/AVAComparator.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/AVAComparator.java
@@ -16,7 +16,7 @@
package sun.security.x509;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
class AVAComparator implements java.util.Comparator<sun.security.x509.AVA> {
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/AVAKeyword.java b/ojluni/annotations/hiddenapi/sun/security/x509/AVAKeyword.java
index 78d379f..adadd59 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/AVAKeyword.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/AVAKeyword.java
@@ -17,7 +17,7 @@
package sun.security.x509;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
class AVAKeyword {
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/AccessDescription.java b/ojluni/annotations/hiddenapi/sun/security/x509/AccessDescription.java
index 5f3d77f..d6f5e1d 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/AccessDescription.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/AccessDescription.java
@@ -36,17 +36,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public AccessDescription(sun.security.util.DerValue derValue) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.ObjectIdentifier getAccessMethod() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.GeneralName getAccessLocation() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/AlgorithmId.java b/ojluni/annotations/hiddenapi/sun/security/x509/AlgorithmId.java
index 3f9214b..7948de8 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/AlgorithmId.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/AlgorithmId.java
@@ -26,7 +26,7 @@
package sun.security.x509;
-import dalvik.annotation.compat.UnsupportedAppUsage;
+import android.compat.annotation.UnsupportedAppUsage;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class AlgorithmId implements java.io.Serializable, sun.security.util.DerEncoder {
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/AttributeNameEnumeration.java b/ojluni/annotations/hiddenapi/sun/security/x509/AttributeNameEnumeration.java
index c3728d7..6bda58e 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/AttributeNameEnumeration.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/AttributeNameEnumeration.java
@@ -29,7 +29,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class AttributeNameEnumeration extends java.util.Vector<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public AttributeNameEnumeration() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CRLDistributionPointsExtension.java b/ojluni/annotations/hiddenapi/sun/security/x509/CRLDistributionPointsExtension.java
index 84063ed..2e8439f 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CRLDistributionPointsExtension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CRLDistributionPointsExtension.java
@@ -100,7 +100,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void encodeThis() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CRLNumberExtension.java b/ojluni/annotations/hiddenapi/sun/security/x509/CRLNumberExtension.java
index 00d0ee0..40eb1b8 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CRLNumberExtension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CRLNumberExtension.java
@@ -49,7 +49,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CRLNumberExtension(java.lang.Boolean critical, java.lang.Object value)
throws java.io.IOException {
throw new RuntimeException("Stub!");
@@ -65,7 +65,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void encodeThis() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -74,7 +74,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.math.BigInteger get(java.lang.String name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateAlgorithmId.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateAlgorithmId.java
index 5a3bc38..4a8f963 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateAlgorithmId.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateAlgorithmId.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CertificateAlgorithmId implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateAlgorithmId(sun.security.x509.AlgorithmId algId) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateExtensions.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateExtensions.java
index cad6f74..da41fbd 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateExtensions.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateExtensions.java
@@ -32,12 +32,12 @@
public class CertificateExtensions
implements sun.security.x509.CertAttrSet<sun.security.x509.Extension> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateExtensions() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateExtensions(sun.security.util.DerInputStream in) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -55,18 +55,18 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(java.io.OutputStream out, boolean isCertReq)
throws java.security.cert.CertificateException, java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void set(java.lang.String name, java.lang.Object obj) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.Extension get(java.lang.String name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateIssuerName.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateIssuerName.java
index 22380db..c6736ff 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateIssuerName.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateIssuerName.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CertificateIssuerName implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateIssuerName(sun.security.x509.X500Name name) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSerialNumber.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSerialNumber.java
index 131b445..1a0cb81 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSerialNumber.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSerialNumber.java
@@ -30,12 +30,12 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CertificateSerialNumber implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateSerialNumber(java.math.BigInteger num) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateSerialNumber(int num) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSubjectName.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSubjectName.java
index f5ff910..87842ca 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSubjectName.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateSubjectName.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CertificateSubjectName implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateSubjectName(sun.security.x509.X500Name name) {
throw new RuntimeException("Stub!");
}
@@ -55,7 +55,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Object get(java.lang.String name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateValidity.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateValidity.java
index bb5d599..db96a7a 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateValidity.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateValidity.java
@@ -35,7 +35,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateValidity(java.util.Date notBefore, java.util.Date notAfter) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateVersion.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateVersion.java
index 85ad759..3b3c180 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateVersion.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateVersion.java
@@ -34,7 +34,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateVersion(int version) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateX509Key.java b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateX509Key.java
index 6f45057..ff5cc1d 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/CertificateX509Key.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/CertificateX509Key.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class CertificateX509Key implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public CertificateX509Key(java.security.PublicKey key) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/Extension.java b/ojluni/annotations/hiddenapi/sun/security/x509/Extension.java
index f4acc6c..60cd779 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/Extension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/Extension.java
@@ -44,7 +44,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public Extension(sun.security.x509.Extension ext) {
throw new RuntimeException("Stub!");
}
@@ -61,7 +61,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(sun.security.util.DerOutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -70,7 +70,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.util.ObjectIdentifier getExtensionId() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/GeneralName.java b/ojluni/annotations/hiddenapi/sun/security/x509/GeneralName.java
index c7eb02e..9fa401c 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/GeneralName.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/GeneralName.java
@@ -30,7 +30,7 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class GeneralName {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GeneralName(sun.security.x509.GeneralNameInterface name) {
throw new RuntimeException("Stub!");
}
@@ -44,12 +44,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int getType() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.GeneralNameInterface getName() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/GeneralNames.java b/ojluni/annotations/hiddenapi/sun/security/x509/GeneralNames.java
index fdac69f..df5f5ee 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/GeneralNames.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/GeneralNames.java
@@ -31,17 +31,17 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class GeneralNames {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GeneralNames(sun.security.util.DerValue derVal) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public GeneralNames() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.GeneralNames add(sun.security.x509.GeneralName name) {
throw new RuntimeException("Stub!");
}
@@ -50,7 +50,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean isEmpty() {
throw new RuntimeException("Stub!");
}
@@ -67,7 +67,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(sun.security.util.DerOutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/KeyIdentifier.java b/ojluni/annotations/hiddenapi/sun/security/x509/KeyIdentifier.java
index 8faa83a..427b133 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/KeyIdentifier.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/KeyIdentifier.java
@@ -38,12 +38,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public KeyIdentifier(java.security.PublicKey pubKey) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getIdentifier() {
throw new RuntimeException("Stub!");
}
@@ -64,5 +64,5 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private byte[] octetString;
+ @android.compat.annotation.UnsupportedAppUsage private byte[] octetString;
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/KeyUsageExtension.java b/ojluni/annotations/hiddenapi/sun/security/x509/KeyUsageExtension.java
index e9addc9..cd2ff3e 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/KeyUsageExtension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/KeyUsageExtension.java
@@ -35,7 +35,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public KeyUsageExtension(boolean[] bitString) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -69,7 +69,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Boolean get(java.lang.String name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/NetscapeCertTypeExtension.java b/ojluni/annotations/hiddenapi/sun/security/x509/NetscapeCertTypeExtension.java
index 88e4f11..2db2b55 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/NetscapeCertTypeExtension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/NetscapeCertTypeExtension.java
@@ -32,7 +32,7 @@
public class NetscapeCertTypeExtension extends sun.security.x509.Extension
implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public NetscapeCertTypeExtension(byte[] bitString) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -70,7 +70,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Boolean get(java.lang.String name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/OIDMap.java b/ojluni/annotations/hiddenapi/sun/security/x509/OIDMap.java
index 8186c23..12be25a 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/OIDMap.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/OIDMap.java
@@ -60,7 +60,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.lang.Class<?> getClass(sun.security.util.ObjectIdentifier oid)
throws java.security.cert.CertificateException {
throw new RuntimeException("Stub!");
@@ -136,14 +136,14 @@
private static final java.lang.String SUB_KEY_IDENTIFIER =
"x509.info.extensions.SubjectKeyIdentifier";
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static final java.util.Map<java.lang.String, sun.security.x509.OIDMap.OIDInfo> nameMap;
static {
nameMap = null;
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private static final java.util.Map<
sun.security.util.ObjectIdentifier, sun.security.x509.OIDMap.OIDInfo>
oidMap;
@@ -166,7 +166,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage private volatile java.lang.Class<?> clazz;
+ @android.compat.annotation.UnsupportedAppUsage private volatile java.lang.Class<?> clazz;
final java.lang.String name;
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/PKIXExtensions.java b/ojluni/annotations/hiddenapi/sun/security/x509/PKIXExtensions.java
index de3027a..105172c 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/PKIXExtensions.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/PKIXExtensions.java
@@ -95,7 +95,7 @@
CRLNumber_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier CertificateIssuer_Id;
static {
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/SerialNumber.java b/ojluni/annotations/hiddenapi/sun/security/x509/SerialNumber.java
index 1c14ef3..f6b1663 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/SerialNumber.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/SerialNumber.java
@@ -42,7 +42,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public SerialNumber(sun.security.util.DerValue val) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/SubjectAlternativeNameExtension.java b/ojluni/annotations/hiddenapi/sun/security/x509/SubjectAlternativeNameExtension.java
index 44aa6ab..9b1ed0b 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/SubjectAlternativeNameExtension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/SubjectAlternativeNameExtension.java
@@ -67,7 +67,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.GeneralNames get(java.lang.String name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/SubjectKeyIdentifierExtension.java b/ojluni/annotations/hiddenapi/sun/security/x509/SubjectKeyIdentifierExtension.java
index 2a85bd5..a9c323d 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/SubjectKeyIdentifierExtension.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/SubjectKeyIdentifierExtension.java
@@ -25,13 +25,11 @@
package sun.security.x509;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class SubjectKeyIdentifierExtension extends sun.security.x509.Extension
implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public SubjectKeyIdentifierExtension(byte[] octetString) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/URIName.java b/ojluni/annotations/hiddenapi/sun/security/x509/URIName.java
index 5030158..5b8ee8f 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/URIName.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/URIName.java
@@ -25,8 +25,6 @@
package sun.security.x509;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class URIName implements sun.security.x509.GeneralNameInterface {
@@ -67,12 +65,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getName() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getScheme() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/UniqueIdentity.java b/ojluni/annotations/hiddenapi/sun/security/x509/UniqueIdentity.java
index b43e762..c5b0995 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/UniqueIdentity.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/UniqueIdentity.java
@@ -25,8 +25,6 @@
package sun.security.x509;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class UniqueIdentity {
@@ -38,12 +36,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public UniqueIdentity(sun.security.util.DerInputStream in) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public UniqueIdentity(sun.security.util.DerValue derVal) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -52,7 +50,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(sun.security.util.DerOutputStream out, byte tag) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/X500Name.java b/ojluni/annotations/hiddenapi/sun/security/x509/X500Name.java
index 4c697ab..fd8e9b6 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/X500Name.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/X500Name.java
@@ -26,14 +26,10 @@
package sun.security.x509;
-import java.lang.reflect.*;
-import java.util.*;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X500Name implements sun.security.x509.GeneralNameInterface, java.security.Principal {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(java.lang.String dname) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -44,12 +40,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(java.lang.String dname, java.lang.String format) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(
java.lang.String commonName,
java.lang.String organizationUnit,
@@ -59,7 +55,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(
java.lang.String commonName,
java.lang.String organizationUnit,
@@ -75,17 +71,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(sun.security.util.DerValue value) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(sun.security.util.DerInputStream in) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X500Name(byte[] name) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -98,7 +94,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.util.List<sun.security.x509.AVA> allAvas() {
throw new RuntimeException("Stub!");
}
@@ -107,7 +103,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean isEmpty() {
throw new RuntimeException("Stub!");
}
@@ -141,7 +137,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getCommonName() throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -235,7 +231,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void encode(sun.security.util.DerOutputStream out) throws java.io.IOException {
throw new RuntimeException("Stub!");
}
@@ -300,12 +296,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public javax.security.auth.x500.X500Principal asX500Principal() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.security.x509.X500Name asX500Name(javax.security.auth.x500.X500Principal p) {
throw new RuntimeException("Stub!");
}
@@ -316,7 +312,7 @@
DNQUALIFIER_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier DNQUALIFIER_OID;
static {
@@ -329,7 +325,7 @@
DOMAIN_COMPONENT_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier DOMAIN_COMPONENT_OID;
static {
@@ -342,7 +338,7 @@
GENERATIONQUALIFIER_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier GENERATIONQUALIFIER_OID;
static {
@@ -355,7 +351,7 @@
GIVENNAME_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier GIVENNAME_OID;
static {
@@ -368,7 +364,7 @@
INITIALS_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier INITIALS_OID;
static {
@@ -381,7 +377,7 @@
SERIALNUMBER_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier SERIALNUMBER_OID;
static {
@@ -394,7 +390,7 @@
SURNAME_DATA = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier SURNAME_OID;
static {
@@ -411,7 +407,7 @@
commonName_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier commonName_oid;
static {
@@ -424,7 +420,7 @@
countryName_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier countryName_oid;
static {
@@ -449,7 +445,7 @@
ipAddress_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier ipAddress_oid;
static {
@@ -462,7 +458,7 @@
localityName_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier localityName_oid;
static {
@@ -477,7 +473,7 @@
orgName_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier orgName_oid;
static {
@@ -490,7 +486,7 @@
orgUnitName_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier orgUnitName_oid;
static {
@@ -522,7 +518,7 @@
stateName_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier stateName_oid;
static {
@@ -535,7 +531,7 @@
streetAddress_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier streetAddress_oid;
static {
@@ -548,7 +544,7 @@
title_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier title_oid;
static {
@@ -561,7 +557,7 @@
userid_data = new int[0];
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final sun.security.util.ObjectIdentifier userid_oid;
static {
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLEntryImpl.java b/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLEntryImpl.java
index 066a4ad..5684afa 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLEntryImpl.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLEntryImpl.java
@@ -25,9 +25,6 @@
package sun.security.x509;
-import java.util.*;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509CRLEntryImpl extends java.security.cert.X509CRLEntry
implements java.lang.Comparable<sun.security.x509.X509CRLEntryImpl> {
@@ -120,7 +117,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.security.x509.Extension getExtension(sun.security.util.ObjectIdentifier oid) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLImpl.java b/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLImpl.java
index 7f353de..64cf8db 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLImpl.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/X509CRLImpl.java
@@ -25,9 +25,6 @@
package sun.security.x509;
-import java.util.*;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509CRLImpl extends java.security.cert.X509CRL
implements sun.security.util.DerEncoder {
@@ -36,17 +33,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CRLImpl(byte[] crlData) throws java.security.cert.CRLException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CRLImpl(sun.security.util.DerValue val) throws java.security.cert.CRLException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CRLImpl(java.io.InputStream inStrm) throws java.security.cert.CRLException {
throw new RuntimeException("Stub!");
}
@@ -75,7 +72,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getEncodedInternal() throws java.security.cert.CRLException {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/X509CertImpl.java b/ojluni/annotations/hiddenapi/sun/security/x509/X509CertImpl.java
index 9333689..5188e10 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/X509CertImpl.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/X509CertImpl.java
@@ -25,11 +25,6 @@
package sun.security.x509;
-import java.security.*;
-import java.security.cert.*;
-import java.util.*;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509CertImpl extends java.security.cert.X509Certificate
implements sun.security.util.DerEncoder {
@@ -38,17 +33,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertImpl(byte[] certData) throws java.security.cert.CertificateException {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertImpl(sun.security.x509.X509CertInfo certInfo) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertImpl(sun.security.util.DerValue derVal)
throws java.security.cert.CertificateException {
throw new RuntimeException("Stub!");
@@ -72,7 +67,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public byte[] getEncodedInternal() throws java.security.cert.CertificateEncodingException {
throw new RuntimeException("Stub!");
}
@@ -106,7 +101,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void sign(java.security.PrivateKey key, java.lang.String algorithm)
throws java.security.cert.CertificateException, java.security.InvalidKeyException,
java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException,
@@ -134,7 +129,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Object get(java.lang.String name)
throws java.security.cert.CertificateParsingException {
throw new RuntimeException("Stub!");
@@ -366,7 +361,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void parse(sun.security.util.DerValue val)
throws java.security.cert.CertificateException, java.io.IOException {
throw new RuntimeException("Stub!");
@@ -460,7 +455,7 @@
public static final java.lang.String VERSION = "x509.info.version.number";
- @dalvik.annotation.compat.UnsupportedAppUsage protected sun.security.x509.AlgorithmId algId;
+ @android.compat.annotation.UnsupportedAppUsage protected sun.security.x509.AlgorithmId algId;
private java.util.Set<sun.security.x509.AccessDescription> authInfoAccess;
@@ -472,13 +467,13 @@
private java.util.Collection<java.util.List<?>> issuerAlternativeNames;
- @dalvik.annotation.compat.UnsupportedAppUsage private boolean readOnly = false;
+ @android.compat.annotation.UnsupportedAppUsage private boolean readOnly = false;
private static final long serialVersionUID = -3457612960190864406L; // 0xd0041754f90963eaL
- @dalvik.annotation.compat.UnsupportedAppUsage protected byte[] signature;
+ @android.compat.annotation.UnsupportedAppUsage protected byte[] signature;
- @dalvik.annotation.compat.UnsupportedAppUsage private byte[] signedCert;
+ @android.compat.annotation.UnsupportedAppUsage private byte[] signedCert;
private java.util.Collection<java.util.List<?>> subjectAlternativeNames;
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/X509CertInfo.java b/ojluni/annotations/hiddenapi/sun/security/x509/X509CertInfo.java
index 21b4d61..2309a50 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/X509CertInfo.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/X509CertInfo.java
@@ -25,19 +25,15 @@
package sun.security.x509;
-import java.security.cert.*;
-import java.util.*;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509CertInfo implements sun.security.x509.CertAttrSet<java.lang.String> {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertInfo() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509CertInfo(byte[] cert) throws java.security.cert.CertificateParsingException {
throw new RuntimeException("Stub!");
}
@@ -80,7 +76,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void set(java.lang.String name, java.lang.Object val)
throws java.security.cert.CertificateException, java.io.IOException {
throw new RuntimeException("Stub!");
@@ -91,7 +87,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.Object get(java.lang.String name)
throws java.security.cert.CertificateException, java.io.IOException {
throw new RuntimeException("Stub!");
diff --git a/ojluni/annotations/hiddenapi/sun/security/x509/X509Key.java b/ojluni/annotations/hiddenapi/sun/security/x509/X509Key.java
index 2a830d7..8c4924f 100644
--- a/ojluni/annotations/hiddenapi/sun/security/x509/X509Key.java
+++ b/ojluni/annotations/hiddenapi/sun/security/x509/X509Key.java
@@ -25,13 +25,10 @@
package sun.security.x509;
-import java.io.*;
-import sun.security.util.*;
-
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class X509Key implements java.security.PublicKey {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public X509Key() {
throw new RuntimeException("Stub!");
}
@@ -49,7 +46,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static java.security.PublicKey parse(sun.security.util.DerValue in)
throws java.io.IOException {
throw new RuntimeException("Stub!");
@@ -129,15 +126,15 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage protected sun.security.x509.AlgorithmId algid;
+ @android.compat.annotation.UnsupportedAppUsage protected sun.security.x509.AlgorithmId algid;
private sun.security.util.BitArray bitStringKey;
- @dalvik.annotation.compat.UnsupportedAppUsage protected byte[] encodedKey;
+ @android.compat.annotation.UnsupportedAppUsage protected byte[] encodedKey;
- @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage protected byte[] key;
+ @Deprecated @android.compat.annotation.UnsupportedAppUsage protected byte[] key;
private static final long serialVersionUID = -5359250853002055002L; // 0xb5a01dbe649a72a6L
- @Deprecated @dalvik.annotation.compat.UnsupportedAppUsage private int unusedBits = 0; // 0x0
+ @Deprecated @android.compat.annotation.UnsupportedAppUsage private int unusedBits = 0; // 0x0
}
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/AbstractCalendar.java b/ojluni/annotations/hiddenapi/sun/util/calendar/AbstractCalendar.java
index dd8fd2b..3e1be5e 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/AbstractCalendar.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/AbstractCalendar.java
@@ -37,7 +37,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.Era[] getEras() {
throw new RuntimeException("Stub!");
}
@@ -75,7 +75,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public long getTimeOfDayValue(sun.util.calendar.CalendarDate date) {
throw new RuntimeException("Stub!");
}
@@ -104,7 +104,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static long getDayOfWeekDateOnOrBefore(long fixedDate, int dayOfWeek) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/BaseCalendar.java b/ojluni/annotations/hiddenapi/sun/util/calendar/BaseCalendar.java
index 8c8f122..660ba87 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/BaseCalendar.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/BaseCalendar.java
@@ -185,10 +185,10 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract int getNormalizedYear();
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract void setNormalizedYear(int normalizedYear);
protected final boolean hit(int year) {
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarDate.java b/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarDate.java
index f63c574..165920c 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarDate.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarDate.java
@@ -45,7 +45,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int getYear() {
throw new RuntimeException("Stub!");
}
@@ -66,7 +66,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int getMonth() {
throw new RuntimeException("Stub!");
}
@@ -79,12 +79,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int getDayOfMonth() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate setDayOfMonth(int date) {
throw new RuntimeException("Stub!");
}
@@ -101,7 +101,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate setHours(int hours) {
throw new RuntimeException("Stub!");
}
@@ -114,7 +114,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate setMinutes(int minutes) {
throw new RuntimeException("Stub!");
}
@@ -127,7 +127,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate setSeconds(int seconds) {
throw new RuntimeException("Stub!");
}
@@ -140,7 +140,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate setMillis(int millis) {
throw new RuntimeException("Stub!");
}
@@ -149,12 +149,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public long getTimeOfDay() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate setDate(int year, int month, int dayOfMonth) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarSystem.java b/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarSystem.java
index bddd682..c847641 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarSystem.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarSystem.java
@@ -34,12 +34,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.util.calendar.Gregorian getGregorianCalendar() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static sun.util.calendar.CalendarSystem forName(java.lang.String calendarName) {
throw new RuntimeException("Stub!");
}
@@ -62,10 +62,10 @@
public abstract sun.util.calendar.CalendarDate newCalendarDate();
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract sun.util.calendar.CalendarDate newCalendarDate(java.util.TimeZone zone);
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract long getTime(sun.util.calendar.CalendarDate date);
public abstract int getYearLength(sun.util.calendar.CalendarDate date);
@@ -88,7 +88,7 @@
public abstract sun.util.calendar.CalendarDate setTimeOfDay(
sun.util.calendar.CalendarDate date, int timeOfDay);
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public abstract boolean validate(sun.util.calendar.CalendarDate date);
public abstract boolean normalize(sun.util.calendar.CalendarDate date);
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarUtils.java b/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarUtils.java
index 9ecd8dc..2a05603 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarUtils.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/CalendarUtils.java
@@ -40,12 +40,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final long floorDivide(long n, long d) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final int floorDivide(int n, int d) {
throw new RuntimeException("Stub!");
}
@@ -58,12 +58,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final long mod(long x, long y) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public static final int mod(int x, int y) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/Era.java b/ojluni/annotations/hiddenapi/sun/util/calendar/Era.java
index 28e5095..49aa034 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/Era.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/Era.java
@@ -28,12 +28,12 @@
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Era {
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public Era(java.lang.String name, java.lang.String abbr, long since, boolean localTime) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getName() {
throw new RuntimeException("Stub!");
}
@@ -42,7 +42,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public java.lang.String getAbbreviation() {
throw new RuntimeException("Stub!");
}
@@ -55,7 +55,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.CalendarDate getSinceDate() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/ImmutableGregorianDate.java b/ojluni/annotations/hiddenapi/sun/util/calendar/ImmutableGregorianDate.java
index 825e9d6..aa92656 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/ImmutableGregorianDate.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/ImmutableGregorianDate.java
@@ -242,7 +242,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
private void unsupported() {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/hiddenapi/sun/util/calendar/LocalGregorianCalendar.java b/ojluni/annotations/hiddenapi/sun/util/calendar/LocalGregorianCalendar.java
index 95267d0..b1320c5 100644
--- a/ojluni/annotations/hiddenapi/sun/util/calendar/LocalGregorianCalendar.java
+++ b/ojluni/annotations/hiddenapi/sun/util/calendar/LocalGregorianCalendar.java
@@ -68,12 +68,12 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.LocalGregorianCalendar.Date newCalendarDate(java.util.TimeZone zone) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean validate(sun.util.calendar.CalendarDate date) {
throw new RuntimeException("Stub!");
}
@@ -82,7 +82,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public boolean normalize(sun.util.calendar.CalendarDate date) {
throw new RuntimeException("Stub!");
}
@@ -122,7 +122,7 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.LocalGregorianCalendar.Date setEra(sun.util.calendar.Era era) {
throw new RuntimeException("Stub!");
}
@@ -131,17 +131,17 @@
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public sun.util.calendar.LocalGregorianCalendar.Date setYear(int localYear) {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public int getNormalizedYear() {
throw new RuntimeException("Stub!");
}
- @dalvik.annotation.compat.UnsupportedAppUsage
+ @android.compat.annotation.UnsupportedAppUsage
public void setNormalizedYear(int normalizedYear) {
throw new RuntimeException("Stub!");
}
diff --git a/ojluni/annotations/mmodule/java/nio/charset/CharsetDecoder.annotated.java b/ojluni/annotations/mmodule/java/nio/charset/CharsetDecoder.annotated.java
new file mode 100644
index 0000000..ed0f378
--- /dev/null
+++ b/ojluni/annotations/mmodule/java/nio/charset/CharsetDecoder.annotated.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (c) 2000, 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+
+package java.nio.charset;
+
+import java.nio.CharBuffer;
+import java.nio.ByteBuffer;
+import java.nio.Buffer;
+import java.nio.charset.CoderMalfunctionError;
+
+@SuppressWarnings({"unchecked", "deprecation", "all"})
+public abstract class CharsetDecoder {
+
+@libcore.api.IntraCoreApi
+protected CharsetDecoder(java.nio.charset.Charset cs, float averageCharsPerByte, float maxCharsPerByte) { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.Charset charset() { throw new RuntimeException("Stub!"); }
+
+public final java.lang.String replacement() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetDecoder replaceWith(java.lang.String newReplacement) { throw new RuntimeException("Stub!"); }
+
+protected void implReplaceWith(java.lang.String newReplacement) { throw new RuntimeException("Stub!"); }
+
+public java.nio.charset.CodingErrorAction malformedInputAction() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetDecoder onMalformedInput(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+protected void implOnMalformedInput(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+public java.nio.charset.CodingErrorAction unmappableCharacterAction() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetDecoder onUnmappableCharacter(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+protected void implOnUnmappableCharacter(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+public final float averageCharsPerByte() { throw new RuntimeException("Stub!"); }
+
+public final float maxCharsPerByte() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CoderResult decode(java.nio.ByteBuffer in, java.nio.CharBuffer out, boolean endOfInput) { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CoderResult flush(java.nio.CharBuffer out) { throw new RuntimeException("Stub!"); }
+
+protected java.nio.charset.CoderResult implFlush(java.nio.CharBuffer out) { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetDecoder reset() { throw new RuntimeException("Stub!"); }
+
+protected void implReset() { throw new RuntimeException("Stub!"); }
+
+protected abstract java.nio.charset.CoderResult decodeLoop(java.nio.ByteBuffer in, java.nio.CharBuffer out);
+
+public final java.nio.CharBuffer decode(java.nio.ByteBuffer in) throws java.nio.charset.CharacterCodingException { throw new RuntimeException("Stub!"); }
+
+public boolean isAutoDetecting() { throw new RuntimeException("Stub!"); }
+
+public boolean isCharsetDetected() { throw new RuntimeException("Stub!"); }
+
+public java.nio.charset.Charset detectedCharset() { throw new RuntimeException("Stub!"); }
+}
+
diff --git a/ojluni/annotations/mmodule/java/nio/charset/CharsetEncoder.annotated.java b/ojluni/annotations/mmodule/java/nio/charset/CharsetEncoder.annotated.java
new file mode 100644
index 0000000..ceb323e
--- /dev/null
+++ b/ojluni/annotations/mmodule/java/nio/charset/CharsetEncoder.annotated.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (c) 2000, 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+
+package java.nio.charset;
+
+import java.nio.CharBuffer;
+import java.nio.ByteBuffer;
+import java.nio.Buffer;
+import java.nio.charset.CoderMalfunctionError;
+
+@SuppressWarnings({"unchecked", "deprecation", "all"})
+public abstract class CharsetEncoder {
+
+protected CharsetEncoder(java.nio.charset.Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement) { throw new RuntimeException("Stub!"); }
+
+@libcore.api.IntraCoreApi
+protected CharsetEncoder(java.nio.charset.Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement, boolean trusted) { throw new RuntimeException("Stub!"); }
+
+protected CharsetEncoder(java.nio.charset.Charset cs, float averageBytesPerChar, float maxBytesPerChar) { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.Charset charset() { throw new RuntimeException("Stub!"); }
+
+public final byte[] replacement() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetEncoder replaceWith(byte[] newReplacement) { throw new RuntimeException("Stub!"); }
+
+protected void implReplaceWith(byte[] newReplacement) { throw new RuntimeException("Stub!"); }
+
+public boolean isLegalReplacement(byte[] repl) { throw new RuntimeException("Stub!"); }
+
+public java.nio.charset.CodingErrorAction malformedInputAction() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetEncoder onMalformedInput(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+protected void implOnMalformedInput(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+public java.nio.charset.CodingErrorAction unmappableCharacterAction() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetEncoder onUnmappableCharacter(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+protected void implOnUnmappableCharacter(java.nio.charset.CodingErrorAction newAction) { throw new RuntimeException("Stub!"); }
+
+public final float averageBytesPerChar() { throw new RuntimeException("Stub!"); }
+
+public final float maxBytesPerChar() { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CoderResult encode(java.nio.CharBuffer in, java.nio.ByteBuffer out, boolean endOfInput) { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CoderResult flush(java.nio.ByteBuffer out) { throw new RuntimeException("Stub!"); }
+
+protected java.nio.charset.CoderResult implFlush(java.nio.ByteBuffer out) { throw new RuntimeException("Stub!"); }
+
+public final java.nio.charset.CharsetEncoder reset() { throw new RuntimeException("Stub!"); }
+
+protected void implReset() { throw new RuntimeException("Stub!"); }
+
+protected abstract java.nio.charset.CoderResult encodeLoop(java.nio.CharBuffer in, java.nio.ByteBuffer out);
+
+public final java.nio.ByteBuffer encode(java.nio.CharBuffer in) throws java.nio.charset.CharacterCodingException { throw new RuntimeException("Stub!"); }
+
+public boolean canEncode(char c) { throw new RuntimeException("Stub!"); }
+
+public boolean canEncode(java.lang.CharSequence cs) { throw new RuntimeException("Stub!"); }
+}
+
diff --git a/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java b/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java
index 5cbfa49..cb99f54 100644
--- a/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java
@@ -141,9 +141,9 @@
@libcore.util.Nullable public java.io.InputStream getResourceAsStream(@libcore.util.NonNull java.lang.String name) { throw new RuntimeException("Stub!"); }
-public java.net.URL getResource(@libcore.util.NonNull java.lang.String name) { throw new RuntimeException("Stub!"); }
+@libcore.util.Nullable public java.net.URL getResource(@libcore.util.NonNull java.lang.String name) { throw new RuntimeException("Stub!"); }
-public java.security.ProtectionDomain getProtectionDomain() { throw new RuntimeException("Stub!"); }
+@libcore.util.Nullable public java.security.ProtectionDomain getProtectionDomain() { throw new RuntimeException("Stub!"); }
public boolean desiredAssertionStatus() { throw new RuntimeException("Stub!"); }
@@ -156,7 +156,7 @@
@libcore.util.NonNull public <U> java.lang.Class<? extends U> asSubclass(@libcore.util.NonNull java.lang.Class<U> clazz) { throw new RuntimeException("Stub!"); }
-public <A extends java.lang.annotation.Annotation> A getAnnotation(@libcore.util.NonNull java.lang.Class<A> annotationClass) { throw new RuntimeException("Stub!"); }
+@libcore.util.Nullable public <A extends java.lang.annotation.Annotation> A getAnnotation(@libcore.util.NonNull java.lang.Class<A> annotationClass) { throw new RuntimeException("Stub!"); }
public boolean isAnnotationPresent(@libcore.util.NonNull java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass) { throw new RuntimeException("Stub!"); }
diff --git a/ojluni/annotations/sdk/nullability/java/lang/StringBuilder.annotated.java b/ojluni/annotations/sdk/nullability/java/lang/StringBuilder.annotated.java
index 9ec4039..6fdde8a 100644
--- a/ojluni/annotations/sdk/nullability/java/lang/StringBuilder.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/lang/StringBuilder.annotated.java
@@ -119,11 +119,11 @@
public void setCharAt(int index, char ch) { throw new RuntimeException("Stub!"); }
-public java.lang.CharSequence subSequence(int start, int end) { throw new RuntimeException("Stub!"); }
+@libcore.util.NonNull public java.lang.CharSequence subSequence(int start, int end) { throw new RuntimeException("Stub!"); }
-public java.lang.String substring(int start) { throw new RuntimeException("Stub!"); }
+@libcore.util.NonNull public java.lang.String substring(int start) { throw new RuntimeException("Stub!"); }
-public java.lang.String substring(int start, int end) { throw new RuntimeException("Stub!"); }
+@libcore.util.NonNull public java.lang.String substring(int start, int end) { throw new RuntimeException("Stub!"); }
public int capacity() { throw new RuntimeException("Stub!"); }
diff --git a/ojluni/annotations/sdk/nullability/java/lang/System.annotated.java b/ojluni/annotations/sdk/nullability/java/lang/System.annotated.java
index b39f09a..4cd1c31 100644
--- a/ojluni/annotations/sdk/nullability/java/lang/System.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/lang/System.annotated.java
@@ -76,7 +76,7 @@
@libcore.util.Nullable public static java.lang.String getenv(@libcore.util.NonNull java.lang.String name) { throw new RuntimeException("Stub!"); }
-public static java.util.Map<java.lang.String,java.lang.String> getenv() { throw new RuntimeException("Stub!"); }
+@libcore.util.NonNull public static java.util.Map<java.lang.String,java.lang.String> getenv() { throw new RuntimeException("Stub!"); }
public static void exit(int status) { throw new RuntimeException("Stub!"); }
diff --git a/ojluni/annotations/sdk/nullability/java/lang/ThreadLocal.annotated.java b/ojluni/annotations/sdk/nullability/java/lang/ThreadLocal.annotated.java
index 3b7e93a..b8cf527 100644
--- a/ojluni/annotations/sdk/nullability/java/lang/ThreadLocal.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/lang/ThreadLocal.annotated.java
@@ -37,7 +37,7 @@
@libcore.util.Nullable protected T initialValue() { throw new RuntimeException("Stub!"); }
-public static <S> java.lang.ThreadLocal<S> withInitial(@libcore.util.NonNull java.util.function.Supplier<? extends S> supplier) { throw new RuntimeException("Stub!"); }
+@libcore.util.NonNull public static <S> java.lang.ThreadLocal<S> withInitial(@libcore.util.NonNull java.util.function.Supplier<? extends S> supplier) { throw new RuntimeException("Stub!"); }
@libcore.util.Nullable public T get() { throw new RuntimeException("Stub!"); }
@@ -45,4 +45,3 @@
public void remove() { throw new RuntimeException("Stub!"); }
}
-
diff --git a/ojluni/annotations/sdk/nullability/java/util/List.annotated.java b/ojluni/annotations/sdk/nullability/java/util/List.annotated.java
index 958b335..2ef4a6f 100644
--- a/ojluni/annotations/sdk/nullability/java/util/List.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/util/List.annotated.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -86,4 +86,29 @@
@libcore.util.NonNull public java.util.List<@libcore.util.NullFromTypeParam E> subList(int fromIndex, int toIndex);
@libcore.util.NonNull public default java.util.Spliterator<@libcore.util.NullFromTypeParam E> spliterator() { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of() { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7, @libcore.util.NonNull E e8) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7, @libcore.util.NonNull E e8, @libcore.util.NonNull E e9) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7, @libcore.util.NonNull E e8, @libcore.util.NonNull E e9, @libcore.util.NonNull E e10) { throw new RuntimeException("Stub!"); }
+
+@java.lang.SafeVarargs
+@libcore.util.NonNull public static <E> java.util.List<@libcore.util.NonNull E> of(E @libcore.util.NonNull ... elements) { throw new RuntimeException("Stub!"); }
}
diff --git a/ojluni/annotations/sdk/nullability/java/util/Map.annotated.java b/ojluni/annotations/sdk/nullability/java/util/Map.annotated.java
index 4008996..c19add2 100644
--- a/ojluni/annotations/sdk/nullability/java/util/Map.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/util/Map.annotated.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -80,6 +80,33 @@
@libcore.util.Nullable public default V compute(@libcore.util.NullFromTypeParam K key, @libcore.util.NonNull java.util.function.BiFunction<? super @libcore.util.NullFromTypeParam K,? super @libcore.util.Nullable V,? extends @libcore.util.Nullable V> remappingFunction) { throw new RuntimeException("Stub!"); }
@libcore.util.Nullable public default V merge(@libcore.util.NullFromTypeParam K key, @libcore.util.NonNull V value, @libcore.util.NonNull java.util.function.BiFunction<? super @libcore.util.NonNull V,? super @libcore.util.NonNull V,? extends @libcore.util.Nullable V> remappingFunction) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of() { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4, @libcore.util.NonNull K k5, @libcore.util.NonNull V v5) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4, @libcore.util.NonNull K k5, @libcore.util.NonNull V v5, @libcore.util.NonNull K k6, @libcore.util.NonNull V v6) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4, @libcore.util.NonNull K k5, @libcore.util.NonNull V v5, @libcore.util.NonNull K k6, @libcore.util.NonNull V v6, @libcore.util.NonNull K k7, @libcore.util.NonNull V v7) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4, @libcore.util.NonNull K k5, @libcore.util.NonNull V v5, @libcore.util.NonNull K k6, @libcore.util.NonNull V v6, @libcore.util.NonNull K k7, @libcore.util.NonNull V v7, @libcore.util.NonNull K k8, @libcore.util.NonNull V v8) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4, @libcore.util.NonNull K k5, @libcore.util.NonNull V v5, @libcore.util.NonNull K k6, @libcore.util.NonNull V v6, @libcore.util.NonNull K k7, @libcore.util.NonNull V v7, @libcore.util.NonNull K k8, @libcore.util.NonNull V v8, @libcore.util.NonNull K k9, @libcore.util.NonNull V v9) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> of(@libcore.util.NonNull K k1, @libcore.util.NonNull V v1, @libcore.util.NonNull K k2, @libcore.util.NonNull V v2, @libcore.util.NonNull K k3, @libcore.util.NonNull V v3, @libcore.util.NonNull K k4, @libcore.util.NonNull V v4, @libcore.util.NonNull K k5, @libcore.util.NonNull V v5, @libcore.util.NonNull K k6, @libcore.util.NonNull V v6, @libcore.util.NonNull K k7, @libcore.util.NonNull V v7, @libcore.util.NonNull K k8, @libcore.util.NonNull V v8, @libcore.util.NonNull K k9, @libcore.util.NonNull V v9, @libcore.util.NonNull K k10, @libcore.util.NonNull V v10) { throw new RuntimeException("Stub!"); }
+
+@java.lang.SafeVarargs
+@libcore.util.NonNull public static <K, V> java.util.Map<@libcore.util.NonNull K, @libcore.util.NonNull V> ofEntries(@libcore.util.NonNull java.util.Map.Entry<? extends @libcore.util.NonNull K,? extends @libcore.util.NonNull V>... entries) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <K, V> java.util.Map.Entry<@libcore.util.NonNull K, @libcore.util.NonNull V> entry(@libcore.util.NonNull K k, @libcore.util.NonNull V v) { throw new RuntimeException("Stub!"); }
@SuppressWarnings({"unchecked", "deprecation", "all"})
public static interface Entry<K, V> {
diff --git a/ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java b/ojluni/annotations/sdk/nullability/java/util/Objects.annotated.java
index 591a022..ee1b692 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 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!"); }
}
diff --git a/ojluni/annotations/sdk/nullability/java/util/Set.annotated.java b/ojluni/annotations/sdk/nullability/java/util/Set.annotated.java
index 1257b5c..bae8bdd 100644
--- a/ojluni/annotations/sdk/nullability/java/util/Set.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/util/Set.annotated.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -62,4 +62,29 @@
public int hashCode();
@libcore.util.NonNull public default java.util.Spliterator<@libcore.util.NullFromTypeParam E> spliterator() { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of() { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7, @libcore.util.NonNull E e8) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7, @libcore.util.NonNull E e8, @libcore.util.NonNull E e9) { throw new RuntimeException("Stub!"); }
+
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(@libcore.util.NonNull E e1, @libcore.util.NonNull E e2, @libcore.util.NonNull E e3, @libcore.util.NonNull E e4, @libcore.util.NonNull E e5, @libcore.util.NonNull E e6, @libcore.util.NonNull E e7, @libcore.util.NonNull E e8, @libcore.util.NonNull E e9, @libcore.util.NonNull E e10) { throw new RuntimeException("Stub!"); }
+
+@java.lang.SafeVarargs
+@libcore.util.NonNull public static <E> java.util.Set<@libcore.util.NonNull E> of(E @libcore.util.NonNull ... elements) { throw new RuntimeException("Stub!"); }
}
diff --git a/ojluni/src/main/java/java/io/FilterOutputStream.java b/ojluni/src/main/java/java/io/FilterOutputStream.java
index 209e63b..89f5ef5 100644
--- a/ojluni/src/main/java/java/io/FilterOutputStream.java
+++ b/ojluni/src/main/java/java/io/FilterOutputStream.java
@@ -48,6 +48,12 @@
*/
protected OutputStream out;
+ // Android-added: Integrate OpenJDK 9 fix for double-close. http://b/122733269.
+ /**
+ * Whether the stream is closed; implicitly initialized to false.
+ */
+ private boolean closed;
+
/**
* Creates an output stream filter built on top of the specified
* underlying output stream.
@@ -144,18 +150,58 @@
* Closes this output stream and releases any system resources
* associated with the stream.
* <p>
- * The <code>close</code> method of <code>FilterOutputStream</code>
- * calls its <code>flush</code> method, and then calls the
- * <code>close</code> method of its underlying output stream.
+ * When not already closed, the {@code close} method of {@code
+ * FilterOutputStream} calls its {@code flush} method, and then
+ * calls the {@code close} method of its underlying output stream.
*
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#flush()
* @see java.io.FilterOutputStream#out
*/
+ // BEGIN Android-changed: Integrate OpenJDK 9 fix for double-close. http://b/122733269.
+ /*
@SuppressWarnings("try")
public void close() throws IOException {
try (OutputStream ostream = out) {
flush();
}
}
+ */
+ @Override
+ public void close() throws IOException {
+ if (closed) {
+ return;
+ }
+ closed = true;
+
+ Throwable flushException = null;
+ try {
+ flush();
+ } catch (Throwable e) {
+ flushException = e;
+ throw e;
+ } finally {
+ if (flushException == null) {
+ out.close();
+ } else {
+ try {
+ out.close();
+ } catch (Throwable closeException) {
+ // evaluate possible precedence of flushException over closeException
+ if ((flushException instanceof ThreadDeath) &&
+ !(closeException instanceof ThreadDeath)) {
+ flushException.addSuppressed(closeException);
+ throw (ThreadDeath) flushException;
+ }
+
+ if (flushException != closeException) {
+ closeException.addSuppressed(flushException);
+ }
+
+ throw closeException;
+ }
+ }
+ }
+ }
+ // END Android-changed: Integrate OpenJDK 9 fix for double-close. http://b/122733269.
}
diff --git a/ojluni/src/main/java/java/lang/Runtime.java b/ojluni/src/main/java/java/lang/Runtime.java
index bb0bcb4..f5c52e7 100644
--- a/ojluni/src/main/java/java/lang/Runtime.java
+++ b/ojluni/src/main/java/java/lang/Runtime.java
@@ -35,7 +35,8 @@
import java.lang.ref.FinalizerReference;
import java.util.ArrayList;
import java.util.List;
-import dalvik.system.BaseDexClassLoader;
+import dalvik.system.DelegateLastClassLoader;
+import dalvik.system.PathClassLoader;
import dalvik.system.VMDebug;
import dalvik.system.VMRuntime;
import sun.reflect.Reflection;
@@ -1058,6 +1059,21 @@
// have returned null; therefore we treat BootClassLoader the same as null here.
if (loader != null && !(loader instanceof BootClassLoader)) {
String filename = loader.findLibrary(libraryName);
+ if (filename == null &&
+ (loader.getClass() == PathClassLoader.class ||
+ loader.getClass() == DelegateLastClassLoader.class)) {
+ // Don't give up even if we failed to find the library in the native lib paths.
+ // The underlying dynamic linker might be able to find the lib in one of the linker
+ // namespaces associated with the current linker namespace. In order to give the
+ // dynamic linker a chance, proceed to load the library with its soname, which
+ // is the fileName.
+ // Note that we do this only for PathClassLoader and DelegateLastClassLoader to
+ // minimize the scope of this behavioral change as much as possible, which might
+ // cause problem like b/143649498. These two class loaders are the only
+ // platform-provided class loaders that can load apps. See the classLoader attribute
+ // of the application tag in app manifest.
+ filename = System.mapLibraryName(libraryName);
+ }
if (filename == null) {
// It's not necessarily true that the ClassLoader used
// System.mapLibraryName, but the default setup does, and it's
diff --git a/ojluni/src/main/java/java/lang/System.java b/ojluni/src/main/java/java/lang/System.java
index 8235bf7..9cec068 100644
--- a/ojluni/src/main/java/java/lang/System.java
+++ b/ojluni/src/main/java/java/lang/System.java
@@ -25,20 +25,18 @@
*/
package java.lang;
+import com.android.icu.util.Icu4cMetadata;
import dalvik.annotation.optimization.FastNative;
import android.system.ErrnoException;
import android.system.StructPasswd;
import android.system.StructUtsname;
import dalvik.system.VMRuntime;
import java.io.*;
-import java.lang.annotation.Annotation;
import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider;
import java.util.Locale;
-import java.util.Map;
import java.util.Properties;
import java.util.PropertyPermission;
-import libcore.icu.ICU;
import libcore.io.Libcore;
import libcore.timezone.TimeZoneDataFiles;
@@ -1000,9 +998,9 @@
p.put("os.version", info.release);
// Android-added: Undocumented properties that exist only on Android.
- p.put("android.icu.library.version", ICU.getIcuVersion());
- p.put("android.icu.unicode.version", ICU.getUnicodeVersion());
- p.put("android.icu.cldr.version", ICU.getCldrVersion());
+ p.put("android.icu.library.version", Icu4cMetadata.getIcuVersion());
+ p.put("android.icu.unicode.version", Icu4cMetadata.getUnicodeVersion());
+ p.put("android.icu.cldr.version", Icu4cMetadata.getCldrVersion());
// Property override for ICU4J : this is the location of the ICU4C data. This
// is prioritized over the properties in ICUConfig.properties. The issue with using
diff --git a/ojluni/src/main/java/java/lang/Thread.java b/ojluni/src/main/java/java/lang/Thread.java
index 2e2af6a..699a1ac 100644
--- a/ojluni/src/main/java/java/lang/Thread.java
+++ b/ojluni/src/main/java/java/lang/Thread.java
@@ -40,6 +40,8 @@
import java.util.concurrent.locks.LockSupport;
import sun.nio.ch.Interruptible;
import sun.reflect.CallerSensitive;
+import dalvik.system.RuntimeHooks;
+import dalvik.system.ThreadPrioritySetter;
import dalvik.system.VMStack;
import libcore.util.EmptyArray;
@@ -1244,7 +1246,18 @@
synchronized(this) {
this.priority = newPriority;
if (isAlive()) {
- setPriority0(newPriority);
+ // BEGIN Android-added: Customize behavior of Thread.setPriority().
+ // http://b/139521784
+ // setPriority0(newPriority);
+ ThreadPrioritySetter threadPrioritySetter =
+ RuntimeHooks.getThreadPrioritySetter();
+ int nativeTid = this.getNativeTid();
+ if (threadPrioritySetter != null && nativeTid != 0) {
+ threadPrioritySetter.setPriority(nativeTid, newPriority);
+ } else {
+ setPriority0(newPriority);
+ }
+ // END Android-added: Customize behavior of Thread.setPriority().
}
}
}
@@ -2327,4 +2340,14 @@
// Android-added: Android specific nativeGetStatus() method.
private native int nativeGetStatus(boolean hasBeenStarted);
+
+ // BEGIN Android-added: Customize behavior of Thread.setPriority(). http://b/139521784
+ /**
+ * Returns the thread ID of the underlying native thread -- which is different from
+ * the {@link #getId() managed thread ID} -- or 0 if the native thread is not
+ * started or has stopped.
+ */
+ @FastNative
+ private native int getNativeTid();
+ // END Android-added: Customize behavior of Thread.setPriority(). http://b/139521784
}
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandles.java b/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
index 3b39fbd..1188ac6 100644
--- a/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
@@ -2597,15 +2597,24 @@
MethodType oldType = target.type();
if (oldType == newType) return target;
if (oldType.explicitCastEquivalentToAsType(newType)) {
- return target.asFixedArity().asType(newType);
+ if (Transformers.Transformer.class.isAssignableFrom(target.getClass())) {
+ // The StackFrameReader and StackFrameWriter used to perform transforms on
+ // EmulatedStackFrames (in Transformers.java) do not how to perform asType()
+ // conversions, but we know here that an explicit cast transform is the same as
+ // having called asType() on the method handle.
+ return new Transformers.ExplicitCastArguments(target.asFixedArity(), newType);
+ } else {
+ // Runtime will perform asType() conversion during invocation.
+ return target.asFixedArity().asType(newType);
+ }
}
-
return new Transformers.ExplicitCastArguments(target, newType);
}
private static void explicitCastArgumentsChecks(MethodHandle target, MethodType newType) {
if (target.type().parameterCount() != newType.parameterCount()) {
- throw new WrongMethodTypeException("cannot explicitly cast " + target + " to " + newType);
+ throw new WrongMethodTypeException("cannot explicitly cast " + target +
+ " to " + newType);
}
}
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodType.java b/ojluni/src/main/java/java/lang/invoke/MethodType.java
index b2ff6e7..4652c93 100644
--- a/ojluni/src/main/java/java/lang/invoke/MethodType.java
+++ b/ojluni/src/main/java/java/lang/invoke/MethodType.java
@@ -894,9 +894,6 @@
return true;
}
- // Android-changed: Temporary workaround for bug in MethodHandle.asType(MethodType).
- // See http://b/113855305 for more details
- // Update documentation to describe new behavior.
/** Reports true if the src can be converted to the dst, by both asType and MHs.eCE,
* and with the same effect.
* MHs.eCA has the following "upgrades" to MH.asType:
@@ -914,9 +911,7 @@
*/
private static boolean explicitCastEquivalentToAsType(Class<?> src, Class<?> dst) {
if (src == dst || dst == Object.class || dst == void.class) return true;
- // Android-changed: Temporary workaround for bug in MethodHandle.asType(MethodType).
- // if (src.isPrimitive()) {
- if (src.isPrimitive() && src != void.class) {
+ if (src.isPrimitive()) {
// Could be a prim/prim conversion, where casting is a strict superset.
// Or a boxing conversion, which is always to an exact wrapper class.
return canConvert(src, dst);
diff --git a/ojluni/src/main/java/java/lang/invoke/Transformers.java b/ojluni/src/main/java/java/lang/invoke/Transformers.java
index fc8727a..15546a8 100644
--- a/ojluni/src/main/java/java/lang/invoke/Transformers.java
+++ b/ojluni/src/main/java/java/lang/invoke/Transformers.java
@@ -417,7 +417,7 @@
@Override
public void transform(EmulatedStackFrame emulatedStackFrame) throws Throwable {
- final Class<?> receiverType = type().rtype();
+ final Class<?> receiverType = constructorHandle.type().parameterType(0);
checkInstantiable(receiverType);
// Allocate memory for receiver.
@@ -1827,27 +1827,9 @@
throw new InternalError("Unexpected type: " + unexpectedType);
}
- private static void explicitCastFromBoolean(boolean fromValue,
- final StackFrameWriter writer,
- final Class<?> to) {
- int value = fromValue ? 1 : 0;
- if (to == byte.class) {
- writer.putNextByte((byte) value);
- } else if (to == char.class) {
- writer.putNextChar((char) value);
- } else if (to == short.class) {
- writer.putNextShort((short) value);
- } else if (to == int.class) {
- writer.putNextInt(value);
- } else if (to == long.class) {
- writer.putNextLong(value);
- } else if (to == float.class) {
- writer.putNextFloat(value);
- } else if (to == double.class) {
- writer.putNextDouble(value);
- } else {
- throwUnexpectedType(to);
- }
+ @SuppressWarnings("unchecked")
+ private static void badCast(final Class<?> from, final Class<?> to) {
+ throw new ClassCastException("Cannot cast " + from.getName() + " to " + to.getName());
}
/**
@@ -1874,6 +1856,8 @@
return (byte) reader.nextFloat();
} else if (from == double.class) {
return (byte) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? (byte) 1 : (byte) 0;
} else {
throwUnexpectedType(from);
return 0;
@@ -1896,6 +1880,8 @@
return (char) reader.nextFloat();
} else if (from == double.class) {
return (char) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? (char) 1 : (char) 0;
} else {
throwUnexpectedType(from);
return 0;
@@ -1918,6 +1904,8 @@
return (short) reader.nextFloat();
} else if (from == double.class) {
return (short) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? (short) 1 : (short) 0;
} else {
throwUnexpectedType(from);
return 0;
@@ -1940,6 +1928,8 @@
return (int) reader.nextFloat();
} else if (from == double.class) {
return (int) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? 1 : 0;
} else {
throwUnexpectedType(from);
return 0;
@@ -1962,6 +1952,8 @@
return (long) reader.nextFloat();
} else if (from == double.class) {
return (long) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? 1L : 0L;
} else {
throwUnexpectedType(from);
return 0;
@@ -1984,6 +1976,8 @@
return (float) reader.nextFloat();
} else if (from == double.class) {
return (float) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? 1.0f : 0.0f;
} else {
throwUnexpectedType(from);
return 0;
@@ -2006,19 +2000,14 @@
return (double) reader.nextFloat();
} else if (from == double.class) {
return (double) reader.nextDouble();
+ } else if (from == boolean.class) {
+ return reader.nextBoolean() ? 1.0 : 0.0;
} else {
throwUnexpectedType(from);
return 0;
}
}
- private static void explicitCastToBoolean(final StackFrameReader reader,
- final Class<?> from,
- final StackFrameWriter writer) {
- byte byteValue = readPrimitiveAsByte(reader, from);
- writer.putNextBoolean(toBoolean(byteValue));
- }
-
private static void explicitCastPrimitives(final StackFrameReader reader,
final Class<?> from,
final StackFrameWriter writer,
@@ -2044,6 +2033,9 @@
} else if (to == double.class) {
double value = readPrimitiveAsDouble(reader, from);
writer.putNextDouble(value);
+ } else if (to == boolean.class) {
+ byte byteValue = readPrimitiveAsByte(reader, from);
+ writer.putNextBoolean(toBoolean(byteValue));
} else {
throwUnexpectedType(to);
}
@@ -2073,32 +2065,176 @@
private static void unboxNonNull(final Object ref, final Class<?> from,
final StackFrameWriter writer, final Class<?> to) {
- if (to == boolean.class) {
- if (from == Boolean.class) {
- writer.putNextBoolean((boolean) ref);
- } else if (from == Float.class || from == Double.class) {
- byte b = (byte) ((double) ref);
- writer.putNextBoolean(toBoolean(b));
+ if (from == Boolean.class) {
+ boolean z = (boolean) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean(z);
+ } else if (to == byte.class) {
+ writer.putNextByte(z ? (byte) 1 : (byte) 0);
+ } else if (to == short.class) {
+ writer.putNextShort(z ? (short) 1 : (short) 0);
+ } else if (to == char.class) {
+ writer.putNextChar(z ? (char) 1 : (char) 0);
+ } else if (to == int.class) {
+ writer.putNextInt(z ? 1 : 0);
+ } else if (to == long.class) {
+ writer.putNextLong(z ? 1l : 0l);
+ } else if (to == float.class) {
+ writer.putNextFloat(z ? 1.0f : 0.0f);
+ } else if (to == double.class) {
+ writer.putNextDouble(z ? 1.0 : 0.0);
} else {
- byte b = (byte) ((long) ref);
- writer.putNextBoolean(toBoolean(b));
+ badCast(from, to);
}
- } else if (to == byte.class) {
- writer.putNextByte((byte) ref);
- } else if (to == char.class) {
- writer.putNextChar((char) ref);
- } else if (to == short.class) {
- writer.putNextShort((short) ref);
- } else if (to == int.class) {
- writer.putNextInt((int) ref);
- } else if (to == long.class) {
- writer.putNextLong((long) ref);
- } else if (to == float.class) {
- writer.putNextFloat((float) ref);
- } else if (to == double.class) {
- writer.putNextDouble((double) ref);
+ } else if (from == Byte.class) {
+ byte b = (byte) ref;
+ if (to == byte.class) {
+ writer.putNextByte(b);
+ } else if (to == boolean.class) {
+ writer.putNextBoolean(toBoolean(b));
+ } else if (to == short.class) {
+ writer.putNextShort((short) b);
+ } else if (to == char.class) {
+ writer.putNextChar((char) b);
+ } else if (to == int.class) {
+ writer.putNextInt((int) b);
+ } else if (to == long.class) {
+ writer.putNextLong((long) b);
+ } else if (to == float.class) {
+ writer.putNextFloat((float) b);
+ } else if (to == double.class) {
+ writer.putNextDouble((double) b);
+ } else {
+ badCast(from, to);
+ }
+ } else if (from == Short.class) {
+ short s = (short) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean((s & 1) == 1);
+ } else if (to == byte.class) {
+ writer.putNextByte((byte) s);
+ } else if (to == short.class) {
+ writer.putNextShort(s);
+ } else if (to == char.class) {
+ writer.putNextChar((char) s);
+ } else if (to == int.class) {
+ writer.putNextInt((int) s);
+ } else if (to == long.class) {
+ writer.putNextLong((long) s);
+ } else if (to == float.class) {
+ writer.putNextFloat((float) s);
+ } else if (to == double.class) {
+ writer.putNextDouble((double) s);
+ } else {
+ badCast(from, to);
+ }
+ } else if (from == Character.class) {
+ char c = (char) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean((c & (char) 1) == (char) 1);
+ } else if (to == byte.class) {
+ writer.putNextByte((byte) c);
+ } else if (to == short.class) {
+ writer.putNextShort((short) c);
+ } else if (to == char.class) {
+ writer.putNextChar(c);
+ } else if (to == int.class) {
+ writer.putNextInt((int) c);
+ } else if (to == long.class) {
+ writer.putNextLong((long) c);
+ } else if (to == float.class) {
+ writer.putNextFloat((float) c);
+ } else if (to == double.class) {
+ writer.putNextDouble((double) c);
+ } else {
+ badCast(from, to);
+ }
+ } else if (from == Integer.class) {
+ int i = (int) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean((i & 1) == 1);
+ } else if (to == byte.class) {
+ writer.putNextByte((byte) i);
+ } else if (to == short.class) {
+ writer.putNextShort((short) i);
+ } else if (to == char.class) {
+ writer.putNextChar((char) i);
+ } else if (to == int.class) {
+ writer.putNextInt(i);
+ } else if (to == long.class) {
+ writer.putNextLong((long) i);
+ } else if (to == float.class) {
+ writer.putNextFloat((float) i);
+ } else if (to == double.class) {
+ writer.putNextDouble((double) i);
+ } else {
+ badCast(from, to);
+ }
+ } else if (from == Long.class) {
+ long j = (long) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean((j & 1l) == 1l);
+ } else if (to == byte.class) {
+ writer.putNextByte((byte) j);
+ } else if (to == short.class) {
+ writer.putNextShort((short) j);
+ } else if (to == char.class) {
+ writer.putNextChar((char) j);
+ } else if (to == int.class) {
+ writer.putNextInt((int) j);
+ } else if (to == long.class) {
+ writer.putNextLong(j);
+ } else if (to == float.class) {
+ writer.putNextFloat((float) j);
+ } else if (to == double.class) {
+ writer.putNextDouble((double) j);
+ } else {
+ badCast(from, to);
+ }
+ } else if (from == Float.class) {
+ float f = (float) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean(((byte) f & 1) != 0);
+ } else if (to == byte.class) {
+ writer.putNextByte((byte) f);
+ } else if (to == short.class) {
+ writer.putNextShort((short) f);
+ } else if (to == char.class) {
+ writer.putNextChar((char) f);
+ } else if (to == int.class) {
+ writer.putNextInt((int) f);
+ } else if (to == long.class) {
+ writer.putNextLong((long) f);
+ } else if (to == float.class) {
+ writer.putNextFloat(f);
+ } else if (to == double.class) {
+ writer.putNextDouble((double) f);
+ } else {
+ badCast(from, to);
+ }
+ } else if (from == Double.class) {
+ double d = (double) ref;
+ if (to == boolean.class) {
+ writer.putNextBoolean(((byte) d & 1) != 0);
+ } else if (to == byte.class) {
+ writer.putNextByte((byte) d);
+ } else if (to == short.class) {
+ writer.putNextShort((short) d);
+ } else if (to == char.class) {
+ writer.putNextChar((char) d);
+ } else if (to == int.class) {
+ writer.putNextInt((int) d);
+ } else if (to == long.class) {
+ writer.putNextLong((long) d);
+ } else if (to == float.class) {
+ writer.putNextFloat((float) d);
+ } else if (to == double.class) {
+ writer.putNextDouble(d);
+ } else {
+ badCast(from, to);
+ }
} else {
- throwUnexpectedType(to);
+ badCast(from, to);
}
}
@@ -2140,31 +2276,31 @@
final StackFrameWriter writer, final Class<?> to) {
if (from.equals(to)) {
StackFrameAccessor.copyNext(reader, writer, from);
- } else if (!from.isPrimitive()) {
+ return;
+ }
+
+ if (from.isPrimitive()) {
+ if (to.isPrimitive()) {
+ // |from| and |to| are primitive types.
+ explicitCastPrimitives(reader, from, writer, to);
+ } else {
+ // |from| is a primitive type, |to| is a reference type.
+ box(reader, from, writer, to);
+ }
+ } else {
+ // |from| is a reference type.
Object ref = reader.nextReference(from);
- if (to.isInterface()) {
+ if (to.isPrimitive()) {
+ // |from| is a reference type, |to| is a primitive type,
+ unbox(ref, from, writer, to);
+ } else if (to.isInterface()) {
// Pass from without a cast according to description for
// {@link java.lang.invoke.MethodHandles#explicitCastArguments()}.
writer.putNextReference(ref, to);
- } else if (!to.isPrimitive()) {
- // |to| is a reference type, perform class cast check.
+ } else {
+ // |to| and from |from| are reference types, perform class cast check.
writer.putNextReference(to.cast(ref), to);
- } else {
- // |from| is a reference type, |to| is a primitive type,
- unbox(ref, from, writer, to);
}
- } else if (to.isPrimitive()) {
- // |from| and |to| are primitive types.
- if (from == boolean.class) {
- explicitCastFromBoolean(reader.nextBoolean(), writer, to);
- } else if (to == boolean.class) {
- explicitCastToBoolean(reader, from, writer);
- } else {
- explicitCastPrimitives(reader, from, writer, to);
- }
- } else {
- // |from| is a primitive type, |to| is a reference type.
- box(reader, from, writer, to);
}
}
}
diff --git a/ojluni/src/main/java/java/net/Inet6AddressImpl.java b/ojluni/src/main/java/java/net/Inet6AddressImpl.java
index 29ccda2..84bcf17 100644
--- a/ojluni/src/main/java/java/net/Inet6AddressImpl.java
+++ b/ojluni/src/main/java/java/net/Inet6AddressImpl.java
@@ -258,7 +258,7 @@
byte[] packet;
// ICMP is unreliable, try sending requests every second until timeout.
- for (int to = timeout, seq = 0; to > 0; ++seq) {
+ for (int to = timeout, seq = 1; to > 0; ++seq) {
int sockTo = to >= 1000 ? 1000 : to;
IoBridge.setSocketOption(fd, SocketOptions.SO_TIMEOUT, sockTo);
@@ -277,11 +277,11 @@
if (receivedPacket.getAddress().equals(addr)
&& received[0] == expectedType
&& received[4] == (byte) (icmpId >> 8)
- && received[5] == (byte) icmpId
- && received[6] == (byte) (seq >> 8)
- && received[7] == (byte) seq) {
- // This is the packet we're expecting.
- return true;
+ && received[5] == (byte) icmpId) {
+ int receivedSequence = ((received[6] & 0xff) << 8) + (received[7] & 0xff);
+ if (receivedSequence <= seq) {
+ return true;
+ }
}
}
to -= sockTo;
diff --git a/ojluni/src/main/java/java/net/NetworkInterface.java b/ojluni/src/main/java/java/net/NetworkInterface.java
index 673a1d2..c8044fd 100644
--- a/ojluni/src/main/java/java/net/NetworkInterface.java
+++ b/ojluni/src/main/java/java/net/NetworkInterface.java
@@ -47,6 +47,7 @@
// Android-note: NetworkInterface has been rewritten to avoid native code.
// Fix upstream bug not returning link-down interfaces. http://b/26238832
+// Android-added: Document restrictions for targetSdkVersion > 29. http://b/141455849
/**
* This class represents a Network Interface made up of a name,
* and a list of IP addresses assigned to this interface.
@@ -54,6 +55,12 @@
* is joined.
*
* Interfaces are normally known by names such as "le0".
+ * <p>
+ * <a name="access-restrictions"></a>Note that information about
+ * {@link NetworkInterface}s may be restricted. For example, non-system apps
+ * with {@code targetSdkVersion > 29} will only have access to information
+ * about {@link NetworkInterface}s that are associated with an
+ * {@link InetAddress}.
*
* @since 1.4
*/
@@ -265,6 +272,7 @@
return "".equals(displayName) ? null : displayName;
}
+ // Android-added: Document restrictions for targetSdkVersion > 29. http://b/141455849
/**
* Searches for the network interface with the specified name.
*
@@ -272,8 +280,9 @@
* The name of the network interface.
*
* @return A {@code NetworkInterface} with the specified name,
- * or {@code null} if there is no network interface
- * with the specified name.
+ * or {@code null} if the network interface with the specified
+ * name does not exist or <a href="#access-restrictions">can't be
+ * accessed</a>.
*
* @throws SocketException
* If an I/O error occurs.
@@ -295,12 +304,14 @@
return null;
}
+ // Android-added: Document restrictions for targetSdkVersion > 29. http://b/141455849
/**
* Get a network interface given its index.
*
* @param index an integer, the index of the interface
* @return the NetworkInterface obtained from its index, or {@code null} if
- * there is no interface with such an index on the system
+ * an interface with the specified index does not exist or
+ * <a href="#access-restrictions">can't be accessed</a>.
* @throws SocketException if an I/O error occurs.
* @throws IllegalArgumentException if index has a negative value
* @see #getIndex()
@@ -362,6 +373,7 @@
return null;
}
+ // Android-added: Document restrictions for targetSdkVersion > 29. http://b/141455849
/**
* Returns all the interfaces on this machine. The {@code Enumeration}
* contains at least one element, possibly representing a loopback
@@ -370,20 +382,43 @@
*
* NOTE: can use getNetworkInterfaces()+getInetAddresses()
* to obtain all IP addresses for this node
+ * <p>
+ * For non-system apps with {@code targetSdkVersion > 29}, this
+ * method will only return information for {@link NetworkInterface}s that
+ * are associated with an {@link InetAddress}.
*
* @return an Enumeration of NetworkInterfaces found on this machine
+ * that <a href="#access-restrictions">are accessible</a>.
* @exception SocketException if an I/O error occurs.
*/
public static Enumeration<NetworkInterface> getNetworkInterfaces()
throws SocketException {
final NetworkInterface[] netifs = getAll();
-
// Android-changed: Rewrote NetworkInterface on top of Libcore.io.
- // specified to return null if no network interfaces
+ // // specified to return null if no network interfaces
+ // if (netifs == null)
if (netifs.length == 0)
return null;
+ // Android-changed: Rewrote NetworkInterface on top of Libcore.io.
+ /*
+ return new Enumeration<NetworkInterface>() {
+ private int i = 0;
+ public NetworkInterface nextElement() {
+ if (netifs != null && i < netifs.length) {
+ NetworkInterface netif = netifs[i++];
+ return netif;
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+
+ public boolean hasMoreElements() {
+ return (netifs != null && i < netifs.length);
+ }
+ };
+ */
return Collections.enumeration(Arrays.asList(netifs));
}
@@ -523,6 +558,7 @@
return (getFlags() & IFF_MULTICAST) != 0;
}
+ // Android-added: Document restrictions for targetSdkVersion > 29. http://b/141455849
/**
* Returns the hardware address (usually MAC) of the interface if it
* has one and if it can be accessed given the current privileges.
@@ -532,7 +568,9 @@
* @return a byte array containing the address, or {@code null} if
* the address doesn't exist, is not accessible or a security
* manager is set and the caller does not have the permission
- * NetPermission("getNetworkInformation")
+ * NetPermission("getNetworkInformation"). For example, this
+ * method will generally return {@code null} when called by
+ * non-system apps targeting API levels > 29.
*
* @exception SocketException if an I/O error occurs.
* @since 1.6
diff --git a/ojluni/src/main/java/java/nio/charset/Charset.java b/ojluni/src/main/java/java/nio/charset/Charset.java
index f5c097e..5a3b35a 100755
--- a/ojluni/src/main/java/java/nio/charset/Charset.java
+++ b/ojluni/src/main/java/java/nio/charset/Charset.java
@@ -26,13 +26,12 @@
package java.nio.charset;
+import com.android.icu.charset.CharsetICU;
import java.io.UnsupportedEncodingException;
-import libcore.icu.NativeConverter;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.spi.CharsetProvider;
import java.security.AccessController;
-import java.security.AccessControlException;
import java.security.PrivilegedAction;
import java.util.AbstractMap;
import java.util.Collections;
@@ -509,7 +508,7 @@
// Android-changed: Drop support for "standard" and "extended"
// providers.
- if ((cs = NativeConverter.charsetForName(charsetName)) != null ||
+ if ((cs = CharsetICU.charsetForName(charsetName)) != null ||
(cs = lookupViaProviders(charsetName)) != null)
{
cache(charsetName, cs);
@@ -629,8 +628,8 @@
TreeMap<String,Charset> m =
new TreeMap<String,Charset>(
ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
- for (String charsetName : NativeConverter.getAvailableCharsetNames()) {
- Charset charset = NativeConverter.charsetForName(charsetName);
+ for (String charsetName : CharsetICU.getAvailableCharsetNames()) {
+ Charset charset = CharsetICU.charsetForName(charsetName);
m.put(charset.name(), charset);
}
// Android-changed: No more "standard" provider.
@@ -686,6 +685,7 @@
* @throws IllegalCharsetNameException
* If the canonical name or any of the aliases are illegal
*/
+ @libcore.api.IntraCoreApi
protected Charset(String canonicalName, String[] aliases) {
checkName(canonicalName);
String[] as = (aliases == null) ? new String[0] : aliases;
diff --git a/ojluni/src/main/java/java/nio/charset/CharsetEncoder.java b/ojluni/src/main/java/java/nio/charset/CharsetEncoder.java
index 540199e..98b4dea 100644
--- a/ojluni/src/main/java/java/nio/charset/CharsetEncoder.java
+++ b/ojluni/src/main/java/java/nio/charset/CharsetEncoder.java
@@ -197,8 +197,9 @@
* This constructor is for subclasses to specify whether {@code replacement} can be used as it
* is ("trusted"). If it is trusted, {@link #replaceWith(byte[])} and
* {@link #implReplaceWith(byte[])} will not be called.
+ * @hide
*/
- CharsetEncoder(Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement,
+ protected CharsetEncoder(Charset cs, float averageBytesPerChar, float maxBytesPerChar, byte[] replacement,
boolean trusted)
{
// END Android-added: A hidden constructor for the CharsetEncoderICU subclass.
diff --git a/ojluni/src/main/java/java/text/Collator.java b/ojluni/src/main/java/java/text/Collator.java
index 15f43b7..e7fc8b7 100644
--- a/ojluni/src/main/java/java/text/Collator.java
+++ b/ojluni/src/main/java/java/text/Collator.java
@@ -399,7 +399,7 @@
*/
public static synchronized Locale[] getAvailableLocales() {
// Android-changed: Removed reference to CollatorProvider. Switched to ICU.
- return ICU.getAvailableCollatorLocales();
+ return android.icu.text.Collator.getAvailableLocales();
}
// BEGIN Android-added: conversion method for decompositionMode constants.
diff --git a/ojluni/src/main/java/java/text/DecimalFormat.java b/ojluni/src/main/java/java/text/DecimalFormat.java
index dde8a39..a2a37b1 100644
--- a/ojluni/src/main/java/java/text/DecimalFormat.java
+++ b/ojluni/src/main/java/java/text/DecimalFormat.java
@@ -490,7 +490,7 @@
this.icuDecimalFormat = new android.icu.text.DecimalFormat(pattern,
symbols.getIcuDecimalFormatSymbols());
// Android-changed: Compatibility mode for j.t.DecimalFormat. http://b/112355520
- icuDecimalFormat.setParseStrictMode(ParseMode.COMPATIBILITY);
+ icuDecimalFormat.setParseStrictMode(ParseMode.JAVA_COMPATIBILITY);
updateFieldsFromIcu();
}
diff --git a/ojluni/src/main/java/java/util/AbstractList.java b/ojluni/src/main/java/java/util/AbstractList.java
index a183624..c8c160d 100644
--- a/ojluni/src/main/java/java/util/AbstractList.java
+++ b/ojluni/src/main/java/java/util/AbstractList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -25,6 +25,8 @@
package java.util;
+import java.util.function.Consumer;
+
/**
* This class provides a skeletal implementation of the {@link List}
* interface to minimize the effort required to implement this interface
@@ -87,7 +89,8 @@
* classes should clearly specify in their documentation any restrictions
* on what elements may be added.
*
- * <p>This implementation calls {@code add(size(), e)}.
+ * @implSpec
+ * This implementation calls {@code add(size(), e)}.
*
* <p>Note that this implementation throws an
* {@code UnsupportedOperationException} unless
@@ -114,12 +117,13 @@
*
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
- abstract public E get(int index);
+ public abstract E get(int index);
/**
* {@inheritDoc}
*
- * <p>This implementation always throws an
+ * @implSpec
+ * This implementation always throws an
* {@code UnsupportedOperationException}.
*
* @throws UnsupportedOperationException {@inheritDoc}
@@ -135,7 +139,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation always throws an
+ * @implSpec
+ * This implementation always throws an
* {@code UnsupportedOperationException}.
*
* @throws UnsupportedOperationException {@inheritDoc}
@@ -151,7 +156,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation always throws an
+ * @implSpec
+ * This implementation always throws an
* {@code UnsupportedOperationException}.
*
* @throws UnsupportedOperationException {@inheritDoc}
@@ -167,7 +173,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation first gets a list iterator (with
+ * @implSpec
+ * This implementation first gets a list iterator (with
* {@code listIterator()}). Then, it iterates over the list until the
* specified element is found or the end of the list is reached.
*
@@ -191,7 +198,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation first gets a list iterator that points to the end
+ * @implSpec
+ * This implementation first gets a list iterator that points to the end
* of the list (with {@code listIterator(size())}). Then, it iterates
* backwards over the list until the specified element is found, or the
* beginning of the list is reached.
@@ -220,7 +228,8 @@
* Removes all of the elements from this list (optional operation).
* The list will be empty after this call returns.
*
- * <p>This implementation calls {@code removeRange(0, size())}.
+ * @implSpec
+ * This implementation calls {@code removeRange(0, size())}.
*
* <p>Note that this implementation throws an
* {@code UnsupportedOperationException} unless {@code remove(int
@@ -237,7 +246,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation gets an iterator over the specified collection
+ * @implSpec
+ * This implementation gets an iterator over the specified collection
* and iterates over it, inserting the elements obtained from the
* iterator into this list at the appropriate position, one at a time,
* using {@code add(int, E)}.
@@ -269,7 +279,8 @@
/**
* Returns an iterator over the elements in this list in proper sequence.
*
- * <p>This implementation returns a straightforward implementation of the
+ * @implSpec
+ * This implementation returns a straightforward implementation of the
* iterator interface, relying on the backing list's {@code size()},
* {@code get(int)}, and {@code remove(int)} methods.
*
@@ -291,7 +302,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation returns {@code listIterator(0)}.
+ * @implSpec
+ * This implementation returns {@code listIterator(0)}.
*
* @see #listIterator(int)
*/
@@ -302,7 +314,8 @@
/**
* {@inheritDoc}
*
- * <p>This implementation returns a straightforward implementation of the
+ * @implSpec
+ * This implementation returns a straightforward implementation of the
* {@code ListIterator} interface that extends the implementation of the
* {@code Iterator} interface returned by the {@code iterator()} method.
* The {@code ListIterator} implementation relies on the backing list's
@@ -448,12 +461,12 @@
/**
* {@inheritDoc}
*
- * <p>This implementation returns a list that subclasses
+ * @implSpec
+ * This implementation returns a list that subclasses
* {@code AbstractList}. The subclass stores, in private fields, the
- * offset of the subList within the backing list, the size of the subList
- * (which can change over its lifetime), and the expected
- * {@code modCount} value of the backing list. There are two variants
- * of the subclass, one of which implements {@code RandomAccess}.
+ * size of the subList (which can change over its lifetime), and the
+ * expected {@code modCount} value of the backing list. There are two
+ * variants of the subclass, one of which implements {@code RandomAccess}.
* If this list implements {@code RandomAccess} the returned list will
* be an instance of the subclass that implements {@code RandomAccess}.
*
@@ -481,11 +494,22 @@
* {@code (fromIndex > toIndex)}
*/
public List<E> subList(int fromIndex, int toIndex) {
+ subListRangeCheck(fromIndex, toIndex, size());
return (this instanceof RandomAccess ?
new RandomAccessSubList<>(this, fromIndex, toIndex) :
new SubList<>(this, fromIndex, toIndex));
}
+ static void subListRangeCheck(int fromIndex, int toIndex, int size) {
+ if (fromIndex < 0)
+ throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
+ if (toIndex > size)
+ throw new IndexOutOfBoundsException("toIndex = " + toIndex);
+ if (fromIndex > toIndex)
+ throw new IllegalArgumentException("fromIndex(" + fromIndex +
+ ") > toIndex(" + toIndex + ")");
+ }
+
// Comparison and hashing
/**
@@ -495,8 +519,9 @@
* the two lists are <i>equal</i>. (Two elements {@code e1} and
* {@code e2} are <i>equal</i> if {@code (e1==null ? e2==null :
* e1.equals(e2))}.) In other words, two lists are defined to be
- * equal if they contain the same elements in the same order.<p>
+ * equal if they contain the same elements in the same order.
*
+ * @implSpec
* This implementation first checks if the specified object is this
* list. If so, it returns {@code true}; if not, it checks if the
* specified object is a list. If not, it returns {@code false}; if so,
@@ -529,7 +554,8 @@
/**
* Returns the hash code value for this list.
*
- * <p>This implementation uses exactly the code that is used to define the
+ * @implSpec
+ * This implementation uses exactly the code that is used to define the
* list hash function in the documentation for the {@link List#hashCode}
* method.
*
@@ -555,7 +581,8 @@
* improve the performance of the {@code clear} operation on this list
* and its subLists.
*
- * <p>This implementation gets a list iterator positioned before
+ * @implSpec
+ * This implementation gets a list iterator positioned before
* {@code fromIndex}, and repeatedly calls {@code ListIterator.next}
* followed by {@code ListIterator.remove} until the entire range has
* been removed. <b>Note: if {@code ListIterator.remove} requires linear
@@ -608,174 +635,308 @@
private String outOfBoundsMsg(int index) {
return "Index: "+index+", Size: "+size();
}
-}
-class SubList<E> extends AbstractList<E> {
- private final AbstractList<E> l;
- private final int offset;
- private int size;
+ /**
+ * An index-based split-by-two, lazily initialized Spliterator covering
+ * a List that access elements via {@link List#get}.
+ *
+ * If access results in an IndexOutOfBoundsException then a
+ * ConcurrentModificationException is thrown instead (since the list has
+ * been structurally modified while traversing).
+ *
+ * If the List is an instance of AbstractList then concurrent modification
+ * checking is performed using the AbstractList's modCount field.
+ */
+ static final class RandomAccessSpliterator<E> implements Spliterator<E> {
- SubList(AbstractList<E> list, int fromIndex, int toIndex) {
- if (fromIndex < 0)
- throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
- if (toIndex > list.size())
- throw new IndexOutOfBoundsException("toIndex = " + toIndex);
- if (fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex(" + fromIndex +
- ") > toIndex(" + toIndex + ")");
- l = list;
- offset = fromIndex;
- size = toIndex - fromIndex;
- this.modCount = l.modCount;
- }
+ private final List<E> list;
+ private int index; // current index, modified on advance/split
+ private int fence; // -1 until used; then one past last index
- public E set(int index, E element) {
- rangeCheck(index);
- checkForComodification();
- return l.set(index+offset, element);
- }
+ // The following fields are valid if covering an AbstractList
+ private final AbstractList<E> alist;
+ private int expectedModCount; // initialized when fence set
- public E get(int index) {
- rangeCheck(index);
- checkForComodification();
- return l.get(index+offset);
- }
+ RandomAccessSpliterator(List<E> list) {
+ assert list instanceof RandomAccess;
- public int size() {
- checkForComodification();
- return size;
- }
+ this.list = list;
+ this.index = 0;
+ this.fence = -1;
- public void add(int index, E element) {
- rangeCheckForAdd(index);
- checkForComodification();
- l.add(index+offset, element);
- this.modCount = l.modCount;
- size++;
- }
+ this.alist = list instanceof AbstractList ? (AbstractList<E>) list : null;
+ this.expectedModCount = alist != null ? alist.modCount : 0;
+ }
- public E remove(int index) {
- rangeCheck(index);
- checkForComodification();
- E result = l.remove(index+offset);
- this.modCount = l.modCount;
- size--;
- return result;
- }
+ /** Create new spliterator covering the given range */
+ private RandomAccessSpliterator(RandomAccessSpliterator<E> parent,
+ int origin, int fence) {
+ this.list = parent.list;
+ this.index = origin;
+ this.fence = fence;
- protected void removeRange(int fromIndex, int toIndex) {
- checkForComodification();
- l.removeRange(fromIndex+offset, toIndex+offset);
- this.modCount = l.modCount;
- size -= (toIndex-fromIndex);
- }
+ this.alist = parent.alist;
+ this.expectedModCount = parent.expectedModCount;
+ }
- public boolean addAll(Collection<? extends E> c) {
- return addAll(size, c);
- }
+ private int getFence() { // initialize fence to size on first use
+ int hi;
+ List<E> lst = list;
+ if ((hi = fence) < 0) {
+ if (alist != null) {
+ expectedModCount = alist.modCount;
+ }
+ hi = fence = lst.size();
+ }
+ return hi;
+ }
- public boolean addAll(int index, Collection<? extends E> c) {
- rangeCheckForAdd(index);
- int cSize = c.size();
- if (cSize==0)
+ public Spliterator<E> trySplit() {
+ int hi = getFence(), lo = index, mid = (lo + hi) >>> 1;
+ return (lo >= mid) ? null : // divide range in half unless too small
+ new RandomAccessSpliterator<>(this, lo, index = mid);
+ }
+
+ public boolean tryAdvance(Consumer<? super E> action) {
+ if (action == null)
+ throw new NullPointerException();
+ int hi = getFence(), i = index;
+ if (i < hi) {
+ index = i + 1;
+ action.accept(get(list, i));
+ checkAbstractListModCount(alist, expectedModCount);
+ return true;
+ }
return false;
+ }
- checkForComodification();
- l.addAll(offset+index, c);
- this.modCount = l.modCount;
- size += cSize;
- return true;
+ public void forEachRemaining(Consumer<? super E> action) {
+ Objects.requireNonNull(action);
+ List<E> lst = list;
+ int hi = getFence();
+ int i = index;
+ index = hi;
+ for (; i < hi; i++) {
+ action.accept(get(lst, i));
+ }
+ checkAbstractListModCount(alist, expectedModCount);
+ }
+
+ public long estimateSize() {
+ return (long) (getFence() - index);
+ }
+
+ public int characteristics() {
+ return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
+ }
+
+ private static <E> E get(List<E> list, int i) {
+ try {
+ return list.get(i);
+ } catch (IndexOutOfBoundsException ex) {
+ throw new ConcurrentModificationException();
+ }
+ }
+
+ static void checkAbstractListModCount(AbstractList<?> alist, int expectedModCount) {
+ if (alist != null && alist.modCount != expectedModCount) {
+ throw new ConcurrentModificationException();
+ }
+ }
}
- public Iterator<E> iterator() {
- return listIterator();
+ private static class SubList<E> extends AbstractList<E> {
+ private final AbstractList<E> root;
+ private final SubList<E> parent;
+ private final int offset;
+ protected int size;
+
+ /**
+ * Constructs a sublist of an arbitrary AbstractList, which is
+ * not a SubList itself.
+ */
+ public SubList(AbstractList<E> root, int fromIndex, int toIndex) {
+ this.root = root;
+ this.parent = null;
+ this.offset = fromIndex;
+ this.size = toIndex - fromIndex;
+ this.modCount = root.modCount;
+ }
+
+ /**
+ * Constructs a sublist of another SubList.
+ */
+ protected SubList(SubList<E> parent, int fromIndex, int toIndex) {
+ this.root = parent.root;
+ this.parent = parent;
+ this.offset = parent.offset + fromIndex;
+ this.size = toIndex - fromIndex;
+ this.modCount = root.modCount;
+ }
+
+ public E set(int index, E element) {
+ Objects.checkIndex(index, size);
+ checkForComodification();
+ return root.set(offset + index, element);
+ }
+
+ public E get(int index) {
+ Objects.checkIndex(index, size);
+ checkForComodification();
+ return root.get(offset + index);
+ }
+
+ public int size() {
+ checkForComodification();
+ return size;
+ }
+
+ public void add(int index, E element) {
+ rangeCheckForAdd(index);
+ checkForComodification();
+ root.add(offset + index, element);
+ updateSizeAndModCount(1);
+ }
+
+ public E remove(int index) {
+ Objects.checkIndex(index, size);
+ checkForComodification();
+ E result = root.remove(offset + index);
+ updateSizeAndModCount(-1);
+ return result;
+ }
+
+ protected void removeRange(int fromIndex, int toIndex) {
+ checkForComodification();
+ root.removeRange(offset + fromIndex, offset + toIndex);
+ updateSizeAndModCount(fromIndex - toIndex);
+ }
+
+ public boolean addAll(Collection<? extends E> c) {
+ return addAll(size, c);
+ }
+
+ public boolean addAll(int index, Collection<? extends E> c) {
+ rangeCheckForAdd(index);
+ int cSize = c.size();
+ if (cSize==0)
+ return false;
+ checkForComodification();
+ root.addAll(offset + index, c);
+ updateSizeAndModCount(cSize);
+ return true;
+ }
+
+ public Iterator<E> iterator() {
+ return listIterator();
+ }
+
+ public ListIterator<E> listIterator(int index) {
+ checkForComodification();
+ rangeCheckForAdd(index);
+
+ return new ListIterator<E>() {
+ private final ListIterator<E> i =
+ root.listIterator(offset + index);
+
+ public boolean hasNext() {
+ return nextIndex() < size;
+ }
+
+ public E next() {
+ if (hasNext())
+ return i.next();
+ else
+ throw new NoSuchElementException();
+ }
+
+ public boolean hasPrevious() {
+ return previousIndex() >= 0;
+ }
+
+ public E previous() {
+ if (hasPrevious())
+ return i.previous();
+ else
+ throw new NoSuchElementException();
+ }
+
+ public int nextIndex() {
+ return i.nextIndex() - offset;
+ }
+
+ public int previousIndex() {
+ return i.previousIndex() - offset;
+ }
+
+ public void remove() {
+ i.remove();
+ updateSizeAndModCount(-1);
+ }
+
+ public void set(E e) {
+ i.set(e);
+ }
+
+ public void add(E e) {
+ i.add(e);
+ updateSizeAndModCount(1);
+ }
+ };
+ }
+
+ public List<E> subList(int fromIndex, int toIndex) {
+ subListRangeCheck(fromIndex, toIndex, size);
+ return new SubList<>(this, fromIndex, toIndex);
+ }
+
+ private void rangeCheckForAdd(int index) {
+ if (index < 0 || index > size)
+ throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+ }
+
+ private String outOfBoundsMsg(int index) {
+ return "Index: "+index+", Size: "+size;
+ }
+
+ private void checkForComodification() {
+ if (root.modCount != this.modCount)
+ throw new ConcurrentModificationException();
+ }
+
+ private void updateSizeAndModCount(int sizeChange) {
+ SubList<E> slist = this;
+ do {
+ slist.size += sizeChange;
+ slist.modCount = root.modCount;
+ slist = slist.parent;
+ } while (slist != null);
+ }
}
- public ListIterator<E> listIterator(final int index) {
- checkForComodification();
- rangeCheckForAdd(index);
+ private static class RandomAccessSubList<E>
+ extends SubList<E> implements RandomAccess {
- return new ListIterator<E>() {
- private final ListIterator<E> i = l.listIterator(index+offset);
+ /**
+ * Constructs a sublist of an arbitrary AbstractList, which is
+ * not a RandomAccessSubList itself.
+ */
+ RandomAccessSubList(AbstractList<E> root,
+ int fromIndex, int toIndex) {
+ super(root, fromIndex, toIndex);
+ }
- public boolean hasNext() {
- return nextIndex() < size;
- }
+ /**
+ * Constructs a sublist of another RandomAccessSubList.
+ */
+ RandomAccessSubList(RandomAccessSubList<E> parent,
+ int fromIndex, int toIndex) {
+ super(parent, fromIndex, toIndex);
+ }
- public E next() {
- if (hasNext())
- return i.next();
- else
- throw new NoSuchElementException();
- }
-
- public boolean hasPrevious() {
- return previousIndex() >= 0;
- }
-
- public E previous() {
- if (hasPrevious())
- return i.previous();
- else
- throw new NoSuchElementException();
- }
-
- public int nextIndex() {
- return i.nextIndex() - offset;
- }
-
- public int previousIndex() {
- return i.previousIndex() - offset;
- }
-
- public void remove() {
- i.remove();
- SubList.this.modCount = l.modCount;
- size--;
- }
-
- public void set(E e) {
- i.set(e);
- }
-
- public void add(E e) {
- i.add(e);
- SubList.this.modCount = l.modCount;
- size++;
- }
- };
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- return new SubList<>(this, fromIndex, toIndex);
- }
-
- private void rangeCheck(int index) {
- if (index < 0 || index >= size)
- throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
- }
-
- private void rangeCheckForAdd(int index) {
- if (index < 0 || index > size)
- throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
- }
-
- private String outOfBoundsMsg(int index) {
- return "Index: "+index+", Size: "+size;
- }
-
- private void checkForComodification() {
- if (this.modCount != l.modCount)
- throw new ConcurrentModificationException();
- }
-}
-
-class RandomAccessSubList<E> extends SubList<E> implements RandomAccess {
- RandomAccessSubList(AbstractList<E> list, int fromIndex, int toIndex) {
- super(list, fromIndex, toIndex);
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- return new RandomAccessSubList<>(this, fromIndex, toIndex);
+ public List<E> subList(int fromIndex, int toIndex) {
+ subListRangeCheck(fromIndex, toIndex, size);
+ return new RandomAccessSubList<>(this, fromIndex, toIndex);
+ }
}
}
diff --git a/ojluni/src/main/java/java/util/ImmutableCollections.java b/ojluni/src/main/java/java/util/ImmutableCollections.java
new file mode 100644
index 0000000..2bc0cc1
--- /dev/null
+++ b/ojluni/src/main/java/java/util/ImmutableCollections.java
@@ -0,0 +1,964 @@
+/*
+ * Copyright (c) 2016, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.util;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+import jdk.internal.vm.annotation.Stable;
+
+/**
+ * Container class for immutable collections. Not part of the public API.
+ * Mainly for namespace management and shared infrastructure.
+ *
+ * Serial warnings are suppressed throughout because all implementation
+ * classes use a serial proxy and thus have no need to declare serialVersionUID.
+ */
+@SuppressWarnings("serial")
+class ImmutableCollections {
+ /**
+ * A "salt" value used for randomizing iteration order. This is initialized once
+ * and stays constant for the lifetime of the JVM. It need not be truly random, but
+ * it needs to vary sufficiently from one run to the next so that iteration order
+ * will vary between JVM runs.
+ */
+ static final int SALT;
+ static {
+ long nt = System.nanoTime();
+ SALT = (int)((nt >>> 32) ^ nt);
+ }
+
+ /** No instances. */
+ private ImmutableCollections() { }
+
+ /**
+ * The reciprocal of load factor. Given a number of elements
+ * to store, multiply by this factor to get the table size.
+ */
+ static final int EXPAND_FACTOR = 2;
+
+ static UnsupportedOperationException uoe() { return new UnsupportedOperationException(); }
+
+ // ---------- List Implementations ----------
+
+ abstract static class AbstractImmutableList<E> extends AbstractList<E>
+ implements RandomAccess, Serializable {
+ @Override public boolean add(E e) { throw uoe(); }
+ @Override public boolean addAll(Collection<? extends E> c) { throw uoe(); }
+ @Override public boolean addAll(int index, Collection<? extends E> c) { throw uoe(); }
+ @Override public void clear() { throw uoe(); }
+ @Override public boolean remove(Object o) { throw uoe(); }
+ @Override public boolean removeAll(Collection<?> c) { throw uoe(); }
+ @Override public boolean removeIf(Predicate<? super E> filter) { throw uoe(); }
+ @Override public void replaceAll(UnaryOperator<E> operator) { throw uoe(); }
+ @Override public boolean retainAll(Collection<?> c) { throw uoe(); }
+ @Override public void sort(Comparator<? super E> c) { throw uoe(); }
+ }
+
+ static final class List0<E> extends AbstractImmutableList<E> {
+ private static final List0<?> INSTANCE = new List0<>();
+
+ @SuppressWarnings("unchecked")
+ static <T> List0<T> instance() {
+ return (List0<T>) INSTANCE;
+ }
+
+ private List0() { }
+
+ @Override
+ public int size() {
+ return 0;
+ }
+
+ @Override
+ public E get(int index) {
+ Objects.checkIndex(index, 0); // always throws IndexOutOfBoundsException
+ return null; // but the compiler doesn't know this
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return Collections.emptyIterator();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_LIST);
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ Objects.requireNonNull(o);
+ return false;
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> o) {
+ return o.isEmpty(); // implicit nullcheck of o
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+ }
+
+ static final class List1<E> extends AbstractImmutableList<E> {
+ @Stable
+ private final E e0;
+
+ List1(E e0) {
+ this.e0 = Objects.requireNonNull(e0);
+ }
+
+ @Override
+ public int size() {
+ return 1;
+ }
+
+ @Override
+ public E get(int index) {
+ Objects.checkIndex(index, 1);
+ return e0;
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_LIST, e0);
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return o.equals(e0); // implicit nullcheck of o
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 + e0.hashCode();
+ }
+ }
+
+ static final class List2<E> extends AbstractImmutableList<E> {
+ @Stable
+ private final E e0;
+ @Stable
+ private final E e1;
+
+ List2(E e0, E e1) {
+ this.e0 = Objects.requireNonNull(e0);
+ this.e1 = Objects.requireNonNull(e1);
+ }
+
+ @Override
+ public int size() {
+ return 2;
+ }
+
+ @Override
+ public E get(int index) {
+ Objects.checkIndex(index, 2);
+ if (index == 0) {
+ return e0;
+ } else { // index == 1
+ return e1;
+ }
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return o.equals(e0) || o.equals(e1); // implicit nullcheck of o
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 31 + e0.hashCode();
+ return 31 * hash + e1.hashCode();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_LIST, e0, e1);
+ }
+ }
+
+ static final class ListN<E> extends AbstractImmutableList<E> {
+ @Stable
+ private final E[] elements;
+
+ @SafeVarargs
+ ListN(E... input) {
+ // copy and check manually to avoid TOCTOU
+ @SuppressWarnings("unchecked")
+ E[] tmp = (E[])new Object[input.length]; // implicit nullcheck of input
+ for (int i = 0; i < input.length; i++) {
+ tmp[i] = Objects.requireNonNull(input[i]);
+ }
+ this.elements = tmp;
+ }
+
+ @Override
+ public int size() {
+ return elements.length;
+ }
+
+ @Override
+ public E get(int index) {
+ Objects.checkIndex(index, elements.length);
+ return elements[index];
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ for (E e : elements) {
+ if (o.equals(e)) { // implicit nullcheck of o
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 1;
+ for (E e : elements) {
+ hash = 31 * hash + e.hashCode();
+ }
+ return hash;
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_LIST, elements);
+ }
+ }
+
+ // ---------- Set Implementations ----------
+
+ abstract static class AbstractImmutableSet<E> extends AbstractSet<E> implements Serializable {
+ @Override public boolean add(E e) { throw uoe(); }
+ @Override public boolean addAll(Collection<? extends E> c) { throw uoe(); }
+ @Override public void clear() { throw uoe(); }
+ @Override public boolean remove(Object o) { throw uoe(); }
+ @Override public boolean removeAll(Collection<?> c) { throw uoe(); }
+ @Override public boolean removeIf(Predicate<? super E> filter) { throw uoe(); }
+ @Override public boolean retainAll(Collection<?> c) { throw uoe(); }
+ }
+
+ static final class Set0<E> extends AbstractImmutableSet<E> {
+ private static final Set0<?> INSTANCE = new Set0<>();
+
+ @SuppressWarnings("unchecked")
+ static <T> Set0<T> instance() {
+ return (Set0<T>) INSTANCE;
+ }
+
+ private Set0() { }
+
+ @Override
+ public int size() {
+ return 0;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ Objects.requireNonNull(o);
+ return false;
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> o) {
+ return o.isEmpty(); // implicit nullcheck of o
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return Collections.emptyIterator();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_SET);
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+ }
+
+ static final class Set1<E> extends AbstractImmutableSet<E> {
+ @Stable
+ private final E e0;
+
+ Set1(E e0) {
+ this.e0 = Objects.requireNonNull(e0);
+ }
+
+ @Override
+ public int size() {
+ return 1;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return o.equals(e0); // implicit nullcheck of o
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return Collections.singletonIterator(e0);
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_SET, e0);
+ }
+
+ @Override
+ public int hashCode() {
+ return e0.hashCode();
+ }
+ }
+
+ static final class Set2<E> extends AbstractImmutableSet<E> {
+ @Stable
+ final E e0;
+ @Stable
+ final E e1;
+
+ Set2(E e0, E e1) {
+ if (e0.equals(Objects.requireNonNull(e1))) { // implicit nullcheck of e0
+ throw new IllegalArgumentException("duplicate element: " + e0);
+ }
+
+ if (SALT >= 0) {
+ this.e0 = e0;
+ this.e1 = e1;
+ } else {
+ this.e0 = e1;
+ this.e1 = e0;
+ }
+ }
+
+ @Override
+ public int size() {
+ return 2;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return o.equals(e0) || o.equals(e1); // implicit nullcheck of o
+ }
+
+ @Override
+ public int hashCode() {
+ return e0.hashCode() + e1.hashCode();
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new Iterator<E>() {
+ private int idx = 0;
+
+ @Override
+ public boolean hasNext() {
+ return idx < 2;
+ }
+
+ @Override
+ public E next() {
+ if (idx == 0) {
+ idx = 1;
+ return e0;
+ } else if (idx == 1) {
+ idx = 2;
+ return e1;
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+ };
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_SET, e0, e1);
+ }
+ }
+
+ /**
+ * An array-based Set implementation. The element array must be strictly
+ * larger than the size (the number of contained elements) so that at
+ * least one null is always present.
+ * @param <E> the element type
+ */
+ static final class SetN<E> extends AbstractImmutableSet<E> {
+ @Stable
+ final E[] elements;
+ @Stable
+ final int size;
+
+ @SafeVarargs
+ @SuppressWarnings("unchecked")
+ SetN(E... input) {
+ size = input.length; // implicit nullcheck of input
+
+ elements = (E[])new Object[EXPAND_FACTOR * input.length];
+ for (int i = 0; i < input.length; i++) {
+ E e = input[i];
+ int idx = probe(e); // implicit nullcheck of e
+ if (idx >= 0) {
+ throw new IllegalArgumentException("duplicate element: " + e);
+ } else {
+ elements[-(idx + 1)] = e;
+ }
+ }
+ }
+
+ @Override
+ public int size() {
+ return size;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return probe(o) >= 0; // implicit nullcheck of o
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new Iterator<E>() {
+ private int idx = 0;
+
+ @Override
+ public boolean hasNext() {
+ while (idx < elements.length) {
+ if (elements[idx] != null)
+ return true;
+ idx++;
+ }
+ return false;
+ }
+
+ @Override
+ public E next() {
+ if (! hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return elements[idx++];
+ }
+ };
+ }
+
+ @Override
+ public int hashCode() {
+ int h = 0;
+ for (E e : elements) {
+ if (e != null) {
+ h += e.hashCode();
+ }
+ }
+ return h;
+ }
+
+ // returns index at which element is present; or if absent,
+ // (-i - 1) where i is location where element should be inserted.
+ // Callers are relying on this method to perform an implicit nullcheck
+ // of pe
+ private int probe(Object pe) {
+ int idx = Math.floorMod(pe.hashCode() ^ SALT, elements.length);
+ while (true) {
+ E ee = elements[idx];
+ if (ee == null) {
+ return -idx - 1;
+ } else if (pe.equals(ee)) {
+ return idx;
+ } else if (++idx == elements.length) {
+ idx = 0;
+ }
+ }
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ Object[] array = new Object[size];
+ int dest = 0;
+ for (Object o : elements) {
+ if (o != null) {
+ array[dest++] = o;
+ }
+ }
+ return new CollSer(CollSer.IMM_SET, array);
+ }
+ }
+
+ // ---------- Map Implementations ----------
+
+ abstract static class AbstractImmutableMap<K,V> extends AbstractMap<K,V> implements Serializable {
+ @Override public void clear() { throw uoe(); }
+ @Override public V compute(K key, BiFunction<? super K,? super V,? extends V> rf) { throw uoe(); }
+ @Override public V computeIfAbsent(K key, Function<? super K,? extends V> mf) { throw uoe(); }
+ @Override public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> rf) { throw uoe(); }
+ @Override public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> rf) { throw uoe(); }
+ @Override public V put(K key, V value) { throw uoe(); }
+ @Override public void putAll(Map<? extends K,? extends V> m) { throw uoe(); }
+ @Override public V putIfAbsent(K key, V value) { throw uoe(); }
+ @Override public V remove(Object key) { throw uoe(); }
+ @Override public boolean remove(Object key, Object value) { throw uoe(); }
+ @Override public V replace(K key, V value) { throw uoe(); }
+ @Override public boolean replace(K key, V oldValue, V newValue) { throw uoe(); }
+ @Override public void replaceAll(BiFunction<? super K,? super V,? extends V> f) { throw uoe(); }
+ }
+
+ static final class Map0<K,V> extends AbstractImmutableMap<K,V> {
+ private static final Map0<?,?> INSTANCE = new Map0<>();
+
+ @SuppressWarnings("unchecked")
+ static <K,V> Map0<K,V> instance() {
+ return (Map0<K,V>) INSTANCE;
+ }
+
+ private Map0() { }
+
+ @Override
+ public Set<Map.Entry<K,V>> entrySet() {
+ return Set.of();
+ }
+
+ @Override
+ public boolean containsKey(Object o) {
+ Objects.requireNonNull(o);
+ return false;
+ }
+
+ @Override
+ public boolean containsValue(Object o) {
+ Objects.requireNonNull(o);
+ return false;
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_MAP);
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+ }
+
+ static final class Map1<K,V> extends AbstractImmutableMap<K,V> {
+ @Stable
+ private final K k0;
+ @Stable
+ private final V v0;
+
+ Map1(K k0, V v0) {
+ this.k0 = Objects.requireNonNull(k0);
+ this.v0 = Objects.requireNonNull(v0);
+ }
+
+ @Override
+ public Set<Map.Entry<K,V>> entrySet() {
+ return Set.of(new KeyValueHolder<>(k0, v0));
+ }
+
+ @Override
+ public boolean containsKey(Object o) {
+ return o.equals(k0); // implicit nullcheck of o
+ }
+
+ @Override
+ public boolean containsValue(Object o) {
+ return o.equals(v0); // implicit nullcheck of o
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ return new CollSer(CollSer.IMM_MAP, k0, v0);
+ }
+
+ @Override
+ public int hashCode() {
+ return k0.hashCode() ^ v0.hashCode();
+ }
+ }
+
+ /**
+ * An array-based Map implementation. There is a single array "table" that
+ * contains keys and values interleaved: table[0] is kA, table[1] is vA,
+ * table[2] is kB, table[3] is vB, etc. The table size must be even. It must
+ * also be strictly larger than the size (the number of key-value pairs contained
+ * in the map) so that at least one null key is always present.
+ * @param <K> the key type
+ * @param <V> the value type
+ */
+ static final class MapN<K,V> extends AbstractImmutableMap<K,V> {
+ @Stable
+ final Object[] table; // pairs of key, value
+ @Stable
+ final int size; // number of pairs
+
+ MapN(Object... input) {
+ if ((input.length & 1) != 0) { // implicit nullcheck of input
+ throw new InternalError("length is odd");
+ }
+ size = input.length >> 1;
+
+ int len = EXPAND_FACTOR * input.length;
+ len = (len + 1) & ~1; // ensure table is even length
+ table = new Object[len];
+
+ for (int i = 0; i < input.length; i += 2) {
+ @SuppressWarnings("unchecked")
+ K k = Objects.requireNonNull((K)input[i]);
+ @SuppressWarnings("unchecked")
+ V v = Objects.requireNonNull((V)input[i+1]);
+ int idx = probe(k);
+ if (idx >= 0) {
+ throw new IllegalArgumentException("duplicate key: " + k);
+ } else {
+ int dest = -(idx + 1);
+ table[dest] = k;
+ table[dest+1] = v;
+ }
+ }
+ }
+
+ @Override
+ public boolean containsKey(Object o) {
+ return probe(o) >= 0; // implicit nullcheck of o
+ }
+
+ @Override
+ public boolean containsValue(Object o) {
+ for (int i = 1; i < table.length; i += 2) {
+ Object v = table[i];
+ if (v != null && o.equals(v)) { // implicit nullcheck of o
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ for (int i = 0; i < table.length; i += 2) {
+ Object k = table[i];
+ if (k != null) {
+ hash += k.hashCode() ^ table[i + 1].hashCode();
+ }
+ }
+ return hash;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public V get(Object o) {
+ int i = probe(o);
+ if (i >= 0) {
+ return (V)table[i+1];
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public int size() {
+ return size;
+ }
+
+ @Override
+ public Set<Map.Entry<K,V>> entrySet() {
+ return new AbstractSet<Map.Entry<K,V>>() {
+ @Override
+ public int size() {
+ return MapN.this.size;
+ }
+
+ @Override
+ public Iterator<Map.Entry<K,V>> iterator() {
+ return new Iterator<Map.Entry<K,V>>() {
+ int idx = 0;
+
+ @Override
+ public boolean hasNext() {
+ while (idx < table.length) {
+ if (table[idx] != null)
+ return true;
+ idx += 2;
+ }
+ return false;
+ }
+
+ @Override
+ public Map.Entry<K,V> next() {
+ if (hasNext()) {
+ @SuppressWarnings("unchecked")
+ Map.Entry<K,V> e =
+ new KeyValueHolder<>((K)table[idx], (V)table[idx+1]);
+ idx += 2;
+ return e;
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+ };
+ }
+ };
+ }
+
+ // returns index at which the probe key is present; or if absent,
+ // (-i - 1) where i is location where element should be inserted.
+ // Callers are relying on this method to perform an implicit nullcheck
+ // of pk.
+ private int probe(Object pk) {
+ int idx = Math.floorMod(pk.hashCode() ^ SALT, table.length >> 1) << 1;
+ while (true) {
+ @SuppressWarnings("unchecked")
+ K ek = (K)table[idx];
+ if (ek == null) {
+ return -idx - 1;
+ } else if (pk.equals(ek)) {
+ return idx;
+ } else if ((idx += 2) == table.length) {
+ idx = 0;
+ }
+ }
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new InvalidObjectException("not serial proxy");
+ }
+
+ private Object writeReplace() {
+ Object[] array = new Object[2 * size];
+ int len = table.length;
+ int dest = 0;
+ for (int i = 0; i < len; i += 2) {
+ if (table[i] != null) {
+ array[dest++] = table[i];
+ array[dest++] = table[i+1];
+ }
+ }
+ return new CollSer(CollSer.IMM_MAP, array);
+ }
+ }
+}
+
+// ---------- Serialization Proxy ----------
+
+/**
+ * A unified serialization proxy class for the immutable collections.
+ *
+ * @serial
+ * @since 9
+ */
+final class CollSer implements Serializable {
+ private static final long serialVersionUID = 6309168927139932177L;
+
+ static final int IMM_LIST = 1;
+ static final int IMM_SET = 2;
+ static final int IMM_MAP = 3;
+
+ /**
+ * Indicates the type of collection that is serialized.
+ * The low order 8 bits have the value 1 for an immutable
+ * {@code List}, 2 for an immutable {@code Set}, and 3 for
+ * an immutable {@code Map}. Any other value causes an
+ * {@link InvalidObjectException} to be thrown. The high
+ * order 24 bits are zero when an instance is serialized,
+ * and they are ignored when an instance is deserialized.
+ * They can thus be used by future implementations without
+ * causing compatibility issues.
+ *
+ * <p>The tag value also determines the interpretation of the
+ * transient {@code Object[] array} field.
+ * For {@code List} and {@code Set}, the array's length is the size
+ * of the collection, and the array contains the elements of the collection.
+ * Null elements are not allowed. For {@code Set}, duplicate elements
+ * are not allowed.
+ *
+ * <p>For {@code Map}, the array's length is twice the number of mappings
+ * present in the map. The array length is necessarily even.
+ * The array contains a succession of key and value pairs:
+ * {@code k1, v1, k2, v2, ..., kN, vN.} Nulls are not allowed,
+ * and duplicate keys are not allowed.
+ *
+ * @serial
+ * @since 9
+ */
+ private final int tag;
+
+ /**
+ * @serial
+ * @since 9
+ */
+ private transient Object[] array;
+
+ CollSer(int t, Object... a) {
+ tag = t;
+ array = a;
+ }
+
+ /**
+ * Reads objects from the stream and stores them
+ * in the transient {@code Object[] array} field.
+ *
+ * @serialData
+ * A nonnegative int, indicating the count of objects,
+ * followed by that many objects.
+ *
+ * @param ois the ObjectInputStream from which data is read
+ * @throws IOException if an I/O error occurs
+ * @throws ClassNotFoundException if a serialized class cannot be loaded
+ * @throws InvalidObjectException if the count is negative
+ * @since 9
+ */
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ois.defaultReadObject();
+ int len = ois.readInt();
+
+ if (len < 0) {
+ throw new InvalidObjectException("negative length " + len);
+ }
+
+ Object[] a = new Object[len];
+ for (int i = 0; i < len; i++) {
+ a[i] = ois.readObject();
+ }
+
+ array = a;
+ }
+
+ /**
+ * Writes objects to the stream from
+ * the transient {@code Object[] array} field.
+ *
+ * @serialData
+ * A nonnegative int, indicating the count of objects,
+ * followed by that many objects.
+ *
+ * @param oos the ObjectOutputStream to which data is written
+ * @throws IOException if an I/O error occurs
+ * @since 9
+ */
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ oos.writeInt(array.length);
+ for (int i = 0; i < array.length; i++) {
+ oos.writeObject(array[i]);
+ }
+ }
+
+ /**
+ * Creates and returns an immutable collection from this proxy class.
+ * The instance returned is created as if by calling one of the
+ * static factory methods for
+ * <a href="List.html#immutable">List</a>,
+ * <a href="Map.html#immutable">Map</a>, or
+ * <a href="Set.html#immutable">Set</a>.
+ * This proxy class is the serial form for all immutable collection instances,
+ * regardless of implementation type. This is necessary to ensure that the
+ * existence of any particular implementation type is kept out of the
+ * serialized form.
+ *
+ * @return a collection created from this proxy object
+ * @throws InvalidObjectException if the tag value is illegal or if an exception
+ * is thrown during creation of the collection
+ * @throws ObjectStreamException if another serialization error has occurred
+ * @since 9
+ */
+ private Object readResolve() throws ObjectStreamException {
+ try {
+ if (array == null) {
+ throw new InvalidObjectException("null array");
+ }
+
+ // use low order 8 bits to indicate "kind"
+ // ignore high order 24 bits
+ switch (tag & 0xff) {
+ case IMM_LIST:
+ return List.of(array);
+ case IMM_SET:
+ return Set.of(array);
+ case IMM_MAP:
+ if (array.length == 0) {
+ return ImmutableCollections.Map0.instance();
+ } else if (array.length == 2) {
+ return new ImmutableCollections.Map1<>(array[0], array[1]);
+ } else {
+ return new ImmutableCollections.MapN<>(array);
+ }
+ default:
+ throw new InvalidObjectException(String.format("invalid flags 0x%x", tag));
+ }
+ } catch (NullPointerException|IllegalArgumentException ex) {
+ InvalidObjectException ioe = new InvalidObjectException("invalid object");
+ ioe.initCause(ex);
+ throw ioe;
+ }
+ }
+}
diff --git a/ojluni/src/main/java/java/util/KeyValueHolder.java b/ojluni/src/main/java/java/util/KeyValueHolder.java
new file mode 100644
index 0000000..3b7250e
--- /dev/null
+++ b/ojluni/src/main/java/java/util/KeyValueHolder.java
@@ -0,0 +1,130 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.util;
+
+import jdk.internal.vm.annotation.Stable;
+
+/**
+ * An immutable container for a key and a value, suitable for use
+ * in creating and populating {@code Map} instances.
+ *
+ * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a>
+ * class; use of identity-sensitive operations (including reference equality
+ * ({@code ==}), identity hash code, or synchronization) on instances of
+ * {@code KeyValueHolder} may have unpredictable results and should be avoided.
+ *
+ * @apiNote
+ * This class is not public. Instances can be created using the
+ * {@link Map#entry Map.entry(k, v)} factory method, which is public.
+ *
+ * <p>This class differs from AbstractMap.SimpleImmutableEntry in the following ways:
+ * it is not serializable, it is final, and its key and value must be non-null.
+ *
+ * @param <K> the key type
+ * @param <V> the value type
+ *
+ * @see Map#ofEntries Map.ofEntries()
+ * @since 9
+ */
+final class KeyValueHolder<K,V> implements Map.Entry<K,V> {
+ @Stable
+ final K key;
+ @Stable
+ final V value;
+
+ KeyValueHolder(K k, V v) {
+ key = Objects.requireNonNull(k);
+ value = Objects.requireNonNull(v);
+ }
+
+ /**
+ * Gets the key from this holder.
+ *
+ * @return the key
+ */
+ @Override
+ public K getKey() {
+ return key;
+ }
+
+ /**
+ * Gets the value from this holder.
+ *
+ * @return the value
+ */
+ @Override
+ public V getValue() {
+ return value;
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ *
+ * @param value ignored
+ * @return never returns normally
+ */
+ @Override
+ public V setValue(V value) {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ /**
+ * Compares the specified object with this entry for equality.
+ * Returns {@code true} if the given object is also a map entry and
+ * the two entries' keys and values are equal. Note that key and
+ * value are non-null, so equals() can be called safely on them.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Map.Entry))
+ return false;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
+ return key.equals(e.getKey()) && value.equals(e.getValue());
+ }
+
+ /**
+ * Returns the hash code value for this map entry. The hash code
+ * is {@code key.hashCode() ^ value.hashCode()}. Note that key and
+ * value are non-null, so hashCode() can be called safely on them.
+ */
+ @Override
+ public int hashCode() {
+ return key.hashCode() ^ value.hashCode();
+ }
+
+ /**
+ * Returns a String representation of this map entry. This
+ * implementation returns the string representation of this
+ * entry's key followed by the equals character ("{@code =}")
+ * followed by the string representation of this entry's value.
+ *
+ * @return a String representation of this map entry
+ */
+ @Override
+ public String toString() {
+ return key + "=" + value;
+ }
+}
diff --git a/ojluni/src/main/java/java/util/List.java b/ojluni/src/main/java/java/util/List.java
index c15a522..1b9deb3 100644
--- a/ojluni/src/main/java/java/util/List.java
+++ b/ojluni/src/main/java/java/util/List.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,6 +27,7 @@
import java.util.function.UnaryOperator;
+// Android-removed: removed link to collections framework docs
/**
* An ordered collection (also known as a <i>sequence</i>). The user of this
* interface has precise control over where in the list each element is
@@ -34,50 +35,50 @@
* the list), and search for elements in the list.<p>
*
* Unlike sets, lists typically allow duplicate elements. More formally,
- * lists typically allow pairs of elements <tt>e1</tt> and <tt>e2</tt>
- * such that <tt>e1.equals(e2)</tt>, and they typically allow multiple
+ * lists typically allow pairs of elements {@code e1} and {@code e2}
+ * such that {@code e1.equals(e2)}, and they typically allow multiple
* null elements if they allow null elements at all. It is not inconceivable
* that someone might wish to implement a list that prohibits duplicates, by
* throwing runtime exceptions when the user attempts to insert them, but we
* expect this usage to be rare.<p>
*
- * The <tt>List</tt> interface places additional stipulations, beyond those
- * specified in the <tt>Collection</tt> interface, on the contracts of the
- * <tt>iterator</tt>, <tt>add</tt>, <tt>remove</tt>, <tt>equals</tt>, and
- * <tt>hashCode</tt> methods. Declarations for other inherited methods are
+ * The {@code List} interface places additional stipulations, beyond those
+ * specified in the {@code Collection} interface, on the contracts of the
+ * {@code iterator}, {@code add}, {@code remove}, {@code equals}, and
+ * {@code hashCode} methods. Declarations for other inherited methods are
* also included here for convenience.<p>
*
- * The <tt>List</tt> interface provides four methods for positional (indexed)
+ * The {@code List} interface provides four methods for positional (indexed)
* access to list elements. Lists (like Java arrays) are zero based. Note
* that these operations may execute in time proportional to the index value
- * for some implementations (the <tt>LinkedList</tt> class, for
+ * for some implementations (the {@code LinkedList} class, for
* example). Thus, iterating over the elements in a list is typically
* preferable to indexing through it if the caller does not know the
* implementation.<p>
*
- * The <tt>List</tt> interface provides a special iterator, called a
- * <tt>ListIterator</tt>, that allows element insertion and replacement, and
+ * The {@code List} interface provides a special iterator, called a
+ * {@code ListIterator}, that allows element insertion and replacement, and
* bidirectional access in addition to the normal operations that the
- * <tt>Iterator</tt> interface provides. A method is provided to obtain a
+ * {@code Iterator} interface provides. A method is provided to obtain a
* list iterator that starts at a specified position in the list.<p>
*
- * The <tt>List</tt> interface provides two methods to search for a specified
+ * The {@code List} interface provides two methods to search for a specified
* object. From a performance standpoint, these methods should be used with
* caution. In many implementations they will perform costly linear
* searches.<p>
*
- * The <tt>List</tt> interface provides two methods to efficiently insert and
+ * The {@code List} interface provides two methods to efficiently insert and
* remove multiple elements at an arbitrary point in the list.<p>
*
* Note: While it is permissible for lists to contain themselves as elements,
- * extreme caution is advised: the <tt>equals</tt> and <tt>hashCode</tt>
+ * extreme caution is advised: the {@code equals} and {@code hashCode}
* methods are no longer well defined on such a list.
*
* <p>Some list 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
- * <tt>NullPointerException</tt> or <tt>ClassCastException</tt>. Attempting
+ * {@code NullPointerException} or {@code ClassCastException}. Attempting
* to query the presence of an ineligible element may throw an exception,
* or it may simply return false; some implementations will exhibit the former
* behavior and some will exhibit the latter. More generally, attempting an
@@ -87,9 +88,31 @@
* Such exceptions are marked as "optional" in the specification for this
* interface.
*
- * <p>This interface is a member of the
- * <a href="{@docRoot}/../technotes/guides/collections/index.html">
- * Java Collections Framework</a>.
+ * <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}
+ * 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.
+ * 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
+ * {@code null} elements result in {@code NullPointerException}.
+ * <li>They are serializable if all elements are serializable.
+ * <li>The order of elements in the list is the same as the order of the
+ * provided arguments, or of the elements in the provided array.
+ * <li>They are <a href="../lang/doc-files/ValueBased.html">value-based</a>.
+ * Callers should make no assumptions about the identity of the returned instances.
+ * Factories are free to create new instances or reuse existing ones. Therefore,
+ * identity-sensitive operations on these instances (reference equality ({@code ==}),
+ * identity hash code, and synchronization) are unreliable and should be avoided.
+ * <li>They are serialized as specified on the
+ * <a href="{@docRoot}/serialized-form.html#java.util.CollSer">Serialized Form</a>
+ * page.
+ * </ul>
*
* @param <E> the type of elements in this list
*
@@ -113,28 +136,28 @@
/**
* Returns the number of elements in this list. If this list contains
- * more than <tt>Integer.MAX_VALUE</tt> elements, returns
- * <tt>Integer.MAX_VALUE</tt>.
+ * more than {@code Integer.MAX_VALUE} elements, returns
+ * {@code Integer.MAX_VALUE}.
*
* @return the number of elements in this list
*/
int size();
/**
- * Returns <tt>true</tt> if this list contains no elements.
+ * Returns {@code true} if this list contains no elements.
*
- * @return <tt>true</tt> if this list contains no elements
+ * @return {@code true} if this list contains no elements
*/
boolean isEmpty();
/**
- * Returns <tt>true</tt> if this list contains the specified element.
- * More formally, returns <tt>true</tt> if and only if this list contains
- * at least one element <tt>e</tt> such that
- * <tt>(o==null ? e==null : o.equals(e))</tt>.
+ * Returns {@code true} if this list contains the specified element.
+ * More formally, returns {@code true} if and only if this list contains
+ * at least one element {@code e} such that
+ * {@code Objects.equals(o, e)}.
*
* @param o element whose presence in this list is to be tested
- * @return <tt>true</tt> if this list contains the specified element
+ * @return {@code true} if this list contains the specified element
* @throws ClassCastException if the type of the specified element
* is incompatible with this list
* (<a href="Collection.html#optional-restrictions">optional</a>)
@@ -179,7 +202,7 @@
*
* <p>If the list fits in the specified array with room to spare (i.e.,
* the array has more elements than the list), the element in the array
- * immediately following the end of the list is set to <tt>null</tt>.
+ * immediately following the end of the list is set to {@code null}.
* (This is useful in determining the length of the list <i>only</i> if
* the caller knows that the list does not contain any null elements.)
*
@@ -188,16 +211,16 @@
* precise control over the runtime type of the output array, and may,
* under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose <tt>x</tt> is a list known to contain only strings.
+ * <p>Suppose {@code x} is a list known to contain only strings.
* The following code can be used to dump the list into a newly
- * allocated array of <tt>String</tt>:
+ * allocated array of {@code String}:
*
* <pre>{@code
* String[] y = x.toArray(new String[0]);
* }</pre>
*
- * Note that <tt>toArray(new Object[0])</tt> is identical in function to
- * <tt>toArray()</tt>.
+ * Note that {@code toArray(new Object[0])} is identical in function to
+ * {@code toArray()}.
*
* @param a the array into which the elements of this list are to
* be stored, if it is big enough; otherwise, a new array of the
@@ -225,8 +248,8 @@
* on what elements may be added.
*
* @param e element to be appended to this list
- * @return <tt>true</tt> (as specified by {@link Collection#add})
- * @throws UnsupportedOperationException if the <tt>add</tt> operation
+ * @return {@code true} (as specified by {@link Collection#add})
+ * @throws UnsupportedOperationException if the {@code add} operation
* is not supported by this list
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this list
@@ -241,21 +264,21 @@
* Removes the first occurrence of the specified element from this list,
* if it is present (optional operation). If this list does not contain
* the element, it is unchanged. More formally, removes the element with
- * the lowest index <tt>i</tt> such that
- * <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>
- * (if such an element exists). Returns <tt>true</tt> if this list
+ * the lowest index {@code i} such that
+ * {@code Objects.equals(o, get(i))}
+ * (if such an element exists). Returns {@code true} if this list
* contained the specified element (or equivalently, if this list changed
* as a result of the call).
*
* @param o element to be removed from this list, if present
- * @return <tt>true</tt> if this list contained the specified element
+ * @return {@code true} if this list contained the specified element
* @throws ClassCastException if the type of the specified element
* is incompatible with this list
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified element is null and this
* list does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>)
- * @throws UnsupportedOperationException if the <tt>remove</tt> operation
+ * @throws UnsupportedOperationException if the {@code remove} operation
* is not supported by this list
*/
boolean remove(Object o);
@@ -264,11 +287,11 @@
// Bulk Modification Operations
/**
- * Returns <tt>true</tt> if this list contains all of the elements of the
+ * Returns {@code true} if this list contains all of the elements of the
* specified collection.
*
* @param c collection to be checked for containment in this list
- * @return <tt>true</tt> if this list contains all of the elements of the
+ * @return {@code true} if this list contains all of the elements of the
* specified collection
* @throws ClassCastException if the types of one or more elements
* in the specified collection are incompatible with this
@@ -292,8 +315,8 @@
* specified collection is this list, and it's nonempty.)
*
* @param c collection containing elements to be added to this list
- * @return <tt>true</tt> if this list changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>addAll</tt> operation
+ * @return {@code true} if this list changed as a result of the call
+ * @throws UnsupportedOperationException if the {@code addAll} operation
* is not supported by this list
* @throws ClassCastException if the class of an element of the specified
* collection prevents it from being added to this list
@@ -320,8 +343,8 @@
* @param index index at which to insert the first element from the
* specified collection
* @param c collection containing elements to be added to this list
- * @return <tt>true</tt> if this list changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>addAll</tt> operation
+ * @return {@code true} if this list changed as a result of the call
+ * @throws UnsupportedOperationException if the {@code addAll} operation
* is not supported by this list
* @throws ClassCastException if the class of an element of the specified
* collection prevents it from being added to this list
@@ -331,7 +354,7 @@
* @throws IllegalArgumentException if some property of an element of the
* specified collection prevents it from being added to this list
* @throws IndexOutOfBoundsException if the index is out of range
- * (<tt>index < 0 || index > size()</tt>)
+ * ({@code index < 0 || index > size()})
*/
boolean addAll(int index, Collection<? extends E> c);
@@ -340,8 +363,8 @@
* specified collection (optional operation).
*
* @param c collection containing elements to be removed from this list
- * @return <tt>true</tt> if this list changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>removeAll</tt> operation
+ * @return {@code true} if this list changed as a result of the call
+ * @throws UnsupportedOperationException if the {@code removeAll} operation
* is not supported by this list
* @throws ClassCastException if the class of an element of this list
* is incompatible with the specified collection
@@ -362,8 +385,8 @@
* specified collection.
*
* @param c collection containing elements to be retained in this list
- * @return <tt>true</tt> if this list changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>retainAll</tt> operation
+ * @return {@code true} if this list changed as a result of the call
+ * @throws UnsupportedOperationException if the {@code retainAll} operation
* is not supported by this list
* @throws ClassCastException if the class of an element of this list
* is incompatible with the specified collection
@@ -443,12 +466,12 @@
* @Override
* public void sort(Comparator<? super E> c) {
* Object[] elements = toArray();
- * Arrays.sort(elements, c);
- * ListIterator<E> iterator = (ListIterator<Object>) listIterator();
- * for (Object element : elements) {
- * iterator.next();
- * iterator.set((E) element);
- * }
+ * Arrays.sort(elements, c);
+ * ListIterator<E> iterator = (ListIterator<Object>) listIterator();
+ * for (Object element : elements) {
+ * iterator.next();
+ * iterator.set((E) element);
+ * }
* }
* </pre>
*
@@ -510,7 +533,7 @@
* Removes all of the elements from this list (optional operation).
* The list will be empty after this call returns.
*
- * @throws UnsupportedOperationException if the <tt>clear</tt> operation
+ * @throws UnsupportedOperationException if the {@code clear} operation
* is not supported by this list
*/
void clear();
@@ -520,17 +543,17 @@
/**
* Compares the specified object with this list for equality. Returns
- * <tt>true</tt> if and only if the specified object is also a list, both
+ * {@code true} if and only if the specified object is also a list, both
* lists have the same size, and all corresponding pairs of elements in
- * the two lists are <i>equal</i>. (Two elements <tt>e1</tt> and
- * <tt>e2</tt> are <i>equal</i> if <tt>(e1==null ? e2==null :
- * e1.equals(e2))</tt>.) In other words, two lists are defined to be
+ * the two lists are <i>equal</i>. (Two elements {@code e1} and
+ * {@code e2} are <i>equal</i> if {@code Objects.equals(e1, e2)}.)
+ * In other words, two lists are defined to be
* equal if they contain the same elements in the same order. This
* definition ensures that the equals method works properly across
- * different implementations of the <tt>List</tt> interface.
+ * different implementations of the {@code List} interface.
*
* @param o the object to be compared for equality with this list
- * @return <tt>true</tt> if the specified object is equal to this list
+ * @return {@code true} if the specified object is equal to this list
*/
boolean equals(Object o);
@@ -542,9 +565,9 @@
* for (E e : list)
* hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
* }</pre>
- * This ensures that <tt>list1.equals(list2)</tt> implies that
- * <tt>list1.hashCode()==list2.hashCode()</tt> for any two lists,
- * <tt>list1</tt> and <tt>list2</tt>, as required by the general
+ * This ensures that {@code list1.equals(list2)} implies that
+ * {@code list1.hashCode()==list2.hashCode()} for any two lists,
+ * {@code list1} and {@code list2}, as required by the general
* contract of {@link Object#hashCode}.
*
* @return the hash code value for this list
@@ -562,7 +585,7 @@
* @param index index of the element to return
* @return the element at the specified position in this list
* @throws IndexOutOfBoundsException if the index is out of range
- * (<tt>index < 0 || index >= size()</tt>)
+ * ({@code index < 0 || index >= size()})
*/
E get(int index);
@@ -573,7 +596,7 @@
* @param index index of the element to replace
* @param element element to be stored at the specified position
* @return the element previously at the specified position
- * @throws UnsupportedOperationException if the <tt>set</tt> operation
+ * @throws UnsupportedOperationException if the {@code set} operation
* is not supported by this list
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this list
@@ -582,7 +605,7 @@
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this list
* @throws IndexOutOfBoundsException if the index is out of range
- * (<tt>index < 0 || index >= size()</tt>)
+ * ({@code index < 0 || index >= size()})
*/
E set(int index, E element);
@@ -594,7 +617,7 @@
*
* @param index index at which the specified element is to be inserted
* @param element element to be inserted
- * @throws UnsupportedOperationException if the <tt>add</tt> operation
+ * @throws UnsupportedOperationException if the {@code add} operation
* is not supported by this list
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this list
@@ -603,7 +626,7 @@
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this list
* @throws IndexOutOfBoundsException if the index is out of range
- * (<tt>index < 0 || index > size()</tt>)
+ * ({@code index < 0 || index > size()})
*/
void add(int index, E element);
@@ -615,10 +638,10 @@
*
* @param index the index of the element to be removed
* @return the element previously at the specified position
- * @throws UnsupportedOperationException if the <tt>remove</tt> operation
+ * @throws UnsupportedOperationException if the {@code remove} operation
* is not supported by this list
* @throws IndexOutOfBoundsException if the index is out of range
- * (<tt>index < 0 || index >= size()</tt>)
+ * ({@code index < 0 || index >= size()})
*/
E remove(int index);
@@ -628,8 +651,8 @@
/**
* Returns the index of the first occurrence of the specified element
* in this list, or -1 if this list does not contain the element.
- * More formally, returns the lowest index <tt>i</tt> such that
- * <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>,
+ * More formally, returns the lowest index {@code i} such that
+ * {@code Objects.equals(o, get(i))},
* or -1 if there is no such index.
*
* @param o element to search for
@@ -647,8 +670,8 @@
/**
* Returns the index of the last occurrence of the specified element
* in this list, or -1 if this list does not contain the element.
- * More formally, returns the highest index <tt>i</tt> such that
- * <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>,
+ * More formally, returns the highest index {@code i} such that
+ * {@code Objects.equals(o, get(i))},
* or -1 if there is no such index.
*
* @param o element to search for
@@ -696,8 +719,8 @@
/**
* Returns a view of the portion of this list between the specified
- * <tt>fromIndex</tt>, inclusive, and <tt>toIndex</tt>, exclusive. (If
- * <tt>fromIndex</tt> and <tt>toIndex</tt> are equal, the returned list is
+ * {@code fromIndex}, inclusive, and {@code toIndex}, exclusive. (If
+ * {@code fromIndex} and {@code toIndex} are equal, the returned list is
* empty.) The returned list is backed by this list, so non-structural
* changes in the returned list are reflected in this list, and vice-versa.
* The returned list supports all of the optional list operations supported
@@ -711,9 +734,9 @@
* <pre>{@code
* list.subList(from, to).clear();
* }</pre>
- * Similar idioms may be constructed for <tt>indexOf</tt> and
- * <tt>lastIndexOf</tt>, and all of the algorithms in the
- * <tt>Collections</tt> class can be applied to a subList.<p>
+ * Similar idioms may be constructed for {@code indexOf} and
+ * {@code lastIndexOf}, and all of the algorithms in the
+ * {@code Collections} class can be applied to a subList.<p>
*
* The semantics of the list returned by this method become undefined if
* the backing list (i.e., this list) is <i>structurally modified</i> in
@@ -725,8 +748,8 @@
* @param toIndex high endpoint (exclusive) of the subList
* @return a view of the specified range within this list
* @throws IndexOutOfBoundsException for an illegal endpoint index value
- * (<tt>fromIndex < 0 || toIndex > size ||
- * fromIndex > toIndex</tt>)
+ * ({@code fromIndex < 0 || toIndex > size ||
+ * fromIndex > toIndex})
*/
List<E> subList(int fromIndex, int toIndex);
@@ -739,9 +762,22 @@
*
* @implSpec
* The default implementation creates a
- * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
- * from the list's {@code Iterator}. The spliterator inherits the
- * <em>fail-fast</em> properties of the list's iterator.
+ * <em><a href="Spliterator.html#binding">late-binding</a></em>
+ * spliterator as follows:
+ * <ul>
+ * <li>If the list is an instance of {@link RandomAccess} then the default
+ * implementation creates a spliterator that traverses elements by
+ * invoking the method {@link List#get}. If such invocation results or
+ * would result in an {@code IndexOutOfBoundsException} then the
+ * spliterator will <em>fail-fast</em> and throw a
+ * {@code ConcurrentModificationException}.
+ * If the list is also an instance of {@link AbstractList} then the
+ * spliterator will use the list's {@link AbstractList#modCount modCount}
+ * field to provide additional <em>fail-fast</em> behavior.
+ * <li>Otherwise, the default implementation creates a spliterator from the
+ * list's {@code Iterator}. The spliterator inherits the
+ * <em>fail-fast</em> of the list's iterator.
+ * </ul>
*
* @implNote
* The created {@code Spliterator} additionally reports
@@ -752,6 +788,274 @@
*/
@Override
default Spliterator<E> spliterator() {
- return Spliterators.spliterator(this, Spliterator.ORDERED);
+ if (this instanceof RandomAccess) {
+ return new AbstractList.RandomAccessSpliterator<>(this);
+ } else {
+ return Spliterators.spliterator(this, Spliterator.ORDERED);
+ }
+ }
+
+ /**
+ * Returns an immutable list containing zero elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @return an empty {@code List}
+ *
+ * @since 9
+ */
+ static <E> List<E> of() {
+ return ImmutableCollections.List0.instance();
+ }
+
+ /**
+ * Returns an immutable list containing one element.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the single element
+ * @return a {@code List} containing the specified element
+ * @throws NullPointerException if the element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1) {
+ return new ImmutableCollections.List1<>(e1);
+ }
+
+ /**
+ * Returns an immutable list containing two elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2) {
+ return new ImmutableCollections.List2<>(e1, e2);
+ }
+
+ /**
+ * Returns an immutable list containing three elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3);
+ }
+
+ /**
+ * Returns an immutable list containing four elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4);
+ }
+
+ /**
+ * Returns an immutable list containing five elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4, E e5) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5);
+ }
+
+ /**
+ * Returns an immutable list containing six elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
+ e6);
+ }
+
+ /**
+ * Returns an immutable list containing seven elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
+ e6, e7);
+ }
+
+ /**
+ * Returns an immutable list containing eight elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @param e8 the eighth element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
+ e6, e7, e8);
+ }
+
+ /**
+ * Returns an immutable list containing nine elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @param e8 the eighth element
+ * @param e9 the ninth element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
+ e6, e7, e8, e9);
+ }
+
+ /**
+ * Returns an immutable list containing ten elements.
+ *
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @param e8 the eighth element
+ * @param e9 the ninth element
+ * @param e10 the tenth element
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
+ return new ImmutableCollections.ListN<>(e1, e2, e3, e4, e5,
+ e6, e7, e8, e9, e10);
+ }
+
+ /**
+ * Returns an immutable list containing an arbitrary number of elements.
+ * See <a href="#immutable">Immutable List Static Factory Methods</a> for details.
+ *
+ * @apiNote
+ * This method also accepts a single array as an argument. The element type of
+ * the resulting list will be the component type of the array, and the size of
+ * the list will be equal to the length of the array. To create a list with
+ * a single element that is an array, do the following:
+ *
+ * <pre>{@code
+ * String[] array = ... ;
+ * List<String[]> list = List.<String[]>of(array);
+ * }</pre>
+ *
+ * This will cause the {@link List#of(Object) List.of(E)} method
+ * to be invoked instead.
+ *
+ * @param <E> the {@code List}'s element type
+ * @param elements the elements to be contained in the list
+ * @return a {@code List} containing the specified elements
+ * @throws NullPointerException if an element is {@code null} or if the array is {@code null}
+ *
+ * @since 9
+ */
+ @SafeVarargs
+ @SuppressWarnings("varargs")
+ static <E> List<E> of(E... elements) {
+ switch (elements.length) { // implicit null check of elements
+ case 0:
+ return ImmutableCollections.List0.instance();
+ case 1:
+ return new ImmutableCollections.List1<>(elements[0]);
+ case 2:
+ return new ImmutableCollections.List2<>(elements[0], elements[1]);
+ default:
+ return new ImmutableCollections.ListN<>(elements);
+ }
}
}
diff --git a/ojluni/src/main/java/java/util/Locale.java b/ojluni/src/main/java/java/util/Locale.java
index c66559a..1ce4a202 100644
--- a/ojluni/src/main/java/java/util/Locale.java
+++ b/ojluni/src/main/java/java/util/Locale.java
@@ -41,6 +41,7 @@
package java.util;
+import com.android.icu.util.LocaleNative;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -1874,9 +1875,9 @@
// TODO: We need a new hack or a complete fix for http://b/8049507 --- We would
// cover the frameworks' tracks when they were using "tl" instead of "fil".
- String result = ICU.getDisplayLanguage(this, locale);
+ String result = LocaleNative.getDisplayLanguage(this, locale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayLanguage(this, Locale.getDefault());
+ result = LocaleNative.getDisplayLanguage(this, Locale.getDefault());
}
return result;
}
@@ -1949,9 +1950,9 @@
return "";
}
- String result = ICU.getDisplayScript(this, inLocale);
+ String result = LocaleNative.getDisplayScript(this, inLocale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayScript(this, Locale.getDefault(Category.DISPLAY));
+ result = LocaleNative.getDisplayScript(this, Locale.getDefault(Category.DISPLAY));
}
return result;
@@ -2043,9 +2044,9 @@
return countryCode;
}
- String result = ICU.getDisplayCountry(this, locale);
+ String result = LocaleNative.getDisplayCountry(this, locale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayCountry(this, Locale.getDefault());
+ result = LocaleNative.getDisplayCountry(this, Locale.getDefault());
}
return result;
}
@@ -2154,9 +2155,9 @@
return variantCode;
}
- String result = ICU.getDisplayVariant(this, inLocale);
+ String result = LocaleNative.getDisplayVariant(this, inLocale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayVariant(this, Locale.getDefault());
+ result = LocaleNative.getDisplayVariant(this, Locale.getDefault());
}
// The "old style" locale constructors allow us to pass in variants that aren't
@@ -2349,7 +2350,7 @@
* <li>{@code new Locale("en").getDisplayName(Locale.US)} -> {@code English}
* <li>{@code new Locale("en", "US").getDisplayName(Locale.US)} -> {@code English (United States)}
* <li>{@code new Locale("en", "US", "POSIX").getDisplayName(Locale.US)} -> {@code English (United States,Computer)}
- * <li>{@code Locale.fromLanguageTag("zh-Hant-CN").getDisplayName(Locale.US)} -> {@code Chinese (Traditional Han,China)}
+ * <li>{@code Locale.forLanguageTag("zh-Hant-CN").getDisplayName(Locale.US)} -> {@code Chinese (Traditional Han,China)}
* <li>{@code new Locale("en").getDisplayName(Locale.FRANCE)} -> {@code anglais}
* <li>{@code new Locale("en", "US").getDisplayName(Locale.FRANCE)} -> {@code anglais (États-Unis)}
* <li>{@code new Locale("en", "US", "POSIX").getDisplayName(Locale.FRANCE)} -> {@code anglais (États-Unis,informatique)}.
diff --git a/ojluni/src/main/java/java/util/Map.java b/ojluni/src/main/java/java/util/Map.java
index 2715b15..ed365ec 100644
--- a/ojluni/src/main/java/java/util/Map.java
+++ b/ojluni/src/main/java/java/util/Map.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -30,7 +30,6 @@
import java.util.function.Function;
import java.io.Serializable;
-// Android-changed: removed docs for removed OpenJDK 9 Immutable Map static methods
// Android-changed: removed link to collections framework docs
/**
* An object that maps keys to values. A map cannot contain duplicate keys;
@@ -112,6 +111,35 @@
* 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.
+ * 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.
+ * 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
+ * {@code null} keys or values result in {@code NullPointerException}.
+ * <li>They are serializable if all keys and values are serializable.
+ * <li>They reject duplicate keys at creation time. Duplicate keys
+ * passed to a static factory method result in {@code IllegalArgumentException}.
+ * <li>The iteration order of mappings is unspecified and is subject to change.
+ * <li>They are <a href="../lang/doc-files/ValueBased.html">value-based</a>.
+ * Callers should make no assumptions about the identity of the returned instances.
+ * Factories are free to create new instances or reuse existing ones. Therefore,
+ * identity-sensitive operations on these instances (reference equality ({@code ==}),
+ * identity hash code, and synchronization) are unreliable and should be avoided.
+ * <li>They are serialized as specified on the
+ * <a href="{@docRoot}/serialized-form.html#java.util.CollSer">Serialized Form</a>
+ * page.
+ * </ul>
+ *
* @param <K> the type of keys maintained by this map
* @param <V> the type of mapped values
*
@@ -1245,5 +1273,384 @@
return newValue;
}
- // Android-removed: OpenJDK 9 Immutable Map static methods
+ /**
+ * Returns an immutable map containing zero mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @return an empty {@code Map}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of() {
+ return ImmutableCollections.Map0.instance();
+ }
+
+ /**
+ * Returns an immutable map containing a single mapping.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the mapping's key
+ * @param v1 the mapping's value
+ * @return a {@code Map} containing the specified mapping
+ * @throws NullPointerException if the key or the value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1) {
+ return new ImmutableCollections.Map1<>(k1, v1);
+ }
+
+ /**
+ * Returns an immutable map containing two mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if the keys are duplicates
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2);
+ }
+
+ /**
+ * Returns an immutable map containing three mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3);
+ }
+
+ /**
+ * Returns an immutable map containing four mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4);
+ }
+
+ /**
+ * Returns an immutable map containing five mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @param k5 the fifth mapping's key
+ * @param v5 the fifth mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
+ }
+
+ /**
+ * Returns an immutable map containing six mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @param k5 the fifth mapping's key
+ * @param v5 the fifth mapping's value
+ * @param k6 the sixth mapping's key
+ * @param v6 the sixth mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5,
+ K k6, V v6) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5,
+ k6, v6);
+ }
+
+ /**
+ * Returns an immutable map containing seven mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @param k5 the fifth mapping's key
+ * @param v5 the fifth mapping's value
+ * @param k6 the sixth mapping's key
+ * @param v6 the sixth mapping's value
+ * @param k7 the seventh mapping's key
+ * @param v7 the seventh mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5,
+ K k6, V v6, K k7, V v7) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5,
+ k6, v6, k7, v7);
+ }
+
+ /**
+ * Returns an immutable map containing eight mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @param k5 the fifth mapping's key
+ * @param v5 the fifth mapping's value
+ * @param k6 the sixth mapping's key
+ * @param v6 the sixth mapping's value
+ * @param k7 the seventh mapping's key
+ * @param v7 the seventh mapping's value
+ * @param k8 the eighth mapping's key
+ * @param v8 the eighth mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5,
+ K k6, V v6, K k7, V v7, K k8, V v8) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5,
+ k6, v6, k7, v7, k8, v8);
+ }
+
+ /**
+ * Returns an immutable map containing nine mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @param k5 the fifth mapping's key
+ * @param v5 the fifth mapping's value
+ * @param k6 the sixth mapping's key
+ * @param v6 the sixth mapping's value
+ * @param k7 the seventh mapping's key
+ * @param v7 the seventh mapping's value
+ * @param k8 the eighth mapping's key
+ * @param v8 the eighth mapping's value
+ * @param k9 the ninth mapping's key
+ * @param v9 the ninth mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5,
+ K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5,
+ k6, v6, k7, v7, k8, v8, k9, v9);
+ }
+
+ /**
+ * Returns an immutable map containing ten mappings.
+ * See <a href="#immutable">Immutable Map Static Factory Methods</a> for details.
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param k1 the first mapping's key
+ * @param v1 the first mapping's value
+ * @param k2 the second mapping's key
+ * @param v2 the second mapping's value
+ * @param k3 the third mapping's key
+ * @param v3 the third mapping's value
+ * @param k4 the fourth mapping's key
+ * @param v4 the fourth mapping's value
+ * @param k5 the fifth mapping's key
+ * @param v5 the fifth mapping's value
+ * @param k6 the sixth mapping's key
+ * @param v6 the sixth mapping's value
+ * @param k7 the seventh mapping's key
+ * @param v7 the seventh mapping's value
+ * @param k8 the eighth mapping's key
+ * @param v8 the eighth mapping's value
+ * @param k9 the ninth mapping's key
+ * @param v9 the ninth mapping's value
+ * @param k10 the tenth mapping's key
+ * @param v10 the tenth mapping's value
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any key or value is {@code null}
+ *
+ * @since 9
+ */
+ static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5,
+ K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) {
+ return new ImmutableCollections.MapN<>(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5,
+ k6, v6, k7, v7, k8, v8, k9, v9, k10, v10);
+ }
+
+ /**
+ * Returns an immutable 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.
+ *
+ * @apiNote
+ * It is convenient to create the map entries using the {@link Map#entry Map.entry()} method.
+ * For example,
+ *
+ * <pre>{@code
+ * import static java.util.Map.entry;
+ *
+ * Map<Integer,String> map = Map.ofEntries(
+ * entry(1, "a"),
+ * entry(2, "b"),
+ * entry(3, "c"),
+ * ...
+ * entry(26, "z"));
+ * }</pre>
+ *
+ * @param <K> the {@code Map}'s key type
+ * @param <V> the {@code Map}'s value type
+ * @param entries {@code Map.Entry}s containing the keys and values from which the map is populated
+ * @return a {@code Map} containing the specified mappings
+ * @throws IllegalArgumentException if there are any duplicate keys
+ * @throws NullPointerException if any entry, key, or value is {@code null}, or if
+ * the {@code entries} array is {@code null}
+ *
+ * @see Map#entry Map.entry()
+ * @since 9
+ */
+ @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
+ return ImmutableCollections.Map0.instance();
+ } else if (entries.length == 1) {
+ 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) {
+ kva[a++] = entry.getKey();
+ kva[a++] = entry.getValue();
+ }
+ return new ImmutableCollections.MapN<>(kva);
+ }
+ }
+
+ /**
+ * Returns an immutable {@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:
+ *
+ * <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()}
+ * 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>.
+ * Callers should make no assumptions about the identity of the returned instances.
+ * This method is free to create new instances or reuse existing ones. Therefore,
+ * identity-sensitive operations on these instances (reference equality ({@code ==}),
+ * identity hash code, and synchronization) are unreliable and should be avoided.
+ * </ul>
+ *
+ * @apiNote
+ * For a serializable {@code Entry}, see {@link AbstractMap.SimpleEntry} or
+ * {@link AbstractMap.SimpleImmutableEntry}.
+ *
+ * @param <K> the key's type
+ * @param <V> the value's type
+ * @param k the key
+ * @param v the value
+ * @return an {@code Entry} containing the specified key and value
+ * @throws NullPointerException if the key or value is {@code null}
+ *
+ * @see Map#ofEntries Map.ofEntries()
+ * @since 9
+ */
+ static <K, V> Entry<K, V> entry(K k, V v) {
+ // KeyValueHolder checks for nulls
+ return new KeyValueHolder<>(k, v);
+ }
}
diff --git a/ojluni/src/main/java/java/util/Objects.java b/ojluni/src/main/java/java/util/Objects.java
index e526079..1f76487 100644
--- a/ojluni/src/main/java/java/util/Objects.java
+++ b/ojluni/src/main/java/java/util/Objects.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
@@ -25,13 +25,30 @@
package java.util;
+import jdk.internal.util.Preconditions;
+
import java.util.function.Supplier;
/**
* This class consists of {@code static} utility methods for operating
- * on objects. These utilities include {@code null}-safe or {@code
- * null}-tolerant methods for computing the hash code of an object,
- * returning a string for an object, and comparing two objects.
+ * on objects, or checking certain conditions before operation. These utilities
+ * include {@code null}-safe or {@code null}-tolerant methods for computing the
+ * hash code of an object, returning a string for an object, comparing two
+ * objects, and checking if indexes or sub-range values are out-of-bounds.
+ *
+ * @apiNote
+ * Static methods such as {@link Objects#checkIndex},
+ * {@link Objects#checkFromToIndex}, and {@link Objects#checkFromIndexSize} are
+ * provided for the convenience of checking if values corresponding to indexes
+ * and sub-ranges are out-of-bounds.
+ * Variations of these static methods support customization of the runtime
+ * exception, and corresponding exception detail message, that is thrown when
+ * values are out-of-bounds. Such methods accept a functional interface
+ * argument, instances of {@code BiFunction}, that maps out-of-bound values to a
+ * runtime exception. Care should be taken when using such methods in
+ * combination with an argument that is a lambda expression, method reference or
+ * class that capture values. In such cases the cost of capture, related to
+ * functional interface allocation, may exceed the cost of checking bounds.
*
* @since 1.7
*/
@@ -266,6 +283,44 @@
}
/**
+ * Returns the first argument if it is non-{@code null} and
+ * otherwise returns the non-{@code null} second argument.
+ *
+ * @param obj an object
+ * @param defaultObj a non-{@code null} object to return if the first argument
+ * is {@code null}
+ * @param <T> the type of the reference
+ * @return the first argument if it is non-{@code null} and
+ * otherwise the second argument if it is non-{@code null}
+ * @throws NullPointerException if both {@code obj} is null and
+ * {@code defaultObj} is {@code null}
+ * @since 9
+ */
+ public static <T> T requireNonNullElse(T obj, T defaultObj) {
+ return (obj != null) ? obj : requireNonNull(defaultObj, "defaultObj");
+ }
+
+ /**
+ * Returns the first argument if it is non-{@code null} and otherwise
+ * returns the non-{@code null} value of {@code supplier.get()}.
+ *
+ * @param obj an object
+ * @param supplier of a non-{@code null} object to return if the first argument
+ * is {@code null}
+ * @param <T> the type of the first argument and return type
+ * @return the first argument if it is non-{@code null} and otherwise
+ * the value from {@code supplier.get()} if it is non-{@code null}
+ * @throws NullPointerException if both {@code obj} is null and
+ * either the {@code supplier} is {@code null} or
+ * the {@code supplier.get()} value is {@code null}
+ * @since 9
+ */
+ public static <T> T requireNonNullElseGet(T obj, Supplier<? extends T> supplier) {
+ return (obj != null) ? obj
+ : requireNonNull(requireNonNull(supplier, "supplier").get(), "supplier.get()");
+ }
+
+ /**
* Checks that the specified object reference is not {@code null} and
* throws a customized {@link NullPointerException} if it is.
*
@@ -287,7 +342,86 @@
*/
public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) {
if (obj == null)
- throw new NullPointerException(messageSupplier.get());
+ throw new NullPointerException(messageSupplier == null ?
+ null : messageSupplier.get());
return obj;
}
+
+ /**
+ * Checks if the {@code index} is within the bounds of the range from
+ * {@code 0} (inclusive) to {@code length} (exclusive).
+ *
+ * <p>The {@code index} is defined to be out-of-bounds if any of the
+ * following inequalities is true:
+ * <ul>
+ * <li>{@code index < 0}</li>
+ * <li>{@code index >= length}</li>
+ * <li>{@code length < 0}, which is implied from the former inequalities</li>
+ * </ul>
+ *
+ * @param index the index
+ * @param length the upper-bound (exclusive) of the range
+ * @return {@code index} if it is within bounds of the range
+ * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
+ * @since 9
+ */
+ // Android-removed: @ForceInline is an unsupported attribute.
+ //@ForceInline
+ public static
+ int checkIndex(int index, int length) {
+ return Preconditions.checkIndex(index, length, null);
+ }
+
+ /**
+ * Checks if the sub-range from {@code fromIndex} (inclusive) to
+ * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
+ * (inclusive) to {@code length} (exclusive).
+ *
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
+ * inequalities is true:
+ * <ul>
+ * <li>{@code fromIndex < 0}</li>
+ * <li>{@code fromIndex > toIndex}</li>
+ * <li>{@code toIndex > length}</li>
+ * <li>{@code length < 0}, which is implied from the former inequalities</li>
+ * </ul>
+ *
+ * @param fromIndex the lower-bound (inclusive) of the sub-range
+ * @param toIndex the upper-bound (exclusive) of the sub-range
+ * @param length the upper-bound (exclusive) the range
+ * @return {@code fromIndex} if the sub-range within bounds of the range
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds
+ * @since 9
+ */
+ public static
+ int checkFromToIndex(int fromIndex, int toIndex, int length) {
+ return Preconditions.checkFromToIndex(fromIndex, toIndex, length, null);
+ }
+
+ /**
+ * Checks if the sub-range from {@code fromIndex} (inclusive) to
+ * {@code fromIndex + size} (exclusive) is within the bounds of range from
+ * {@code 0} (inclusive) to {@code length} (exclusive).
+ *
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
+ * inequalities is true:
+ * <ul>
+ * <li>{@code fromIndex < 0}</li>
+ * <li>{@code size < 0}</li>
+ * <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
+ * <li>{@code length < 0}, which is implied from the former inequalities</li>
+ * </ul>
+ *
+ * @param fromIndex the lower-bound (inclusive) of the sub-interval
+ * @param size the size of the sub-range
+ * @param length the upper-bound (exclusive) of the range
+ * @return {@code fromIndex} if the sub-range within bounds of the range
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds
+ * @since 9
+ */
+ public static
+ int checkFromIndexSize(int fromIndex, int size, int length) {
+ return Preconditions.checkFromIndexSize(fromIndex, size, length, null);
+ }
+
}
diff --git a/ojluni/src/main/java/java/util/Set.java b/ojluni/src/main/java/java/util/Set.java
index 2703049..0499ea3 100644
--- a/ojluni/src/main/java/java/util/Set.java
+++ b/ojluni/src/main/java/java/util/Set.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,16 +27,16 @@
/**
* A collection that contains no duplicate elements. More formally, sets
- * contain no pair of elements <code>e1</code> and <code>e2</code> such that
- * <code>e1.equals(e2)</code>, and at most one null element. As implied by
+ * contain no pair of elements {@code e1} and {@code e2} such that
+ * {@code e1.equals(e2)}, and at most one null element. As implied by
* its name, this interface models the mathematical <i>set</i> abstraction.
*
- * <p>The <tt>Set</tt> interface places additional stipulations, beyond those
- * inherited from the <tt>Collection</tt> interface, on the contracts of all
- * constructors and on the contracts of the <tt>add</tt>, <tt>equals</tt> and
- * <tt>hashCode</tt> methods. Declarations for other inherited methods are
+ * <p>The {@code Set} interface places additional stipulations, beyond those
+ * inherited from the {@code Collection} interface, on the contracts of all
+ * constructors and on the contracts of the {@code add}, {@code equals} and
+ * {@code hashCode} methods. Declarations for other inherited methods are
* also included here for convenience. (The specifications accompanying these
- * declarations have been tailored to the <tt>Set</tt> interface, but they do
+ * declarations have been tailored to the {@code Set} interface, but they do
* not contain any additional stipulations.)
*
* <p>The additional stipulation on constructors is, not surprisingly,
@@ -45,7 +45,7 @@
*
* <p>Note: Great care must be exercised if mutable objects are used as set
* elements. The behavior of a set is not specified if the value of an object
- * is changed in a manner that affects <tt>equals</tt> comparisons while the
+ * is changed in a manner that affects {@code equals} comparisons while the
* object is an element in the set. A special case of this prohibition is
* that it is not permissible for a set to contain itself as an element.
*
@@ -53,7 +53,7 @@
* 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
- * <tt>NullPointerException</tt> or <tt>ClassCastException</tt>. Attempting
+ * {@code NullPointerException} or {@code ClassCastException}. Attempting
* to query the presence of an ineligible element may throw an exception,
* or it may simply return false; some implementations will exhibit the former
* behavior and some will exhibit the latter. More generally, attempting an
@@ -63,6 +63,33 @@
* 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}
+ * 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.
+ * 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
+ * {@code null} elements result in {@code NullPointerException}.
+ * <li>They are serializable if all elements are serializable.
+ * <li>They reject duplicate elements at creation time. Duplicate elements
+ * passed to a static factory method result in {@code IllegalArgumentException}.
+ * <li>The iteration order of set elements is unspecified and is subject to change.
+ * <li>They are <a href="../lang/doc-files/ValueBased.html">value-based</a>.
+ * Callers should make no assumptions about the identity of the returned instances.
+ * Factories are free to create new instances or reuse existing ones. Therefore,
+ * identity-sensitive operations on these instances (reference equality ({@code ==}),
+ * identity hash code, and synchronization) are unreliable and should be avoided.
+ * <li>They are serialized as specified on the
+ * <a href="{@docRoot}/serialized-form.html#java.util.CollSer">Serialized Form</a>
+ * page.
+ * </ul>
+ *
* <p>This interface is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
@@ -87,28 +114,28 @@
/**
* Returns the number of elements in this set (its cardinality). If this
- * set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
- * <tt>Integer.MAX_VALUE</tt>.
+ * set contains more than {@code Integer.MAX_VALUE} elements, returns
+ * {@code Integer.MAX_VALUE}.
*
* @return the number of elements in this set (its cardinality)
*/
int size();
/**
- * Returns <tt>true</tt> if this set contains no elements.
+ * Returns {@code true} if this set contains no elements.
*
- * @return <tt>true</tt> if this set contains no elements
+ * @return {@code true} if this set contains no elements
*/
boolean isEmpty();
/**
- * Returns <tt>true</tt> if this set contains the specified element.
- * More formally, returns <tt>true</tt> if and only if this set
- * contains an element <tt>e</tt> such that
- * <tt>(o==null ? e==null : o.equals(e))</tt>.
+ * Returns {@code true} if this set contains the specified element.
+ * More formally, returns {@code true} if and only if this set
+ * contains an element {@code e} such that
+ * {@code Objects.equals(o, e)}.
*
* @param o element whose presence in this set is to be tested
- * @return <tt>true</tt> if this set contains the specified element
+ * @return {@code true} if this set contains the specified element
* @throws ClassCastException if the type of the specified element
* is incompatible with this set
* (<a href="Collection.html#optional-restrictions">optional</a>)
@@ -155,7 +182,7 @@
* <p>If this set fits in the specified array with room to spare
* (i.e., the array has more elements than this set), the element in
* the array immediately following the end of the set is set to
- * <tt>null</tt>. (This is useful in determining the length of this
+ * {@code null}. (This is useful in determining the length of this
* set <i>only</i> if the caller knows that this set does not contain
* any null elements.)
*
@@ -168,15 +195,15 @@
* precise control over the runtime type of the output array, and may,
* under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose <tt>x</tt> is a set known to contain only strings.
+ * <p>Suppose {@code x} is a set known to contain only strings.
* The following code can be used to dump the set into a newly allocated
- * array of <tt>String</tt>:
+ * array of {@code String}:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * Note that <tt>toArray(new Object[0])</tt> is identical in function to
- * <tt>toArray()</tt>.
+ * Note that {@code toArray(new Object[0])} is identical in function to
+ * {@code toArray()}.
*
* @param a the array into which the elements of this set are to be
* stored, if it is big enough; otherwise, a new array of the same
@@ -195,25 +222,25 @@
/**
* Adds the specified element to this set if it is not already present
* (optional operation). More formally, adds the specified element
- * <tt>e</tt> to this set if the set contains no element <tt>e2</tt>
+ * {@code e} to this set if the set contains no element {@code e2}
* such that
- * <tt>(e==null ? e2==null : e.equals(e2))</tt>.
+ * {@code Objects.equals(e, e2)}.
* If this set already contains the element, the call leaves the set
- * unchanged and returns <tt>false</tt>. In combination with the
+ * unchanged and returns {@code false}. In combination with the
* restriction on constructors, this ensures that sets never contain
* duplicate elements.
*
* <p>The stipulation above does not imply that sets must accept all
* elements; sets may refuse to add any particular element, including
- * <tt>null</tt>, and throw an exception, as described in the
+ * {@code null}, and throw an exception, as described in the
* specification for {@link Collection#add Collection.add}.
* Individual set implementations should clearly document any
* restrictions on the elements that they may contain.
*
* @param e element to be added to this set
- * @return <tt>true</tt> if this set did not already contain the specified
+ * @return {@code true} if this set did not already contain the specified
* element
- * @throws UnsupportedOperationException if the <tt>add</tt> operation
+ * @throws UnsupportedOperationException if the {@code add} operation
* is not supported by this set
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this set
@@ -227,23 +254,23 @@
/**
* Removes the specified element from this set if it is present
- * (optional operation). More formally, removes an element <tt>e</tt>
+ * (optional operation). More formally, removes an element {@code e}
* such that
- * <tt>(o==null ? e==null : o.equals(e))</tt>, if
- * this set contains such an element. Returns <tt>true</tt> if this set
+ * {@code Objects.equals(o, e)}, if
+ * this set contains such an element. Returns {@code true} if this set
* contained the element (or equivalently, if this set changed as a
* result of the call). (This set will not contain the element once the
* call returns.)
*
* @param o object to be removed from this set, if present
- * @return <tt>true</tt> if this set contained the specified element
+ * @return {@code true} if this set contained the specified element
* @throws ClassCastException if the type of the specified element
* is incompatible with this set
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified element is null and this
* set does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>)
- * @throws UnsupportedOperationException if the <tt>remove</tt> operation
+ * @throws UnsupportedOperationException if the {@code remove} operation
* is not supported by this set
*/
boolean remove(Object o);
@@ -252,12 +279,12 @@
// Bulk Operations
/**
- * Returns <tt>true</tt> if this set contains all of the elements of the
+ * Returns {@code true} if this set contains all of the elements of the
* specified collection. If the specified collection is also a set, this
- * method returns <tt>true</tt> if it is a <i>subset</i> of this set.
+ * method returns {@code true} if it is a <i>subset</i> of this set.
*
* @param c collection to be checked for containment in this set
- * @return <tt>true</tt> if this set contains all of the elements of the
+ * @return {@code true} if this set contains all of the elements of the
* specified collection
* @throws ClassCastException if the types of one or more elements
* in the specified collection are incompatible with this
@@ -275,15 +302,15 @@
/**
* Adds all of the elements in the specified collection to this set if
* they're not already present (optional operation). If the specified
- * collection is also a set, the <tt>addAll</tt> operation effectively
+ * collection is also a set, the {@code addAll} operation effectively
* modifies this set so that its value is the <i>union</i> of the two
* sets. The behavior of this operation is undefined if the specified
* collection is modified while the operation is in progress.
*
* @param c collection containing elements to be added to this set
- * @return <tt>true</tt> if this set changed as a result of the call
+ * @return {@code true} if this set changed as a result of the call
*
- * @throws UnsupportedOperationException if the <tt>addAll</tt> operation
+ * @throws UnsupportedOperationException if the {@code addAll} operation
* is not supported by this set
* @throws ClassCastException if the class of an element of the
* specified collection prevents it from being added to this set
@@ -305,8 +332,8 @@
* <i>intersection</i> of the two sets.
*
* @param c collection containing elements to be retained in this set
- * @return <tt>true</tt> if this set changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>retainAll</tt> operation
+ * @return {@code true} if this set changed as a result of the call
+ * @throws UnsupportedOperationException if the {@code retainAll} operation
* is not supported by this set
* @throws ClassCastException if the class of an element of this set
* is incompatible with the specified collection
@@ -327,8 +354,8 @@
* the two sets.
*
* @param c collection containing elements to be removed from this set
- * @return <tt>true</tt> if this set changed as a result of the call
- * @throws UnsupportedOperationException if the <tt>removeAll</tt> operation
+ * @return {@code true} if this set changed as a result of the call
+ * @throws UnsupportedOperationException if the {@code removeAll} operation
* is not supported by this set
* @throws ClassCastException if the class of an element of this set
* is incompatible with the specified collection
@@ -346,7 +373,7 @@
* Removes all of the elements from this set (optional operation).
* The set will be empty after this call returns.
*
- * @throws UnsupportedOperationException if the <tt>clear</tt> method
+ * @throws UnsupportedOperationException if the {@code clear} method
* is not supported by this set
*/
void clear();
@@ -356,7 +383,7 @@
/**
* Compares the specified object with this set for equality. Returns
- * <tt>true</tt> if the specified object is also a set, the two sets
+ * {@code true} if the specified object is also a set, the two sets
* have the same size, and every member of the specified set is
* contained in this set (or equivalently, every member of this set is
* contained in the specified set). This definition ensures that the
@@ -364,17 +391,17 @@
* set interface.
*
* @param o object to be compared for equality with this set
- * @return <tt>true</tt> if the specified object is equal to this set
+ * @return {@code true} if the specified object is equal to this set
*/
boolean equals(Object o);
/**
* Returns the hash code value for this set. The hash code of a set is
* defined to be the sum of the hash codes of the elements in the set,
- * where the hash code of a <tt>null</tt> element is defined to be zero.
- * This ensures that <tt>s1.equals(s2)</tt> implies that
- * <tt>s1.hashCode()==s2.hashCode()</tt> for any two sets <tt>s1</tt>
- * and <tt>s2</tt>, as required by the general contract of
+ * where the hash code of a {@code null} element is defined to be zero.
+ * This ensures that {@code s1.equals(s2)} implies that
+ * {@code s1.hashCode()==s2.hashCode()} for any two sets {@code s1}
+ * and {@code s2}, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this set
@@ -410,4 +437,267 @@
default Spliterator<E> spliterator() {
return Spliterators.spliterator(this, Spliterator.DISTINCT);
}
+
+ /**
+ * Returns an immutable set containing zero elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @return an empty {@code Set}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of() {
+ return ImmutableCollections.Set0.instance();
+ }
+
+ /**
+ * Returns an immutable set containing one element.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the single element
+ * @return a {@code Set} containing the specified element
+ * @throws NullPointerException if the element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1) {
+ return new ImmutableCollections.Set1<>(e1);
+ }
+
+ /**
+ * Returns an immutable set containing two elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if the elements are duplicates
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2) {
+ return new ImmutableCollections.Set2<>(e1, e2);
+ }
+
+ /**
+ * Returns an immutable set containing three elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3);
+ }
+
+ /**
+ * Returns an immutable set containing four elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4);
+ }
+
+ /**
+ * Returns an immutable set containing five elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4, E e5) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4, e5);
+ }
+
+ /**
+ * Returns an immutable set containing six elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4, E e5, E e6) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4, e5,
+ e6);
+ }
+
+ /**
+ * Returns an immutable set containing seven elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4, e5,
+ e6, e7);
+ }
+
+ /**
+ * Returns an immutable set containing eight elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @param e8 the eighth element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4, e5,
+ e6, e7, e8);
+ }
+
+ /**
+ * Returns an immutable set containing nine elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @param e8 the eighth element
+ * @param e9 the ninth element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4, e5,
+ e6, e7, e8, e9);
+ }
+
+ /**
+ * Returns an immutable set containing ten elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param e1 the first element
+ * @param e2 the second element
+ * @param e3 the third element
+ * @param e4 the fourth element
+ * @param e5 the fifth element
+ * @param e6 the sixth element
+ * @param e7 the seventh element
+ * @param e8 the eighth element
+ * @param e9 the ninth element
+ * @param e10 the tenth element
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null}
+ *
+ * @since 9
+ */
+ static <E> Set<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
+ return new ImmutableCollections.SetN<>(e1, e2, e3, e4, e5,
+ e6, e7, e8, e9, e10);
+ }
+
+ /**
+ * Returns an immutable set containing an arbitrary number of elements.
+ * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
+ *
+ * @apiNote
+ * This method also accepts a single array as an argument. The element type of
+ * the resulting set will be the component type of the array, and the size of
+ * the set will be equal to the length of the array. To create a set with
+ * a single element that is an array, do the following:
+ *
+ * <pre>{@code
+ * String[] array = ... ;
+ * Set<String[]> list = Set.<String[]>of(array);
+ * }</pre>
+ *
+ * This will cause the {@link Set#of(Object) Set.of(E)} method
+ * to be invoked instead.
+ *
+ * @param <E> the {@code Set}'s element type
+ * @param elements the elements to be contained in the set
+ * @return a {@code Set} containing the specified elements
+ * @throws IllegalArgumentException if there are any duplicate elements
+ * @throws NullPointerException if an element is {@code null} or if the array is {@code null}
+ *
+ * @since 9
+ */
+ @SafeVarargs
+ @SuppressWarnings("varargs")
+ static <E> Set<E> of(E... elements) {
+ switch (elements.length) { // implicit null check of elements
+ case 0:
+ return ImmutableCollections.Set0.instance();
+ case 1:
+ return new ImmutableCollections.Set1<>(elements[0]);
+ case 2:
+ return new ImmutableCollections.Set2<>(elements[0], elements[1]);
+ default:
+ return new ImmutableCollections.SetN<>(elements);
+ }
+ }
}
diff --git a/ojluni/src/main/java/java/util/TimeZone.java b/ojluni/src/main/java/java/util/TimeZone.java
index 61826ba..cf5e5f8 100644
--- a/ojluni/src/main/java/java/util/TimeZone.java
+++ b/ojluni/src/main/java/java/util/TimeZone.java
@@ -47,7 +47,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libcore.io.IoUtils;
-import libcore.timezone.ZoneInfoDB;
+import libcore.timezone.ZoneInfoDb;
import dalvik.system.RuntimeHooks;
@@ -557,7 +557,7 @@
* @return the specified <code>TimeZone</code>, or the GMT zone if the given ID
* cannot be understood.
*/
- // Android-changed: param s/ID/id; use ZoneInfoDB instead of ZoneInfo class.
+ // Android-changed: param s/ID/id; use ZoneInfoDb instead of ZoneInfo class.
public static synchronized TimeZone getTimeZone(String id) {
if (id == null) {
throw new NullPointerException("id == null");
@@ -576,7 +576,7 @@
// In the database?
TimeZone zone = null;
try {
- zone = ZoneInfoDB.getInstance().makeTimeZone(id);
+ zone = ZoneInfoDb.getInstance().makeTimeZone(id);
} catch (IOException ignored) {
}
@@ -666,7 +666,7 @@
* @see #getRawOffset()
*/
public static synchronized String[] getAvailableIDs(int rawOffset) {
- return ZoneInfoDB.getInstance().getAvailableIDs(rawOffset);
+ return ZoneInfoDb.getInstance().getAvailableIDs(rawOffset);
}
/**
@@ -674,7 +674,7 @@
* @return an array of IDs.
*/
public static synchronized String[] getAvailableIDs() {
- return ZoneInfoDB.getInstance().getAvailableIDs();
+ return ZoneInfoDb.getInstance().getAvailableIDs();
}
/**
diff --git a/ojluni/src/main/java/java/util/concurrent/Flow.java b/ojluni/src/main/java/java/util/concurrent/Flow.java
new file mode 100644
index 0000000..0231790
--- /dev/null
+++ b/ojluni/src/main/java/java/util/concurrent/Flow.java
@@ -0,0 +1,319 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+package java.util.concurrent;
+
+// Android-changed: Remove reference to SubmissionPublisher class (not present on Android).
+/**
+ * Interrelated interfaces and static methods for establishing
+ * flow-controlled components in which {@link Publisher Publishers}
+ * produce items consumed by one or more {@link Subscriber
+ * Subscribers}, each managed by a {@link Subscription
+ * Subscription}.
+ *
+ * <p>These interfaces correspond to the <a
+ * href="http://www.reactive-streams.org/"> reactive-streams</a>
+ * specification. They apply in both concurrent and distributed
+ * asynchronous settings: All (seven) methods are defined in {@code
+ * void} "one-way" message style. Communication relies on a simple form
+ * of flow control (method {@link Subscription#request}) that can be
+ * used to avoid resource management problems that may otherwise occur
+ * in "push" based systems.
+ *
+ * <p><b>Examples.</b> A {@link Publisher} usually defines its own
+ * {@link Subscription} implementation; constructing one in method
+ * {@code subscribe} and issuing it to the calling {@link
+ * Subscriber}. It publishes items to the subscriber asynchronously,
+ * normally using an {@link Executor}. For example, here is a very
+ * simple publisher that only issues (when requested) a single {@code
+ * TRUE} item to a single subscriber. Because the subscriber receives
+ * only a single item, this class does not use buffering and ordering
+ * control required in most implementations.
+ *
+ * <pre> {@code
+ * class OneShotPublisher implements Publisher<Boolean> {
+ * private final ExecutorService executor = ForkJoinPool.commonPool(); // daemon-based
+ * private boolean subscribed; // true after first subscribe
+ * public synchronized void subscribe(Subscriber<? super Boolean> subscriber) {
+ * if (subscribed)
+ * subscriber.onError(new IllegalStateException()); // only one allowed
+ * else {
+ * subscribed = true;
+ * subscriber.onSubscribe(new OneShotSubscription(subscriber, executor));
+ * }
+ * }
+ * static class OneShotSubscription implements Subscription {
+ * private final Subscriber<? super Boolean> subscriber;
+ * private final ExecutorService executor;
+ * private Future<?> future; // to allow cancellation
+ * private boolean completed;
+ * OneShotSubscription(Subscriber<? super Boolean> subscriber,
+ * ExecutorService executor) {
+ * this.subscriber = subscriber;
+ * this.executor = executor;
+ * }
+ * public synchronized void request(long n) {
+ * if (n != 0 && !completed) {
+ * completed = true;
+ * if (n < 0) {
+ * IllegalArgumentException ex = new IllegalArgumentException();
+ * executor.execute(() -> subscriber.onError(ex));
+ * } else {
+ * future = executor.submit(() -> {
+ * subscriber.onNext(Boolean.TRUE);
+ * subscriber.onComplete();
+ * });
+ * }
+ * }
+ * }
+ * public synchronized void cancel() {
+ * completed = true;
+ * if (future != null) future.cancel(false);
+ * }
+ * }
+ * }}</pre>
+ *
+ * <p>A {@link Subscriber} arranges that items be requested and
+ * processed. Items (invocations of {@link Subscriber#onNext}) are
+ * not issued unless requested, but multiple items may be requested.
+ * Many Subscriber implementations can arrange this in the style of
+ * the following example, where a buffer size of 1 single-steps, and
+ * larger sizes usually allow for more efficient overlapped processing
+ * with less communication; for example with a value of 64, this keeps
+ * total outstanding requests between 32 and 64.
+ * Because Subscriber method invocations for a given {@link
+ * Subscription} are strictly ordered, there is no need for these
+ * methods to use locks or volatiles unless a Subscriber maintains
+ * multiple Subscriptions (in which case it is better to instead
+ * define multiple Subscribers, each with its own Subscription).
+ *
+ * <pre> {@code
+ * class SampleSubscriber<T> implements Subscriber<T> {
+ * final Consumer<? super T> consumer;
+ * Subscription subscription;
+ * final long bufferSize;
+ * long count;
+ * SampleSubscriber(long bufferSize, Consumer<? super T> consumer) {
+ * this.bufferSize = bufferSize;
+ * this.consumer = consumer;
+ * }
+ * public void onSubscribe(Subscription subscription) {
+ * long initialRequestSize = bufferSize;
+ * count = bufferSize - bufferSize / 2; // re-request when half consumed
+ * (this.subscription = subscription).request(initialRequestSize);
+ * }
+ * public void onNext(T item) {
+ * if (--count <= 0)
+ * subscription.request(count = bufferSize - bufferSize / 2);
+ * consumer.accept(item);
+ * }
+ * public void onError(Throwable ex) { ex.printStackTrace(); }
+ * public void onComplete() {}
+ * }}</pre>
+ *
+ * <p>The default value of {@link #defaultBufferSize} may provide a
+ * useful starting point for choosing request sizes and capacities in
+ * Flow components based on expected rates, resources, and usages.
+ * Or, when flow control is never needed, a subscriber may initially
+ * request an effectively unbounded number of items, as in:
+ *
+ * <pre> {@code
+ * class UnboundedSubscriber<T> implements Subscriber<T> {
+ * public void onSubscribe(Subscription subscription) {
+ * subscription.request(Long.MAX_VALUE); // effectively unbounded
+ * }
+ * public void onNext(T item) { use(item); }
+ * public void onError(Throwable ex) { ex.printStackTrace(); }
+ * public void onComplete() {}
+ * void use(T item) { ... }
+ * }}</pre>
+ *
+ * @author Doug Lea
+ * @since 9
+ */
+public final class Flow {
+
+ private Flow() {} // uninstantiable
+
+ /**
+ * A producer of items (and related control messages) received by
+ * Subscribers. Each current {@link Subscriber} receives the same
+ * items (via method {@code onNext}) in the same order, unless
+ * drops or errors are encountered. If a Publisher encounters an
+ * error that does not allow items to be issued to a Subscriber,
+ * that Subscriber receives {@code onError}, and then receives no
+ * further messages. Otherwise, when it is known that no further
+ * messages will be issued to it, a subscriber receives {@code
+ * onComplete}. Publishers ensure that Subscriber method
+ * invocations for each subscription are strictly ordered in <a
+ * href="package-summary.html#MemoryVisibility"><i>happens-before</i></a>
+ * order.
+ *
+ * <p>Publishers may vary in policy about whether drops (failures
+ * to issue an item because of resource limitations) are treated
+ * as unrecoverable errors. Publishers may also vary about
+ * whether Subscribers receive items that were produced or
+ * available before they subscribed.
+ *
+ * @param <T> the published item type
+ */
+ @FunctionalInterface
+ public static interface Publisher<T> {
+ /**
+ * Adds the given Subscriber if possible. If already
+ * subscribed, or the attempt to subscribe fails due to policy
+ * violations or errors, the Subscriber's {@code onError}
+ * method is invoked with an {@link IllegalStateException}.
+ * Otherwise, the Subscriber's {@code onSubscribe} method is
+ * invoked with a new {@link Subscription}. Subscribers may
+ * enable receiving items by invoking the {@code request}
+ * method of this Subscription, and may unsubscribe by
+ * invoking its {@code cancel} method.
+ *
+ * @param subscriber the subscriber
+ * @throws NullPointerException if subscriber is null
+ */
+ public void subscribe(Subscriber<? super T> subscriber);
+ }
+
+ /**
+ * A receiver of messages. The methods in this interface are
+ * invoked in strict sequential order for each {@link
+ * Subscription}.
+ *
+ * @param <T> the subscribed item type
+ */
+ public static interface Subscriber<T> {
+ /**
+ * Method invoked prior to invoking any other Subscriber
+ * methods for the given Subscription. If this method throws
+ * an exception, resulting behavior is not guaranteed, but may
+ * cause the Subscription not to be established or to be cancelled.
+ *
+ * <p>Typically, implementations of this method invoke {@code
+ * subscription.request} to enable receiving items.
+ *
+ * @param subscription a new subscription
+ */
+ public void onSubscribe(Subscription subscription);
+
+ /**
+ * Method invoked with a Subscription's next item. If this
+ * method throws an exception, resulting behavior is not
+ * guaranteed, but may cause the Subscription to be cancelled.
+ *
+ * @param item the item
+ */
+ public void onNext(T item);
+
+ /**
+ * Method invoked upon an unrecoverable error encountered by a
+ * Publisher or Subscription, after which no other Subscriber
+ * methods are invoked by the Subscription. If this method
+ * itself throws an exception, resulting behavior is
+ * undefined.
+ *
+ * @param throwable the exception
+ */
+ public void onError(Throwable throwable);
+
+ /**
+ * Method invoked when it is known that no additional
+ * Subscriber method invocations will occur for a Subscription
+ * that is not already terminated by error, after which no
+ * other Subscriber methods are invoked by the Subscription.
+ * If this method throws an exception, resulting behavior is
+ * undefined.
+ */
+ public void onComplete();
+ }
+
+ /**
+ * Message control linking a {@link Publisher} and {@link
+ * Subscriber}. Subscribers receive items only when requested,
+ * and may cancel at any time. The methods in this interface are
+ * intended to be invoked only by their Subscribers; usages in
+ * other contexts have undefined effects.
+ */
+ public static interface Subscription {
+ /**
+ * Adds the given number {@code n} of items to the current
+ * unfulfilled demand for this subscription. If {@code n} is
+ * less than or equal to zero, the Subscriber will receive an
+ * {@code onError} signal with an {@link
+ * IllegalArgumentException} argument. Otherwise, the
+ * Subscriber will receive up to {@code n} additional {@code
+ * onNext} invocations (or fewer if terminated).
+ *
+ * @param n the increment of demand; a value of {@code
+ * Long.MAX_VALUE} may be considered as effectively unbounded
+ */
+ public void request(long n);
+
+ /**
+ * Causes the Subscriber to (eventually) stop receiving
+ * messages. Implementation is best-effort -- additional
+ * messages may be received after invoking this method.
+ * A cancelled subscription need not ever receive an
+ * {@code onComplete} or {@code onError} signal.
+ */
+ public void cancel();
+ }
+
+ /**
+ * A component that acts as both a Subscriber and Publisher.
+ *
+ * @param <T> the subscribed item type
+ * @param <R> the published item type
+ */
+ public static interface Processor<T,R> extends Subscriber<T>, Publisher<R> {
+ }
+
+ static final int DEFAULT_BUFFER_SIZE = 256;
+
+ /**
+ * Returns a default value for Publisher or Subscriber buffering,
+ * that may be used in the absence of other constraints.
+ *
+ * @implNote
+ * The current value returned is 256.
+ *
+ * @return the buffer size value
+ */
+ public static int defaultBufferSize() {
+ return DEFAULT_BUFFER_SIZE;
+ }
+
+}
diff --git a/ojluni/src/main/java/java/util/regex/Matcher.java b/ojluni/src/main/java/java/util/regex/Matcher.java
index eca98db..d50ea32 100644
--- a/ojluni/src/main/java/java/util/regex/Matcher.java
+++ b/ojluni/src/main/java/java/util/regex/Matcher.java
@@ -26,7 +26,7 @@
package java.util.regex;
-import com.android.icu.util.regex.NativeMatcher;
+import com.android.icu.util.regex.MatcherNative;
/**
* An engine that performs match operations on a {@linkplain java.lang.CharSequence
@@ -132,7 +132,7 @@
*/
private boolean matchFound;
- private NativeMatcher nativeMatcher;
+ private MatcherNative nativeMatcher;
/**
* The index of the last position appended in a substitution.
@@ -208,12 +208,12 @@
public Matcher usePattern(Pattern newPattern) {
if (newPattern == null)
throw new IllegalArgumentException("Pattern cannot be null");
- parentPattern = newPattern;
synchronized (this) {
- nativeMatcher = null; // In case NativeMatcher.create throws.
- nativeMatcher = NativeMatcher.create(parentPattern.nativePattern);
+ // may throw
+ nativeMatcher = MatcherNative.create(newPattern.nativePattern);
}
+ parentPattern = newPattern;
if (text != null) {
resetForInput();
diff --git a/ojluni/src/main/java/java/util/regex/Pattern.java b/ojluni/src/main/java/java/util/regex/Pattern.java
index 3a5ad63..a4ead58 100644
--- a/ojluni/src/main/java/java/util/regex/Pattern.java
+++ b/ojluni/src/main/java/java/util/regex/Pattern.java
@@ -26,7 +26,7 @@
package java.util.regex;
-import com.android.icu.util.regex.NativePattern;
+import com.android.icu.util.regex.PatternNative;
import dalvik.system.VMRuntime;
import java.util.Iterator;
@@ -943,7 +943,7 @@
// BEGIN Android-changed: reimplement matching logic natively via ICU.
// We only need some tie-ins to native memory, instead of a large number
// of fields on the .java side.
- /* package */ transient NativePattern nativePattern;
+ /* package */ transient PatternNative nativePattern;
// END Android-changed: reimplement matching logic natively via ICU.
/**
@@ -1423,7 +1423,7 @@
// These are the flags natively supported by ICU.
// They even have the same value in native code.
int icuFlags = flags & (CASE_INSENSITIVE | COMMENTS | MULTILINE | DOTALL | UNIX_LINES);
- nativePattern = NativePattern.create(icuPattern, icuFlags);
+ nativePattern = PatternNative.create(icuPattern, icuFlags);
}
// END Android-changed: reimplement matching logic natively via ICU.
diff --git a/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java b/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java
index b71d11a..c3e3c30 100644
--- a/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java
+++ b/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java
@@ -30,6 +30,7 @@
import java.net.HttpURLConnection;
import java.security.Principal;
import java.security.cert.X509Certificate;
+import libcore.api.CorePlatformApi;
/**
* <code>HttpsURLConnection</code> extends <code>HttpURLConnection</code>
@@ -186,6 +187,8 @@
* Holds the default instance so class preloading doesn't create an instance of
* it.
*/
+ private static final String OK_HOSTNAME_VERIFIER_CLASS
+ = "com.android.okhttp.internal.tls.OkHostnameVerifier";
private static class NoPreloadHolder {
public static HostnameVerifier defaultHostnameVerifier;
static {
@@ -197,7 +200,7 @@
* the server name from the certificate mismatch.
*/
defaultHostnameVerifier = (HostnameVerifier)
- Class.forName("com.android.okhttp.internal.tls.OkHostnameVerifier")
+ Class.forName(OK_HOSTNAME_VERIFIER_CLASS)
.getField("INSTANCE").get(null);
} catch (Exception e) {
throw new AssertionError("Failed to obtain okhttp HostnameVerifier", e);
@@ -319,6 +322,30 @@
hostnameVerifier = v;
}
+ // BEGIN Android-added: Core platform API to obtain a strict hostname verifier
+ /**
+ * Obtains a stricter <code>HostnameVerifier</code>.
+ *
+ * The <code>HostnameVerifier</code> returned by this method will reject certificates
+ * with wildcards for top-level domains such "*.com".
+ *
+ * @see com.squareup.okhttp.internal.tls.OkHostnameVerifier
+ *
+ * @hide
+ */
+ @CorePlatformApi
+ public static HostnameVerifier getStrictHostnameVerifier() {
+ try {
+ return (HostnameVerifier) Class
+ .forName(OK_HOSTNAME_VERIFIER_CLASS)
+ .getMethod("strictInstance")
+ .invoke(null);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ // END Android-added: Core platform API to obtain a strict hostname verifier
+
/**
* Gets the <code>HostnameVerifier</code> in place on this instance.
*
diff --git a/ojluni/src/main/java/jdk/internal/util/Preconditions.java b/ojluni/src/main/java/jdk/internal/util/Preconditions.java
new file mode 100644
index 0000000..0e91afd
--- /dev/null
+++ b/ojluni/src/main/java/jdk/internal/util/Preconditions.java
@@ -0,0 +1,345 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.util;
+
+import java.util.List;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+/**
+ * Utility methods to check if state or arguments are correct.
+ *
+ */
+public class Preconditions {
+
+ /**
+ * Maps out-of-bounds values to a runtime exception.
+ *
+ * @param checkKind the kind of bounds check, whose name may correspond
+ * to the name of one of the range check methods, checkIndex,
+ * checkFromToIndex, checkFromIndexSize
+ * @param args the out-of-bounds arguments that failed the range check.
+ * If the checkKind corresponds a the name of a range check method
+ * then the bounds arguments are those that can be passed in order
+ * to the method.
+ * @param oobef the exception formatter that when applied with a checkKind
+ * and a list out-of-bounds arguments returns a runtime exception.
+ * If {@code null} then, it is as if an exception formatter was
+ * supplied that returns {@link IndexOutOfBoundsException} for any
+ * given arguments.
+ * @return the runtime exception
+ */
+ private static RuntimeException outOfBounds(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobef,
+ String checkKind,
+ Integer... args) {
+ List<Integer> largs = List.of(args);
+ RuntimeException e = oobef == null
+ ? null : oobef.apply(checkKind, largs);
+ return e == null
+ ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e;
+ }
+
+ private static RuntimeException outOfBoundsCheckIndex(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+ int index, int length) {
+ return outOfBounds(oobe, "checkIndex", index, length);
+ }
+
+ private static RuntimeException outOfBoundsCheckFromToIndex(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+ int fromIndex, int toIndex, int length) {
+ return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length);
+ }
+
+ private static RuntimeException outOfBoundsCheckFromIndexSize(
+ BiFunction<String, List<Integer>, ? extends RuntimeException> oobe,
+ int fromIndex, int size, int length) {
+ return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length);
+ }
+
+ /**
+ * Returns an out-of-bounds exception formatter from an given exception
+ * factory. The exception formatter is a function that formats an
+ * out-of-bounds message from its arguments and applies that message to the
+ * given exception factory to produce and relay an exception.
+ *
+ * <p>The exception formatter accepts two arguments: a {@code String}
+ * describing the out-of-bounds range check that failed, referred to as the
+ * <em>check kind</em>; and a {@code List<Integer>} containing the
+ * out-of-bound integer values that failed the check. The list of
+ * out-of-bound values is not modified.
+ *
+ * <p>Three check kinds are supported {@code checkIndex},
+ * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding
+ * respectively to the specified application of an exception formatter as an
+ * argument to the out-of-bounds range check methods
+ * {@link #checkIndex(int, int, BiFunction) checkIndex},
+ * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and
+ * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}.
+ * Thus a supported check kind corresponds to a method name and the
+ * out-of-bound integer values correspond to method argument values, in
+ * order, preceding the exception formatter argument (similar in many
+ * respects to the form of arguments required for a reflective invocation of
+ * such a range check method).
+ *
+ * <p>Formatter arguments conforming to such supported check kinds will
+ * produce specific exception messages describing failed out-of-bounds
+ * checks. Otherwise, more generic exception messages will be produced in
+ * any of the following cases: the check kind is supported but fewer
+ * or more out-of-bounds values are supplied, the check kind is not
+ * supported, the check kind is {@code null}, or the list of out-of-bound
+ * values is {@code null}.
+ *
+ * @apiNote
+ * This method produces an out-of-bounds exception formatter that can be
+ * passed as an argument to any of the supported out-of-bounds range check
+ * methods declared by {@code Objects}. For example, a formatter producing
+ * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a
+ * {@code static final} field as follows:
+ * <pre>{@code
+ * static final
+ * BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException> AIOOBEF =
+ * outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
+ * }</pre>
+ * The formatter instance {@code AIOOBEF} may be passed as an argument to an
+ * out-of-bounds range check method, such as checking if an {@code index}
+ * is within the bounds of a {@code limit}:
+ * <pre>{@code
+ * checkIndex(index, limit, AIOOBEF);
+ * }</pre>
+ * If the bounds check fails then the range check method will throw an
+ * {@code ArrayIndexOutOfBoundsException} with an appropriate exception
+ * message that is a produced from {@code AIOOBEF} as follows:
+ * <pre>{@code
+ * AIOOBEF.apply("checkIndex", List.of(index, limit));
+ * }</pre>
+ *
+ * @param f the exception factory, that produces an exception from a message
+ * where the message is produced and formatted by the returned
+ * exception formatter. If this factory is stateless and side-effect
+ * free then so is the returned formatter.
+ * Exceptions thrown by the factory are relayed to the caller
+ * of the returned formatter.
+ * @param <X> the type of runtime exception to be returned by the given
+ * exception factory and relayed by the exception formatter
+ * @return the out-of-bounds exception formatter
+ */
+ public static <X extends RuntimeException>
+ BiFunction<String, List<Integer>, X> outOfBoundsExceptionFormatter(Function<String, X> f) {
+ // Use anonymous class to avoid bootstrap issues if this method is
+ // used early in startup
+ return new BiFunction<String, List<Integer>, X>() {
+ @Override
+ public X apply(String checkKind, List<Integer> args) {
+ return f.apply(outOfBoundsMessage(checkKind, args));
+ }
+ };
+ }
+
+ private static String outOfBoundsMessage(String checkKind, List<Integer> args) {
+ if (checkKind == null && args == null) {
+ return String.format("Range check failed");
+ } else if (checkKind == null) {
+ return String.format("Range check failed: %s", args);
+ } else if (args == null) {
+ return String.format("Range check failed: %s", checkKind);
+ }
+
+ int argSize = 0;
+ switch (checkKind) {
+ case "checkIndex":
+ argSize = 2;
+ break;
+ case "checkFromToIndex":
+ case "checkFromIndexSize":
+ argSize = 3;
+ break;
+ default:
+ }
+
+ // Switch to default if fewer or more arguments than required are supplied
+ switch ((args.size() != argSize) ? "" : checkKind) {
+ case "checkIndex":
+ return String.format("Index %d out-of-bounds for length %d",
+ args.get(0), args.get(1));
+ case "checkFromToIndex":
+ return String.format("Range [%d, %d) out-of-bounds for length %d",
+ args.get(0), args.get(1), args.get(2));
+ case "checkFromIndexSize":
+ return String.format("Range [%d, %<d + %d) out-of-bounds for length %d",
+ args.get(0), args.get(1), args.get(2));
+ default:
+ return String.format("Range check failed: %s %s", checkKind, args);
+ }
+ }
+
+ /**
+ * Checks if the {@code index} is within the bounds of the range from
+ * {@code 0} (inclusive) to {@code length} (exclusive).
+ *
+ * <p>The {@code index} is defined to be out-of-bounds if any of the
+ * following inequalities is true:
+ * <ul>
+ * <li>{@code index < 0}</li>
+ * <li>{@code index >= length}</li>
+ * <li>{@code length < 0}, which is implied from the former inequalities</li>
+ * </ul>
+ *
+ * <p>If the {@code index} is out-of-bounds, then a runtime exception is
+ * thrown that is the result of applying the following arguments to the
+ * exception formatter: the name of this method, {@code checkIndex};
+ * and an unmodifiable list integers whose values are, in order, the
+ * out-of-bounds arguments {@code index} and {@code length}.
+ *
+ * @param <X> the type of runtime exception to throw if the arguments are
+ * out-of-bounds
+ * @param index the index
+ * @param length the upper-bound (exclusive) of the range
+ * @param oobef the exception formatter that when applied with this
+ * method name and out-of-bounds arguments returns a runtime
+ * exception. If {@code null} or returns {@code null} then, it is as
+ * if an exception formatter produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+ * instead (though it may be more efficient).
+ * Exceptions thrown by the formatter are relayed to the caller.
+ * @return {@code index} if it is within bounds of the range
+ * @throws X if the {@code index} is out-of-bounds and the exception
+ * formatter is non-{@code null}
+ * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds
+ * and the exception formatter is {@code null}
+ * @since 9
+ *
+ * @implNote
+ * This method is made intrinsic in optimizing compilers to guide them to
+ * perform unsigned comparisons of the index and length when it is known the
+ * length is a non-negative value (such as that of an array length or from
+ * the upper bound of a loop)
+ */
+ // Android-removed: @HotSpotIntrinsicCandidate not present on Android yet (could reconsider).
+ // @HotSpotIntrinsicCandidate
+ public static <X extends RuntimeException>
+ int checkIndex(int index, int length,
+ BiFunction<String, List<Integer>, X> oobef) {
+ if (index < 0 || index >= length)
+ throw outOfBoundsCheckIndex(oobef, index, length);
+ return index;
+ }
+
+ /**
+ * Checks if the sub-range from {@code fromIndex} (inclusive) to
+ * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
+ * (inclusive) to {@code length} (exclusive).
+ *
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
+ * inequalities is true:
+ * <ul>
+ * <li>{@code fromIndex < 0}</li>
+ * <li>{@code fromIndex > toIndex}</li>
+ * <li>{@code toIndex > length}</li>
+ * <li>{@code length < 0}, which is implied from the former inequalities</li>
+ * </ul>
+ *
+ * <p>If the sub-range is out-of-bounds, then a runtime exception is
+ * thrown that is the result of applying the following arguments to the
+ * exception formatter: the name of this method, {@code checkFromToIndex};
+ * and an unmodifiable list integers whose values are, in order, the
+ * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}.
+ *
+ * @param <X> the type of runtime exception to throw if the arguments are
+ * out-of-bounds
+ * @param fromIndex the lower-bound (inclusive) of the sub-range
+ * @param toIndex the upper-bound (exclusive) of the sub-range
+ * @param length the upper-bound (exclusive) the range
+ * @param oobef the exception formatter that when applied with this
+ * method name and out-of-bounds arguments returns a runtime
+ * exception. If {@code null} or returns {@code null} then, it is as
+ * if an exception formatter produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+ * instead (though it may be more efficient).
+ * Exceptions thrown by the formatter are relayed to the caller.
+ * @return {@code fromIndex} if the sub-range within bounds of the range
+ * @throws X if the sub-range is out-of-bounds and the exception factory
+ * function is non-{@code null}
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+ * the exception factory function is {@code null}
+ * @since 9
+ */
+ public static <X extends RuntimeException>
+ int checkFromToIndex(int fromIndex, int toIndex, int length,
+ BiFunction<String, List<Integer>, X> oobef) {
+ if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
+ throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length);
+ return fromIndex;
+ }
+
+ /**
+ * Checks if the sub-range from {@code fromIndex} (inclusive) to
+ * {@code fromIndex + size} (exclusive) is within the bounds of range from
+ * {@code 0} (inclusive) to {@code length} (exclusive).
+ *
+ * <p>The sub-range is defined to be out-of-bounds if any of the following
+ * inequalities is true:
+ * <ul>
+ * <li>{@code fromIndex < 0}</li>
+ * <li>{@code size < 0}</li>
+ * <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
+ * <li>{@code length < 0}, which is implied from the former inequalities</li>
+ * </ul>
+ *
+ * <p>If the sub-range is out-of-bounds, then a runtime exception is
+ * thrown that is the result of applying the following arguments to the
+ * exception formatter: the name of this method, {@code checkFromIndexSize};
+ * and an unmodifiable list integers whose values are, in order, the
+ * out-of-bounds arguments {@code fromIndex}, {@code size}, and
+ * {@code length}.
+ *
+ * @param <X> the type of runtime exception to throw if the arguments are
+ * out-of-bounds
+ * @param fromIndex the lower-bound (inclusive) of the sub-interval
+ * @param size the size of the sub-range
+ * @param length the upper-bound (exclusive) of the range
+ * @param oobef the exception formatter that when applied with this
+ * method name and out-of-bounds arguments returns a runtime
+ * exception. If {@code null} or returns {@code null} then, it is as
+ * if an exception formatter produced from an invocation of
+ * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used
+ * instead (though it may be more efficient).
+ * Exceptions thrown by the formatter are relayed to the caller.
+ * @return {@code fromIndex} if the sub-range within bounds of the range
+ * @throws X if the sub-range is out-of-bounds and the exception factory
+ * function is non-{@code null}
+ * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and
+ * the exception factory function is {@code null}
+ * @since 9
+ */
+ public static <X extends RuntimeException>
+ int checkFromIndexSize(int fromIndex, int size, int length,
+ BiFunction<String, List<Integer>, X> oobef) {
+ if ((length | fromIndex | size) < 0 || size > length - fromIndex)
+ throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length);
+ return fromIndex;
+ }
+}
diff --git a/ojluni/src/main/java/jdk/internal/vm/annotation/Stable.java b/ojluni/src/main/java/jdk/internal/vm/annotation/Stable.java
new file mode 100644
index 0000000..34b6540
--- /dev/null
+++ b/ojluni/src/main/java/jdk/internal/vm/annotation/Stable.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.vm.annotation;
+
+import java.lang.annotation.*;
+
+// Android-removed: HotSpot-specific implementation notes not relevant for Android.
+/**
+ * A field may be annotated as stable if all of its component variables
+ * changes value at most once.
+ * A field's value counts as its component value.
+ * If the field is typed as an array, then all the non-null components
+ * of the array, of depth up to the rank of the field's array type,
+ * also count as component values.
+ * By extension, any variable (either array or field) which has annotated
+ * as stable is called a stable variable, and its non-null or non-zero
+ * value is called a stable value.
+ * <p>
+ * Since all fields begin with a default value of null for references
+ * (resp., zero for primitives), it follows that this annotation indicates
+ * that the first non-null (resp., non-zero) value stored in the field
+ * will never be changed.
+ * <p>
+ * If the field is not of an array type, there are no array elements,
+ * then the value indicated as stable is simply the value of the field.
+ * If the dynamic type of the field value is an array but the static type
+ * is not, the components of the array are <em>not</em> regarded as stable.
+ * <p>
+ * If the field is an array type, then both the field value and
+ * all the components of the field value (if the field value is non-null)
+ * are indicated to be stable.
+ * If the field type is an array type with rank {@code N > 1},
+ * then each component of the field value (if the field value is non-null),
+ * is regarded as a stable array of rank {@code N-1}.
+ * <p>
+ * Fields which are declared {@code final} may also be annotated as stable.
+ * Since final fields already behave as stable values, such an annotation
+ * conveys no additional information regarding change of the field's value, but
+ * still conveys information regarding change of additional components values if
+ * the type of the field is an array type (as described above).
+ * <p>
+ * It is (currently) undefined what happens if a field annotated as stable
+ * is given a third value (by explicitly updating a stable field, a component of
+ * a stable array, or a final stable field via reflection or other means).
+ *
+ * @implNote
+ * This annotation only takes effect for fields of classes loaded by the boot
+ * loader. Annoations on fields of classes loaded outside of the boot loader
+ * are ignored.
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Stable {
+}
diff --git a/ojluni/src/test/java/time/test/java/time/format/TestDateTimeTextProvider.java b/ojluni/src/test/java/time/test/java/time/format/TestDateTimeTextProvider.java
index 7628eeb..76296df 100644
--- a/ojluni/src/test/java/time/test/java/time/format/TestDateTimeTextProvider.java
+++ b/ojluni/src/test/java/time/test/java/time/format/TestDateTimeTextProvider.java
@@ -94,14 +94,14 @@
{DAY_OF_WEEK, 6, TextStyle.SHORT, enUS, "Sat"},
{DAY_OF_WEEK, 7, TextStyle.SHORT, enUS, "Sun"},
- // Android-changed: upstream tests expect title case names for pt_BR, but CLDR has lower
- {DAY_OF_WEEK, 1, TextStyle.SHORT, ptBR, "seg"},
- {DAY_OF_WEEK, 2, TextStyle.SHORT, ptBR, "ter"},
- {DAY_OF_WEEK, 3, TextStyle.SHORT, ptBR, "qua"},
- {DAY_OF_WEEK, 4, TextStyle.SHORT, ptBR, "qui"},
- {DAY_OF_WEEK, 5, TextStyle.SHORT, ptBR, "sex"},
- {DAY_OF_WEEK, 6, TextStyle.SHORT, ptBR, "s\u00E1b"},
- {DAY_OF_WEEK, 7, TextStyle.SHORT, ptBR, "dom"},
+ // Android-changed: upstream tests expect title case names for pt_BR, but CLDR has lower with dot
+ {DAY_OF_WEEK, 1, TextStyle.SHORT, ptBR, "seg."},
+ {DAY_OF_WEEK, 2, TextStyle.SHORT, ptBR, "ter."},
+ {DAY_OF_WEEK, 3, TextStyle.SHORT, ptBR, "qua."},
+ {DAY_OF_WEEK, 4, TextStyle.SHORT, ptBR, "qui."},
+ {DAY_OF_WEEK, 5, TextStyle.SHORT, ptBR, "sex."},
+ {DAY_OF_WEEK, 6, TextStyle.SHORT, ptBR, "s\u00E1b."},
+ {DAY_OF_WEEK, 7, TextStyle.SHORT, ptBR, "dom."},
{DAY_OF_WEEK, 1, TextStyle.FULL, enUS, "Monday"},
{DAY_OF_WEEK, 2, TextStyle.FULL, enUS, "Tuesday"},
@@ -133,18 +133,19 @@
{MONTH_OF_YEAR, 11, TextStyle.SHORT, enUS, "Nov"},
{MONTH_OF_YEAR, 12, TextStyle.SHORT, enUS, "Dec"},
- {MONTH_OF_YEAR, 1, TextStyle.SHORT, ptBR, "jan"},
- {MONTH_OF_YEAR, 2, TextStyle.SHORT, ptBR, "fev"},
- {MONTH_OF_YEAR, 3, TextStyle.SHORT, ptBR, "mar"},
- {MONTH_OF_YEAR, 4, TextStyle.SHORT, ptBR, "abr"},
- {MONTH_OF_YEAR, 5, TextStyle.SHORT, ptBR, "mai"},
- {MONTH_OF_YEAR, 6, TextStyle.SHORT, ptBR, "jun"},
- {MONTH_OF_YEAR, 7, TextStyle.SHORT, ptBR, "jul"},
- {MONTH_OF_YEAR, 8, TextStyle.SHORT, ptBR, "ago"},
- {MONTH_OF_YEAR, 9, TextStyle.SHORT, ptBR, "set"},
- {MONTH_OF_YEAR, 10, TextStyle.SHORT, ptBR, "out"},
- {MONTH_OF_YEAR, 11, TextStyle.SHORT, ptBR, "nov"},
- {MONTH_OF_YEAR, 12, TextStyle.SHORT, ptBR, "dez"},
+ // Android-changed: upstream tests expect title case names for pt_BR, but CLDR has lower with dot
+ {MONTH_OF_YEAR, 1, TextStyle.SHORT, ptBR, "jan."},
+ {MONTH_OF_YEAR, 2, TextStyle.SHORT, ptBR, "fev."},
+ {MONTH_OF_YEAR, 3, TextStyle.SHORT, ptBR, "mar."},
+ {MONTH_OF_YEAR, 4, TextStyle.SHORT, ptBR, "abr."},
+ {MONTH_OF_YEAR, 5, TextStyle.SHORT, ptBR, "mai."},
+ {MONTH_OF_YEAR, 6, TextStyle.SHORT, ptBR, "jun."},
+ {MONTH_OF_YEAR, 7, TextStyle.SHORT, ptBR, "jul."},
+ {MONTH_OF_YEAR, 8, TextStyle.SHORT, ptBR, "ago."},
+ {MONTH_OF_YEAR, 9, TextStyle.SHORT, ptBR, "set."},
+ {MONTH_OF_YEAR, 10, TextStyle.SHORT, ptBR, "out."},
+ {MONTH_OF_YEAR, 11, TextStyle.SHORT, ptBR, "nov."},
+ {MONTH_OF_YEAR, 12, TextStyle.SHORT, ptBR, "dez."},
{MONTH_OF_YEAR, 1, TextStyle.FULL, enUS, "January"},
{MONTH_OF_YEAR, 2, TextStyle.FULL, enUS, "February"},
diff --git a/openjdk_java_files.bp b/openjdk_java_files.bp
index 57f6251..7ba860c 100644
--- a/openjdk_java_files.bp
+++ b/openjdk_java_files.bp
@@ -950,6 +950,7 @@
"ojluni/src/main/java/java/util/concurrent/ExecutorCompletionService.java",
"ojluni/src/main/java/java/util/concurrent/ExecutorService.java",
"ojluni/src/main/java/java/util/concurrent/Executors.java",
+ "ojluni/src/main/java/java/util/concurrent/Flow.java",
"ojluni/src/main/java/java/util/concurrent/ForkJoinPool.java",
"ojluni/src/main/java/java/util/concurrent/ForkJoinTask.java",
"ojluni/src/main/java/java/util/concurrent/ForkJoinWorkerThread.java",
@@ -1434,6 +1435,8 @@
"ojluni/src/main/java/java/beans/ChangeListenerMap.java",
"ojluni/src/main/java/java/time/zone/IcuZoneRulesProvider.java",
"ojluni/src/main/java/java/time/zone/ZoneRulesProvider.java",
+ "ojluni/src/main/java/java/util/ImmutableCollections.java",
+ "ojluni/src/main/java/java/util/KeyValueHolder.java",
"ojluni/src/main/java/java/util/JapaneseImperialCalendar.java",
"ojluni/src/main/java/sun/misc/FDBigInteger.java",
"ojluni/src/main/java/sun/misc/FloatingDecimal.java",
@@ -1441,6 +1444,8 @@
"ojluni/src/main/java/jdk/net/NetworkPermission.java",
"ojluni/src/main/java/jdk/net/SocketFlow.java",
"ojluni/src/main/java/jdk/net/Sockets.java",
+ "ojluni/src/main/java/jdk/internal/vm/annotation/Stable.java",
+ "ojluni/src/main/java/jdk/internal/util/Preconditions.java",
"ojluni/src/main/java/sun/invoke/util/BytecodeDescriptor.java",
"ojluni/src/main/java/sun/invoke/util/Wrapper.java",
"ojluni/src/main/java/sun/invoke/util/VerifyAccess.java",
diff --git a/test-rules/src/main/java/libcore/junit/util/SwitchTargetSdkVersionRule.java b/test-rules/src/main/java/libcore/junit/util/SwitchTargetSdkVersionRule.java
index 455d3cb..b860ea6 100644
--- a/test-rules/src/main/java/libcore/junit/util/SwitchTargetSdkVersionRule.java
+++ b/test-rules/src/main/java/libcore/junit/util/SwitchTargetSdkVersionRule.java
@@ -135,8 +135,8 @@
public void evaluate() throws Throwable {
Object runtime = runtimeInstanceGetter.invoke(null);
int oldTargetSdkVersion = (int) targetSdkVersionGetter.invoke(runtime);
+ targetSdkVersionSetter.invoke(runtime, targetSdkVersion);
try {
- targetSdkVersionSetter.invoke(runtime, targetSdkVersion);
statement.evaluate();
} finally {
targetSdkVersionSetter.invoke(runtime, oldTargetSdkVersion);
diff --git a/test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java b/test-rules/src/platform_compat/java/libcore/junit/util/CoreCompatChangeRule.java
similarity index 68%
rename from test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java
rename to test-rules/src/platform_compat/java/libcore/junit/util/CoreCompatChangeRule.java
index 1bae1a2..b526707 100644
--- a/test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java
+++ b/test-rules/src/platform_compat/java/libcore/junit/util/CoreCompatChangeRule.java
@@ -14,19 +14,11 @@
* limitations under the License.
*/
-package android.compat;
+package libcore.junit.util.compat;
-import android.app.Instrumentation;
+import android.compat.Compatibility;
import android.compat.Compatibility.Callbacks;
import android.compat.Compatibility.ChangeConfig;
-import android.content.Context;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.support.test.InstrumentationRegistry;
-import android.util.ArraySet;
-
-import com.android.internal.compat.CompatibilityChangeConfig;
-import com.android.internal.compat.IPlatformCompat;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -37,11 +29,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import com.google.common.primitives.Longs;
-
/**
* Allows tests to specify the which change to disable.
*
@@ -50,7 +40,7 @@
*
* <pre>
* @Rule
- * public TestRule compatChangeRule = new CompatChangeRule();
+ * public TestRule compatChangeRule = new CoreCompatChangeRule();
* </pre>
*
* <p>Each test method that needs to disable a specific change needs to be annotated
@@ -71,7 +61,8 @@
*
* </pre>
*/
-public class CompatChangeRule implements TestRule {
+public class CoreCompatChangeRule implements TestRule {
+
@Override
public Statement apply(final Statement statement, Description description) {
Set<Long> enabled = new HashSet<>();
@@ -88,10 +79,14 @@
}
ChangeConfig config = new ChangeConfig(enabled, disabled);
if (config.isEmpty()) {
- throw new IllegalArgumentException("Added a CompatChangeRule without specifying any "
- + "@EnableCompatChanges or @DisableCompatChanges !");
+ return statement;
+ } else {
+ return createStatementForConfig(statement, config);
}
- return new CompatChangeStatement(statement, config);
+ }
+
+ protected Statement createStatementForConfig(final Statement statement, ChangeConfig config) {
+ return new CompatChangeStatement(statement, config);
}
private static class CompatChangeStatement extends Statement {
@@ -105,23 +100,9 @@
@Override
public void evaluate() throws Throwable {
- Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
- String packageName = instrumentation.getTargetContext().getPackageName();
- IPlatformCompat platformCompat = IPlatformCompat.Stub
- .asInterface(ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE));
- if (platformCompat == null) {
- throw new IllegalStateException("Could not get IPlatformCompat service!");
- }
Compatibility.setOverrides(config);
try {
- platformCompat.setOverrides(new CompatibilityChangeConfig(config), packageName);
- try {
- testStatement.evaluate();
- } finally {
- platformCompat.clearOverrides(packageName);
- }
- } catch(RemoteException e) {
- throw new RuntimeException("Could not call IPlatformCompat binder method!", e);
+ testStatement.evaluate();
} finally {
Compatibility.clearOverrides();
}
diff --git a/test-rules/src/test/java/android/compat/testing/DummyApi.java b/test-rules/src/test/java/android/compat/testing/DummyApi.java
new file mode 100644
index 0000000..dfe40cc
--- /dev/null
+++ b/test-rules/src/test/java/android/compat/testing/DummyApi.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 android.compat.testing;
+
+import android.compat.Compatibility;
+
+/**
+ * This is a dummy API to test gating
+ *
+ * @hide
+ */
+public class DummyApi {
+
+ public static final long CHANGE_ID = 666013;
+ public static final long CHANGE_ID_1 = 666014;
+ public static final long CHANGE_ID_2 = 666015;
+
+ /**
+ * Dummy method
+ * @return "A" if change is enabled, "B" otherwise.
+ */
+ public static String dummyFunc() {
+ if (Compatibility.isChangeEnabled(CHANGE_ID)) {
+ return "A";
+ }
+ return "B";
+ }
+
+ /**
+ * Dummy combined method
+ * @return "0" if {@link CHANGE_ID_1} is disabled and {@link CHANGE_ID_2} is disabled,
+ "1" if {@link CHANGE_ID_1} is disabled and {@link CHANGE_ID_2} is enabled,
+ "2" if {@link CHANGE_ID_1} is enabled and {@link CHANGE_ID_2} is disabled,
+ "3" if {@link CHANGE_ID_1} is enabled and {@link CHANGE_ID_2} is enabled.
+ */
+ public static String dummyCombinedFunc() {
+ if (!Compatibility.isChangeEnabled(CHANGE_ID_1)
+ && !Compatibility.isChangeEnabled(CHANGE_ID_2)) {
+ return "0";
+ } else if (!Compatibility.isChangeEnabled(CHANGE_ID_1)
+ && Compatibility.isChangeEnabled(CHANGE_ID_2)) {
+ return "1";
+ } else if (Compatibility.isChangeEnabled(CHANGE_ID_1)
+ && !Compatibility.isChangeEnabled(CHANGE_ID_2)) {
+ return "2";
+ }
+ return "3";
+ }
+
+}
\ No newline at end of file
diff --git a/test-rules/src/test/java/libcore/junit/util/compat/CoreCompatChangeRuleTest.java b/test-rules/src/test/java/libcore/junit/util/compat/CoreCompatChangeRuleTest.java
new file mode 100644
index 0000000..87b9446
--- /dev/null
+++ b/test-rules/src/test/java/libcore/junit/util/compat/CoreCompatChangeRuleTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed 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
+ *
+ * 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 libcore.junit.util.compat;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.compat.testing.DummyApi;
+
+import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
+import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for compatibility change gating.
+ */
+@RunWith(JUnit4.class)
+public class CoreCompatChangeRuleTest {
+
+ @Rule
+ public TestRule compatChangeRule = new CoreCompatChangeRule();
+
+ @Test
+ @EnableCompatChanges({DummyApi.CHANGE_ID})
+ public void testDummyGatingPositive() {
+ assertThat(DummyApi.dummyFunc()).isEqualTo("A");
+ }
+
+ @Test
+ @DisableCompatChanges({DummyApi.CHANGE_ID})
+ public void testDummyGatingNegative() {
+ assertThat(DummyApi.dummyFunc()).isEqualTo("B");
+ }
+
+ @Test
+ @DisableCompatChanges({DummyApi.CHANGE_ID_1, DummyApi.CHANGE_ID_2})
+ public void testDummyGatingCombined0() {
+ assertThat(DummyApi.dummyCombinedFunc()).isEqualTo("0");
+ }
+
+ @Test
+ @DisableCompatChanges({DummyApi.CHANGE_ID_1})
+ @EnableCompatChanges({DummyApi.CHANGE_ID_2})
+ public void testDummyGatingCombined1() {
+ assertThat(DummyApi.dummyCombinedFunc()).isEqualTo("1");
+ }
+
+ @Test
+ @EnableCompatChanges({DummyApi.CHANGE_ID_1})
+ @DisableCompatChanges({DummyApi.CHANGE_ID_2})
+ public void testDummyGatingCombined2() {
+ assertThat(DummyApi.dummyCombinedFunc()).isEqualTo("2");
+ }
+
+ @Test
+ @EnableCompatChanges({DummyApi.CHANGE_ID_1, DummyApi.CHANGE_ID_2})
+ public void testDummyGatingCombined3() {
+ assertThat(DummyApi.dummyCombinedFunc()).isEqualTo("3");
+ }
+}
\ No newline at end of file
diff --git a/tools/upstream/src/main/java/libcore/CompareUpstreams.java b/tools/upstream/src/main/java/libcore/CompareUpstreams.java
index bdd2364..d9588a7 100644
--- a/tools/upstream/src/main/java/libcore/CompareUpstreams.java
+++ b/tools/upstream/src/main/java/libcore/CompareUpstreams.java
@@ -47,7 +47,7 @@
* - The ANDROID_BUILD_TOP environment variable must be set to point to the
* AOSP root directory (parent of libcore).
*
- * To check out upstreams OpenJDK 7u40, 8u60, 8u121-b13, and 9+181, run:
+ * To check out upstreams OpenJDK 7u40, 8u60, 8u121-b13, 8u222-b01 and 9+181, run:
*
* mkdir ~/openjdk
* cd ~/openjdk
@@ -58,6 +58,8 @@
* (cd !$ ; hg update -r jdk8u121-b13 && sh get_source.sh && sh common/bin/hgforest.sh update -r jdk8u121-b13)
* hg clone http://hg.openjdk.java.net/jdk8u/jdk8u60/ 8u60
* (cd !$ ; sh get_source.sh)
+ * hg clone http://hg.openjdk.java.net/jdk8u/jdk8u 8u222-b01
+ * (cd !$ ; hg update -r jdk8u222-b01 && sh get_source.sh && sh common/bin/hgforest.sh update -r jdk8u222-b01)
* hg clone http://hg.openjdk.java.net/jdk9/jdk9/ 9+181
* (cd !$ ; hg update -r jdk-9+181 && sh get_source.sh && sh common/bin/hgforest.sh update -r jdk-9+181)
*
@@ -170,8 +172,7 @@
: null;
for (Path relPath : relPaths) {
- Repository expectedUpstream = standardRepositories.referenceUpstreamAsOfAndroidP(
- relPath);
+ Repository expectedUpstream = standardRepositories.referenceUpstream(relPath);
out.print(relPath + "\t");
Path ojluniFile = standardRepositories.ojluni().absolutePath(relPath);
List<String> linesB = Util.readLines(ojluniFile);
diff --git a/tools/upstream/src/main/java/libcore/CopyUpstreamFiles.java b/tools/upstream/src/main/java/libcore/CopyUpstreamFiles.java
index 7137861..807607f 100644
--- a/tools/upstream/src/main/java/libcore/CopyUpstreamFiles.java
+++ b/tools/upstream/src/main/java/libcore/CopyUpstreamFiles.java
@@ -45,8 +45,7 @@
}
}
for (Path relPath : relPaths) {
- Repository expectedUpstream = standardRepositories.referenceUpstreamAsOfAndroidP(
- relPath);
+ Repository expectedUpstream = standardRepositories.referenceUpstream(relPath);
for (Repository upstream : standardRepositories.upstreams()) {
Path upstreamFile = upstream.absolutePath(relPath);
if (upstreamFile != null) {
diff --git a/tools/upstream/src/main/java/libcore/StandardRepositories.java b/tools/upstream/src/main/java/libcore/StandardRepositories.java
index 31efe94..7047c60 100644
--- a/tools/upstream/src/main/java/libcore/StandardRepositories.java
+++ b/tools/upstream/src/main/java/libcore/StandardRepositories.java
@@ -35,8 +35,10 @@
private final List<Repository> allUpstreams;
// upstreams older than what is currently the default
private final List<Repository> historicUpstreams;
+ private final Repository openJdk8u222;
private final Repository openJdk8u121;
private final Repository openJdk9b113;
+ private final Repository openJdk9p181;
private final Repository openJdk7u40;
private final OjluniRepository ojluni;
@@ -46,6 +48,8 @@
allUpstreams.add(openJdk9(upstreamRoot, "9+181"));
this.openJdk9b113 = addAndReturn(allUpstreams, openJdk9(upstreamRoot, "9b113+"));
this.openJdk8u121 = addAndReturn(allUpstreams, openJdkLegacy(upstreamRoot, "8u121-b13"));
+ this.openJdk8u222 = addAndReturn(allUpstreams, openJdkLegacy(upstreamRoot, "8u222-b01"));
+ this.openJdk9p181 = addAndReturn(allUpstreams, openJdk9(upstreamRoot, "9+181"));
Repository openJdk8u60 = addAndReturn(allUpstreams, openJdkLegacy(upstreamRoot, "8u60"));
this.openJdk7u40 = addAndReturn(allUpstreams, openJdkLegacy(upstreamRoot, "7u40"));
this.allUpstreams = Collections.unmodifiableList(new ArrayList<>(allUpstreams));
@@ -109,9 +113,41 @@
return result;
}
- public Repository referenceUpstreamAsOfAndroidP(Path relPath) {
+ private static final Set<String> REL_PATHS_AT_OPENJDK9_181 = Collections.unmodifiableSet(
+ new HashSet<>(Arrays.asList(
+ "java/util/concurrent/Flow.java",
+ "java/util/AbstractList.java",
+ "java/util/ImmutableCollections.java",
+ "java/util/KeyValueHolder.java",
+ "java/util/List.java",
+ "java/util/Map.java",
+ "java/util/Objects.java",
+ "java/util/Set.java",
+ "jdk/internal/HotSpotIntrinsicCandidate.java",
+ "jdk/internal/vm/annotation/Stable.java",
+ "jdk/internal/util/Preconditions.java"
+ )));
+
+ private static final Set<String> REL_PATHS_AT_OPENJDK8_222 = Collections.unmodifiableSet(
+ new HashSet<>(Arrays.asList(
+ "java/time/chrono/JapaneseEra.java",
+ "java/util/JapaneseImperialCalendar.java",
+ "sun/util/calendar/Era.java",
+ // Tests:
+ "java/time/tck/java/time/chrono/TCKJapaneseChronology.java",
+ "java/time/tck/java/time/chrono/TCKJapaneseEra.java",
+ "java/time/test/java/time/chrono/TestJapaneseChronology.java",
+ "java/time/test/java/time/chrono/TestUmmAlQuraChronology.java",
+ "java/time/test/java/time/format/TestNonIsoFormatter.java"
+ )));
+
+ public Repository referenceUpstream(Path relPath) {
boolean isJsr166 = isJsr166(relPath);
- if (isJsr166) {
+ if (REL_PATHS_AT_OPENJDK9_181.contains(relPath.toString())) {
+ return openJdk9p181;
+ } else if (REL_PATHS_AT_OPENJDK8_222.contains(relPath.toString())) {
+ return openJdk8u222;
+ } else if (isJsr166) {
return openJdk9b113;
} else if (relPath.startsWith("java/sql/") || relPath.startsWith("javax/sql/")) {
return openJdk7u40;