[cp-patches] Re: FYI: java.util.Locale - fix broken serialization and equals()

2006-08-12 Thread Sven de Marothy
Now I get to share in the embarassment, I'd missed the strings are
supposed to be interned.

2006-08-13  Sven de Marothy  <[EMAIL PROTECTED]>

* java/util/Locale.java
(hashcodeCache): New field.
(hashCode): use the above field instead of the serialized one
(writeObject): Removed method.
(equals): Revert to previous method.

Index: java/util/Locale.java
===
RCS file: /sources/classpath/classpath/java/util/Locale.java,v
retrieving revision 1.34
diff -U3 -r1.34 Locale.java
--- java/util/Locale.java	13 Aug 2006 00:20:11 -	1.34
+++ java/util/Locale.java	13 Aug 2006 01:19:00 -
@@ -188,11 +188,17 @@
   private String variant;
 
   /**
-   * This is the cached hashcode. When writing to stream, we write -1.
+   * This is where the JDK caches its hashcode. This is is only here
+   * for serialization purposes. The actual cache is hashcodeCache
*
* @serial should be -1 in serial streams
*/
-  private int hashcode;
+  private int hashcode = -1;
+
+  /**
+   * This is the cached hashcode. 
+   */
+  private transient int hashcodeCache;
 
   /**
* Array storing all available locales.
@@ -324,7 +330,7 @@
 this.language = language;
 this.country = country;
 this.variant = variant;
-hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
+hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
   }
 
   /**
@@ -899,7 +905,7 @@
*/
   public int hashCode()
   {
-return hashcode;
+return hashcodeCache;
   }
 
   /**
@@ -917,29 +923,9 @@
   return false;
 Locale l = (Locale) obj;
 
-return (language.equals( l.language )
-&& country.equals( l.country )
-&& variant.equals( l.variant ) );
-  }
-
-  /**
-   * Write the locale to an object stream.
-   *
-   * @param s the stream to write to
-   * @throws IOException if the write fails
-   * @serialData The first three fields are Strings representing language,
-   * country, and variant. The fourth field is a placeholder for 
-   * the cached hashcode, but this is always written as -1, and 
-   * recomputed when reading it back.
-   */
-  private void writeObject(ObjectOutputStream s)
-throws IOException
-  {
-// Hashcode field is always written as -1.
-int temp = hashcode;
-hashcode = -1;
-s.defaultWriteObject();
-hashcode = temp;
+return (language == l.language 
+&& country == l.country 
+&& variant == l.variant);
   }
 
   /**
@@ -954,7 +940,9 @@
 throws IOException, ClassNotFoundException
   {
 s.defaultReadObject();
-// Recompute hashcode.
-hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
+language = language.intern();
+country = country.intern();
+variant = variant.intern();
+hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
   }
 } // class Locale


[cp-patches] FYI: JTabbedPane

2006-08-12 Thread Roman Kennke

Another fixlet that helps with jircii.

2006-08-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/JTabbedPane.java
(JTabbedPane): Call setModel() here and let this install the
change listener correctly.
(setModel): Correctly uninstall and reinstall ChangeListener when
model changes.

/Roman
Index: javax/swing/JTabbedPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTabbedPane.java,v
retrieving revision 1.43
diff -u -1 -2 -r1.43 JTabbedPane.java
--- javax/swing/JTabbedPane.java	26 Jul 2006 14:45:33 -	1.43
+++ javax/swing/JTabbedPane.java	13 Aug 2006 01:12:59 -
@@ -751,29 +751,25 @@
*/
   public JTabbedPane(int tabPlacement, int tabLayoutPolicy)
   {
 if (tabPlacement != TOP && tabPlacement != BOTTOM && tabPlacement != RIGHT
 && tabPlacement != LEFT)
   throw new IllegalArgumentException("tabPlacement is not valid.");
 if (tabLayoutPolicy != SCROLL_TAB_LAYOUT
 && tabLayoutPolicy != WRAP_TAB_LAYOUT)
   throw new IllegalArgumentException("tabLayoutPolicy is not valid.");
 this.tabPlacement = tabPlacement;
 layoutPolicy = tabLayoutPolicy;
 
-changeEvent = new ChangeEvent(this);
-changeListener = createChangeListener();
-
-model = new DefaultSingleSelectionModel();
-model.addChangeListener(changeListener);
+setModel(new DefaultSingleSelectionModel());
 
 updateUI();
   }
 
   /**
* This method returns the UI used to display the JTabbedPane.
*
* @return The UI used to display the JTabbedPane.
*/
   public TabbedPaneUI getUI()
   {
 return (TabbedPaneUI) ui;
@@ -868,34 +864,42 @@
* This method returns the model used with the JTabbedPane.
*
* @return The JTabbedPane's model.
*/
   public SingleSelectionModel getModel()
   {
 return model;
   }
 
   /**
* This method changes the model property of the JTabbedPane.
*
-   * @param model The new model to use with the JTabbedPane.
+   * @param m The new model to use with the JTabbedPane.
*/
-  public void setModel(SingleSelectionModel model)
+  public void setModel(SingleSelectionModel m)
   {
-if (model != this.model)
+if (m != model)
   {
 	SingleSelectionModel oldModel = this.model;
-	this.model.removeChangeListener(changeListener);
-	this.model = model;
-	this.model.addChangeListener(changeListener);
+if (oldModel != null && changeListener != null)
+  oldModel.removeChangeListener(changeListener);
+
+	model = m;
+
+if (model != null)
+  {
+if (changeListener != null)
+  changeListener = createChangeListener();
+model.addChangeListener(changeListener);
+  }
 	firePropertyChange("model", oldModel, this.model);
   }
   }
 
   /**
* This method returns the tabPlacement.
*
* @return The tabPlacement used with the JTabbedPane.
*/
   public int getTabPlacement()
   {
 return tabPlacement;


[cp-patches] FYI: fix for PR Classpath/23952

2006-08-12 Thread Raif S. Naffah
hello all,

the attached patch --already committed-- fixes the above PR by having the 
cache of previously resolved resource bundles as an LRU, of CACHE_SIZE 
elements, organized by access.


2006-08-13  Raif S. Naffah  <[EMAIL PROTECTED]>

PR Classpath/23952
* java/util/ResourceBundle.java (CACHE_SIZE): New constant.
(bundleCache): Replaced with an LRU of CACHE_SIZE elements.
(lastDefaultLocale): Removed.
(emptyLocale): Likewise.
(BundleKey.defaultLocale): New field.
(BundleKey.BundleKey): Add a Locale (as a 1st positional) argument.
(BundleKey.set): Likewise.
(BundleKey.equals): Take defaultLocal field into consideration.
(getBundle(String, Locale, ClassLoader)): Use updated BundleKey and LRU.


cheers;
rsn
Index: ResourceBundle.java
===
RCS file: /cvsroot/classpath/classpath/java/util/ResourceBundle.java,v
retrieving revision 1.37
diff -u -r1.37 ResourceBundle.java
--- ResourceBundle.java	1 Mar 2006 12:14:24 -	1.37
+++ ResourceBundle.java	13 Aug 2006 00:45:37 -
@@ -91,6 +91,14 @@
 public abstract class ResourceBundle
 {
   /**
+   * Maximum size of our cache of ResourceBundles keyed by
+   * [EMAIL PROTECTED] BundleKey} instances.
+   *
+   * @see BundleKey
+   */
+  private static final int CACHE_SIZE = 100;
+
+  /**
* The parent bundle. This is consulted when you call getObject and there
* is no such resource in the current bundle. This field may be null.
*/
@@ -104,21 +112,22 @@
   private Locale locale;

   /**
-   * The resource bundle cache.
-   */
-  private static Map bundleCache;
-
-  /**
-   * The last default Locale we saw. If this ever changes then we have to
-   * reset our caches.
-   */
-  private static Locale lastDefaultLocale;
-
-  /**
-   * The `empty' locale is created once in order to optimize
-   * tryBundle().
+   * A VM-wide cache of resource bundles already fetched.
+   * 
+   * This [EMAIL PROTECTED] Map} is a Least Recently Used (LRU) cache, of the last
+   * [EMAIL PROTECTED] #CACHE_SIZE} accessed ResourceBundles keyed by the
+   * tuple: default locale, resource-bundle name, resource-bundle locale, and
+   * classloader.
+   *
+   * @see BundleKey
*/
-  private static final Locale emptyLocale = new Locale("");
+  private static Map bundleCache = new LinkedHashMap(CACHE_SIZE + 1, 0.75F, true)
+  {
+public boolean removeEldestEntry(Map.Entry entry)
+{
+  return size() > CACHE_SIZE;
+}
+  };

   /**
* The constructor. It does nothing special.
@@ -246,6 +255,7 @@
   by the combination of bundle name, locale, and class loader. */
   private static class BundleKey
   {
+Locale defaultLocale;
 String baseName;
 Locale locale;
 ClassLoader classLoader;
@@ -253,18 +263,19 @@

 BundleKey() {}

-BundleKey(String s, Locale l, ClassLoader cl)
+BundleKey(Locale dl, String s, Locale l, ClassLoader cl)
 {
-  set(s, l, cl);
+  set(dl, s, l, cl);
 }

-void set(String s, Locale l, ClassLoader cl)
+void set(Locale dl, String s, Locale l, ClassLoader cl)
 {
+  defaultLocale = dl;
   baseName = s;
   locale = l;
   classLoader = cl;
-  hashcode = baseName.hashCode() ^ locale.hashCode() ^
-classLoader.hashCode();
+  hashcode = defaultLocale.hashCode() ^ baseName.hashCode()
+  ^ locale.hashCode() ^ classLoader.hashCode();
 }

 public int hashCode()
@@ -277,10 +288,11 @@
   if (! (o instanceof BundleKey))
 return false;
   BundleKey key = (BundleKey) o;
-  return hashcode == key.hashcode &&
-	baseName.equals(key.baseName) &&
-locale.equals(key.locale) &&
-	classLoader.equals(key.classLoader);
+  return hashcode == key.hashcode
+  && defaultLocale.equals(key.defaultLocale)
+  && baseName.equals(key.baseName)
+  && locale.equals(key.locale)
+  && classLoader.equals(key.classLoader);
 }
   }

@@ -370,61 +382,39 @@
   public static synchronized ResourceBundle getBundle
 (String baseName, Locale locale, ClassLoader classLoader)
   {
-// If the default locale changed since the last time we were called,
-// all cache entries are invalidated.
 Locale defaultLocale = Locale.getDefault();
-if (defaultLocale != lastDefaultLocale)
-  {
-	bundleCache = new HashMap();
-	lastDefaultLocale = defaultLocale;
-  }
-
 // This will throw NullPointerException if any arguments are null.
-lookupKey.set(baseName, locale, classLoader);
-
+lookupKey.set(defaultLocale, baseName, locale, classLoader);
 Object obj = bundleCache.get(lookupKey);
-ResourceBundle rb = null;
-
 if (obj instanceof ResourceBundle)
-  {
-return (ResourceBundle) obj;
-  }
-else if (obj == nullEntry)
-  {
-// Lookup has failed previously. Fall through.
-  }
-else
-  {
-	// First, look for a bundle for th

[cp-patches] FYI: JMenu fix

2006-08-12 Thread Roman Kennke
This adds support for firing menu events in JMenu. This makes jircii 
really usable now. Get away with XChat and use jIRCii with Classpath 
now! ;-)


2006-08-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/JMenu.java
(MenuChangeListener): New inner class, helps firing menu events.
(changeListener): New field.
(add(text)): Create new JMenuItem here and call add(JMenuItem).
(add(Action)): Create Action using createActionComponent()
and add via add(Component).
(setModel): Install and uninstall MenuChangeListener here.


/Roman
Index: javax/swing/JMenu.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenu.java,v
retrieving revision 1.30
diff -u -1 -2 -r1.30 JMenu.java
--- javax/swing/JMenu.java	2 Aug 2006 23:05:59 -	1.30
+++ javax/swing/JMenu.java	13 Aug 2006 00:54:06 -
@@ -44,63 +44,102 @@
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.EventListener;
 
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleSelection;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 import javax.swing.plaf.MenuItemUI;
 
 /**
  * This class represents a menu that can be added to a menu bar or
  * can be a submenu in some other menu. When JMenu is selected it
  * displays JPopupMenu containing its menu items.
  *
  * 
  * JMenu's fires MenuEvents when this menu's selection changes. If this menu
  * is selected, then fireMenuSelectedEvent() is invoked. In case when menu is
  * deselected or cancelled, then fireMenuDeselectedEvent() or 
  * fireMenuCancelledEvent() is invoked, respectivelly.
  * 
  */
 public class JMenu extends JMenuItem implements Accessible, MenuElement
 {
+  /**
+   * Receives notifications when the JMenu's ButtonModel is changed and
+   * fires menuSelected or menuDeselected events when appropriate.
+   */
+  private class MenuChangeListener
+implements ChangeListener
+  {
+/**
+ * Indicates the last selected state.
+ */
+private boolean selected;
+
+/**
+ * Receives notification when the JMenu's ButtonModel changes.
+ */
+public void stateChanged(ChangeEvent ev)
+{
+  ButtonModel m = (ButtonModel) ev.getSource();
+  boolean s = m.isSelected();
+  if (s != selected)
+{
+  if (s)
+fireMenuSelected();
+  else
+fireMenuDeselected();
+  selected = s;
+}
+}
+  }
+
   private static final long serialVersionUID = 4227225638931828014L;
 
   /** A Popup menu associated with this menu, which pops up when menu is selected */
   private JPopupMenu popupMenu = null;
 
   /** Whenever menu is selected or deselected the MenuEvent is fired to
  menu's registered listeners. */
   private MenuEvent menuEvent = new MenuEvent(this);
 
   /*Amount of time, in milliseconds, that should pass before popupMenu
 associated with this menu appears or disappers */
   private int delay;
 
   /* PopupListener */
   protected WinListener popupListener;
 
   /** Location at which popup menu associated with this menu will be
  displayed */
   private Point menuLocation;
 
   /**
+   * The ChangeListener for the ButtonModel.
+   *
+   * @see MenuChangeListener
+   */
+  private ChangeListener changeListener;
+
+  /**
* Creates a new JMenu object.
*/
   public JMenu()
   {
 super();
 setOpaque(false);
   }
 
   /**
* Creates a new JMenu with the specified label.
*
* @param text label for this menu
@@ -179,37 +218,40 @@
 return getPopupMenu().add(component, index);
   }
 
   /**
* Adds JMenuItem constructed with the specified label to this menu
*
* @param text label for the menu item that will be added
*
* @return Menu Item that was added to this menu
*/
   public JMenuItem add(String text)
   {
-return getPopupMenu().add(text);
+return add(new JMenuItem(text));
   }
 
   /**
* Adds JMenuItem constructed using properties from specified action.
*
* @param action action to construct the menu item with
*
* @return Menu Item that was added to this menu
*/
   public JMenuItem add(Action action)
   {
-return getPopupMenu().add(action);
+JMenuItem i = createActionComponent(action);
+i.setAction(action);
+add(i);
+return i;
   }
 
   /**
* Removes given menu item from this menu. Nothing happens if
* this menu doesn't contain specified menu item.
*
* @param item Menu Item which needs to be removed
*/
   public void remove(JMenuItem item)
   {
 getPo

Re: [cp-patches] FYI: java.util.Locale - fix broken serialization and equals()

2006-08-12 Thread Mark Wielaard
On Sun, 2006-08-13 at 02:21 +0200, Sven de Marothy wrote:
> 2006-08-13  Sven de Marothy  <[EMAIL PROTECTED]>
> 
>   * java/util/Locale.java
>   (hashcode): Is a serialized field, not transient.
>   (equals): Should NOT compare strings by reference.
>   (readObject/writeObject): Use the default methods and handle the hash
>   seperately.
> [...]
> +int temp = hashcode;
> +hashcode = -1;
> +s.defaultWriteObject();
> +hashcode = temp;

This is not thread-safe. If one thread serializes the Locale and another
uses its hashCode() method.

> [...]
> -language = ((String) s.readObject()).intern();
> -country = ((String) s.readObject()).intern();
> -variant = ((String) s.readObject()).intern();
> +s.defaultReadObject();

There are a couple of places in this class that depend on these three
fields to be interned. Please see the comments in the class that say so.

Cheers,

Mark


signature.asc
Description: This is a digitally signed message part


[cp-patches] FYI: fix for PR Classpath/27372

2006-08-12 Thread Raif S. Naffah
hello all,

the attached patch --already committed-- fixes the above PR and some other 
problems in some of the BigInteger constructor highlighted by recently added 
Mauve tests.

2006-08-13  Raif S. Naffah  <[EMAIL PROTECTED]>

PR Classpath/27372
* java/math/BigInteger.java: Updated copyright year.
(init): Consume as little bytes as possible.
(BigInteger(int, int, Random)): Ensure bitLength bits are used.
(valueOf(String, int)): Throw NumberFormatException for malformed 
strings
as per RI's documentation.

the Mauve tests ctor.java and TestOfPR27372.java, both in the package 
gnu.testlet.java.math.BigInteger should now pass.


cheers;
rsn
Index: BigInteger.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v
retrieving revision 1.28
diff -u -r1.28 BigInteger.java
--- BigInteger.java	27 May 2006 02:09:30 -	1.28
+++ BigInteger.java	13 Aug 2006 00:19:41 -
@@ -1,5 +1,5 @@
 /* java.math.BigInteger -- Arbitary precision integers
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006  Free Software Foundation, Inc.

 This file is part of GNU Classpath.

@@ -197,8 +197,20 @@
   private void init(int numBits, Random rnd)
   {
 int highbits = numBits & 31;
+// minimum number of bytes to store the above number of bits
+int highBitByteCount = (highbits + 7) / 8;
+// number of bits to discard from the last byte
+int discardedBitCount = highbits % 8;
+if (discardedBitCount != 0)
+  discardedBitCount = 8 - discardedBitCount;
+byte[] highBitBytes = new byte[highBitByteCount];
 if (highbits > 0)
-  highbits = rnd.nextInt() >>> (32 - highbits);
+  {
+rnd.nextBytes(highBitBytes);
+highbits = (highBitBytes[highBitByteCount - 1] & 0xFF) >>> discardedBitCount;
+for (int i = highBitByteCount - 2; i >= 0; i--)
+  highbits = (highbits << 8) | (highBitBytes[i] & 0xFF);
+  }
 int nwords = numBits / 32;

 while (highbits == 0 && nwords > 0)
@@ -225,8 +237,13 @@
 this(bitLength, rnd);

 // Keep going until we find a probable prime.
+BigInteger result;
 while (true)
   {
+// ...but first ensure that BI has bitLength bits
+result = setBit(bitLength - 1);
+this.ival = result.ival;
+this.words = result.words;
 	if (isProbablePrime(certainty))
 	  return;

@@ -1589,24 +1606,31 @@
 // but slightly more expensive, for little practical gain.
 if (len <= 15 && radix <= 16)
   return valueOf(Long.parseLong(s, radix));
-
+
+int i, digit;
+boolean negative;
+byte[] bytes;
+char ch = s.charAt(0);
+if (ch == '-')
+  {
+negative = true;
+i = 1;
+bytes = new byte[len - 1];
+  }
+else
+  {
+negative = false;
+i = 0;
+bytes = new byte[len];
+  }
 int byte_len = 0;
-byte[] bytes = new byte[len];
-boolean negative = false;
-for (int i = 0;  i < len;  i++)
+for ( ; i < len;  i++)
   {
-	char ch = s.charAt(i);
-	if (ch == '-')
-	  negative = true;
-	else if (ch == '_' || (byte_len == 0 && (ch == ' ' || ch == '\t')))
-	  continue;
-	else
-	  {
-	int digit = Character.digit(ch, radix);
-	if (digit < 0)
-	  break;
-	bytes[byte_len++] = (byte) digit;
-	  }
+ch = s.charAt(i);
+digit = Character.digit(ch, radix);
+if (digit < 0)
+  throw new NumberFormatException();
+bytes[byte_len++] = (byte) digit;
   }
 return valueOf(bytes, byte_len, negative, radix);
   }


[cp-patches] FYI: java.util.Locale - fix broken serialization and equals()

2006-08-12 Thread Sven de Marothy
This is a major embarassment. 

2006-08-13  Sven de Marothy  <[EMAIL PROTECTED]>

* java/util/Locale.java
(hashcode): Is a serialized field, not transient.
(equals): Should NOT compare strings by reference.
(readObject/writeObject): Use the default methods and handle the hash
seperately.


Index: java/util/Locale.java
===
RCS file: /sources/classpath/classpath/java/util/Locale.java,v
retrieving revision 1.33
diff -U3 -r1.33 Locale.java
--- java/util/Locale.java	20 Apr 2006 09:29:27 -	1.33
+++ java/util/Locale.java	13 Aug 2006 00:17:42 -
@@ -192,7 +192,7 @@
*
* @serial should be -1 in serial streams
*/
-  private transient int hashcode;
+  private int hashcode;
 
   /**
* Array storing all available locales.
@@ -917,9 +917,9 @@
   return false;
 Locale l = (Locale) obj;
 
-return (language == l.language
-&& country == l.country
-&& variant == l.variant);
+return (language.equals( l.language )
+&& country.equals( l.country )
+&& variant.equals( l.variant ) );
   }
 
   /**
@@ -935,11 +935,11 @@
   private void writeObject(ObjectOutputStream s)
 throws IOException
   {
-s.writeObject(language);
-s.writeObject(country);
-s.writeObject(variant);
 // Hashcode field is always written as -1.
-s.writeInt(-1);
+int temp = hashcode;
+hashcode = -1;
+s.defaultWriteObject();
+hashcode = temp;
   }
 
   /**
@@ -953,9 +953,7 @@
   private void readObject(ObjectInputStream s)
 throws IOException, ClassNotFoundException
   {
-language = ((String) s.readObject()).intern();
-country = ((String) s.readObject()).intern();
-variant = ((String) s.readObject()).intern();
+s.defaultReadObject();
 // Recompute hashcode.
 hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
   }


[cp-patches] FYI: several Swing (styled) text fixes

2006-08-12 Thread Roman Kennke
Here come a couple of fixes for the (styled) text rendering in Swing, 
which should greatly improve stability for styled text using apps like 
BeanShell.


Next thing I'm working on right now is CSS processing and fixing up the 
HTML rendering to use this, and finish up HTML in general.


2006-08-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/JEditorPane.java
(getScrollableTracksViewportHeight): Also check maximum size.
* javax/swing/JTextPane.java
(insertIcon): Use input attributes for adding the icon
attribute.
* javax/swing/plaf/basic/BasicTextUI.java
(RootView.setSize): Overridden to forward to real view.
(getPreferredSize): Trigger setSize() on the view.
(viewToModel(JTextComponent,Point)): Pass Position.Bias array
to viewToModel() call, rather then null.
* javax/swing/text/ParagraphView.java
(changedUpdate): Invalide layout. Call super.
* javax/swing/text/SimpleAttributeSet.java
(clone): Use super's clone method to create clone.
* javax/swing/text/StyleConstants.java
(setIcon): Also set element name attribute.
* javax/swing/text/StyledEditorKit.java
(BoldAction.actionPerformed): Actually set the bold attribute,
not italic.
(setCharacterAttributes): Replaced with more straightforward
impl.
* javax/swing/text/TextAction.java
(getFocusedComponent): Implemented.
* javax/swing/text/Utilities.java
(getNextVisualPositionFrom): Pass Position.Bias arrays instead
of null.
* javax/swing/text/View.java
(changedUpdate): Nullify element change when updateChildren
says so.

/Roman
Index: javax/swing/JEditorPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JEditorPane.java,v
retrieving revision 1.33
diff -u -1 -2 -r1.33 JEditorPane.java
--- javax/swing/JEditorPane.java	1 Jun 2006 04:38:49 -	1.33
+++ javax/swing/JEditorPane.java	12 Aug 2006 22:15:00 -
@@ -708,25 +708,26 @@
* true when  the parent is an instance of JViewport and
* the viewport height > the UI's minimum height.
*
* @return true when a Viewport should force the height of
* this component to match the viewport height
*/
   public boolean getScrollableTracksViewportHeight()
   {
 // Tests show that this returns true when the parent is a JViewport
 // and has a height > minimum UI height.
 Container parent = getParent();
 return parent instanceof JViewport
-   && parent.getHeight() > getUI().getMinimumSize(this).height;
+   && parent.getHeight() >= getUI().getMinimumSize(this).height
+   && parent.getHeight() <= getUI().getMaximumSize(this).height;
   }
 
   /**
* Returns true when a Viewport should force the width of
* this component to match the viewport width. This is implemented to return
* true when  the parent is an instance of JViewport and
* the viewport width > the UI's minimum width.
*
* @return true when a Viewport should force the width of
* this component to match the viewport width
*/
   public boolean getScrollableTracksViewportWidth()
Index: javax/swing/JTextPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTextPane.java,v
retrieving revision 1.15
diff -u -1 -2 -r1.15 JTextPane.java
--- javax/swing/JTextPane.java	7 Feb 2006 11:40:56 -	1.15
+++ javax/swing/JTextPane.java	12 Aug 2006 22:15:01 -
@@ -205,38 +205,29 @@
 err.initCause(ex);
 throw err;
   }
   }
 
   /**
* Inserts an Icon into the text at the current caret position.
*
* @param icon the Icon to be inserted
*/
   public void insertIcon(Icon icon)
   {
-SimpleAttributeSet atts = new SimpleAttributeSet();
-atts.addAttribute(StyleConstants.IconAttribute, icon);
-atts.addAttribute(StyleConstants.NameAttribute,
-  StyleConstants.IconElementName);
-try
-  {
-getDocument().insertString(getCaret().getDot(), " ", atts);
-  }
-catch (BadLocationException ex)
-  {
-AssertionError err = new AssertionError("Unexpected bad location");
-err.initCause(ex);
-throw err;
-  }
+MutableAttributeSet inputAtts = getInputAttributes();
+inputAtts.removeAttributes(inputAtts);
+StyleConstants.setIcon(inputAtts, icon);
+replaceSelection(" ");
+inputAtts.removeAttributes(inputAtts);
   }
 
   /**
* Adds a style into the style hierarchy. Unspecified style attributes
* can be resolved in the parent style, if one is specified.
*
* While it is legal to add nameless styles (nm == nullnull if the style should
Index: javax/swing/plaf/basic/BasicTextUI.java
===
RCS file: /cvsroot/clas

[cp-patches] Re: FYI: PR 28580 - HTTP fixes...

2006-08-12 Thread David Daney

Tom Tromey wrote:

"David" == David Daney <[EMAIL PROTECTED]> writes:



David> Do we want to bring this into libgcj before this would be
David> imported also?

It is fine by me if you want to do this.
However, if we're going to import 0.92 it might be friendlier to wait
for that to happen first.  Last I heard, Mark was working on this
... I don't know if he's planning to do more here?
  

That was what I was thinking.

I guess my question was:  Are we going to import 0.93 before GCC-4.2 
ships?  If not, I would be inclined to apply the patch to libgcj, 
otherwise I would wait for the next import.


David Daney







Re: [cp-patches] RFC: merge ssl-nio-branch into generics-branch

2006-08-12 Thread Tom Tromey
> "Casey" == Casey Marshall <[EMAIL PROTECTED]> writes:

Casey> The ssl-nio work is complete enough to the point where it can be merged
Casey> into the generics branch. Now that 0.92 has been released, this is a
Casey> good time to do that merge. I've accomplished three of the four goals I
Casey> set out on this project, which were [1]:

Congratulations!

Casey> Unless there are any issues with this, I'll try to commit the patch this
Casey> weekend.

Sounds good to me.

Tom