Patch: java/awt/image/PixelGrabber.java

Bryce McKinlay bryce@waitaki.otago.ac.nz
Thu Jan 24 20:39:00 GMT 2002


The build was failing on PixelGrabber due to an "Unreachable Statement" 
error. This is probably a bug in GCJ because with -O it considers "(x != 
1 || x != 2)" to a constant expression with the value of true, while I 
guess the JLS does not. This likely happens due to fold() collapsing it.

In any case, the PixelGrabber code is certainly not right, and this 
patch is a slight improvement which at least compiles.

regards

Bryce.



Index: PixelGrabber.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/PixelGrabber.java,v
retrieving revision 1.1
diff -u -r1.1 PixelGrabber.java
--- PixelGrabber.java   2002/01/24 01:05:12     1.1
+++ PixelGrabber.java   2002/01/25 04:23:10
@@ -155,15 +155,7 @@
      */
     public boolean grabPixels() throws InterruptedException
     {
-       startGrabbing();
-       while ( (status != ImageObserver.ALLBITS ) ||
-               (status != ImageObserver.ERROR ) ||
-               (status != ImageObserver.ABORT ) );
-
-       if( status == ImageObserver.ALLBITS )
-           return true;
-       else
-           return false;
+      return grabPixels(0);
     }
 
     /**
@@ -176,24 +168,17 @@
      */
     public synchronized boolean grabPixels(long ms) throws 
InterruptedException
     {
-       long start = System.currentTimeMillis();
        startGrabbing();
-       while ( (status != ImageObserver.ALLBITS ) ||
-               (status != ImageObserver.ERROR ) ||
-               (status != ImageObserver.ABORT ) )
-           {
-               if( (System.currentTimeMillis() - start ) >= ms )
-                   {
-                       abortGrabbing();
-                       throw new InterruptedException();
-                   }
-           }
-
-       if( status == ImageObserver.ALLBITS )
+
+       if (ms < 0)
+         return (status == ImageObserver.ALLBITS);
+
+       wait(ms);
+
+       if (status == ImageObserver.ALLBITS)
            return true;
        else
            return false;
-
     }
 
     /**




More information about the Java-patches mailing list