Merge "Remove referenceStaticOffsets from Class.java since it's not needed anymore."
diff --git a/libart/src/main/java/java/lang/ref/Reference.java b/libart/src/main/java/java/lang/ref/Reference.java
index 31ea588..70967b5 100644
--- a/libart/src/main/java/java/lang/ref/Reference.java
+++ b/libart/src/main/java/java/lang/ref/Reference.java
@@ -199,7 +199,19 @@
      * @return the referent to which reference refers, or {@code null} if the
      *         object has been cleared.
      */
-    public native T get();
+    public T get() {
+        return getReferent();
+    }
+
+    /**
+     * Returns the referent of the reference object.
+     *
+     * @return the referent to which reference refers, or {@code null} if the
+     *         object has been cleared. Required since the compiler
+     *         intrisifies getReferent() since we can't intrinsify Reference.get()
+     *         due to incorrect devirtualization (and inlining) of PhantomReference.get().
+     */
+    private final native T getReferent();
 
     /**
      * Checks whether the reference object has been enqueued.
diff --git a/luni/src/main/java/java/nio/SelectorImpl.java b/luni/src/main/java/java/nio/SelectorImpl.java
index efa8712..45406b1 100644
--- a/luni/src/main/java/java/nio/SelectorImpl.java
+++ b/luni/src/main/java/java/nio/SelectorImpl.java
@@ -39,6 +39,7 @@
 import libcore.io.Libcore;
 
 import static android.system.OsConstants.EINTR;
+import static android.system.OsConstants.POLLERR;
 import static android.system.OsConstants.POLLHUP;
 import static android.system.OsConstants.POLLIN;
 import static android.system.OsConstants.POLLOUT;
@@ -259,7 +260,7 @@
 
             int ops = key.interestOpsNoCheck();
             int selectedOps = 0;
-            if ((pollFd.revents & POLLHUP) != 0) {
+            if ((pollFd.revents & POLLHUP) != 0 || (pollFd.revents & POLLERR) != 0) {
                 // If there was an error condition, we definitely want to wake listeners,
                 // regardless of what they're waiting for. Failure is always interesting.
                 selectedOps |= ops;