Re: Patch: image loading fixes

2003-11-12 Thread Sascha Brawer
Hi Tom,

Thomas Fitzsimmons <[EMAIL PROTECTED]> wrote on Tue, 11 Nov
2003 16:33:30 -0500:

>[patch to java/awt/Component.java]

public boolean prepareImage(Image image, ImageObserver observer)
{
+if (image == null)
+  throw new NullPointerException ();
+
 return prepareImage(image, image.getWidth(observer),
 image.getHeight(observer), observer);
}

Actually, the test for image == null is not needed.

-- Sascha

Sascha Brawer, [EMAIL PROTECTED], http://www.dandelis.ch/people/brawer/ 




___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: Patch: image loading fixes

2003-11-12 Thread Tom Fitzsimmons
On Wed, 2003-11-12 at 03:12, Sascha Brawer wrote:
> Hi Tom,
> 
> Thomas Fitzsimmons <[EMAIL PROTECTED]> wrote on Tue, 11 Nov
> 2003 16:33:30 -0500:
> 
> >[patch to java/awt/Component.java]
> 
> public boolean prepareImage(Image image, ImageObserver observer)
> {
> +if (image == null)
> +  throw new NullPointerException ();
> +
>  return prepareImage(image, image.getWidth(observer),
>  image.getHeight(observer), observer);
> }
> 
> Actually, the test for image == null is not needed.
> 

Yes, I know an NPE will be thrown either way.  I just thought it better
to be explicit.  But the other methods in Component don't follow this
policy so I'll remove the check.

Thanks,
Tom




___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


Re: Patch: image loading fixes

2003-11-12 Thread Ricky Clarkson
Surely the exception to throw here would be IllegalArgumentException
anyway, as null would be an illegal input to the method.

Ricky.

> > >[patch to java/awt/Component.java]
> > 
> > public boolean prepareImage(Image image, ImageObserver observer)
> > {
> > +if (image == null)
> > +  throw new NullPointerException ();
> > +
> >  return prepareImage(image, image.getWidth(observer),
> >  image.getHeight(observer), observer);
> > }
> > 
> > Actually, the test for image == null is not needed.
> > 
> 
> Yes, I know an NPE will be thrown either way.  I just thought it better
> to be explicit.  But the other methods in Component don't follow this
> policy so I'll remove the check.

-- 
Phasers locked on target, Captain.


___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


[PATCH] Small fix for Jetty 4.2.14

2003-11-12 Thread Dalibor Topic
Hi,

attached is a small fix for Jetty 4.2.14 that is needed to get Jetty to 
work with Classpath's file URL Connection. Jetty otherwise breaks on 
startup and complains that webapps/templates can not be found, despite 
that it exists. Jetty wants to access the path of the file permission on 
a file URL connection to determine the existence of a file, apparently.

The fix overwrites getPermission the file URL connection to return a 
FilePermission with the file path and a read permission.

cheers,
dalibor topic
2003-11-13  Dalibor Topic <[EMAIL PROTECTED]>

   * libraries/javalib/gnu/java/net/protocol/file/Connection.java:
   Added imports for java.io.FilePermission and
   java.security.Permission.
   (permission) New field.
   (DEFAULT_PERMISSION) New constant.
   (Connection) Create a FilePermission with permission to read
   from file.
   (getPermission) Overwrite getPermission to return a
   FilePermission.
Index: libraries/javalib/gnu/java/net/protocol/file/Connection.java
===
RCS file: 
/cvs/kaffe/kaffe/libraries/javalib/gnu/java/net/protocol/file/Connection.java,v
retrieving revision 1.1
diff -u -r1.1 Connection.java
--- libraries/javalib/gnu/java/net/protocol/file/Connection.java29 Oct 2003 
18:30:49 -  1.1
+++ libraries/javalib/gnu/java/net/protocol/file/Connection.java13 Nov 2003 
00:20:38 -
@@ -44,12 +44,14 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.FilePermission;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.ProtocolException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.security.Permission;
 import java.util.AbstractSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -79,7 +81,17 @@
* OutputStream if we are writing to the file
*/
   private BufferedOutputStream outputStream;
-  
+
+  /**
+   * FilePermission to read the file
+   */
+  private FilePermission permission;
+
+  /**
+   * Default permission for a file
+   */
+  private static final String DEFAULT_PERMISSION = "read";
+
   /**
* Calls superclass constructor to initialize.
*/
@@ -89,6 +101,8 @@
 
 /* Set up some variables */
 doOutput = false;
+
+permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
   }
   
   /**
@@ -193,6 +207,19 @@
   }
   }
 
+
+  /**
+   * This method returns a Permission object representing the
+   * permissions required to access this URL.  This method returns a
+   * java.io.FilePermission for the file's path with a read
+   * permission.
+   *
+   * @return A Permission object
+   */
+  public Permission getPermission() throws IOException
+  {
+return permission;
+  }
 
   /**
* Does the resource pointed to actually exist?
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath