[cp-patches] FYI: Generics Backport #01 (java.lang.Integer)
I'm committing the attached patch which merges the new 1.5 features of java.lang.Integer back into HEAD from the generics branch. These don't use any new language features (although methods like valueOf() have an indirect use in autoboxing) and simply seem to have landed on the generics branch due to their 1.5 status. Putting them on HEAD makes them more prominent and avoids duplication of these methods by those who may be unaware of their presence on the generics branch. Changelog: 2005-06-27 Tom Tromey [EMAIL PROTECTED] * java/lang/Integer.java: (valueOf(int)): Implemented. (bitCount(int)): Implemented. (rotateLeft(int,int)): Implemented. (rotateRight(int,int)): Implemented. (highestOneBit(int)): Implemented. (numberOfLeadingZeros(int)): Implemented. (lowestOneBit(int)): Implemented. (numberOfTrailingZeros(int)): Implemented. (signum(int)): Implmented. (reverseBytes(int)): Implemented. (reverse(int)): Implemented. -- Andrew :-) Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments. See http://www.fsf.org/philosophy/no-word-attachments.html No software patents in Europe -- http://nosoftwarepatents.com Value your freedom, or you will lose it, teaches history. `Don't bother us with politics' respond those who don't want to learn. -- Richard Stallman Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... } Index: java/lang/Integer.java === RCS file: /cvsroot/classpath/classpath/java/lang/Integer.java,v retrieving revision 1.30 diff -u -3 -p -u -r1.30 Integer.java --- java/lang/Integer.java 16 Feb 2005 11:18:37 - 1.30 +++ java/lang/Integer.java 26 Jun 2005 23:33:51 - @@ -1,5 +1,6 @@ /* Integer.java -- object wrapper for int - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,8 +50,9 @@ package java.lang; * @author John Keiser * @author Warren Levy * @author Eric Blake ([EMAIL PROTECTED]) + * @author Tom Tromey ([EMAIL PROTECTED]) * @since 1.0 - * @status updated to 1.4 + * @status largely updated to 1.5 */ public final class Integer extends Number implements Comparable { @@ -79,6 +81,19 @@ public final class Integer extends Numbe public static final Class TYPE = VMClassLoader.getPrimitiveClass('I'); /** + * The number of bits needed to represent an codeint/code. + * @since 1.5 + */ + public static final int SIZE = 32; + + // This caches some Integer values, and is used by boxing + // conversions via valueOf(). We must cache at least -128..127; + // these constants control how much we actually cache. + private static final int MIN_CACHE = -128; + private static final int MAX_CACHE = 127; + private static Integer[] intCache = new Integer[MAX_CACHE - MIN_CACHE + 1]; + + /** * The immutable value of this Integer. * * @serial the wrapped int @@ -279,6 +294,26 @@ public final class Integer extends Numbe } /** + * Returns an codeInteger/code object wrapping the value. + * In contrast to the codeInteger/code constructor, this method + * will cache some values. It is used by boxing conversion. + * + * @param val the value to wrap + * @return the codeInteger/code + */ + public static Integer valueOf(int val) + { +if (val MIN_CACHE || val MAX_CACHE) + return new Integer(val); +synchronized (intCache) + { + if (intCache[val - MIN_CACHE] == null) + intCache[val - MIN_CACHE] = new Integer(val); + return intCache[val - MIN_CACHE]; + } + } + + /** * Return the value of this codeInteger/code as a codebyte/code. * * @return the byte value @@ -507,6 +542,137 @@ public final class Integer extends Numbe } /** + * Return the number of bits set in x. + * @param x value to examine + * @since 1.5 + */ + public static int bitCount(int x) + { +// Successively collapse alternating bit groups into a sum. +x = ((x 1) 0x) + (x 0x); +x = ((x 2) 0x) + (x 0x); +x = ((x 4) 0x0f0f0f0f) + (x 0x0f0f0f0f); +x = ((x 8) 0x00ff00ff) + (x 0x00ff00ff); +return ((x 16) 0x) + (x 0x); + } + + /** + * Rotate x to the left by distance bits. + * @param x the value to rotate + * @param distance the number of bits by which to rotate + * @since 1.5 + */ + public static int rotateLeft(int x, int distance) + { +// This trick works because the shift operators implicitly mask +// the shift count. +return (x distance) | (x - distance); + } + + /** + * Rotate x to the right by distance bits. + * @param x the value to rotate + * @param distance the number of bits by which
[cp-patches] FYI: Completing org/omg/PortableServer/POAPackage.
2005-06-25 Audrius Meskauskas [EMAIL PROTECTED] * org/omg/PortableServer/POAPackage/ServantAlreadyActive.java, org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java: New files. /* ServantAlreadyActiveHelper.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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., 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 conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend 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 org.omg.PortableServer.POAPackage; import gnu.CORBA.EmptyExceptionHolder; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TCKind; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; /** * The helper operations for the exception [EMAIL PROTECTED] ServantAlreadyActive}. * * @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED]) */ public abstract class ServantAlreadyActiveHelper { /** * The cached typecode value, computed only once. */ private static TypeCode typeCode; /** * Create the ServantAlreadyActive typecode (structure, * named ServantAlreadyActive). */ public static TypeCode type() { if (typeCode == null) { ORB orb = ORB.init(); StructMember[] members = new StructMember[ 0 ]; typeCode = orb.create_exception_tc(id(), ServantAlreadyActive, members); } return typeCode; } /* Every user exception with no user defined fields can use EmptyExceptionHolder */ /** * Insert the ServantAlreadyActive into the given Any. * * @param any the Any to insert into. * @param that the ServantAlreadyActive to insert. */ public static void insert(Any any, ServantAlreadyActive that) { any.insert_Streamable(new EmptyExceptionHolder(that, type())); } /** * Extract the ServantAlreadyActive from given Any. * * @throws BAD_OPERATION if the passed Any does not contain ServantAlreadyActive. */ public static ServantAlreadyActive extract(Any any) { try { EmptyExceptionHolder h = (EmptyExceptionHolder) any.extract_Streamable(); return (ServantAlreadyActive) h.value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION(ServantAlreadyActive expected); bad.initCause(cex); throw bad; } } /** * Get the ServantAlreadyActive repository id. * * @return IDL:omg.org/PortableServer/POA/ServantAlreadyActive:1.0, always. */ public static String id() { return IDL:omg.org/PortableServer/POA/ServantAlreadyActive:1.0; } /** * Read the exception from the CDR intput stream. * * @param input a org.omg.CORBA.portable stream to read from. */ public static ServantAlreadyActive read(InputStream input) { // Read the exception repository id. String id = input.read_string(); ServantAlreadyActive value = new ServantAlreadyActive(id); return value; } /** * Write the exception to the CDR output stream. * * @param output a org.omg.CORBA.portable stream stream to write into. * @param value a value to write. */ public static void write(OutputStream output, ServantAlreadyActive value) { // Write the exception repository id. output.write_string(id()); } }/* ServantAlreadyActive.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU
[cp-patches] FYI: New 1.4 CORBA classes.
2005-06-27 Audrius Meskauskas [EMAIL PROTECTED] org/omg/DynamicAny/DynAnyPackage/InvalidValue.java, org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java, org/omg/DynamicAny/DynAnyPackage/TypeMismatch.java, org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java, org/omg/DynamicAny/DynAnyPackage/package.html, org/omg/IOP/ComponentIdHelper.java: New files./* TypeMismatchHelper.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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., 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 conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend 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 org.omg.DynamicAny.DynAnyPackage; import gnu.CORBA.EmptyExceptionHolder; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TCKind; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; /** * The helper operations for the exception [EMAIL PROTECTED] TypeMismatch}. * * @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED]) */ public abstract class TypeMismatchHelper { /** * The cached typecode value, computed only once. */ private static TypeCode typeCode; /** * Create the TypeMismatch typecode (structure, * named TypeMismatch). */ public static TypeCode type() { if (typeCode == null) { ORB orb = ORB.init(); StructMember[] members = new StructMember[ 0 ]; typeCode = orb.create_exception_tc(id(), TypeMismatch, members); } return typeCode; } /* Every user exception with no user defined fields can use EmptyExceptionHolder */ /** * Insert the TypeMismatch into the given Any. * * @param any the Any to insert into. * @param that the TypeMismatch to insert. */ public static void insert(Any any, TypeMismatch that) { any.insert_Streamable(new EmptyExceptionHolder(that, type())); } /** * Extract the TypeMismatch from given Any. * * @throws BAD_OPERATION if the passed Any does not contain TypeMismatch. */ public static TypeMismatch extract(Any any) { try { EmptyExceptionHolder h = (EmptyExceptionHolder) any.extract_Streamable(); return (TypeMismatch) h.value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION(TypeMismatch expected); bad.initCause(cex); throw bad; } } /** * Get the TypeMismatch repository id. * * @return IDL:omg.org/DynamicAny/DynAny/TypeMismatch:1.0, always. */ public static String id() { return IDL:omg.org/DynamicAny/DynAny/TypeMismatch:1.0; } /** * Read the exception from the CDR intput stream. * * @param input a org.omg.CORBA.portable stream to read from. */ public static TypeMismatch read(InputStream input) { // Read the exception repository id. String id = input.read_string(); TypeMismatch value = new TypeMismatch(id); return value; } /** * Write the exception to the CDR output stream. * * @param output a org.omg.CORBA.portable stream stream to write into. * @param value a value to write. */ public static void write(OutputStream output, TypeMismatch value) { // Write the exception repository id. output.write_string(id()); } }/* InvalidValue.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU
Re: [cp-patches] ieeefp.h endianness detection
On Mon, 2005-06-27 at 08:31 -0600, Tom Tromey wrote: Guilhem == Guilhem Lavaux [EMAIL PROTECTED] writes: Guilhem Here is a quick patch to replace the existing magic in ieeefp.h to Guilhem detect endianness using a configure defined macro. Guilhem Comments before commit ? How does this handle ARM machines with the weird 'double' layout? Or do we not care about those any more? Tom We do care. :) So maybe I should bring back the block concerning arm. If there are other machines which behaves the same way we would have to implement something in configure though. Do you have other in mind ? or the hack which was in ieeefp.h will be sufficient ? Guilhem. ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: JComponent fixlet
JComponent.getPreferredSize lets the ComponentUI override a manually set preferredSize. This is not allowed. The priority is as follows: (0. constrained by minimumSize) 1. user set preferredSize 2. ComponentUI preferredSize 3. Container preferredSize (LayoutManager) 4. Component preferredSize This is fixed. 2005-06-27 Roman Kennke [EMAIL PROTECTED] * javax/swing/JComponent.java (getPreferredSize): Don't let the UI replace a manually set preferred size. /Roman Index: javax/swing/JComponent.java === RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v retrieving revision 1.46 diff -u -r1.46 JComponent.java --- javax/swing/JComponent.java 20 Jun 2005 14:35:53 - 1.46 +++ javax/swing/JComponent.java 27 Jun 2005 14:57:18 - @@ -1022,12 +1022,13 @@ if (preferredSize != null) prefSize = preferredSize; -if (ui != null) +else if (ui != null) { Dimension s = ui.getPreferredSize(this); if (s != null) prefSize = s; } + if (prefSize == null) prefSize = super.getPreferredSize(); // make sure that prefSize is not smaller than minSize ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: Fixlet for Box
I fixed two smaller issues in javax.swing.Box: 2005-06-27 Roman Kennke [EMAIL PROTECTED] * javax/swing/Box.java (createGlue): Return Short.MAX_VALUE instead of Integer.MAX_VALUE as dimension in the Filler component. (createHorizontalGlue): Return a new Filler object with the correct value instead of relying on createGlue(). The object returned by createHorizontalGlue must not have a vertical dimension. /Roman Index: javax/swing/Box.java === RCS file: /cvsroot/classpath/classpath/javax/swing/Box.java,v retrieving revision 1.13 diff -u -r1.13 Box.java --- javax/swing/Box.java22 Oct 2004 12:43:59 - 1.13 +++ javax/swing/Box.java27 Jun 2005 14:54:21 - @@ -192,7 +192,7 @@ public static Component createGlue() { Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0), - new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE) + new Dimension(Short.MAX_VALUE,Short.MAX_VALUE) ); return glue; } @@ -211,7 +211,10 @@ */ public static Component createHorizontalGlue() { -return createGlue(); +Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0), + new Dimension(Short.MAX_VALUE, 0) + ); +return glue; } /** ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] FYI: Fixed BoxLayout
Hi, I finally fixed the horribly broken BoxLayout. I have rewritten the layout algorithm from scratch. It is now more comprehensible and correct (I have a couple of testcases here that I commit to Mauve soon). The layout algorithm now uses an inner interface (Direction) which allows the algorithm to be abstracted from the layout direction. The new layout algorithm works as follows: - first all components are set to their preferredSizes - the remaining space (might be positiv or negativ, depending on the size of the parent container) is then distributed over the components. - this distribution is not even but depends on the minimum and maximumSizes. A component that has 'more room' (i.e. a maxSize of (1, 1)) gets a bigger share of the excess space than components that have 'less room' (i.e. a maximumSize of (100, 100)). This is what the JDK also does, AFAICS. - if the maximum/minimumSize of a component is exceeded in this distribution, then the size of the component is set to the min/max Size respectivly. The component is marked as beeing not-free (i.e. it cannot move anymore). The difference is summed up in a new remaining space for later distribution - after all space is distributed, we probably call distributeSpace recursivly, if there is new space allocated that must be distributed over the components that are still free-to-be-moved (i.e. not constrained by max/min size requirements) This is committed. 2005-06-27 Roman Kennke [EMAIL PROTECTED] * javax/swing/BoxLayout.java (Direction): New inner interface. This abstracts the layout algorithm from the layout direction. (Horizontal): Implementation for the above interface for the horizontal direction. (Vertical): Implementation for the above interface for the vertical direction. (SizeReq): An inner helper class that holds size requirements for Components that are laid out. This is similar but not equal to the SizeRequirements class in javax.swing. (layoutContainer): Removed the actual algorithm into a new method, using the Direction interface. (layoutAlgorithm): This is the new layout algorithm. This uses the Direction interface, so that the algorithm is not duplicated and can be expressed more readable. (distributeSpace): A new helper method that distributes excess space over a set of components. This is the actual 'worker' in BoxLayout. /Roman Index: javax/swing/BoxLayout.java === RCS file: /cvsroot/classpath/classpath/javax/swing/BoxLayout.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- javax/swing/BoxLayout.java 24 Jun 2005 14:39:49 - 1.12 +++ javax/swing/BoxLayout.java 27 Jun 2005 14:41:10 - 1.13 @@ -45,6 +45,9 @@ import java.awt.Insets; import java.awt.LayoutManager2; import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; +import java.util.Vector; import gnu.java.awt.AWTUtilities; @@ -52,9 +55,251 @@ * A layout for swing components. * * @author Ronald Veldema ([EMAIL PROTECTED]) + * @author Roman Kennke ([EMAIL PROTECTED]) */ public class BoxLayout implements LayoutManager2, Serializable { + + /** + * This is an abstraction that allows the BoxLayout algorithm to + * be applied to both direction (X and Y) without duplicating the + * algorithm. It defines several methods that access properties of + * a component for a specific direction. + */ + static interface Direction + { +/** + * Returns the correct part of coded/code for this direction. This will + * be coded.width/code for horizontal and coded.height/code for + * vertical direction. + * + * @param d the size as Dimension object + * + * @return the correct part of coded/code for this direction + */ +int size(Dimension d); + +/** + * Returns the lower bounds of the [EMAIL PROTECTED] Insets} object according to this + * direction. This will be codeinsets.top/code for vertical direction + * and codeinsets.left/code for horizontal direction. + * + * @param the [EMAIL PROTECTED] Insets} object from which to return the lower bounds + * + * @return the lower bounds of the [EMAIL PROTECTED] Insets} object according to this + * direction + */ +int lower(Insets insets); + +/** + * Returns the alignment property according to this direction. + * + * @param comp the Component for which to return the alignment property + * + * @return the alignment property according to this direction + */ +float alignment(Component comp); + +/** + * Sets the location for Component codec/code. codecoord1/code + * specifies the coordinate of the location in this direction, + * codecoord2/code the coordinate of the location in the opposite + *
[cp-patches] Re: [RFA/JDWP] CommandSet interface and PacketProcessor
Aaron Luchko wrote: Ok, after some discussions with Bryce and Keith I've arrived at an improved version of the patch. The first couple changes involve using an array instead of the hashtable and tossing the IOException up from _processOnePacket and exiting in run() when we get it. The final changes involve the streams used to read the command packet data and write the reply packet data. The data portion of the command packet is now wrapped in a ByteBuffer. For the reply packet however the size of the data portion is simply too variable so we had to stick with a DataInputStream, the constructors however have been moved out and the only action required between packets is a reset() call. This also adds a simple convenience constructor to JdwpReplyPacket. Comments on the new implementation? The CommandSet objects don't actually need a JdwpConnection at all so I've removed them from the where I construct the array and fixed the line length too. Aaron ChangeLog 2005-06-24 Aaron Luchko [EMAIL PROTECTED] * gnu/classpath/jdwp/processor/CommandSet.java: New file. * gnu/classpath/jdwp/processor/PacketProcessor.java: Use CommandSets to handle JdwpCommandPackets. * gnu/classpath/jdwp/transport/JdwpReplyPacket.java: New Constructor. This is OK. Thanks. Bryce ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] Re: RFC: Swing/Java2D fixes
Hi, Ziga Mahkovec a écrit : Following up my previous patch[1], this patch enables the use of BufferedImages for component double buffering. This results in much better performance and surprisingly even fixes the Pango text rendering issues. What about the Batik tests ? p.b. ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] Re: [RFA/JDWP] JdwpConnection cleanup
Keith Seitz wrote: I believe the attached patch addresses concerns over temporary OutputStream allocations. Yes, this looks better. At least by using reset() on the ByteArrayOutputStream we are eliminating one level of allocation and potential copying. Aaron managed to convince me that the ByteArrayOutputStream was better than using ByteBuffer, at least for now. However, there is still a bit too much copying going on - couldn't JdwpPacket.toBytes() write directly to the stream, instead of creating another temporary byte[]? That can be fixed in another patch, though. The changes in this patch are reflected in gnu.classpath.jdwp.event.Event submission. Comments/questions/concerns? Keith ChangeLog * gnu/classpath/jdwp/transport/JdwpConnection.java (sendPacket): Rename to ... (send): ... this. (send): New overloaded method for sending Events. I think I liked the old sendPacket() name better, but maybe thats just me :) Otherwise, this looks OK. Bryce ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches] Re: RFC: Swing/Java2D fixes
On Mon, 2005-06-27 at 21:18 +0200, Pierrick Brihaye wrote: Ziga Mahkovec a écrit : Following up my previous patch[1], this patch enables the use of BufferedImages for component double buffering. This results in much better performance and surprisingly even fixes the Pango text rendering issues. What about the Batik tests ? The Batik tests are not really affected by this change, since they already use BufferedImages and Graphics2D. This patch deals with JComponents, and their ability to use Java2D for double buffering. That said, I do plan on updating the Java2D test results with the new bindings. I'll post the results and any improvements/regressions to the classpath list. -- Ziga ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
Re: [cp-patches]: Patch: JTree related class' implementations
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wow, what a huge patch. My nitpicks: - - each author gets a separate @author tag (instead of using commas) - - null and field names in (doc-) comments should be enclosed by code - - Instead of comments like Returns true if largeModel is set try to explain what the resulting value means for the user of the class. cu Robert -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFCwJm2G9cfwmwwEtoRApcFAKCZBonW6p9koNLGCCpkEYhcIvAQUQCdFUju K7sAGiVmCu8lzQPjUD0a8uQ= =HZc6 -END PGP SIGNATURE- ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] Re: [RFA/JDWP] IdManager, Events
On Mon, 2005-06-27 at 17:03 -0400, Bryce McKinlay wrote: Please post ChangeLog entries whenever you post a patch. I've made some comments below. ChangeLog's were posted with the original patches, and their all the same * filename.java: New file. I assumed such a trivial thing would be far too silly to repost. I am incorrect, and I shall simply post links to everything next time. It seems like most JDWP events will be generated at the VM level. So, rather than implementing event filtering here, I think it would be better to pass the event filter through to the VM and have it implement filtering right at the source. This would be more efficient because the un-needed events would never be generated, instead of being created and then being discarded by the Java JDWP code. There are reasons for doing it this way, though. The biggest one is code re-use, since any VM wanting to use JDWP support will need to implement exactly the same thing. In any case, please allow me to walk through a simple example of class preparation notification to see if we can find a better solution. For class prepare events, the debugger can specify the following notification parameters: ignore count, thread, class, and class name glob (matching and not matching). Regardless of how/where filtering is performed, the VM must generate/get IDs for thread and class, compute any hit counts, and get the string representation of the class name (if it does not have that data available). That's a whole lot of work already mandated by filtering. IMO pushing filtering down into the VM is not going to provide sufficient incentive to outweigh re-usability. The only alternative solution I could devise involved looking up, e.g., the Thread when an event request comes in, storing a Soft/WeakReference to that Object and then comparing that against the Thread supplied with the event notification. I guess there is sufficient incentive to move to this, even though I had misgivings about this earlier (but it's been so long, I don't recall why). Nonetheless, none of this addresses your concerns. Perhaps a bigger piece of the puzzle might help elide a new solution? For ClassPrepareEvent, I have a notification in gcj which looks something like (pardon lots of pseudo-code): if (gnu::classpath::jdwp::Jdwp::isDebugging) { using namespace gnu::classpath::jdwp; java::lang::Thread* t = currentThread(); java::lang::Class* clazz = defining class; int flags = class preparation flags; event::ClassPrepareEvent* event = new event::ClassPrepareEvent (t, clazz, flags); Jdwp.notify (event); } Jdwp.notify actually attempts to ascertain what request from the debugger actually wanted the notification. If no registered notification exists, the event is never converted into bytes and sent. Otherwise, the request ID is returned and the event is converted to bytes and sent over the transport. I'm afraid I just don't see where any appreciable performance gain is going to be made, other than running native+JNI vs. (possibly) interpreted java. Note that WeakHashMap matches keys based on equals(), not object identity. This might not be what you want for a debugger, since two equal but different objects may be an important distinction for the user. Of course, IdentityHashMap isn't what we want either because the references won't be weak. I think that some custom data structure is needed here. Then again, perhaps this isn't so important for all cases, so I wouldn't be against this patch if you want to commit this as-is in the interim, then come back and fix it later. I don't really know. I don't recall reading anything in the JDWP specification alluding to a distinction. If worse comes to worse, we can revive and revise the ReferenceKey patch and make it work. Keith ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches