This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH] Fix for Dialog and FileDialog argument handling
- From: Fernando Nasser <fnasser at redhat dot com>
- To: GCJ Patches <java-patches at gcc dot gnu dot org>
- Date: Wed, 31 Dec 2003 18:30:24 -0500
- Subject: [PATCH] Fix for Dialog and FileDialog argument handling
- Organization: Red Hat , Inc. - Toronto
I wonder if this can be considered an obvious fix.
A quick check to javadocs show that we can pass null for title (Dialog, and by
inheritance FileDialog) and that we must throw an exception if the FileDialog
mode is not either SAVE or LOAD.
Happy New Year!
2003-12-31 Fernando Nasser <fnasser@redhat.com>
* java/awt/Dialog.java (constructor): Accept null title as per spec.
* java/awt/FileDialog.java (constructor): Throw exception on invalid
argument as per spec.
Index: java/awt/Dialog.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Dialog.java,v
retrieving revision 1.10
diff -c -p -r1.10 Dialog.java
*** java/awt/Dialog.java 19 Sep 2003 19:27:58 -0000 1.10
--- java/awt/Dialog.java 31 Dec 2003 23:18:11 -0000
*************** Dialog (Frame parent, String title, bool
*** 187,193 ****
{
super (parent, gc);
! this.title = title;
this.modal = modal;
visible = false;
--- 187,194 ----
{
super (parent, gc);
! // A null title is equivalent to an empty title
! this.title = (title != null) ? title : "";
this.modal = modal;
visible = false;
*************** public
*** 254,261 ****
Dialog (Dialog parent, String title, boolean modal, GraphicsConfiguration gc)
{
super (parent, parent.getGraphicsConfiguration ());
!
! this.title = title;
this.modal = modal;
visible = false;
--- 255,263 ----
Dialog (Dialog parent, String title, boolean modal, GraphicsConfiguration gc)
{
super (parent, parent.getGraphicsConfiguration ());
!
! // A null title is equivalent to an empty title
! this.title = (title != null) ? title : "";
this.modal = modal;
visible = false;
*************** getTitle()
*** 289,295 ****
public synchronized void
setTitle(String title)
{
! this.title = title;
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
--- 291,299 ----
public synchronized void
setTitle(String title)
{
! // A null title is equivalent to an empty title
! this.title = (title != null) ? title : "";
!
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
Index: java/awt/FileDialog.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/FileDialog.java,v
retrieving revision 1.6
diff -c -p -r1.6 FileDialog.java
*** java/awt/FileDialog.java 5 Jun 2003 19:58:39 -0000 1.6
--- java/awt/FileDialog.java 31 Dec 2003 23:22:20 -0000
*************** FileDialog(Frame parent, String title)
*** 145,152 ****
--- 145,158 ----
*/
public
FileDialog(Frame parent, String title, int mode)
+ throws IllegalArgumentException
{
super(parent, title, true);
+
+ if ((mode != LOAD) && (mode != SAVE))
+ throw new IllegalArgumentException (
+ "Mode argument must be either LOAD or SAVE");
+
setMode (mode);
}