OSDN Git Service

DO NOT MERGE: Fix implementation of Thread.isAlive
authorAndy McFadden <fadden@android.com>
Tue, 1 Sep 2009 19:20:13 +0000 (12:20 -0700)
committerAndy McFadden <fadden@android.com>
Wed, 2 Sep 2009 21:30:54 +0000 (14:30 -0700)
(Originally submitted to master, pulling over to eclair.)

The implementation of Thread.isAlive() was changed a couple of years ago
as part of the Harmony integration.  The current version relies on the
thread's state value to determine its liveness, but the VM was
originally written to be like JamVM, which used GNU ClassPath, which
uses the vmThread field instead.

It looks like it's possible for Thread.join() to get stuck, though as
far as I know this hasn't happened.

We're essentially rolling back part of 27774-p9.  For internal bug 1966734.

Also: ran --update on test 044.

libcore/luni-kernel/src/main/java/java/lang/Thread.java
tests/044-proxy/expected.txt

index 484c258..4f9f988 100644 (file)
@@ -922,9 +922,7 @@ public class Thread implements Runnable {
      * @since Android 1.0
      */
     public final boolean isAlive() {
-        Thread.State state = getState();
-
-        return (state != Thread.State.TERMINATED && state != Thread.State.NEW);
+        return (vmThread != null);
     }
 
     /**
index 255cf99..69a94f2 100644 (file)
@@ -45,10 +45,10 @@ Invoke public abstract void Shapes.upCheck() throws java.lang.InterruptedExcepti
  (no args)
 Got expected ie
 
-Proxy methods: [public native boolean .$Proxy0.equals(java.lang.Object), public native int .$Proxy0.hashCode(), public native java.lang.String .$Proxy0.toString(), public native int .$Proxy0.rectangle(int,int), public native int .$Proxy0.square(int,int), public native int .$Proxy0.trapezoid(int,double,int), public native java.lang.String .$Proxy0.blob(), public native void .$Proxy0.circle(int), public native void .$Proxy0.upCheck(), public native void .$Proxy0.upChuck(), public native double .$Proxy0.blue(int), public native R0aa .$Proxy0.checkMe(), public native int .$Proxy0.green(double), public native int .$Proxy0.mauve(java.lang.String), public native int .$Proxy0.red(float)]
+Proxy methods: [public native boolean $Proxy0.equals(java.lang.Object), public native int $Proxy0.hashCode(), public native java.lang.String $Proxy0.toString(), public native int $Proxy0.rectangle(int,int), public native int $Proxy0.square(int,int), public native int $Proxy0.trapezoid(int,double,int), public native java.lang.String $Proxy0.blob(), public native void $Proxy0.circle(int), public native void $Proxy0.upCheck(), public native void $Proxy0.upChuck(), public native double $Proxy0.blue(int), public native R0aa $Proxy0.checkMe(), public native int $Proxy0.green(double), public native int $Proxy0.mauve(java.lang.String), public native int $Proxy0.red(float)]
 Decl annos: []
 Param annos (1) : [[]]
-Proxy fields: [private static [[Ljava.lang.Throwable; .$Proxy0.throws]
+Proxy fields: [private static [[Ljava.lang.Throwable; $Proxy0.throws]
 Dupe threw expected exception
 Clash threw expected exception
 Clash2 threw expected exception