[cp-patches] FYI: Small additional ClassLoader VM extensibility point
Hi, I committed the attached patch, that allows a VM implementer to hook Classloader.findLoadedClass. Regards, Jeroen 2005-07-25 Jeroen Frijters [EMAIL PROTECTED] * java/lang/ClassLoader.java (findLoadedClass): Call VMClassLoader.findLoadedClass. * vm/reference/java/lang/VMClassLoader.java (findLoadedClass): New method. Index: java/lang/ClassLoader.java === RCS file: /cvsroot/classpath/classpath/java/lang/ClassLoader.java,v retrieving revision 1.52 diff -u -r1.52 ClassLoader.java --- java/lang/ClassLoader.java 2 Jul 2005 20:32:38 - 1.52 +++ java/lang/ClassLoader.java 25 Jul 2005 09:28:46 - @@ -556,9 +556,7 @@ */ protected final synchronized Class findLoadedClass(String name) { -// NOTE: If the VM is keeping its own cache, it may make sense to have -// this method be native. -return (Class) loadedClasses.get(name); +return VMClassLoader.findLoadedClass(this, name); } /** Index: vm/reference/java/lang/VMClassLoader.java === RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMClassLoader.java,v retrieving revision 1.26 diff -u -r1.26 VMClassLoader.java --- vm/reference/java/lang/VMClassLoader.java 2 Jul 2005 20:33:08 - 1.26 +++ vm/reference/java/lang/VMClassLoader.java 25 Jul 2005 09:28:53 - @@ -282,4 +282,12 @@ { return ClassLoader.defaultGetSystemClassLoader(); } + + /** + * If the VM wants to keep its own cache, this method can be replaced. + */ + static Class findLoadedClass(ClassLoader cl, String name) + { +return (Class) cl.loadedClasses.get(name); + } } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] [generics] Enum#valueOf implementation
On Mon, 2005-07-25 at 00:33 -0600, Tom Tromey wrote: Ewout == Ewout Prangsma [EMAIL PROTECTED] writes: Ewout Here's the unified diff. Again my question if someone can Ewout commit this, or give me CVS access rights. It still needs a ChangeLog entry. Also the code is not formatted according to the Classpath style. Here is an example of a correct ChangeLog entry and the patch formatted as (I also added a little documentation, please check). 2005-07-25 Ewout Prangsma [EMAIL PROTECTED] * java/lang/Enum.java (valueOf): implemented. ChangeLog and Coding style is discussed int he hacking guide: http://www.gnu.org/software/classpath/docs/hacking.html#SEC6 http://www.gnu.org/software/classpath/docs/hacking.html#SEC8 One question. Will the IllegalAccessException really never be thrown? I can imagine that the Enum value fields are always public or package private to java.lang in which case this is true (but I haven't studied Enums at all). Otherwise we might need a PrivilegedAction that calls setAccessible(true). Andrew, could you please take a look and tell me whether it is OK to commit (compiles, don't have ecj or gcjx installed here) and whether or not it interferes with you current merging work? Thanks, Mark Index: java/lang/Enum.java === RCS file: /cvsroot/classpath/classpath/java/lang/Attic/Enum.java,v retrieving revision 1.1.2.4 diff -u -r1.1.2.4 Enum.java --- java/lang/Enum.java 21 Mar 2005 12:10:17 - 1.1.2.4 +++ java/lang/Enum.java 25 Jul 2005 10:37:30 - @@ -1,5 +1,5 @@ /* Enum.java - Base class for all enums - Copyright (C) 2004 Free Software Foundation + Copyright (C) 2004, 2005 Free Software Foundation This file is part of GNU Classpath. @@ -60,11 +60,32 @@ this.ordinal = ordinal; } + /** + * Returns an Enum for a enum class given a description string of + * the enum constant. + * + * @exception NullPointerException when etype or s are null. + * @exception IllegalArgumentException when there is no value s in + * the enum etype. + */ + @SuppressWarnings(unchecked) public static S extends EnumS Enum valueOf(ClassS etype, String s) { if (etype == null || s == null) throw new NullPointerException(); -return null; // FIXME + +try + { + return (S) etype.getDeclaredField(s).get(null); + } +catch (NoSuchFieldException exception) + { + throw new IllegalArgumentException(s); + } +catch (IllegalAccessException exception) + { + throw new Error(Unable to access Enum class); + } } public final boolean equals(Object o) 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] RFC: cleanup in nio native code
While merging some nio code I came upon some strange code in gnu_java_nio_channels_FileChannelImpl.c. There is some code that initializes the field in, out and err, which I would think would better fit in the Java code. I propose the following patch to move this init code there. Are there any objections? May I commit this? 2005-07-25 Roman Kennke [EMAIL PROTECTED] * gnu/java/nio/channels/FileChannelImpl.java (static initializer): Init out, err and in here. * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c (Java_gnu_java_nio_channels_FileChannelImpl_init): Moved init code for in, out and err to Java code. /Roman Index: gnu/java/nio/channels/FileChannelImpl.java === RCS file: /cvsroot/classpath/classpath/gnu/java/nio/channels/FileChannelImpl.java,v retrieving revision 1.15 diff -u -r1.15 FileChannelImpl.java --- gnu/java/nio/channels/FileChannelImpl.java 11 Jul 2005 17:27:55 - 1.15 +++ gnu/java/nio/channels/FileChannelImpl.java 25 Jul 2005 10:46:41 - @@ -73,6 +73,10 @@ public static final int SYNC = 16; public static final int DSYNC = 32; + public static FileChannelImpl in; + public static FileChannelImpl out; + public static FileChannelImpl err; + private static native void init(); static @@ -83,6 +87,12 @@ } init(); + +// Replaced native code by simpler, equivalent Java code for +// readability and analysability. +in = new FileChannelImpl(0,READ); +out = new FileChannelImpl(1,WRITE); +err = new FileChannelImpl(2,WRITE); } /** @@ -130,16 +140,20 @@ } } - /* Used by init() (native code) */ + /** + * Constructor for default channels in, out and err. + * + * Used by init() (native code). + * + * @param fd the file descriptor (0, 1, 2 for stdin, stdout, stderr). + * + * @param mode READ or WRITE + */ FileChannelImpl (int fd, int mode) { this.fd = fd; this.mode = mode; } - - public static FileChannelImpl in; - public static FileChannelImpl out; - public static FileChannelImpl err; private native int open (String path, int mode) throws FileNotFoundException; Index: native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c === RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c,v retrieving revision 1.19 diff -u -r1.19 gnu_java_nio_channels_FileChannelImpl.c --- native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 24 Jul 2005 03:35:58 - 1.19 +++ native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 25 Jul 2005 10:46:41 - @@ -136,28 +136,6 @@ } native_fd_fieldID = field; - - constructor = (*env)-GetMethodID (env, clazz, init, (II)V); - if (!constructor) -return; - -#define INIT_FIELD(FIELDNAME, FDVALUE, MODE) \ - field = (*env)-GetStaticFieldID (env, clazz, FIELDNAME, \ - Lgnu/java/nio/channels/FileChannelImpl;); \ - if (! field) \ -return;\ - obj = (*env)-NewObject (env, clazz, constructor, FDVALUE, MODE);\ - if (! obj) \ -return;\ - (*env)-SetStaticObjectField (env, clazz, field, obj); \ - if ((*env)-ExceptionOccurred (env)) \ -return; - - INIT_FIELD (in, 0, FILECHANNELIMPL_READ); - INIT_FIELD (out, 1, FILECHANNELIMPL_WRITE); - INIT_FIELD (err, 2, FILECHANNELIMPL_WRITE); - -#undef INIT_FIELD } /* ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: Update assign faq entry
Hi, I got some questions about our contribution requirements so I asked FSF-legal for a better explanation of the assignment policy to add to the FAQ explaining that it is a contract with the FSF committing the FSF to distribute your contribution and derived works under free terms and that you can get a grant-back for any contribution you made for use in other projects (even proprietary) if you wish. Here it is. 2005-07-25 Mark Wielaard [EMAIL PROTECTED] * doc/www.gnu.org/faq.wml: Expand contribution assign answer. Committed, Mark ? doc/www.gnu.org/downloads.diff ? doc/www.gnu.org/escape.patch ? doc/www.gnu.org/gjdoc-home.patch ? doc/www.gnu.org/cp-tools/cp-tools.html Index: doc/www.gnu.org/faq/faq.wml === RCS file: /cvsroot/classpath/classpath/doc/www.gnu.org/faq/faq.wml,v retrieving revision 1.18 diff -u -r1.18 faq.wml --- doc/www.gnu.org/faq/faq.wml 4 Jul 2005 14:31:01 - 1.18 +++ doc/www.gnu.org/faq/faq.wml 25 Jul 2005 11:29:16 - @@ -304,6 +304,28 @@ not see this as a personal offence. pGiving the copyright to the FSF also gives us a clear paper trail where changes come from, which confirms our clean-room status. +/p + +p +The assignment contract commits the foundation to setting distribution terms +that permit free redistribution. +/p + +p +The assignment contract we normally use has a clause that permits you to +use your code in proprietary programs, on 30 days' notice. +(The 30 days' notice is there because, through a legal technicality, +it would improve our position in a suit against a hoarder.) +Although we believe that proprietary software is wrong, we include this +clause because it would serve no purpose to ask you to promise not to do +it. You're giving us a gift in the first place. +/p + +p +You don't need to invoke this clause in order to distribute +copies as free software under the GNU GPL, since everyone is +allowed to do that. +/p pSee also a href=http://www.gnu.org/licenses/why-assign.html;http://www.gnu.org/licenses/why-assign.html/a. /p 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] RFC: RMI Class loader fix
Hi, I'm not an RMI person, but an IKVM user ran into an RMI problem that I think is caused by a problem in the RMI class loader that the attached patch should fix. Please comment. Regards, Jeroen * java/rmi/server/RMIClassLoader.java (loadClass(String, String)): Use Class.forName() instead of directly calling ClassLoader.loadClass(), to handle array types correctly. Index: java/rmi/server/RMIClassLoader.java === RCS file: /cvsroot/classpath/classpath/java/rmi/server/RMIClassLoader.java,v retrieving revision 1.16 diff -u -r1.16 RMIClassLoader.java --- java/rmi/server/RMIClassLoader.java 2 Jul 2005 20:32:40 - 1.16 +++ java/rmi/server/RMIClassLoader.java 25 Jul 2005 12:48:48 - @@ -214,7 +214,7 @@ //try context class loader first try { -return loader.loadClass (name); +return Class.forName(name, false, loader); } catch (ClassNotFoundException e) { @@ -237,7 +237,7 @@ ) at codebase ( + codebases + )); } -return loader.loadClass (name); +return Class.forName(name, false, loader); } /** ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] RFC: cleanup in nio native code
Ok, as I was told on IRC, I have committed the attached slightly (only comments) changed patch. 2005-07-25 Roman Kennke [EMAIL PROTECTED] * gnu/java/nio/channels/FileChannelImpl.java (static initializer): Init out, err and in here. * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c (Java_gnu_java_nio_channels_FileChannelImpl_init): Moved init code for in, out and err to Java code. /Roman Index: gnu/java/nio/channels/FileChannelImpl.java === RCS file: /cvsroot/classpath/classpath/gnu/java/nio/channels/FileChannelImpl.java,v retrieving revision 1.15 diff -u -r1.15 FileChannelImpl.java --- gnu/java/nio/channels/FileChannelImpl.java 11 Jul 2005 17:27:55 - 1.15 +++ gnu/java/nio/channels/FileChannelImpl.java 25 Jul 2005 13:52:11 - @@ -73,6 +73,10 @@ public static final int SYNC = 16; public static final int DSYNC = 32; + public static FileChannelImpl in; + public static FileChannelImpl out; + public static FileChannelImpl err; + private static native void init(); static @@ -83,6 +87,10 @@ } init(); + +in = new FileChannelImpl(0,READ); +out = new FileChannelImpl(1,WRITE); +err = new FileChannelImpl(2,WRITE); } /** @@ -130,16 +138,20 @@ } } - /* Used by init() (native code) */ + /** + * Constructor for default channels in, out and err. + * + * Used by init() (native code). + * + * @param fd the file descriptor (0, 1, 2 for stdin, stdout, stderr). + * + * @param mode READ or WRITE + */ FileChannelImpl (int fd, int mode) { this.fd = fd; this.mode = mode; } - - public static FileChannelImpl in; - public static FileChannelImpl out; - public static FileChannelImpl err; private native int open (String path, int mode) throws FileNotFoundException; Index: native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c === RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c,v retrieving revision 1.19 diff -u -r1.19 gnu_java_nio_channels_FileChannelImpl.c --- native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 24 Jul 2005 03:35:58 - 1.19 +++ native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 25 Jul 2005 13:52:11 - @@ -136,28 +136,6 @@ } native_fd_fieldID = field; - - constructor = (*env)-GetMethodID (env, clazz, init, (II)V); - if (!constructor) -return; - -#define INIT_FIELD(FIELDNAME, FDVALUE, MODE) \ - field = (*env)-GetStaticFieldID (env, clazz, FIELDNAME, \ - Lgnu/java/nio/channels/FileChannelImpl;); \ - if (! field) \ -return;\ - obj = (*env)-NewObject (env, clazz, constructor, FDVALUE, MODE);\ - if (! obj) \ -return;\ - (*env)-SetStaticObjectField (env, clazz, field, obj); \ - if ((*env)-ExceptionOccurred (env)) \ -return; - - INIT_FIELD (in, 0, FILECHANNELIMPL_READ); - INIT_FIELD (out, 1, FILECHANNELIMPL_WRITE); - INIT_FIELD (err, 2, FILECHANNELIMPL_WRITE); - -#undef INIT_FIELD } /* ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: Some fixes and optimizations for Container
Hi, I checked in some fixes and optimizations that I came upon while merging with Jamaica's AWT. Most importantly the Lightweightdispatcher has been reworked so that it is reentrant, and preferredSize is now working optimized, so that it only recalculates the preferredSize if the container is invalid. 2005-07-25 Roman Kennke [EMAIL PROTECTED] * gnu/java/awt/AWTUtilities.java: Added methods from SwingUtilities so that AWT does not have to depend on Swing. * java/awt/Component.java: Reverted my DEFAULT_FONT patch from yesterday. This does not seem to work with the Gtk peers. * java/awt/Container.java (addImpl): Call addNotify() on the added child. Invalidate not only the container but also the added child. Repaint the container. (remove): Repaint the container. (invalidate): Also invalidate the LayoutManager. (invalidateTree): Call super.invalidate to invalidate the container itself. Also invalidate the LayoutManager. (setFont): Only set the font if the specified argument actually differs from the current font. (preferredSize): Optimized this method so the LayoutManager is only called if the layout is invalid. Otherwise we return the preferred size that has been stored during last validation/layout. (getAlignmentX): Despite common belief, this method does _not_ call the LayoutManagers getAlignmentX in the JDK. So we also don't. (getAlignmentY): Despite common belief, this method does _not_ call the LayoutManagers getAlignmentX in the JDK. So we also don't. (dispatchEventImpl): Let the dispatcher decide if it is enabled for the incoming event type. (eventTypeEnabled): Enables only container events for containers. (addNotifyContainerChildren): Coalesced two if statements into one. Enable events on the dispatcher for this container. (LightweightDispatcher): Made this class reentrant. Handle events enabling/disabling here. /Roman Index: gnu/java/awt/AWTUtilities.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/AWTUtilities.java,v retrieving revision 1.3 diff -u -r1.3 AWTUtilities.java --- gnu/java/awt/AWTUtilities.java 2 Jul 2005 20:32:10 - 1.3 +++ gnu/java/awt/AWTUtilities.java 25 Jul 2005 13:45:05 - @@ -1,5 +1,4 @@ -/* AWTUtilities.java -- Common utility methods for AWT and Swing. - Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2004 Free Software Foundation This file is part of GNU Classpath. @@ -15,8 +14,8 @@ You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and @@ -34,20 +33,30 @@ this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ - package gnu.java.awt; +import java.applet.Applet; import java.awt.Component; import java.awt.Container; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.MouseEvent; import java.util.AbstractSequentialList; import java.util.List; import java.util.ListIterator; import java.util.NoSuchElementException; import java.util.WeakHashMap; +import java.lang.reflect.InvocationTargetException; /** - * This class provides utility methods that are commonly used in AWT - * (and Swing). + * This class mirrors the javax.swing.SwingUtilities class. It + * provides commonly needed functionalities for AWT classes without + * the need to reference classes in the javax.swing package. */ public class AWTUtilities { @@ -317,5 +326,366 @@ visibleChildren = (VisibleComponentList) o; return visibleChildren; + } + + /** + * Calculates the portion of the base rectangle which is inside the + * insets. + * + * @param base The rectangle to apply the insets to + * @param insets The insets to apply to the base rectangle + * @param ret A rectangle to use for storing the return value, or + * codenull/code + * + * @return The calculated area inside the base rectangle and its insets, + * either stored in ret or a new Rectangle if ret is codenull/code + * + * @see #calculateInnerArea + */ + public static Rectangle calculateInsetArea(Rectangle base, Insets insets, +
[cp-patches] FYI: JTable selectAll fix
This patch ensures selectAll doesn't affect the lead selection indices for the row or column ListSelectionModel. Since this is fixed, I also replaced some direct code in BasicListUI with a call to selectAll. Also a small touch-up to make the ENTER key press compatible with the JDK. Patch attached. 2005-07-25 Anthony Balkissoon [EMAIL PROTECTED] * javax/swing/JTable.java: (selectAll): Store the lead selection indices and restore them after selecting all cells. * javax/swing/plaf/basic/BasicTableUI.java: (KeyHandler.keyPressed): Changed the criteria for only one selection when the ENTER key is pressed to match the behavior of the JDK. Also replaced direct code for CTRL-A with call to JTable.selectAll(). - Tony Index: javax/swing/JTable.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v retrieving revision 1.35 diff -u -r1.35 JTable.java --- javax/swing/JTable.java 20 Jul 2005 20:25:08 - 1.35 +++ javax/swing/JTable.java 25 Jul 2005 14:46:07 - @@ -2070,8 +2070,17 @@ public void selectAll() { +// rowLead and colLead store the current lead selection indices +int rowLead = selectionModel.getLeadSelectionIndex(); +int colLead = getColumnModel().getSelectionModel().getLeadSelectionIndex(); +// the following calls to setSelectionInterval change the lead selection +// indices setColumnSelectionInterval(0, getColumnCount() - 1); setRowSelectionInterval(0, getRowCount() - 1); +// the following addSelectionInterval calls restore the lead selection +// indices to their previous values +addColumnSelectionInterval(colLead,colLead); +addRowSelectionInterval(rowLead, rowLead); } public Object getValueAt(int row, int column) Index: javax/swing/plaf/basic/BasicTableUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java,v retrieving revision 1.14 diff -u -r1.14 BasicTableUI.java --- javax/swing/plaf/basic/BasicTableUI.java 22 Jul 2005 19:44:35 - 1.14 +++ javax/swing/plaf/basic/BasicTableUI.java 25 Jul 2005 14:46:07 - @@ -265,12 +265,17 @@ return; } - // If there is just one cell selected, select the next row, and wrap + // If there is just one selection, select the next row, and wrap // when you get to the edges of the table. - if ((table.getSelectedRowCount() = 1 - table.getSelectedColumnCount() = 1) - || (table.getRowSelectionAllowed() == false - table.getColumnSelectionAllowed() == false)) + boolean multRowsSelected, multColsSelected; + multRowsSelected = (table.getSelectedRowCount() 1) || +(!table.getRowSelectionAllowed() + table.getSelectedColumnCount() 0); + multColsSelected = (table.getSelectedColumnCount() 1) || +(!table.getColumnSelectionAllowed() + table.getSelectedRowCount() 0); + + if (!multColsSelected || !multRowsSelected) { rowModel.setSelectionInterval((rowLead + 1)%(rowMax + 1), (rowLead + 1)%(rowMax + 1)); @@ -350,13 +355,7 @@ else if ((evt.getKeyCode() == KeyEvent.VK_A || evt.getKeyCode() == KeyEvent.VK_SLASH) evt.isControlDown()) { - rowModel.setSelectionInterval(0, rowMax); - colModel.setSelectionInterval(0, colMax); - // the next two lines are to restore the lead selection indices to - // their previous values, because select-all operations shouldn't - // change them - rowModel.addSelectionInterval(rowLead, rowLead); - colModel.addSelectionInterval(colLead, colLead); + table.selectAll(); } else if (evt.getKeyCode() == KeyEvent.VK_BACK_SLASH evt.isControlDown()) ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
RE: [cp-patches] FYI: ClassLoader caching Part 2
Mark Wielaard wrote: Yes, but unfortunately that doesn't change the byte-code of the ClassLoader class. static final primitive (and String) field values are actually inlined into other classes. So you can replace VMClassLoader all you want with a version the has VM_USE_CACHE set to another value, that won't actually change the ClassLoader code paths unless ClassLoader is also recompiled against this new value. Really, try it out. Trust me, I know all this ;-) It is an annoying byte code optimization. It's Java's version of #define. So for things that can be different at runtime like the VMClasses you unfortunately cannot use static final fields of primitive types. As long as you build everything from source (with the replaced VM* classes) it works, but I must admit that I have no clue about how everyone builds the class library (personally, I don't use any of the build infrastructure that comes with GNU Classpath). Regards, Jeroen ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
RE: [cp-patches] RFC: RMI Class loader fix
Mark Wielaard wrote: On Mon, 2005-07-25 at 14:52 +0200, Jeroen Frijters wrote: I'm not an RMI person, but an IKVM user ran into an RMI problem that I think is caused by a problem in the RMI class loader that the attached patch should fix. Please comment. I assume this is because the code tries to load an array class and forName() allows to specify arrays as type strings, but loadClass() only allows for fully qualified class names? Our documentation isn't very clear here. But if that is the case then this patch looks good. Unfortunately the Sun documentation isn't very clear either, but you are correct that I believe this to be the case. BTW, clearly Class.forName() allows array types, but ClassLoader.loadClass() isn't very clear and the Sun implementation does some weird things. Here's an example I tried: public class test { public static void main(String[] args) throws Exception { System.out.println(test.class.getClassLoader().loadClass(test)); Class.forName([Ltest;); System.out.println(test.class.getClassLoader().loadClass([Ltest;)); } } If you run this on JDK 1.5, the second loadClass succeeds, but if you comment out the Class.forName(), the second load class fails. On JDK 1.4, the Class.forName() isn't required, but if you comment out the first loadClass, the second one will fail... I will commit the RMI fix. Regards, Jeroen ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] RFC: RMI Class loader fix
Hi, On Mon, 2005-07-25 at 14:52 +0200, Jeroen Frijters wrote: I'm not an RMI person, but an IKVM user ran into an RMI problem that I think is caused by a problem in the RMI class loader that the attached patch should fix. Please comment. I assume this is because the code tries to load an array class and forName() allows to specify arrays as type strings, but loadClass() only allows for fully qualified class names? Our documentation isn't very clear here. But if that is the case then this patch looks good. Cheers, Mark 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
RE: [cp-patches] FYI: ClassLoader caching Part 2
Jeroen Frijters wrote: Mark Wielaard wrote: On Mon, 2005-07-25 at 16:29 +0200, Jeroen Frijters wrote: I committed the attached patch to complete to ability of the VM to bypass the class caching in ClassLoader. 2005-07-25 Jeroen Frijters [EMAIL PROTECTED] * java/lang/ClassLoader.java (loadedClasses): Set based on VMClassLoader.VM_USE_CACHE. (defineClass): Modified to respect VMClassLoader.VM_USE_CACHE. * vm/reference/java/lang/VMClassLoader.java (VM_USE_CACHE): New field. This won't work if you make the VM_USE_CACHE field static final. Then the constant will be compiled into ClassLoader making it impossible to override for the runtime vm-classes later. It has to be a static method for that to work. Like Archie says, your comment doesn't make sense ;-) If a VM decides not to use the cache in ClassLoader, it replaces VMClassLoader and sets the constant to true. Oh, I'm sorry, I think see what you mean. If a VM would take a binary GNU Classpath jar, it wouldn't be able to override the value of the flag. Is this an important scenario? I thought you long haired types didn't like binary distributions ;-) Regards, Jeroen ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: Container fixlet
This patch fixes a typo in Container.java that was causing an array out of bounds exception with calls to setFocusedTraversalKeys. Patch attached. 2005-07-25 Anthony Balkissoon [EMAIL PROTECTED] * java/awt/Container.java: (setFocusTraversalKeys): Instantiate focusTraversalKeys to an array of size 4, not 3. This must have been a typo. - Tony Index: java/awt/Container.java === RCS file: /cvsroot/classpath/classpath/java/awt/Container.java,v retrieving revision 1.55 diff -u -r1.55 Container.java --- java/awt/Container.java 25 Jul 2005 14:18:02 - 1.55 +++ java/awt/Container.java 25 Jul 2005 16:31:35 - @@ -1225,7 +1225,7 @@ } if (focusTraversalKeys == null) - focusTraversalKeys = new Set[3]; + focusTraversalKeys = new Set[4]; keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes)); firePropertyChange (name, focusTraversalKeys[id], keystrokes); ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: RMI Class loader fix
Hi, I applied the attached fix. Regards, Jeroen * java/rmi/server/RMIClassLoader.java (loadClass(String, String)): Use Class.forName() instead of directly calling ClassLoader.loadClass(), to handle array types correctly. Index: java/rmi/server/RMIClassLoader.java === RCS file: /cvsroot/classpath/classpath/java/rmi/server/RMIClassLoader.java,v retrieving revision 1.16 diff -u -r1.16 RMIClassLoader.java --- java/rmi/server/RMIClassLoader.java 2 Jul 2005 20:32:40 - 1.16 +++ java/rmi/server/RMIClassLoader.java 25 Jul 2005 12:48:48 - @@ -214,7 +214,7 @@ //try context class loader first try { -return loader.loadClass (name); +return Class.forName(name, false, loader); } catch (ClassNotFoundException e) { @@ -237,7 +237,7 @@ ) at codebase ( + codebases + )); } -return loader.loadClass (name); +return Class.forName(name, false, loader); } /** ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] FYI: ClassLoader caching Part 2
Jeroen Frijters wrote: Oh, I'm sorry, I think see what you mean. If a VM would take a binary GNU Classpath jar, it wouldn't be able to override the value of the flag. Is this an important scenario? I thought you long haired types didn't like binary distributions ;-) OK now I get it too... I call this idea of imposing VM-specific versions of a class in front of the stock Classpath versions overlaying instead of overriding to avoid confusion :-) Yes, I think not breaking overlaying is important.. so a static method (with comment why being used) would be better. -Archie __ Archie Cobbs *CTO, Awarix* http://www.awarix.com ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] RFC: New JCL helper functions for RawData handling
Guilhem Lavaux wrote: Ok. Then I will make a set of patches to first use the new common JCL interface. And then I will rename RawData* to Pointer*. Is it ok ? Absolutely. -- Chris Burdess ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches]: Patch: JTree painting
A fix for the case where there are no icons. 2005-07-25 Lillian Angel [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicTreeUI.java (paint): moved code to paintNode (getCellBounds): width increased, slightly short before (paintNode): changed to paint node depending if icons exist ? examples/gnu/classpath/examples/swing/Demo$1.class ? examples/gnu/classpath/examples/swing/Demo$10.class ? examples/gnu/classpath/examples/swing/Demo$11.class ? examples/gnu/classpath/examples/swing/Demo$2.class ? examples/gnu/classpath/examples/swing/Demo$3.class ? examples/gnu/classpath/examples/swing/Demo$4.class ? examples/gnu/classpath/examples/swing/Demo$5.class ? examples/gnu/classpath/examples/swing/Demo$6.class ? examples/gnu/classpath/examples/swing/Demo$7.class ? examples/gnu/classpath/examples/swing/Demo$8.class ? examples/gnu/classpath/examples/swing/Demo$9.class ? examples/gnu/classpath/examples/swing/Demo$CheckCellRenderer.class ? examples/gnu/classpath/examples/swing/Demo$LabelCellRenderer.class ? examples/gnu/classpath/examples/swing/Demo$LaterMain.class ? examples/gnu/classpath/examples/swing/Demo$PopUpAction.class ? examples/gnu/classpath/examples/swing/Demo.class ? examples/gnu/classpath/examples/swing/GNULookAndFeel.class Index: examples/gnu/classpath/examples/swing/Demo.java === RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/Demo.java,v retrieving revision 1.16 diff -u -r1.16 Demo.java --- examples/gnu/classpath/examples/swing/Demo.java 21 Jul 2005 14:13:36 - 1.16 +++ examples/gnu/classpath/examples/swing/Demo.java 25 Jul 2005 17:35:03 - @@ -70,7 +70,7 @@ Look and Feel notice, JOptionPane.INFORMATION_MESSAGE); -UIManager.setLookAndFeel(new GNULookAndFeel()); +UIManager.setLookAndFeel(new MetalLookAndFeel()); } } catch (UnsupportedLookAndFeelException e) Index: javax/swing/plaf/basic/BasicIconFactory.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicIconFactory.java,v retrieving revision 1.10 diff -u -r1.10 BasicIconFactory.java --- javax/swing/plaf/basic/BasicIconFactory.java 21 Jul 2005 12:07:06 - 1.10 +++ javax/swing/plaf/basic/BasicIconFactory.java 25 Jul 2005 17:35:04 - @@ -113,7 +113,7 @@ // The icon is empty and needs no painting. } } - + /** * The icon used for RadioButtons in the BasicLookAndFeel. This is an empty * icon with a size of 13x13 pixels. @@ -163,7 +163,7 @@ /** The cached CheckBoxIcon instance. */ private static RadioButtonIcon radioButtonIcon; - + public static Icon getMenuItemCheckIcon() { return new DummyIcon(); @@ -217,7 +217,7 @@ checkBoxIcon = new CheckBoxIcon(); return checkBoxIcon; } - + /** * Returns an icon for RadioButtons in the BasicLookAndFeel. RadioButton * icons in the Basic Lamp;F are empty and have a size of 13x13 pixels. Index: javax/swing/plaf/basic/BasicLookAndFeel.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,v retrieving revision 1.40 diff -u -r1.40 BasicLookAndFeel.java --- javax/swing/plaf/basic/BasicLookAndFeel.java 22 Jul 2005 16:45:07 - 1.40 +++ javax/swing/plaf/basic/BasicLookAndFeel.java 25 Jul 2005 17:35:04 - @@ -1013,8 +1013,6 @@ }), Tree.background, new ColorUIResource(light), Tree.changeSelectionWithFocus, Boolean.TRUE, -// Tree.closedIcon, new IconUIResource(new ImageIcon(icons/TreeClosed.png)), -// Tree.collapsedIcon, new IconUIResource(new ImageIcon(icons/TreeCollapsed.png)), Tree.drawsFocusBorderAroundIcon, Boolean.FALSE, Tree.editorBorder, new BorderUIResource.LineBorderUIResource(Color.lightGray), Tree.focusInputMap, new UIDefaults.LazyInputMap(new Object[] { Index: javax/swing/plaf/basic/BasicTreeUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v retrieving revision 1.47 diff -u -r1.47 BasicTreeUI.java --- javax/swing/plaf/basic/BasicTreeUI.java 22 Jul 2005 08:36:52 - 1.47 +++ javax/swing/plaf/basic/BasicTreeUI.java 25 Jul 2005 17:35:04 - @@ -1240,16 +1240,6 @@ if (hasControlIcons()) paintControlIcons(g, 0, 0, 0, 0, tree, mod, root); - - TreePath lead = tree.getLeadSelectionPath(); - if (lead != null tree.isPathSelected(lead)) - { - Rectangle cell = getPathBounds(tree, lead); - g.setColor(UIManager.getLookAndFeelDefaults().getColor( - Tree.selectionBorderColor)); - g.drawRect(cell.x + rightChildIndent - 4, cell.y, -
[cp-patches] Patch: FYI: Properties fixlet
I'm checking this in. This fixes a bug in Properties.load that was found with FindBugs. Tom Index: ChangeLog from Tom Tromey [EMAIL PROTECTED] * java/util/Properties.java (load): Handle case where backslash appears at EOF when reading the key. PR classpath/22994. Index: java/util/Properties.java === RCS file: /cvsroot/classpath/classpath/java/util/Properties.java,v retrieving revision 1.29 diff -u -r1.29 Properties.java --- java/util/Properties.java 5 Jul 2005 10:28:03 - 1.29 +++ java/util/Properties.java 25 Jul 2005 17:27:22 - @@ -209,8 +209,12 @@ { if (pos == line.length()) { -// The line continues on the next line. +// The line continues on the next line. If there +// is no next line, just treat it as a key with an +// empty value. line = reader.readLine(); + if (line == null) + line = ; pos = 0; while (pos line.length() Character.isWhitespace(c = line.charAt(pos))) ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches]: Patch: JTree painting
Done it again! heres the correct patch. On Mon, 2005-07-25 at 13:39 -0400, Lillian Angel wrote: A fix for the case where there are no icons. 2005-07-25 Lillian Angel [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicTreeUI.java (paint): moved code to paintNode (getCellBounds): width increased, slightly short before (paintNode): changed to paint node depending if icons exist ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches Index: javax/swing/plaf/basic/BasicTreeUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v retrieving revision 1.47 diff -u -r1.47 BasicTreeUI.java --- javax/swing/plaf/basic/BasicTreeUI.java 22 Jul 2005 08:36:52 - 1.47 +++ javax/swing/plaf/basic/BasicTreeUI.java 25 Jul 2005 17:35:04 - @@ -1240,16 +1240,6 @@ if (hasControlIcons()) paintControlIcons(g, 0, 0, 0, 0, tree, mod, root); - - TreePath lead = tree.getLeadSelectionPath(); - if (lead != null tree.isPathSelected(lead)) - { - Rectangle cell = getPathBounds(tree, lead); - g.setColor(UIManager.getLookAndFeelDefaults().getColor( - Tree.selectionBorderColor)); - g.drawRect(cell.x + rightChildIndent - 4, cell.y, - cell.width + 4, cell.height); - } } /** @@ -1928,7 +1918,7 @@ boolean cntlClick = false; Rectangle bounds = BasicTreeUI.this.getPathBounds( BasicTreeUI.this.tree, path); -// include icon + bounds.x -= rightChildIndent - 4; bounds.width += rightChildIndent + 4; @@ -2517,7 +2507,7 @@ Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont()); - return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s), + return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + 4, fm.getHeight()); } return null; @@ -2581,7 +2571,8 @@ TreePath curr = new TreePath(((DefaultMutableTreeNode) node).getPath()); boolean selected = tree.isPathSelected(curr); boolean expanded = false; - + boolean hasIcons = false; + if (tree.isVisible(curr)) { DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tree @@ -2589,21 +2580,46 @@ if (!isLeaf) expanded = tree.isExpanded(curr); - + + Icon icon = null; + if (!isLeaf expanded) +icon = dtcr.getOpenIcon(); + else if (!isLeaf !expanded) +icon = dtcr.getClosedIcon(); + else +icon = dtcr.getLeafIcon(); + + if (icon.getIconHeight() -1 icon.getIconWidth() -1) +hasIcons = true; + Component c = dtcr.getTreeCellRendererComponent(tree, node, selected, expanded, isLeaf, 0, false); - if (selected) + if (hasIcons) { -Rectangle cell = getPathBounds(tree, curr); -g.setColor(dtcr.getBackgroundSelectionColor()); -g.fillRect(cell.x + rightChildIndent - 4, cell.y, cell.width + 4, - cell.height); +if (selected) +{ + Rectangle cell = getPathBounds(tree, curr); + g.setColor(dtcr.getBackgroundSelectionColor()); + g.fillRect(cell.x + icon.getIconWidth()/2, cell.y, cell.width, + cell.height); + + if (curr.equals(tree.getLeadSelectionPath())) + { + g.setColor(UIManager.getLookAndFeelDefaults().getColor( +Tree.selectionBorderColor)); + g.drawRect(cell.x + icon.getIconWidth()/2, cell.y, +cell.width, cell.height); + } +} + +g.translate(x, y); +c.paint(g); +g.translate(-x, -y); } - - g.translate(x, y); - c.paint(g); - g.translate(-x, -y); + else +rendererPane.paintComponent(g, c, c.getParent(), + getCellBounds(x, y, node)); } } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] RFC: RMI Class loader fix
Jeroen == Jeroen Frijters [EMAIL PROTECTED] writes: Jeroen * java/rmi/server/RMIClassLoader.java Jeroen (loadClass(String, String)): Use Class.forName() instead of Jeroen directly calling ClassLoader.loadClass(), to handle array Jeroen types correctly. Andrew, didn't we run into code that expected ClassLoader.loadClass to handle array signatures? Tom ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] FYI: Some fixes and optimizations for Container
Roman == Roman Kennke [EMAIL PROTECTED] writes: Roman (getAlignmentX): Despite common belief, this method does _not_ Roman call the LayoutManagers getAlignmentX in the JDK. So we also Roman don't. Information like this should be in comments in the code, not in the ChangeLog entry. Generally speaking the ChangeLog should describe what was done and the code should explain why. Tom ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] rmic error handling
Attached is a patch to the cp-tools rmic that centralizes calls to System.exit and makes handling of exceptions and error conditions more uniform. With the patch, rmic (built with libgcj-3.3.3-7 on FC2) passes the mauve rmic tests. -- Archit Shah Index: src/gnu/classpath/tools/rmi/rmic/RMIC.java === RCS file: /cvsroot/classpath/cp-tools/src/gnu/classpath/tools/rmi/rmic/RMIC.java,v retrieving revision 1.2 diff -u -r1.2 RMIC.java --- src/gnu/classpath/tools/rmi/rmic/RMIC.java 5 Jul 2005 18:11:36 - 1.2 +++ src/gnu/classpath/tools/rmi/rmic/RMIC.java 25 Jul 2005 18:21:50 - @@ -1,4 +1,4 @@ -/* ASMRMIC.java -- +/* RMIC.java -- Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @@ -65,7 +65,7 @@ { private String[] args; private int next; - private Exception exception; + private List errors = new ArrayList(); private boolean keep = false; private boolean need11Stubs = true; private boolean need12Stubs = true; @@ -97,40 +97,66 @@ public static void main(String[] args) { +if (rmic(args)) + System.exit(0); +else + System.exit(1); + } + + /** + * @return true if compilation was successful + */ + public static boolean rmic(String[] args) + { RMIC r = new RMIC(args); -if (r.run() == false) - { - Exception e = r.getException(); - if (e != null) - e.printStackTrace(); - else - System.exit(1); - } +return r.run(); } - public boolean run() + /** + * @return true if run was successful + */ + private boolean run() { -parseOptions(); +boolean done = parseOptions(); +if (done) + return errorCount == 0; + if (next = args.length) - error(no class names found); + { +usage(); +return false; + } + for (int i = next; i args.length; i++) { try { - if (verbose) +if (verbose) System.out.println([Processing class + args[i] + .class]); processClass(args[i].replace(File.separatorChar, '.')); } - catch (Exception e) - { - exception = e; - return (false); - } +catch (IOException e) + { +errors.add(e); + } +catch (RMICException e) + { +errors.add(e); + } } -return (true); +if (errors.size() 0) + { +for (Iterator it = errors.iterator(); it.hasNext(); ) + { +Exception ex = (Exception) it.next(); +logError(ex); + } + } + +return errorCount == 0; } - private boolean processClass(String cls) throws Exception + private void processClass(String cls) throws IOException, RMICException { // reset class specific vars clazz = null; @@ -142,18 +168,14 @@ skelname = null; mRemoteInterfaces = new ArrayList(); -errorCount = 0; - analyzeClass(cls); -if (errorCount 0) - System.exit(1); generateStub(); if (need11Stubs) generateSkel(); -return (true); } - private void analyzeClass(String cname) throws Exception + private void analyzeClass(String cname) +throws RMICException { if (verbose) System.out.println([analyze class + cname + ]); @@ -168,35 +190,35 @@ findRemoteMethods(); } + /** + * @deprecated + */ public Exception getException() { -return (exception); +return errors.size() == 0 ? null : (Exception) errors.get(0); } private void findClass() +throws RMICException { +ClassLoader cl = (loader == null + ? ClassLoader.getSystemClassLoader() + : loader); try { -ClassLoader cl = (loader == null - ? ClassLoader.getSystemClassLoader() - : loader); clazz = Class.forName(fullclassname, false, cl); } catch (ClassNotFoundException cnfe) { -System.err.println(fullclassname + not found in + classpath); -throw new RuntimeException(cnfe); +throw new RMICException + (Class + fullclassname + not found in classpath, cnfe); } if (! Remote.class.isAssignableFrom(clazz)) { -logError(Class + clazz.getName() + is not a remote object. - + It does not implement an interface that is a - + java.rmi.Remote-interface.); -throw new RuntimeException - (Class + clazz.getName() + is not a remote object. - + It does not implement an interface that is a - + java.rmi.Remote-interface.); +throw new RMICException + (Class + clazz.getName() + + does not implement a remote interface.); } } @@ -412,7 +434,8 @@ } } - private void generateStub() throws IOException + private void generateStub() +throws IOException {
RE: [cp-patches] FYI: ClassLoader caching Part 2
On Mon, 2005-07-25 at 18:20 +0200, Mark Wielaard wrote: On Mon, 2005-07-25 at 17:55 +0200, Jeroen Frijters wrote: This won't work if you make the VM_USE_CACHE field static final. Then the constant will be compiled into ClassLoader making it impossible to override for the runtime vm-classes later. It has to be a static method for that to work. Like Archie says, your comment doesn't make sense ;-) If a VM decides not to use the cache in ClassLoader, it replaces VMClassLoader and sets the constant to true. Yes, but unfortunately that doesn't change the byte-code of the ClassLoader class. static final primitive (and String) field values are actually inlined into other classes. So you can replace VMClassLoader all you want with a version the has VM_USE_CACHE set to another value, that won't actually change the ClassLoader code paths unless ClassLoader is also recompiled against this new value. Really, try it out. It is an annoying byte code optimization. So for things that can be different at runtime like the VMClasses you unfortunately cannot use static final fields of primitive types. I haven't looked at jdwp yet, but hopefully jdwp will provide its own VM interface instead of messing around with the internals of other classes. Yeah that would be the clean way to do it indeed. Well if it were decided to have some minor changes to allow VM re-use this is pretty much how I would alter ClassLoader. We're not ready to use it anyways but I'll put it out there so people know what would be required. Aaron Index: java/lang/ClassLoader.java === RCS file: /cvsroot/classpath/classpath/java/lang/ClassLoader.java,v retrieving revision 1.54 diff -u -p -r1.54 ClassLoader.java --- java/lang/ClassLoader.java 25 Jul 2005 14:28:42 - 1.54 +++ java/lang/ClassLoader.java 25 Jul 2005 18:37:38 - @@ -40,6 +40,7 @@ package java.lang; import gnu.classpath.SystemProperties; import gnu.classpath.VMStackWalker; +import gnu.classpath.jdwp.Jdwp; import gnu.java.util.DoubleEnumeration; import gnu.java.util.EmptyEnumeration; @@ -152,6 +153,14 @@ public abstract class ClassLoader */ private final boolean initialized; + /** + * This list is kept around for JDWP. We need a way to know every class + * that this ClassLoader has been asked to load, thus they will be added + * here. There's no need to do anything else, JDWP is able to sniff out + * private fields so we'll just sniff this field as well! + */ + final ArrayList loadRequests = new ArrayList(); + static class StaticData { /** @@ -333,23 +342,25 @@ public abstract class ClassLoader { if (parent == null) { - c = VMClassLoader.loadClass(name, resolve); - if (c != null) - return c; - } - else - { - return parent.loadClass(name, resolve); - } - } - catch (ClassNotFoundException e) - { - } - // Still not found, we have to do it ourself. - c = findClass(name); + c = VMClassLoader.loadClass(name, resolve); + } +else + { + c = parent.loadClass(name, resolve); + } + } + catch (ClassNotFoundException e) + { + } + // Still not found, we have to do it ourself. + if (c == null) +c = findClass(name); } +} if (resolve) resolveClass(c); +if (Jdwp.isDebugging) + loadRequests.add(c); return c; } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] Patch: FYI: fix PR classpath/22986
I'm checking this in. FindBugs pointed out that we were using equals() to compare arrays. In this case, this is incorrect, and we want Arrays.equals(). Tom Index: ChangeLog from Tom Tromey [EMAIL PROTECTED] * java/text/CollationKey.java (equals): Use Arrays.equals. PR classpath/22986. Index: java/text/CollationKey.java === RCS file: /cvsroot/classpath/classpath/java/text/CollationKey.java,v retrieving revision 1.15 diff -u -r1.15 CollationKey.java --- java/text/CollationKey.java 23 Jul 2005 20:25:15 - 1.15 +++ java/text/CollationKey.java 25 Jul 2005 18:26:23 - @@ -38,6 +38,8 @@ package java.text; +import java.util.Arrays; + /* Written using Java Class Libraries, 2nd edition, plus online * API docs for JDK 1.2 from http://www.javasoft.com. * Status: Believed complete and correct. @@ -154,7 +156,7 @@ if (!ck.getSourceString ().equals (getSourceString ())) return false; -if (!ck.toByteArray ().equals (toByteArray ())) +if (! Arrays.equals (ck.toByteArray (), toByteArray ())) return false; return true; ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] FYI: Some fixes and optimizations for Container
Hi, -/* AWTUtilities.java -- Common utility methods for AWT and Swing. - Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2004 Free Software Foundation Don't do that. sorry, I simply copied over the file (from our repo). I will take more care in the future. I'll fix this tomorrow. -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. Please keep the new address in place everywhere. See above. + public static Rectangle calculateInsetArea(Rectangle base, Insets insets, + Rectangle ret) This looks strange, did you forget a return here? There are a couple of similar things like this in the patch. Now I was confused. I thought you meant a missing return statement which would have been rejected by the compiler. I see you mean the bad formatting. I will go over this file and fix everything tomorrow. Sorry for this crap. /Roman ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
RE: [cp-patches] FYI: ClassLoader caching Part 2
Hi Jeroen, On Mon, 2005-07-25 at 18:17 +0200, Jeroen Frijters wrote: Is this an important scenario? I thought you long haired types didn't like binary distributions ;-) He he. Sure we don't. But if you follow the harmony effort of the cleanly shaved apache types you will have noticed that they might actually be paranoid enough to not look at or use something that comes with source code :) But I do care about binary installations! I have here two runtimes (jamvm and kissme) who both use the same GNU Classpath installation, but both overlay the VM classes differently. I would actually like that to be true for some of the others I have installed here too. Cheers, Mark 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
Re: [cp-patches] RFC: New JCL helper functions for RawData handling
Hi, On Mon, 2005-07-25 at 19:21 +0200, Guilhem Lavaux wrote: Ok. Then I will make a set of patches to first use the new common JCL interface. And then I will rename RawData* to Pointer*. Is it ok ? Yes please. And for extra bonus points you could add a little thing to the Hacker Guide about using these new JCL functions! Cheers, Mark 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: BasicTableUI TAB, SHIFT-TAB, and SHIFT-ENTER
This patch implements TAB, SHIFT-TAB, and SHIFT-ENTER key actions and merges them with the code for the ENTER action because of the similarities. Note that you won't be able to test the TAB or SHIFT-TAB unless you also apply the Hack.diff patch because JTable currently uses TABs to change focus. This is incorrect and will be fixed separately, but applying the small Hack.diff will allow you to see the implemented key actions. Patch attached. 2005-07-25 Anthony Balkissoon [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicTableUI.java: (KeyHandler.advanceSingleSelection): New method. Helper method for ENTER, SHIFT-ENTER, TAB, and SHIFT-TAB key events. (KeyHandler.advanceMultipleSelection): Likewise, used when the table has multiple selections at the time that ENTER or TAB was pressed. (KeyHandler.keyPressed): Implemented TAB, SHIFT-TAB, and SHIFT-ENTER and merged these with existing code for ENTER event, because of the similarites. Index: javax/swing/plaf/basic/BasicTableUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java,v retrieving revision 1.15 diff -u -r1.15 BasicTableUI.java --- javax/swing/plaf/basic/BasicTableUI.java 25 Jul 2005 14:48:53 - 1.15 +++ javax/swing/plaf/basic/BasicTableUI.java 25 Jul 2005 19:50:44 - @@ -97,6 +97,171 @@ class KeyHandler implements KeyListener { + +/** + * A helper method for the keyPressed event. Used because the actions + * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar. + * + * Selects the next (previous if SHIFT pressed) column for TAB, or row for + * ENTER from within the currently selected cells. + * + * @param firstModel the ListSelectionModel for columns (TAB) or + * rows (ENTER) + * @param firstMin the first selected index in firstModel + * @param firstMax the last selected index in firstModel + * @param secondModel the ListSelectionModel for rows (TAB) or + * columns (ENTER) + * @param secondMin the first selected index in secondModel + * @param secondMax the last selected index in secondModel + * @param reverse true if shift was held for the event + * @param eventIsTab true if TAB was pressed, false if ENTER pressed + */ +void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin, + int firstMax, ListSelectionModel secondModel, + int secondMin, int secondMax, boolean reverse, + boolean eventIsTab) +{ + // If eventIsTab, all the firsts correspond to columns, otherwise, to rows + // seconds correspond to the opposite + int firstLead = firstModel.getLeadSelectionIndex(); + int secondLead = secondModel.getLeadSelectionIndex(); + int numFirsts = eventIsTab ? +table.getModel().getColumnCount() : table.getModel().getRowCount(); + int numSeconds = eventIsTab ? +table.getModel().getRowCount() : table.getModel().getColumnCount(); + + // check if we have to wrap the firsts around, going to the other side + if ((firstLead == firstMax !reverse) || + (reverse firstLead == firstMin)) +{ + firstModel.addSelectionInterval(reverse ? firstMax : firstMin, + reverse ? firstMax : firstMin); + + // check if we have to wrap the seconds + if ((secondLead == secondMax !reverse) || + (reverse secondLead == secondMin)) +secondModel.addSelectionInterval(reverse ? secondMax : secondMin, + reverse ? secondMax : secondMin); + + // if we're not wrapping the seconds, we have to find out where we + // are within the secondModel and advance to the next cell (or + // go back to the previous cell if reverse == true) + else +{ + int[] secondsSelected; + if (eventIsTab table.getRowSelectionAllowed() || + !eventIsTab table.getColumnSelectionAllowed()) +secondsSelected = eventIsTab ? + table.getSelectedRows() : table.getSelectedColumns(); + else +{ + // if row selection is not allowed, then the entire column gets + // selected when you click on it, so consider ALL rows selected + secondsSelected = new int[numSeconds]; + for (int i = 0; i numSeconds; i++) + secondsSelected[i] = i; +} + + // and now find the next index within the model + int secondIndex = reverse ? secondsSelected.length - 1 : 0; + if (!reverse) +while (secondsSelected[secondIndex] = secondLead) + secondIndex++; + else +
[cp-patches] [patch] examples README
Hi all, a little patchlet for the README in the examples directory. Ok? Andreas 2005-07-25 Andreas Tobler [EMAIL PROTECTED] * examples/README: Add GNULookAndFeel.java to the compile command. Index: README === RCS file: /cvsroot/classpath/classpath/examples/README,v retrieving revision 1.3 diff -u -r1.3 README --- README 2 Jul 2005 20:32:08 - 1.3 +++ README 25 Jul 2005 20:12:26 - @@ -7,7 +7,8 @@ The examples can be compiled and run with gcj as follows: gcj -o swingdemo --main=gnu.classpath.examples.swing.Demo \ - gnu/classpath/examples/swing/Demo.java + gnu/classpath/examples/swing/Demo.java \ + gnu/classpath/examples/swing/GNULookAndFeel.java ./swingdemo Or with a traditional byte code interpreter like: ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] [patch] fix memory image source handling in GTK peers
Hi, This patch does three things: - implements GtkComponentPeer.repaint timed repaints properly - implements GtkComponentPeer.updateCursorImmediately - fixes handling of memory image sources in GtkImageConsumer I committed this to mainline. This patch gets the Cortado applet closer to working out-of-the-box on GNU Classpath. Tom 2005-07-25 Thomas Fitzsimmons [EMAIL PROTECTED] * gnu/java/awt/peer/gtk/GtkComponentPeer.java (repaint): Implement timed repaint. (updateCursorImmediately): Implement. (RepaintTimerTask): New class. * gnu/java/awt/peer/gtk/GtkImageConsumer.java (imageComplete): Don't remove consumer if source is a MemoryImageSource. Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v retrieving revision 1.88 diff -u -r1.88 GtkComponentPeer.java --- gnu/java/awt/peer/gtk/GtkComponentPeer.java 14 Jul 2005 22:07:02 - 1.88 +++ gnu/java/awt/peer/gtk/GtkComponentPeer.java 26 Jul 2005 01:50:52 - @@ -70,6 +70,8 @@ import java.awt.image.ImageProducer; import java.awt.image.VolatileImage; import java.awt.peer.ComponentPeer; +import java.util.Timer; +import java.util.TimerTask; public class GtkComponentPeer extends GtkGenericPeer implements ComponentPeer @@ -372,8 +374,28 @@ if (x == 0 y == 0 width == 0 height == 0) return; -q().postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE, - new Rectangle (x, y, width, height))); +Timer t = new Timer(); + +t.schedule(new RepaintTimerTask(x, y, width, height), tm); + } + + private class RepaintTimerTask extends TimerTask + { +private int x, y, width, height; + +RepaintTimerTask(int x, int y, int width, int height) +{ + this.x = x; + this.y = y; + this.width = width; + this.height = height; +} + +public void run() +{ + q().postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE, + new Rectangle (x, y, width, height))); +} } public void requestFocus () @@ -586,7 +608,8 @@ public void updateCursorImmediately () { - +if (awtComponent.getCursor() != null) + setCursor(awtComponent.getCursor()); } public boolean handlesWheelScrolling () Index: gnu/java/awt/peer/gtk/GtkImageConsumer.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkImageConsumer.java,v retrieving revision 1.3 diff -u -r1.3 GtkImageConsumer.java --- gnu/java/awt/peer/gtk/GtkImageConsumer.java 2 Jul 2005 20:32:12 - 1.3 +++ gnu/java/awt/peer/gtk/GtkImageConsumer.java 26 Jul 2005 01:50:52 - @@ -45,6 +45,7 @@ import java.awt.image.ImageConsumer; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; +import java.awt.image.MemoryImageSource; import java.util.Hashtable; import java.util.Vector; @@ -70,7 +71,10 @@ public synchronized void imageComplete (int status) { -source.removeConsumer(this); +// we need to reuse the pixel cache for memory image sources since +// a memory image's backing array can be updated live. +if (!(source instanceof MemoryImageSource)) + source.removeConsumer(this); target.setImage(width, height, pixelCache, properties); } ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches