[cp-patches] Patch for approval: JMenu setSelected behavior (bug 13683)

2005-07-11 Thread Anthony Balkissoon
This patch is in reference to bug report 13683, JMenu setSelected
behavior.  Direct calls to setSelected no longer expand the popupMenu,
although mouse events still do.

This also allows direct calls to setSelected to select the menu even
while it is disabled (as in the JDK), however it is not properly painted
yet.  Once I look into that I will close the bug report.

This patch is pending approval.

Patch attached.



2005-07-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JMenu.java:
(setSelectedHelper): new method.
(setSelected): Code moved to setSelectedHelper. Calls
setSelectedHelper(selected,true,false) which doesn't expand the popup
menu and works whether the menu is enabled or not.
(menuSelectionChanged): Changed call to setSelected(changed) to 
setSelectedHelper(changed,isEnabled(),true) which does expand the
popup menu, but only if the menu is enabled.

-Tony
Index: javax/swing/JMenu.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenu.java,v
retrieving revision 1.18
diff -u -r1.18 JMenu.java
--- javax/swing/JMenu.java	8 Jul 2005 00:23:22 -	1.18
+++ javax/swing/JMenu.java	11 Jul 2005 16:59:10 -
@@ -332,52 +332,50 @@
   }
 
   /**
-   * Changes this menu selected state if selected is true and false otherwise
-   * This method fires menuEvents to menu's registered listeners.
-   *
-   * @param selected true if the menu should be selected and false otherwise
+   * A helper method to handle setSelected calls from both mouse events and 
+   * direct calls to setSelected.  Direct calls shouldn't expand the popup
+   * menu and should select the JMenu even if it is disabled.  Mouse events
+   * only select the JMenu if it is enabled and should expand the popup menu
+   * associated with this JMenu.
+   * @param selected whether or not the JMenu was selected
+   * @param menuEnabled whether or not selecting the menu is enabled.  This
+   * is always true for direct calls, and is set to isEnabled() for mouse 
+   * based calls.
+   * @param showMenu whether or not to show the popup menu
*/
-  public void setSelected(boolean selected)
+  private void setSelectedHelper(boolean selected, boolean menuEnabled, boolean showMenu)
   {
 // If menu is selected and enabled, activates the menu and 
 // displays associated popup.	
-if (selected  isEnabled())
+if (selected  menuEnabled)
   {
 	super.setArmed(true);
 	super.setSelected(true);
-
-	// FIXME: The reference implementation behaves different here. When
-	// calling setSelected(true) it will *not* open the popup but appear
-	// selected. This is even true when the menu is disabled. Our
-	// implementation will always open the popup (when enabled) and 
-	// will not appear selected when disabled.
-
-	// FIXME: The popup menu should be shown on the screen after certain
-	// number of seconds pass. The 'delay' property of this menu indicates
-	// this amount of seconds. 'delay' property is 0 by default.
+
 	if (isShowing())
 	  {
 	fireMenuSelected();
-
+
 	int x = 0;
 	int y = 0;
-
-	if (menuLocation == null)
-	  {
-		// Calculate correct position of the popup. Note that location of the popup 
-		// passed to show() should be relative to the popup's invoker
-		if (isTopLevelMenu())
-		  y = this.getHeight();
-		else
-		  x = this.getWidth();
-
-		getPopupMenu().show(this, x, y);
-	  }
-	else
-	  getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+if (showMenu)
+  if (menuLocation == null)
+{
+  // Calculate correct position of the popup. Note that location of the popup 
+  // passed to show() should be relative to the popup's invoker
+  if (isTopLevelMenu())
+y = this.getHeight();
+  else
+x = this.getWidth();
+  getPopupMenu().show(this, x, y);
+}
+  else
+{
+  getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+}
 	  }
   }
-
+
 else
   {
 	super.setSelected(false);
@@ -385,6 +383,18 @@
 	fireMenuDeselected();
 	popupMenu.setVisible(false);
   }
+
+  }
+
+  /**
+   * Changes this menu selected state if selected is true and false otherwise
+   * This method fires menuEvents to menu's registered listeners.
+   *
+   * @param selected true if the menu should be selected and false otherwise
+   */
+  public void setSelected(boolean selected)
+  {
+setSelectedHelper(selected, true, false); 
   }
 
   /**
@@ -715,7 +725,7 @@
   {
 // if this menu selection is true, then activate this menu and 
 // display popup associated with this menu
-setSelected(changed);
+setSelectedHelper(changed, isEnabled(), true);
   }
 
   /**
___
Classpath-patches mailing list

[cp-patches] FYI: java-net native cleanup (and Socket timeouts)

2005-07-11 Thread Mark Wielaard
Hi,

This cleans up a lot of the java-net native code. In several places we
were masking the actual exception by throwing a new exception. In other
places we did cleanup before we used the result of perror() which meant
that the error message was often bogus. We weren't checking whether
system calls were interrupted everywhere (most noticeable by failing
connect() calls). We had a completely bogus implementation of
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT and
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT which used an int
instead of a struct timeval. And worse we were ignoring the failure in
the jni code. So socket timeouts didn't work at all.

2005-07-10  Mark Wielaard  [EMAIL PROTECTED]

   * native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c:
   Whenever an ExceptionOccurred just return to throw it, don't mask.
   * native/jni/java-net/javanet.c (_javanet_get_netaddr): Check for
   NULL addr.
   (_javanet_create): Explicitly close socket on failure.
   (_javanet_close): Save error message and retry closing when
   interrupted before throwing exception.
   (_javanet_connect): Keep retrying connect after system call
   interrupted. First construct exception before cleanup.
   (_javanet_bind): Save error string for exception.
   (_javanet_accept): Explicitly close socket on failure.
   (_javanet_recvfrom): Throw SocketTimeoutException when timed out.
   (_javanet_sendto): Send all data even when interrupted.
   (_javanet_set_option): Don't ignore error when setting SO_TIMEOUT.
   * native/target/generic/target_generic_network.h
   (TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT): Use timeval for
   setsockopt.
   (TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT): Likewise for
   getsockopt.

This fixes several Mauve failures and gives no new regressions. Some of
my example applications also work much better.

Committed,

Mark
? native/target/generic/semantic.cache
Index: native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c
===
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c,v
retrieving revision 1.11
diff -u -r1.11 gnu_java_net_PlainDatagramSocketImpl.c
--- native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c	2 Jul 2005 20:32:55 -	1.11
+++ native/jni/java-net/gnu_java_net_PlainDatagramSocketImpl.c	11 Jul 2005 18:00:24 -
@@ -207,7 +207,9 @@
 }
 
   arr = (*env)-CallObjectMethod (env, packet, mid);
-  if ((arr == NULL) || (*env)-ExceptionOccurred (env))
+  if ((*env)-ExceptionOccurred (env))
+return;
+  if (arr == NULL)
 {
   JCL_ThrowException (env, IO_EXCEPTION, Internal error: call getData);
   return;
@@ -223,11 +225,7 @@
 
   offset = (*env)-CallIntMethod (env, packet, mid);
   if ((*env)-ExceptionOccurred (env))
-{
-  JCL_ThrowException (env, IO_EXCEPTION,
-			  Internal error: call getOffset);
-  return;
-}
+return;
 
   DBG (PlainDatagramSocketImpl.receive(): Got the offset\n);
 
@@ -241,16 +239,15 @@
 
   maxlen = (*env)-GetIntField (env, packet, fid);
   if ((*env)-ExceptionOccurred (env))
-{
-  JCL_ThrowException (env, IO_EXCEPTION, Internal error: call length);
-  return;
-}
+return;
 
   /* Receive the packet */
   /* should we try some sort of validation on the length? */
   bytes_read =
 _javanet_recvfrom (env, obj, arr, offset, maxlen, addr, port);
-  if ((bytes_read == -1) || (*env)-ExceptionOccurred (env))
+  if ((*env)-ExceptionOccurred (env))
+return;
+  if (bytes_read == -1)
 {
   JCL_ThrowException (env, IO_EXCEPTION, Internal error: receive);
   return;
@@ -292,11 +289,7 @@
 
   addr_obj = (*env)-CallStaticObjectMethod (env, addr_cls, mid, ip_str_obj);
   if ((*env)-ExceptionOccurred (env))
-{
-  JCL_ThrowException (env, IO_EXCEPTION,
-			  Internal error: call getByName);
-  return;
-}
+return;
 
   mid = (*env)-GetMethodID (env, cls, setAddress,
 			 (Ljava/net/InetAddress;)V);
@@ -308,11 +301,7 @@
 
   (*env)-CallVoidMethod (env, packet, mid, addr_obj);
   if ((*env)-ExceptionOccurred (env))
-{
-  JCL_ThrowException (env, IO_EXCEPTION,
-			  Internal error: call setAddress);
-  return;
-}
+return;
 
   DBG (PlainDatagramSocketImpl.receive(): Stored the address\n);
 
@@ -326,10 +315,7 @@
 
   (*env)-CallVoidMethod (env, packet, mid, port);
   if ((*env)-ExceptionOccurred (env))
-{
-  JCL_ThrowException (env, IO_EXCEPTION, Internal error: call setPort);
-  return;
-}
+return;
 
   DBG (PlainDatagramSocketImpl.receive(): Stored the port\n);
 
@@ -343,10 +329,7 @@
 
   (*env)-SetIntField (env, packet, fid, bytes_read);
   if ((*env)-ExceptionOccurred (env))
-{
-  JCL_ThrowException (env, IO_EXCEPTION, Internal error: call length);
-  return;
-}
+return;
 
   DBG (PlainDatagramSocketImpl.receive(): Stored the length\n);
 #else /* not WITHOUT_NETWORK */
@@ -372,20 

[cp-patches] FYI: 2 JMenu related patches

2005-07-11 Thread Anthony Balkissoon
I committed the patch I sent to the list earlier today which fixes bug
13683.

Second patch fixes BasicMenuUI's handling of MouseEntered events.  To
comply with the JDK a top level menu shouldn't be selected upon a mouse
entered event unless there was a previously selected menu in the same
menubar and that menu had its popup menu visible.  Previously we were
selecting it whether or not the popup menu was visible.  This has been
committed.

Patches attached.

2005-07-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicMenuUI.java:
(MouseInputHandler.mouseEntered): Added check: if a different menu in
the menubar was selected, we don't select this one unless the old one
had its popup menu showing.  This complies with the reference
implementation.

2005-07-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JMenu.java:
(setSelectedHelper): new method.
(setSelected): Code moved to setSelectedHelper. Calls
setSelectedHelper(selected,true,false) which doesn't expand the popup
menu and works whether the menu is enabled or not.
(menuSelectionChanged): Changed call to setSelected(changed) to 
setSelectedHelper(changed,isEnabled(),true) which does expand the
popup menu, but only if the menu is enabled.


-Tony
Index: javax/swing/JMenu.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenu.java,v
retrieving revision 1.18
diff -u -r1.18 JMenu.java
--- javax/swing/JMenu.java	8 Jul 2005 00:23:22 -	1.18
+++ javax/swing/JMenu.java	11 Jul 2005 16:59:10 -
@@ -332,52 +332,50 @@
   }
 
   /**
-   * Changes this menu selected state if selected is true and false otherwise
-   * This method fires menuEvents to menu's registered listeners.
-   *
-   * @param selected true if the menu should be selected and false otherwise
+   * A helper method to handle setSelected calls from both mouse events and 
+   * direct calls to setSelected.  Direct calls shouldn't expand the popup
+   * menu and should select the JMenu even if it is disabled.  Mouse events
+   * only select the JMenu if it is enabled and should expand the popup menu
+   * associated with this JMenu.
+   * @param selected whether or not the JMenu was selected
+   * @param menuEnabled whether or not selecting the menu is enabled.  This
+   * is always true for direct calls, and is set to isEnabled() for mouse 
+   * based calls.
+   * @param showMenu whether or not to show the popup menu
*/
-  public void setSelected(boolean selected)
+  private void setSelectedHelper(boolean selected, boolean menuEnabled, boolean showMenu)
   {
 // If menu is selected and enabled, activates the menu and 
 // displays associated popup.	
-if (selected  isEnabled())
+if (selected  menuEnabled)
   {
 	super.setArmed(true);
 	super.setSelected(true);
-
-	// FIXME: The reference implementation behaves different here. When
-	// calling setSelected(true) it will *not* open the popup but appear
-	// selected. This is even true when the menu is disabled. Our
-	// implementation will always open the popup (when enabled) and 
-	// will not appear selected when disabled.
-
-	// FIXME: The popup menu should be shown on the screen after certain
-	// number of seconds pass. The 'delay' property of this menu indicates
-	// this amount of seconds. 'delay' property is 0 by default.
+
 	if (isShowing())
 	  {
 	fireMenuSelected();
-
+
 	int x = 0;
 	int y = 0;
-
-	if (menuLocation == null)
-	  {
-		// Calculate correct position of the popup. Note that location of the popup 
-		// passed to show() should be relative to the popup's invoker
-		if (isTopLevelMenu())
-		  y = this.getHeight();
-		else
-		  x = this.getWidth();
-
-		getPopupMenu().show(this, x, y);
-	  }
-	else
-	  getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+if (showMenu)
+  if (menuLocation == null)
+{
+  // Calculate correct position of the popup. Note that location of the popup 
+  // passed to show() should be relative to the popup's invoker
+  if (isTopLevelMenu())
+y = this.getHeight();
+  else
+x = this.getWidth();
+  getPopupMenu().show(this, x, y);
+}
+  else
+{
+  getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+}
 	  }
   }
-
+
 else
   {
 	super.setSelected(false);
@@ -385,6 +383,18 @@
 	fireMenuDeselected();
 	popupMenu.setVisible(false);
   }
+
+  }
+
+  /**
+   * Changes this menu selected state if selected is true and false otherwise
+   * This method fires menuEvents to menu's registered listeners.
+   *
+   * @param selected true if the menu should be selected and false otherwise
+   */
+  public void setSelected(boolean selected)
+  {
+setSelectedHelper(selected, 

[cp-patches] FYI: Another small java.net exception hiding fixlet

2005-07-11 Thread Mark Wielaard
Hi,

Here is another fixlet to show the real cause of an exception in
java.net:

2005-07-11  Mark Wielaard  [EMAIL PROTECTED]

   * java/net/DatagramSocket.java (getImpl): Record cause of Exception.

Committed,

Mark

diff -u -r1.44 DatagramSocket.java
--- java/net/DatagramSocket.java2 Jul 2005 20:32:39 -   1.44
+++ java/net/DatagramSocket.java11 Jul 2005 18:35:57 -
@@ -209,7 +209,9 @@
   }
 catch (IOException e)
   {
-   throw new SocketException(e.getMessage());
+   SocketException se = new SocketException();
+   se.initCause(e);
+   throw se;
   }
   }




signature.asc
Description: This is a digitally signed message part
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: BasicMenuUI fixlet

2005-07-11 Thread Anthony Balkissoon
This patch makes our JMenu usage more compatible with the reference
implementation.  Oddly enough, calls to JMenu.setSelected will allow
more than one menu in a menubar to be selected, so I wrote popupVisible
to make clear the criteria for selecting a menu due to a mouse entered
event.

Removing the check for !menu.isArmed is so that if a menu is selected
but doesn't have its popup menu showing, and then receives a valid mouse
entered event (while another menu is open), it will show its popup menu.

Patch attached.

2005-07-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicMenuUI.java:
(MouseHandler.popupVisible): new method.
(MouseHandler.mouseEntered): Removed check for menu being armed to
comply with reference implementation.  Calls popupVisible to check
for menus with their popup menu visible
Index: javax/swing/plaf/basic/BasicMenuUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuUI.java,v
retrieving revision 1.11
diff -u -r1.11 BasicMenuUI.java
--- javax/swing/plaf/basic/BasicMenuUI.java	11 Jul 2005 18:07:15 -	1.11
+++ javax/swing/plaf/basic/BasicMenuUI.java	11 Jul 2005 19:09:53 -
@@ -292,6 +292,19 @@
   manager.processMouseEvent(e);
 }
 
+private boolean popupVisible()
+{
+  JMenuBar mb = (JMenuBar) ((JMenu)menuItem).getParent();
+  // check if mb.isSelected because if no menus are selected
+  // we don't have to look through the list for popup menus
+  if (!mb.isSelected())
+return false;
+  for (int i=0;imb.getMenuCount();i++)
+if (((JMenu)mb.getComponent(i)).isPopupMenuVisible())
+  return true;
+  return false;
+}
+
 public void mouseEntered(MouseEvent e)
 {
   /* When mouse enters menu item, it should be considered selected
@@ -303,12 +316,15 @@
it will be selected)
   */
   JMenu menu = (JMenu) menuItem;
-  JMenuBar mb = (JMenuBar) menu.getParent();
-  if (! menu.isTopLevelMenu()
-  || (mb.isSelected()  (((JMenu)(mb.getComponent 
-   (mb.getSelectionModel().
-getSelectedIndex(.
-  isPopupMenuVisible())  ! menu.isArmed()))
+
+  // NOTE: the following if used to require !menu.isArmed but I could find
+  // no reason for this and it was preventing some JDK-compatible behaviour.
+  // Specifically, if a menu is selected but its popup menu not visible,
+  // and then another menu is selected whose popup menu IS visible, when
+  // the mouse is moved over the first menu, its popup menu should become
+  // visible.
+
+  if (! menu.isTopLevelMenu() || popupVisible())
 {
 	  // set new selection and forward this event to MenuSelectionManager
 	  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: JFileChooser.getSelectedFiles() fixlet

2005-07-11 Thread Mark Wielaard
Hi,

While testing Jump a bit I noticed that you can call getSelectedFiles()
even if in single file selection mode. So this patch makes sure
getSelectedFiles() does return something in that case.

2005-07-11  Mark Wielaard  [EMAIL PROTECTED]

* javax/swing/JFileChooser.java (getSelectedFiles): Return an one
element array containing selectedFile if selectedFiles is null.

Several people on irc said that this was better then the current
implementation. So I committed it. I didn't really get much further with
gump though.

Committed,

Mark

--- javax/swing/JFileChooser.java   2 Jul 2005 20:32:47 -   1.12
+++ javax/swing/JFileChooser.java   11 Jul 2005 19:44:59 -
@@ -357,7 +357,11 @@
*/
   public File[] getSelectedFiles()
   {
-return selectedFiles;
+if (selectedFiles != null)
+  return selectedFiles;
+if (selectedFile != null)
+  return new File[] { selectedFile };
+return null;
   }

   /**



signature.asc
Description: This is a digitally signed message part
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Patch: Demo tree

2005-07-11 Thread Lillian Angel
2005-07-11  Lillian Angel  [EMAIL PROTECTED]
* examples/gnu/classpath/examples/swing/Demo.java
(mkTree): fixed so the JTree appears properly.

Index: examples/gnu/classpath/examples/swing/Demo.java
===
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/Demo.java,v
retrieving revision 1.12
diff -u -r1.12 Demo.java
--- examples/gnu/classpath/examples/swing/Demo.java	11 Jul 2005 20:09:10 -	1.12
+++ examples/gnu/classpath/examples/swing/Demo.java	11 Jul 2005 20:39:01 -
@@ -838,6 +838,12 @@
 child2.add(child24);
 
 JTree tree = new JTree(root);
+tree.setRootVisible(true);
+tree.setLargeModel(true);
+DefaultTreeSelectionModel dtsm = new DefaultTreeSelectionModel();
+dtsm.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
+tree.setSelectionModel(dtsm);
+
 return tree;
   }

___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: GtkImage Error handling (2)

2005-07-11 Thread Sven de Marothy
Previous patch is wrong. This one is right.

2005-07-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkImage.java:
(setImage): Set error flag on bad width, height or pixels.
(checkImage): Return error flag.


-- 
Sven de Marothy [EMAIL PROTECTED]
Index: gnu/java/awt/peer/gtk/GtkImage.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkImage.java,v
retrieving revision 1.19
diff -U3 -r1.19 GtkImage.java
--- gnu/java/awt/peer/gtk/GtkImage.java	2 Jul 2005 20:32:12 -	1.19
+++ gnu/java/awt/peer/gtk/GtkImage.java	11 Jul 2005 21:05:28 -
@@ -100,6 +100,11 @@
   boolean offScreen;
 
   /**
+   * Error flag for loading.
+   */
+  boolean errorLoading;
+
+  /**
* Original source, if created from an ImageProducer.
*/
   ImageProducer source;
@@ -176,6 +181,7 @@
 isLoaded = false;
 observers = new Vector();
 source = producer;
+errorLoading = false;
 source.startProduction(new GtkImageConsumer(this, source));
 offScreen = false;
   }
@@ -243,6 +249,13 @@
 this.width = width;
 this.height = height;
 props = (properties != null) ? properties : new Hashtable();
+
+if (width = 0 || height = 0 || pixels == null)
+  {
+	errorLoading = true;
+	return;
+  }
+
 isLoaded = true;
 deliver();
 createPixmap();
@@ -346,7 +359,12 @@
   public int checkImage (ImageObserver observer)
   {
 if (addObserver(observer))
-  return 0;
+  {
+	if (errorLoading == true)
+	  return ImageObserver.ERROR;
+	else
+	  return 0;
+  }
 
 return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI GtkImage error handling

2005-07-11 Thread Sven de Marothy
2005-07-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkImage.java:
(setImage): Set error flag on bad width, height or pixels.
(checkImage): Return error flag.


-- 
Sven de Marothy [EMAIL PROTECTED]
Index: gnu/java/awt/peer/gtk/GtkImage.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkImage.java,v
retrieving revision 1.19
diff -U3 -r1.19 GtkImage.java
--- gnu/java/awt/peer/gtk/GtkImage.java	2 Jul 2005 20:32:12 -	1.19
+++ gnu/java/awt/peer/gtk/GtkImage.java	11 Jul 2005 21:05:28 -
@@ -100,6 +100,11 @@
   boolean offScreen;
 
   /**
+   * Error flag for loading.
+   */
+  boolean errorLoading;
+
+  /**
* Original source, if created from an ImageProducer.
*/
   ImageProducer source;
@@ -176,6 +181,7 @@
 isLoaded = false;
 observers = new Vector();
 source = producer;
+errorLoading = false;
 source.startProduction(new GtkImageConsumer(this, source));
 offScreen = false;
   }
@@ -243,6 +249,13 @@
 this.width = width;
 this.height = height;
 props = (properties != null) ? properties : new Hashtable();
+
+if (width = 0 || height = 0 || pixels == null)
+  {
+	isError = true;
+	return;
+  }
+
 isLoaded = true;
 deliver();
 createPixmap();
@@ -346,7 +359,12 @@
   public int checkImage (ImageObserver observer)
   {
 if (addObserver(observer))
-  return 0;
+  {
+	if (errorLoading == true)
+	  return ImageObserver.ERROR;
+	else
+	  return 0;
+  }
 
 return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: new icons in MetalIconFactory

2005-07-11 Thread David Gilbert
I committed this patch to add support for the JSlider thumb icons in
MetalIconFactory:

2005-07-11  David Gilbert  [EMAIL PROTECTED]

* javax/swing/plaf/metal/MetalIconFactory.java
(HorizontalSliderThumbIcon): new inner class,
(VerticalSliderThumbIcon): new inner class,
(getHorizontalSliderThumbIcon): implemented,
(getVerticalSliderThumbIcon): implemented.

I have an almost complete MetalSliderUI implementation that uses these -
it works on top of Sun's BasicSliderUI, but not on Classpath's (yet).
I'll put together a patch tomorrow (hopefully) and maybe someone can
spot the problems in BasicSliderUI faster than I can (I'm learning as I
go with the look and feel classes).

Regards,

Dave Gilbert

Index: javax/swing/plaf/metal/MetalIconFactory.java
===
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalIconFactory.java,v
retrieving revision 1.1
diff -u -r1.1 MetalIconFactory.java
--- javax/swing/plaf/metal/MetalIconFactory.java8 Jul 2005 13:53:08 
-   1.1
+++ javax/swing/plaf/metal/MetalIconFactory.java11 Jul 2005 21:15:57 
-
@@ -44,6 +44,7 @@
 import java.io.Serializable;
 
 import javax.swing.Icon;
+import javax.swing.JSlider;
 
 /**
  * Creates icons for the [EMAIL PROTECTED] MetalLookAndFeel}.
@@ -206,7 +207,205 @@
 }
 
   }
+   
+/**
+   * The icon used to display the thumb control on a horizontally oriented
+   * [EMAIL PROTECTED] JSlider} component.
+   */
+  private static class HorizontalSliderThumbIcon 
+  implements Icon, Serializable 
+  {
+
+/**
+ * Creates a new instance.
+ */
+public HorizontalSliderThumbIcon() 
+{
+}
+
+/**
+ * Returns the width of the icon, in pixels.
+ * 
+ * @return The width of the icon.
+ */
+public int getIconWidth() 
+{
+  return 15;
+}
+
+/**
+ * Returns the height of the icon, in pixels.
+ * 
+ * @return The height of the icon.
+ */
+public int getIconHeight() 
+{
+  return 16;
+}
+
+/**
+ * Paints the icon, taking into account whether or not the component has 
+ * the focus.
+ * 
+ * @param c  the component.
+ * @param g  the graphics device.
+ * @param x  the x-coordinate.
+ * @param y  the y-coordinate.
+ */
+public void paintIcon(Component c, Graphics g, int x, int y) 
+{
+  boolean focus = false;
+  if (c != null) 
+focus = c.hasFocus();
+  // TODO: pick up the colors from the look and feel
+  
+  // draw the outline
+  g.setColor(Color.black);
+  g.drawLine(x + 1, y, x + 13, y);
+  g.drawLine(x + 14, y + 1, x + 14, y + 7);
+  g.drawLine(x + 14, y + 8, x + 7, y + 15);
+  g.drawLine(x + 6, y + 14, x, y + 8);
+  g.drawLine(x, y + 7, x, y + 1);
+  
+  // fill the icon
+  g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); 
 // medium
+  g.fillRect(x + 2, y + 2, 12, 7);
+  g.drawLine(x + 2, y + 9, x + 12, y + 9);
+  g.drawLine(x + 3, y + 10, x + 11, y + 10);
+  g.drawLine(x + 4, y + 11, x + 10, y + 11);
+  g.drawLine(x + 5, y + 12, x + 9, y + 12);
+  g.drawLine(x + 6, y + 13, x + 8, y + 13);
+  g.drawLine(x + 7, y + 14, x + 7, y + 14);
+  
+  // draw highlights
+  g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); 
 // light
+  g.drawLine(x + 1, y + 1, x + 13, y + 1);
+  g.drawLine(x + 1, y + 2, x + 1, y + 8);
+  g.drawLine(x + 2, y + 2, x + 2, y + 2);
+  g.drawLine(x + 6, y + 2, x + 6, y + 2);
+  g.drawLine(x + 10, y + 2, x + 10, y + 2);
+
+  g.drawLine(x + 4, y + 4, x + 4, y + 4);
+  g.drawLine(x + 8, y + 4, x + 8, y + 4);
+
+  g.drawLine(x + 2, y + 6, x + 2, y + 6);
+  g.drawLine(x + 6, y + 6, x + 6, y + 6);
+  g.drawLine(x + 10, y + 6, x + 10, y + 6);
+
+  // draw dots
+  g.setColor(focus ? new Color(102, 102, 153) : Color.black);  
   // dark
+  g.drawLine(x + 3, y + 3, x + 3, y + 3);
+  g.drawLine(x + 7, y + 3, x + 7, y + 3);
+  g.drawLine(x + 11, y + 3, x + 11, y + 3);
+
+  g.drawLine(x + 5, y + 5, x + 5, y + 5);
+  g.drawLine(x + 9, y + 5, x + 9, y + 5);
+
+  g.drawLine(x + 3, y + 7, x + 3, y + 7);
+  g.drawLine(x + 7, y + 7, x + 7, y + 7);
+  g.drawLine(x + 11, y + 7, x + 11, y + 7);
+
+}
+  }
+  
+  /**
+   * The icon used to display the thumb control on a horizontally oriented
+   * [EMAIL PROTECTED] JSlider} component.
+   */
+  private static class VerticalSliderThumbIcon implements Icon, Serializable 
+  {
+/**
+ * Creates a new instance.
+ */
+public VerticalSliderThumbIcon() 
+{
+}
+
+/**
+ * Returns the width of the icon, in pixels.
+ * 
+ * @return The width of the icon.
+ */
+public int getIconWidth() 
+{
+  return 16;
+   

[cp-patches] FYI: minor API doc fixes in java.io.*

2005-07-11 Thread David Gilbert
I committed this patch:

2005-07-11  David Gilbert  [EMAIL PROTECTED]

* java/io/DataOutput.java: fixed minor API doc errors,
* java/io/LineNumberInputStream.java: likewise.

Regards,

Dave Gilbert

Index: java/io/DataOutput.java
===
RCS file: /cvsroot/classpath/classpath/java/io/DataOutput.java,v
retrieving revision 1.14
diff -u -r1.14 DataOutput.java
--- java/io/DataOutput.java 2 Jul 2005 20:32:37 -   1.14
+++ java/io/DataOutput.java 11 Jul 2005 21:59:23 -
@@ -195,7 +195,7 @@
*
* @exception IOException If an error occurs
*
-   * @see writeInt
+   * @see #writeInt
* @see DataInput#readFloat
* @see Float#floatToIntBits
*/
@@ -216,7 +216,7 @@
*
* @exception IOException If any other error occurs
*
-   * @see writeLong
+   * @see #writeLong
* @see DataInput#readDouble
* @see Double#doubleToLongBits
*/
@@ -245,7 +245,7 @@
*
* @exception IOException If an error occurs
*
-   * @see writeChar
+   * @see #writeChar(int)
*/
   void writeChars(String value) throws IOException;
 
Index: java/io/LineNumberInputStream.java
===
RCS file: /cvsroot/classpath/classpath/java/io/LineNumberInputStream.java,v
retrieving revision 1.10
diff -u -r1.10 LineNumberInputStream.java
--- java/io/LineNumberInputStream.java  2 Jul 2005 20:32:38 -   1.10
+++ java/io/LineNumberInputStream.java  11 Jul 2005 21:59:23 -
@@ -216,8 +216,8 @@
* a single \n value which is stored in the buffer.  Only a single
* byte is counted towards the number of bytes read in this case.
*
-   * @param buf The array into which the bytes read should be stored
-   * @param offset The offset into the array to start storing bytes
+   * @param b The array into which the bytes read should be stored
+   * @param off The offset into the array to start storing bytes
* @param len The requested number of bytes to read
*
* @return The actual number of bytes read, or -1 if end of stream
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: ParserDelegator compatibility fix.

2005-07-11 Thread Meskauskas Audrius

Roman says this is required to compile the class with JDK1.3's javac
(and only for that compiler).

2005-07-12  Audrius Meskauskas  [EMAIL PROTECTED]

*  javax/swing/text/html/parser/ParserDelegator.java (gnuParser.getDTD):
added super. to refer the inherited field more obvious.


Index: javax/swing/text/html/parser/ParserDelegator.java
===
RCS file: 
/cvsroot/classpath/classpath/javax/swing/text/html/parser/ParserDelegator.java,v
retrieving revision 1.5
diff -u -r1.5 ParserDelegator.java
--- javax/swing/text/html/parser/ParserDelegator.java   2 Jul 2005 20:32:51 
-   1.5
+++ javax/swing/text/html/parser/ParserDelegator.java   11 Jul 2005 22:50:24 
-
@@ -113,7 +113,7 @@
 
 DTD getDTD()
 {
-  return dtd;
+  return super.dtd;
 }
   }
 
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: ParserDelegator compatibility fix.

2005-07-11 Thread Robert Schuster
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,
could you please add a small comment that this is a workaround for 1.3's
javac to make sure no one removes it when the next spring clean happens. :)

cu
Robert

Meskauskas Audrius wrote:
 Roman says this is required to compile the class with JDK1.3's javac
 (and only for that compiler).
 
 2005-07-12  Audrius Meskauskas  [EMAIL PROTECTED]
 
 *  javax/swing/text/html/parser/ParserDelegator.java (gnuParser.getDTD):
 added super. to refer the inherited field more obvious.
 
 
 
 
 
 Index: javax/swing/text/html/parser/ParserDelegator.java
 ===
 RCS file: 
 /cvsroot/classpath/classpath/javax/swing/text/html/parser/ParserDelegator.java,v
 retrieving revision 1.5
 diff -u -r1.5 ParserDelegator.java
 --- javax/swing/text/html/parser/ParserDelegator.java 2 Jul 2005 20:32:51 
 -   1.5
 +++ javax/swing/text/html/parser/ParserDelegator.java 11 Jul 2005 22:50:24 
 -
 @@ -113,7 +113,7 @@
  
  DTD getDTD()
  {
 -  return dtd;
 +  return super.dtd;
  }
}
  
 
 
 
 
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFC0wecG9cfwmwwEtoRAufgAJ48kWah9jO5UNG9oQe2zOLkrKAPqwCdGfQX
nkcSe2+Pyl7MJAK6AqyBWr4=
=afYO
-END PGP SIGNATURE-


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] [patch] indent gdk_threads calls in GTK peers

2005-07-11 Thread Thomas Fitzsimmons
Hi,

I committed this patch.  It is mostly a formatting change that makes it
clearer which native functions are run with the GDK lock held.

This patch may cause some temporary regressions as I separated it out
from other work I had in my tree, but I'll fix any problems in the next
few days.

Tom

2005-07-11  Thomas Fitzsimmons  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkChoicePeer.java (connectSignals): New method.
* include/gnu_java_awt_peer_gtk_GtkChoicePeer.h: Regenerate.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c: Move
gdk_threads_enter calls to start of method bodies.  Move
gdk_threads_leave calls to end of method definitions bodies.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c: Likewise.



peer-indent-gdk-threads.patch.gz
Description: GNU Zip compressed data
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: file locks

2005-07-11 Thread Robert Schuster
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,
should that patch allow me to run Eclipse without -Dosgi.locking=none?

cu
Robert

Casey Marshall wrote:
 Hi,
 
 I'm checking in this little patch that implements file locks in 
 gnu.java.nio.channels.FileChannelImpl. This just uses straight C in  the
 gnu_java_nio_channels_FileChannelImpl.c file, protected by  appropriate
 #ifdefs.
 
 2005-07-10  Casey Marshall  [EMAIL PROTECTED]
 
 * configure.ac (AC_CHECK_HEADERS): add 'fcntl.h'.
 (AC_CHECK_FUNCS): add 'fcntl'.
 * native/jni/java-nio/gnu_java_nio_channels_FileChannel.c:
 Include fcntl.h if HAVE_FCNTL_H.
 (Java_gnu_java_nio_channels_FileChannelImpl_lock,
 Java_gnu_java_nio_channels_FileChannelImpl_unlock): implemented
 if HAVE_FCNTL.
 
 
 
 
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFC0wtyG9cfwmwwEtoRAjtgAJsE42kBvj/7UhFVuXHPyMzqIN8WPgCffr3F
CaqRwqCIwcNXFaXDWDQ+rq0=
=ikRm
-END PGP SIGNATURE-


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] [patch] malloc - g_malloc, free - g_free

2005-07-11 Thread Tom Tromey
 Tom == Thomas Fitzsimmons [EMAIL PROTECTED] writes:

Tom We should use the g_ variants of malloc and free in the GTK peers.  I
Tom committed this patch.

We could try poisoning 'malloc' and 'free' (and realloc I suppose) in
some gtk-peer-specific header.  This would have to be conditional on
gcc 4.x.

Tom


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: file locks

2005-07-11 Thread Casey Marshall

On Jul 11, 2005, at 5:14 PM, Robert Schuster wrote:


Hi,
should that patch allow me to run Eclipse without - 
Dosgi.locking=none?




It might. I don't know what Eclipse does internally, but if it uses  
FileChannel.lock and you are running on a platform that supports the  
'fcntl' function, then I guess it should.




___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: regression in logger?

2005-07-11 Thread Archie Cobbs

David P Grove wrote:
 This started showing up in regression tests of Jikes RVM with classpath
 cvs head recently.  I haven't dug deeply, so it could be a latent problem
 in Jikes RVM that was exposed by a classpath change, rather than a real
 classpath bug, but might still be worth mentioning.  The failing program
 is SPECjbb2000.

 --dave

 Exception in thread main: java.lang.ArrayIndexOutOfBoundsException:
 Array index out of range: 0
 at java.util.logging.Logger.getCallerStackFrame(Logger.java:1173)

Looks like this can only happen if the VM doesn't return Throwable stack
traces. Is this with 0.16? There were recent changes in the VMThrowable
class (see NEWS) that might need to be followed in Jikes RVM.

-Archie

__
Archie Cobbs  *CTO, Awarix*  http://www.awarix.com


___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: String.equals optimisation

2005-07-11 Thread Simon Kitching
On Tue, 2005-07-12 at 11:02 +1200, Simon Kitching wrote:
 It would certainly be nice to know that collection methods will
 automatically work more efficiently when the objects being manipulated
 are String objects that have been interned (of course String.intern has
 to be used appropriately).

Umm..sorry, this particular argument doesn't work. The proposed
optimisation only improves the speed of comparing an object to itself -
not the most common operation in collection work. Operations that speed
up determining when two objects are NOT equal would help much more. [1]

I still think the original patch is relevant though (just not this
point).

[1] eg org.apache.commons.collections.map.IdentityMap, but this relies
on unique objects for keys rather than just trying to optimise for them.

Regards,

Simon




___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


String class: hack for ORP 1.0.9

2005-07-11 Thread Simon Kitching
Hi,

In String.java there is this piece of code:

  public char[] toCharArray()
  {
// XXX ORP 1.0.9 crashes on (char[]) clone() during bootstrap, so we
// omit this optimization for now.
// if (count == value.length)
//   return (char[]) value.clone();
char[] copy = new char[count];
VMSystem.arraycopy(value, offset, copy, 0, count);
return copy;
  }


I see that ORP released 1.0.10 in may 2002 (and nothing since).
  http://sourceforge.net/projects/orp

The most recent email on the general list at sourceforge is dated
2003-07-11. The main site does reference a yahoo groups page for email,
but that group does not appear to be available to the public.

I just wondered if it was time to remove this hack...

Regards,

Simon



___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: String.equals optimisation

2005-07-11 Thread Archie Cobbs

Simon Kitching wrote:.

* Class.getName returns strings that have been interned. I don't
  think this is explicitly required by the java specs but is
  certainly true for Sun's JVM and seems likely to be done by
  any sensible JVM.


You definitely make some good arguments, but this one is not
neccesarily true. In fact, I'd argue a JVM that interns every
class' name (even if only on demand) is potentially wasting
a bunch of heap space.

I.e., is there something special about class names which means
they should be treated differently from any other String randomly
created and used in a Java application? (rhetorical question)
Otherwise, why not intern all Strings? Etc.

In any case, to provide two concrete counter-examples:

  $ cat  zz.java
  public class zz {
public static void main(String[] args) {
zz z = new zz();
System.out.println(z.getClass().getName() == zz);
}
  }
  $ javac zz.java
  $ java zz
  true
  $ jc -Xint zz
  false
  $ jamvm zz
  false

On the other hand, comparing reference equality is very low cost,
so it seems like adding == to equals() might make good sense.

Of course, the real answer lies in empirical testing (something
I can't claim to have done).

-Archie

__
Archie Cobbs  *CTO, Awarix*  http://www.awarix.com


___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: String class: hack for ORP 1.0.9

2005-07-11 Thread Archie Cobbs

Simon Kitching wrote:

  public char[] toCharArray()
  {
// XXX ORP 1.0.9 crashes on (char[]) clone() during bootstrap, so we
// omit this optimization for now.
// if (count == value.length)
//   return (char[]) value.clone();
char[] copy = new char[count];
VMSystem.arraycopy(value, offset, copy, 0, count);
return copy;
  }

I just wondered if it was time to remove this hack...


Sounds good to me... and in any case, ORP should be doing it's
own disoptimization for VM-specific issues like this rather than
forcing it on all Classpath users.

-Archie

__
Archie Cobbs  *CTO, Awarix*  http://www.awarix.com


___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: regression in logger?

2005-07-11 Thread Casey Marshall

On Jul 11, 2005, at 4:54 AM, David P Grove wrote:

This started showing up in regression tests of Jikes RVM with  
classpath
cvs head recently.  I haven't dug deeply, so it could be a latent  
problem
in Jikes RVM that was exposed by a classpath change, rather than a  
real
classpath bug, but might still be worth mentioning.  The failing  
program

is SPECjbb2000.



This is caused, at least in part, by the recent change I've made to  
the X509Certificate class to use java.util.logging for debugging  
instead of System.err.println. It might be that a certificate is  
being loaded too early for there to be a stack trace?


Anyway, I don't think it is unreasonable to use loggers that early.  
Should loggers perhaps not depend on a full stack trace, if one isn't  
available?



___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: String.equals optimisation

2005-07-11 Thread Simon Kitching
Hi Archie,

On Mon, 2005-07-11 at 20:27 -0500, Archie Cobbs wrote:
 Simon Kitching wrote:.
  * Class.getName returns strings that have been interned. I don't
think this is explicitly required by the java specs but is
certainly true for Sun's JVM and seems likely to be done by
any sensible JVM.
 
 You definitely make some good arguments, but this one is not
 neccesarily true. In fact, I'd argue a JVM that interns every
 class' name (even if only on demand) is potentially wasting
 a bunch of heap space.

I'm assuming that the Class object would contain a reference to the
interned string, so there is only one copy of the string, ie somewhere
in the ClassLoader.defineClass method there is this sort of thing:

public Class defineClass(String name, ...)
  Class newClass = new Class();
  newClass.setName(name.intern());
  .
   

The extra space used for interning is therefore just a single extra
reference (as a reference to the string is contained in both the Class
object and the String class internal pool). Yes that is a little space
wasted, but not a bunch.

 
 I.e., is there something special about class names which means
 they should be treated differently from any other String randomly
 created and used in a Java application? (rhetorical question)
 Otherwise, why not intern all Strings? Etc.

I do wonder why Java specified that all literal and constant strings in
a class file are automatically interned. Being able to compare literals
with == is not that useful. 

Maybe the most important goal was to compress class representations in
memory. In particular, when class A references a static final String
field from some other class, A gets a copy of that string not a
reference to it, so without the intern mechanism to merge instances back
together again such strings would get duplicated in ram when the classes
were loaded.

I'd be interested to hear of other reasons for Java's requirement to
intern all literal strings and constants.

But, strangely, I do think that interning classnames (which is optional)
is particularly useful. When ClassLoader resolves a class it has loaded,
it must do lots of lookups to find other classes. Surely being able to
do this using identity to compare classnames would be a significant
timesaver. And class resolution is the biggest issue in application
startup time, so improving this seems like a good idea.

In the general case, whether interning a string proves useful or not
depends upon the usage pattern for that string. I guess the usage
patterns for class literals and classnames are pretty well known: long
lifetimes, and either:
* comparisons against them are common, or
* duplication of the content is common. 
But only users know the usage patterns for the dynamic string objects
they create, so it's up to them to decide when to use intern...

 In any case, to provide two concrete counter-examples:
 
$ cat  zz.java
public class zz {
  public static void main(String[] args) {
  zz z = new zz();
  System.out.println(z.getClass().getName() == zz);
  }
}
$ javac zz.java
$ java zz
true
$ jc -Xint zz
false
$ jamvm zz
false

Hmm..interesting.

$ gij
false

$ gcj -o zz --main=zz zz.java
$ zz
false

Note for others reading this thread: all this is really irrelevant
anyway. The classname stuff was just one example I suggested for when
strings being compared might perform better with String.equals optimised
for comparison by identity. As shown above, sun's java might benefit
from this; other JVMs currently won't. But it's only one example.

 
 
 On the other hand, comparing reference equality is very low cost,
 so it seems like adding == to equals() might make good sense.
 
 Of course, the real answer lies in empirical testing (something
 I can't claim to have done).


Regards,

Simon



___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


[commit-cp] classpath ./ChangeLog javax/swing/JInternalFram...

2005-07-11 Thread Roman Kennke
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Roman Kennke [EMAIL PROTECTED]05/07/11 11:57:23

Modified files:
.  : ChangeLog 
javax/swing: JInternalFrame.java 
javax/swing/plaf/basic: BasicInternalFrameUI.java 
BasicLookAndFeel.java 

Log message:
2005-07-10  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JInternalFrame.java
(pack): Set the JInternalFrame's own size here instead of
layouting its children (this is triggered by setSize anyway).
* javax/swing/plaf/basic/BasicInternalFrameUI.java
(installDefaults): Set the correct border for InternalFrames.
Set InternalFrames to invisible by default.
* javax/swing/plaf/basic/BasicLookAndFeel.java
(initComponentDefaults): Set correct color values for
InternalFrames.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4046tr2=1.4047r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/JInternalFrame.java.diff?tr1=1.19tr2=1.20r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java.diff?tr1=1.11tr2=1.12r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java.diff?tr1=1.26tr2=1.27r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog include/gnu_java_nio_chan...

2005-07-11 Thread Mark Wielaard
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Mark Wielaard [EMAIL PROTECTED]   05/07/11 17:27:55

Modified files:
.  : ChangeLog 
include: gnu_java_nio_channels_FileChannelImpl.h 
gnu/java/nio/channels: FileChannelImpl.java 
native/jni/java-nio: gnu_java_nio_channels_FileChannelImpl.c 

Log message:
* gnu/java/nio/channels/FileChannelImpl.java (force): New native
method.
(force(boolean)): Call new native force method.
* native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
(Java_gnu_java_nio_channels_FileChannelImpl_read__):
Test for result != TARGET_NATIVE_OK as stop condition.
(Java_gnu_java_nio_channels_FileChannelImpl_read___3BII):
Check overflow and underflow. Only increase bytes_read when
we didn't get an error.
(Java_gnu_java_nio_channels_FileChannelImpl_write__I):
Return when we encounter an error.
(Java_gnu_java_nio_channels_FileChannelImpl_write___3BII):
Only increase bytes_written when we didn't get an error.
(Java_gnu_java_nio_channels_FileChannelImpl_force): New function.
* include/gnu_java_nio_channels_FileChannelImpl.h: Regenerated.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4048tr2=1.4049r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/include/gnu_java_nio_channels_FileChannelImpl.h.diff?tr1=1.4tr2=1.5r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/gnu/java/nio/channels/FileChannelImpl.java.diff?tr1=1.14tr2=1.15r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c.diff?tr1=1.17tr2=1.18r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog javax/swing/plaf/basic/Ba...

2005-07-11 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/07/11 18:07:15

Modified files:
.  : ChangeLog 
javax/swing/plaf/basic: BasicMenuUI.java 

Log message:
2005-07-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicMenuUI.java:
(MouseInputHandler.mouseEntered): Added check: if a different menu in
the menubar was selected, we don't select this one unless the old one
had its popup menu showing.  This complies with the reference
implementation.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4050tr2=1.4051r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicMenuUI.java.diff?tr1=1.10tr2=1.11r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog java/net/DatagramSocket.java

2005-07-11 Thread Mark Wielaard
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Mark Wielaard [EMAIL PROTECTED]   05/07/11 18:38:12

Modified files:
.  : ChangeLog 
java/net   : DatagramSocket.java 

Log message:
* java/net/DatagramSocket.java (getImpl): Record cause of Exception.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4052tr2=1.4053r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/net/DatagramSocket.java.diff?tr1=1.44tr2=1.45r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ChangeLog

2005-07-11 Thread Roman Kennke
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Roman Kennke [EMAIL PROTECTED]05/07/11 19:51:05

Modified files:
.  : ChangeLog 

Log message:
Cleaned up the ChangeLog a bit.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4055tr2=1.4056r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog javax/swing/plaf/basic/Ba...

2005-07-11 Thread Lillian Angel
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Lillian Angel [EMAIL PROTECTED]   05/07/11 20:13:56

Modified files:
.  : ChangeLog 
javax/swing/plaf/basic: BasicLookAndFeel.java 

Log message:
2005-07-11  Lillian Angel  [EMAIL PROTECTED]
* javax/swing/plaf/basic/BasicLookAndFeel.java
Changed the default row height for the tree.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4058tr2=1.4059r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java.diff?tr1=1.28tr2=1.29r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog javax/swing/JInternalFram...

2005-07-11 Thread Roman Kennke
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Roman Kennke [EMAIL PROTECTED]05/07/11 20:55:44

Modified files:
.  : ChangeLog 
javax/swing: JInternalFrame.java 

Log message:
2005-07-11  Roman Kennke  [EMAIL PROTECTED]

* javax/swing/JInternalFrame.java
(addImpl): Add to the frame itself if we are in the init
stage, otherwise add to the contentPane.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4060tr2=1.4061r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/JInternalFrame.java.diff?tr1=1.20tr2=1.21r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath gnu/java/awt/peer/gtk/GtkImage.java ....

2005-07-11 Thread Sven de Marothy
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Sven de Marothy [EMAIL PROTECTED] 05/07/11 21:11:20

Modified files:
gnu/java/awt/peer/gtk: GtkImage.java 
.  : ChangeLog 

Log message:
2005-07-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkImage.java:
(setImage): Set error flag on bad width, height or pixels.
(checkImage): Return error flag.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/gnu/java/awt/peer/gtk/GtkImage.java.diff?tr1=1.19tr2=1.20r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4061tr2=1.4062r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog java/io/DataOutput.java j...

2005-07-11 Thread David Gilbert
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: David Gilbert [EMAIL PROTECTED]   05/07/11 22:02:29

Modified files:
.  : ChangeLog 
java/io: DataOutput.java LineNumberInputStream.java 

Log message:
2005-07-11  David Gilbert  [EMAIL PROTECTED]

* java/io/DataOutput.java: fixed minor API doc errors,
* java/io/LineNumberInputStream.java: likewise.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4063tr2=1.4064r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/io/DataOutput.java.diff?tr1=1.14tr2=1.15r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/io/LineNumberInputStream.java.diff?tr1=1.10tr2=1.11r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath


[commit-cp] classpath ./ChangeLog gnu/java/awt/peer/gtk/Gtk...

2005-07-11 Thread Thomas Fitzsimmons
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Thomas Fitzsimmons [EMAIL PROTECTED]  05/07/11 23:27:43

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: GtkChoicePeer.java 
include: gnu_java_awt_peer_gtk_GtkChoicePeer.h 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GdkFontPeer.c 
 gnu_java_awt_peer_gtk_GdkGraphics.c 
 gnu_java_awt_peer_gtk_GdkGraphics2D.c 
 gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c 
 gnu_java_awt_peer_gtk_GdkPixbufDecoder.c 
 gnu_java_awt_peer_gtk_GdkRobotPeer.c 
 gnu_java_awt_peer_gtk_GdkTextLayout.c 
 gnu_java_awt_peer_gtk_GtkButtonPeer.c 
 gnu_java_awt_peer_gtk_GtkCanvasPeer.c 
 gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c 
 gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c 
 gnu_java_awt_peer_gtk_GtkCheckboxPeer.c 
 gnu_java_awt_peer_gtk_GtkChoicePeer.c 
 gnu_java_awt_peer_gtk_GtkClipboard.c 
 gnu_java_awt_peer_gtk_GtkComponentPeer.c 
 gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c 
 gnu_java_awt_peer_gtk_GtkFileDialogPeer.c 
 gnu_java_awt_peer_gtk_GtkFramePeer.c 
 gnu_java_awt_peer_gtk_GtkGenericPeer.c 
 gnu_java_awt_peer_gtk_GtkImage.c 
 gnu_java_awt_peer_gtk_GtkLabelPeer.c 
 gnu_java_awt_peer_gtk_GtkListPeer.c 
 gnu_java_awt_peer_gtk_GtkMenuBarPeer.c 
 gnu_java_awt_peer_gtk_GtkMenuItemPeer.c 
 gnu_java_awt_peer_gtk_GtkMenuPeer.c 
 gnu_java_awt_peer_gtk_GtkPanelPeer.c 
 gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c 
 gnu_java_awt_peer_gtk_GtkScrollPanePeer.c 
 gnu_java_awt_peer_gtk_GtkToolkit.c 
 gnu_java_awt_peer_gtk_GtkWindowPeer.c 

Log message:
2005-07-11  Thomas Fitzsimmons  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkChoicePeer.java (connectSignals): New method.
* include/gnu_java_awt_peer_gtk_GtkChoicePeer.h: Regenerate.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c: Move
gdk_threads_enter calls to start of method bodies.  Move
gdk_threads_leave calls to end of method definitions bodies.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c: 
Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c: Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c: 
Likewise.
* 

[commit-cp] classpath ./ChangeLog native/jni/gtk-peer/gnu_j...

2005-07-11 Thread Thomas Fitzsimmons
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Thomas Fitzsimmons [EMAIL PROTECTED]  05/07/11 23:55:27

Modified files:
.  : ChangeLog 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GdkGraphics2D.c 

Log message:
2005-07-11  Thomas Fitzsimmons  [EMAIL PROTECTED]

* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
Replace occurrences of malloc with g_malloc and free with g_free.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4067tr2=1.4068r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c.diff?tr1=1.29tr2=1.30r1=textr2=text



___
Commit-classpath mailing list
Commit-classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-classpath