Merge "Use the new @IntraCoreApi provided by ZoneInfoData"
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 64d1150..0da4c80 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -866,6 +866,9 @@
patch_module: "java.base",
sdk_version: "none",
system_modules: "java-current-stubs-system-modules",
+
+ // Don't copy any output files to the dist.
+ no_dist: true,
}
// Used when compiling higher-level code against art.module.public.api.stubs.
@@ -991,21 +994,6 @@
check_nullability_warnings: "nullability_warnings.txt",
}
-// A host library containing time zone related classes. Used for
-// host-side tools and tests that have to deal with Android
-// time zone data.
-java_library_host {
- name: "timezone-host",
- visibility: [
- "//art/build/sdk",
- "//system/timezone/distro/core",
- ],
- srcs: [
- ":timezone_host_files",
- ":timezone_host_libcore_files",
- ],
-}
-
// A special set of system modules for building the following library for use
// in the art-module-public-api-system-modules.
java_system_modules {
@@ -1037,6 +1025,8 @@
java_library {
name: "art.module.api.annotations",
visibility: [
+ "//art/build/sdk",
+ "//external/icu/android_icu4j",
"//frameworks/base",
],
host_supported: true,
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceTest.java
index 7a3496e..19ccf03 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceTest.java
@@ -83,6 +83,63 @@
}
/**
+ * java.lang.ref.Reference#refersTo()
+ */
+ public void test_refersTo() {
+ tmpA = new Object();
+ tmpB = new Object();
+ tmpC = new Object();
+ final SoftReference sr = new SoftReference(tmpA, new ReferenceQueue());
+ final WeakReference wr = new WeakReference(tmpB, new ReferenceQueue());
+ final PhantomReference pr = new PhantomReference(tmpC, new ReferenceQueue());
+ assertTrue("soft refersTo(referent)", sr.refersTo(tmpA));
+ assertTrue("weak refersTo(referent)", wr.refersTo(tmpB));
+ assertTrue("phantom refersTo(referent)", pr.refersTo(tmpC));
+ assertFalse("soft refersTo(other)", sr.refersTo(tmpC));
+ assertFalse("weak refersTo(other)", wr.refersTo(tmpA));
+ assertFalse("phantom refersTo(other)", pr.refersTo(tmpB));
+ sr.clear();
+ wr.clear();
+ pr.clear();
+ assertTrue("soft refersTo(null)", sr.refersTo(null));
+ assertTrue("weak refersTo(null)", wr.refersTo(null));
+ assertTrue("phantom refersTo(null)", pr.refersTo(null));
+ assertFalse("soft refersTo(nonnull)", sr.refersTo(tmpA));
+ assertFalse("weak refersTo(nonnull)", wr.refersTo(tmpB));
+ assertFalse("phantom refersTo(nonnull)", pr.refersTo(tmpC));
+
+ // Check that refersTo remains consistent during GC.
+ final WeakReference wr2 = new WeakReference(tmpB, new ReferenceQueue());
+ Thread checker = new Thread(() -> {
+ while (wr2.get() == tmpB && wr2.refersTo(tmpB)
+ && !wr2.refersTo(null) && !wr2.refersTo(tmpA)) {}
+ disappeared = true;
+ });
+ checker.start();
+ for (int i = 0; i < 5; ++i) {
+ Runtime.getRuntime().gc();
+ System.runFinalization();
+ assertFalse("WeakReference prematurely inaccessible", disappeared);
+ }
+ wr2.clear();
+ for (int i = 0; i < 5; ++i) {
+ Runtime.getRuntime().gc();
+ if (disappeared) {
+ break;
+ }
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ fail("InterruptedException : " + e.getMessage());
+ }
+ }
+ assertTrue("WeakReference remained accessible", disappeared);
+ assertTrue("refersTo(null) failed", wr2.refersTo(null) && !wr2.refersTo(tmpB));
+ }
+
+ private volatile boolean disappeared = false;
+
+ /**
* java.lang.ref.Reference#enqueue()
*/
public void test_enqueue() {
diff --git a/libart/src/main/java/dalvik/system/VMRuntime.java b/libart/src/main/java/dalvik/system/VMRuntime.java
index 90e22c7..53e4c7e 100644
--- a/libart/src/main/java/dalvik/system/VMRuntime.java
+++ b/libart/src/main/java/dalvik/system/VMRuntime.java
@@ -17,7 +17,7 @@
package dalvik.system;
import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledAfter;
+import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import dalvik.annotation.compat.VersionCodes;
@@ -70,7 +70,7 @@
* reflection.
*/
@ChangeId
- @EnabledAfter(targetSdkVersion = VersionCodes.Q)
+ @EnabledSince(targetSdkVersion = VersionCodes.R)
private static final long
PREVENT_META_REFLECTION_BLOCKLIST_ACCESS = 142365358; // This is a bug id.
@@ -78,14 +78,14 @@
* Gating access to greylist-max-p APIs.
*/
@ChangeId
- @EnabledAfter(targetSdkVersion = VersionCodes.P)
+ @EnabledSince(targetSdkVersion = VersionCodes.Q)
private static final long HIDE_MAXTARGETSDK_P_HIDDEN_APIS = 149997251; // This is a bug id.
/**
* Gating access to greylist-max-q APIs.
*/
@ChangeId
- @EnabledAfter(targetSdkVersion = VersionCodes.Q)
+ @EnabledSince(targetSdkVersion = VersionCodes.R)
private static final long HIDE_MAXTARGETSDK_Q_HIDDEN_APIS = 149994052; // This is a bug id.
/**
diff --git a/mmodules/core_platform_api/Android.bp b/mmodules/core_platform_api/Android.bp
index 196e204..46c68f8 100644
--- a/mmodules/core_platform_api/Android.bp
+++ b/mmodules/core_platform_api/Android.bp
@@ -45,6 +45,8 @@
system_modules: "none",
patch_module: "java.base",
+ // Don't copy any output files to the dist.
+ no_dist: true,
}
// Referenced implicitly from legacy.art.module.platform.api.
diff --git a/mmodules/intracoreapi/Android.bp b/mmodules/intracoreapi/Android.bp
index 78ebcec..72d5fbf 100644
--- a/mmodules/intracoreapi/Android.bp
+++ b/mmodules/intracoreapi/Android.bp
@@ -54,6 +54,9 @@
sdk_version: "none",
system_modules: "none",
patch_module: "java.base",
+
+ // Don't copy any output files to the dist.
+ no_dist: true,
}
// Bootstrap the art-module-intra-core-api-stubs-system-modules.
diff --git a/non_openjdk_java_files.bp b/non_openjdk_java_files.bp
index 35a0ac4..fe3335d 100644
--- a/non_openjdk_java_files.bp
+++ b/non_openjdk_java_files.bp
@@ -411,13 +411,3 @@
":non_openjdk_javadoc_files",
],
}
-
-// timezone-related source that is also used in host tests / tools and its
-// dependencies.
-filegroup {
- name: "timezone_host_libcore_files",
- srcs: [
- "luni/src/main/java/libcore/api/CorePlatformApi.java",
- "luni/src/main/java/libcore/api/IntraCoreApi.java",
- ],
-}
diff --git a/ojluni/src/main/java/java/lang/ThreadLocal.java b/ojluni/src/main/java/java/lang/ThreadLocal.java
index c29ce7e..1422044 100644
--- a/ojluni/src/main/java/java/lang/ThreadLocal.java
+++ b/ojluni/src/main/java/java/lang/ThreadLocal.java
@@ -413,7 +413,8 @@
private Entry getEntry(ThreadLocal<?> key) {
int i = key.threadLocalHashCode & (table.length - 1);
Entry e = table[i];
- if (e != null && e.get() == key)
+ // Android-changed: Use refersTo()
+ if (e != null && e.refersTo(key))
return e;
else
return getEntryAfterMiss(key, i, e);
@@ -433,10 +434,10 @@
int len = tab.length;
while (e != null) {
- ThreadLocal<?> k = e.get();
- if (k == key)
+ // Android-changed: Use refersTo()
+ if (e.refersTo(key))
return e;
- if (k == null)
+ if (e.refersTo(null))
expungeStaleEntry(i);
else
i = nextIndex(i, len);
diff --git a/ojluni/src/main/java/java/lang/ref/Reference.java b/ojluni/src/main/java/java/lang/ref/Reference.java
index b319316..c84c359 100644
--- a/ojluni/src/main/java/java/lang/ref/Reference.java
+++ b/ojluni/src/main/java/java/lang/ref/Reference.java
@@ -42,6 +42,7 @@
public abstract class Reference<T> {
// BEGIN Android-changed: Reimplemented to accommodate a different GC and compiler.
// ClassLinker knows about the fields of this class.
+ // Backported refersTo() from OpenJDK 16.
/**
* Forces JNI path.
@@ -113,6 +114,23 @@
private final native T getReferent();
/**
+ * Tests if the referent of this reference object is {@code obj}.
+ * Using a {@code null} {@code obj} returns {@code true} if the
+ * reference object has been cleared.
+ *
+ * @param obj the object to compare with this reference object's referent
+ * @return {@code true} if {@code obj} is the referent of this reference object
+ * @hide
+ */
+ public final boolean refersTo(T obj) {
+ return refersTo0(obj);
+ }
+
+ /* Implementation of refersTo(). */
+ @FastNative
+ private final native boolean refersTo0(Object o);
+
+ /**
* Clears this reference object. Invoking this method will not cause this
* object to be enqueued.
*