[cp-patches] FYI: ComponentSampleModel fix
This removes any usage of the Buffers helper class in ComponentSampleModel. The problem with that has been that it casts the DataBuffer to some specific subtype, which wouldn't work for other independent implementations of DataBuffer (e.g. a DataBuffer that maps to raw shared memory). Also, the SampleModels tend to support different types and thus it isn't feasible to share this behaviour. This also removes some 'optimization' that really doesn't do much, and doesn't seem to be present in the JDK either (in setDataElements() and getDataElements). This only makes the code overly complicated and I'm not sure if it's correct in all possible cases either (especially with subclasses altering some behaviour). 2007-03-09 Roman Kennke [EMAIL PROTECTED] * java/awt/image/ComponentSampleModel.java (tightPixelPacking): Removed. (ComponentSampleModel): Removed unnecessary 'optimization' code. (createDataBuffer): Avoid use of Buffers helper class. (getDataElements(int,int,int,int,Object,DataBuffer): Removed. (getDataElements(int,int,Object,DataBuffer): Do not use Buffers helper class and instead fetch the values directly. Don't expect any specific DataBuffer subclass. (setDataElements(int,int,int,int,Object,DataBuffer): Removed. (setDataElements(int,int,Object,DataBuffer): Do not use Buffers helper class and instead set the values directly. Don't expect any specific DataBuffer subclass. /Roman -- aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-0 USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe Geschäftsführer: Dr. James J. Hunt Index: java/awt/image/ComponentSampleModel.java === RCS file: /cvsroot/classpath/classpath/java/awt/image/ComponentSampleModel.java,v retrieving revision 1.16 diff -u -1 -5 -r1.16 ComponentSampleModel.java --- java/awt/image/ComponentSampleModel.java 20 Jul 2006 08:45:20 - 1.16 +++ java/awt/image/ComponentSampleModel.java 9 Mar 2007 09:41:01 - @@ -24,36 +24,32 @@ 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 java.awt.image; -import gnu.java.awt.Buffers; - import java.util.Arrays; -/* FIXME: This class does not yet support data type TYPE_SHORT */ - /** * ComponentSampleModel supports a flexible organization of pixel samples in * memory, permitting pixel samples to be interleaved by band, by scanline, * and by pixel. * * A DataBuffer for this sample model has K banks of data. Pixels have N * samples, so there are N bands in the DataBuffer. Each band is completely * contained in one bank of data, but a bank may contain more than one band. * Each pixel sample is stored in a single data element. * * Within a bank, each band begins at an offset stored in bandOffsets. The * banks containing the band is given by bankIndices. Within the bank, there * are three dimensions - band, pixel, and scanline. The dimension ordering * is controlled by bandOffset, pixelStride, and scanlineStride, which means * that any combination of interleavings is supported. @@ -76,33 +72,31 @@ /** Used when creating data buffers. */ protected int numBanks; /** * The number of data elements between a sample in one row and the * corresponding sample in the next row. */ protected int scanlineStride; /** * The number of data elements between a sample for one pixel and the * corresponding sample for the next pixel in the same row. */ protected int pixelStride; - - private boolean tightPixelPacking = false; - + /** * Creates a new sample model that assumes that all bands are stored in a * single bank of the [EMAIL PROTECTED] DataBuffer}. * p * Note that the codebandOffsets/code array is copied to internal storage * to prevent subsequent changes to the array from affecting this object. * * @param dataType the data type (one of [EMAIL PROTECTED] DataBuffer#TYPE_BYTE}, * [EMAIL PROTECTED] DataBuffer#TYPE_USHORT}, [EMAIL PROTECTED] DataBuffer#TYPE_SHORT}, * [EMAIL PROTECTED] DataBuffer#TYPE_INT}, [EMAIL PROTECTED]
[cp-patches] FYI: SinglePixelPackedSampleModel
This removes one usage of the Buffers class from SinglePixelPackedSampleModel (the Buffers class covers more than is supported by the SPPSM). 2007-03-09 Roman Kennke [EMAIL PROTECTED] * java/awt/image/SinglePixelPackageSampleModel.java (createDataBuffer): Avoid use of Buffers class and create DataBuffer directly in place. /Roman -- aicas Allerton Interworks Computer Automated Systems GmbH Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany http://www.aicas.com * Tel: +49-721-663 968-0 USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe Geschäftsführer: Dr. James J. Hunt Index: java/awt/image/SinglePixelPackedSampleModel.java === RCS file: /cvsroot/classpath/classpath/java/awt/image/SinglePixelPackedSampleModel.java,v retrieving revision 1.16 diff -u -1 -5 -r1.16 SinglePixelPackedSampleModel.java --- java/awt/image/SinglePixelPackedSampleModel.java 10 Feb 2007 13:17:36 - 1.16 +++ java/awt/image/SinglePixelPackedSampleModel.java 9 Mar 2007 10:17:26 - @@ -27,31 +27,30 @@ 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 java.awt.image; import java.util.Arrays; import gnu.java.awt.BitMaskExtent; -import gnu.java.awt.Buffers; /** * A codeSampleModel/code used when all samples are stored in a single * data element in the [EMAIL PROTECTED] DataBuffer}, and each data element contains * samples for one pixel only. * * @author Rolf W. Rasmussen ([EMAIL PROTECTED]) */ public class SinglePixelPackedSampleModel extends SampleModel { private int scanlineStride; private int[] bitMasks; private int[] bitOffsets; private int[] sampleSize; @@ -139,38 +138,49 @@ sizes here by passing these from the current instance to a special private constructor. */ return new SinglePixelPackedSampleModel(dataType, w, h, bitMasks); } /** * Creates a DataBuffer for holding pixel data in the format and * layout described by this SampleModel. The returned buffer will * consist of one single bank. * * @return The data buffer. */ public DataBuffer createDataBuffer() { -int size; - // We can save (scanlineStride - width) pixels at the very end of // the buffer. The Sun reference implementation (J2SE 1.3.1 and // 1.4.1_01) seems to do this; tested with Mauve test code. -size = scanlineStride * (height - 1) + width; +int size = scanlineStride * (height - 1) + width; -return Buffers.createBuffer(getDataType(), size); +DataBuffer buffer = null; +switch (getTransferType()) + { + case DataBuffer.TYPE_BYTE: +buffer = new DataBufferByte(size); +break; + case DataBuffer.TYPE_USHORT: +buffer = new DataBufferUShort(size); +break; + case DataBuffer.TYPE_INT: +buffer = new DataBufferInt(size); +break; + } +return buffer; } /** * Returns an array containing the size (in bits) for each band accessed by * the codeSampleModel/code. * * @return An array. * * @see #getSampleSize(int) */ public int[] getSampleSize() { return (int[]) sampleSize.clone(); }
Re: [cp-patches] java.nio.charset.CharsetEncoder fixlet
Tom Tromey wrote: Marco == Marco Trudel [EMAIL PROTECTED] writes: Marco The attached CharsetEncoderTest.java fails on Windows with an Marco IllegalStateException. It works on Linux. I don't know why, but I Marco assume because it doesn't need a CharsetEncoder. Yeah, I think the Linux code may take a different path on this particular test case. But, I do see a similar bug here on Linux with Mauve. Can you send me that test? I can't reproduce it on Linux... Marco The problem is that this sequence will be called: Marco 1. encode (CharBuffer in, ByteBuffer out,boolean endOfInput = true) Marco - state will be STATE_END Marco 2. flush (ByteBuffer out) Marco - state will be STATE_FLUSHED what is basically the same as STATE_END Marco 3. encode (CharBuffer in, ByteBuffer out,boolean endOfInput = true) According to the JDK javadoc, this sequence is invalid. The last call to encode must come before flush. So, I think we have to fix the caller instead. Yeah, makes sense. Will do. Marco
[cp-patches] Guidelines for annotations?
Hi, The Classpath Hacker's Guide doesn't mention anything about annotations. Doing a quick grep of the sources, I see that, e.g., the @Override annotation is being handled in several different ways: @Override public void foo(); @Override public void foo(); public @Override void foo(); Do we have a standard? Keith
Re: [cp-patches] Guidelines for annotations?
Il giorno ven, 09/03/2007 alle 10.35 -0800, Keith Seitz ha scritto: @Override public void foo(); I suggest this one. It seems more clear to me. Ciao, Mario -- Lima Software - http://www.limasoftware.net/ GNU Classpath Developer - http://www.classpath.org/ Jabber: [EMAIL PROTECTED] - Profile: http://www.gtalkprofile.com/profile/9661.html pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF Please, support open standards: http://opendocumentfellowship.org/petition/ http://www.nosoftwarepatents.com/ signature.asc Description: Questa è una parte del messaggio firmata digitalmente
Re: [cp-patches] Guidelines for annotations?
Mario Torre writes: Il giorno ven, 09/03/2007 alle 10.35 -0800, Keith Seitz ha scritto: @Override public void foo(); I suggest this one. It seems more clear to me. +1 Andrew.
Re: [cp-patches] java.nio.charset.CharsetEncoder fixlet
Marco == Marco Trudel [EMAIL PROTECTED] writes: Yeah, I think the Linux code may take a different path on this particular test case. But, I do see a similar bug here on Linux with Mauve. Marco Can you send me that test? I can't reproduce it on Linux... It is the String.getBytes13 test from Mauve. I think it may be a bug in our CharsetToBytesAdaptor. It fails like: FAIL: java.lang.String.getBytes13 line 60: String.getBytes(UTF-16) [1] -- boolean passed to check was false line 60: String.getBytes(UnicodeBig) [1] -- boolean passed to check was false line 58: String.getBytes(UnicodeBig) [2] -- uncaught exception: java.lang.IllegalStateException at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:204) at gnu.gcj.convert.CharsetToBytesAdaptor.write(CharsetToBytesAdaptor.java:121) at gnu.gcj.convert.CharsetToBytesAdaptor.write(CharsetToBytesAdaptor.java:90) at gnu.gcj.convert.UnicodeToBytes.write(UnicodeToBytes.java:161) at java.lang.String.getBytes(libgcj.so.9) at gnu.testlet.java.lang.String.getBytes13.test1Encoding(getBytes13.java:58) at gnu.testlet.java.lang.String.getBytes13.test(getBytes13.java:46) at RunnerProcess.runtest(RunnerProcess.java:360) at RunnerProcess.runAndReport(RunnerProcess.java:415) at RunnerProcess.main(RunnerProcess.java:227) Tom
Re: [cp-patches] Guidelines for annotations?
Mario == Mario Torre [EMAIL PROTECTED] writes: @Override public void foo(); Mario I suggest this one. It seems more clear to me. Me too. Three votes... maybe the motion passes? :) FWIW you won't see too many annotations in the source right now, especially not @Override. I think it would be fine to add them though. Tom
Re: [cp-patches] Guidelines for annotations?
On Fri, Mar 09, 2007 at 08:25:37PM +0100, Mario Torre wrote: Il giorno ven, 09/03/2007 alle 10.35 -0800, Keith Seitz ha scritto: @Override public void foo(); I suggest this one. It seems more clear to me. +1 Cheers, Michael -- .''`. | Michael Koch [EMAIL PROTECTED] : :' : | Free Java Developer http://www.classpath.org `. `' | `-| 1024D/BAC5 4B28 D436 95E6 F2E0 BD11 5923 A008 2763 483B
Re: [cp-patches] Guidelines for annotations?
Tom Tromey wrote: Mario == Mario Torre [EMAIL PROTECTED] writes: @Override public void foo(); Me too. Three votes... maybe the motion passes? :) So that's several votes for this style already. One last question: what about comments/javadoc? 1) Before @Override /** * foo */ 2) After /** * foo */ @Override I presume most people would prefer #1? Keith
Re: [cp-patches] Guidelines for annotations?
On Fri, Mar 09, 2007 at 12:05:42PM -0800, Keith Seitz wrote: Tom Tromey wrote: Mario == Mario Torre [EMAIL PROTECTED] writes: @Override public void foo(); Me too. Three votes... maybe the motion passes? :) So that's several votes for this style already. One last question: what about comments/javadoc? 1) Before @Override /** * foo */ 2) After /** * foo */ @Override I presume most people would prefer #1? +1 for 2. Michael -- .''`. | Michael Koch [EMAIL PROTECTED] : :' : | Free Java Developer http://www.classpath.org `. `' | `-| 1024D/BAC5 4B28 D436 95E6 F2E0 BD11 5923 A008 2763 483B
Re: [cp-patches] Guidelines for annotations?
Il giorno ven, 09/03/2007 alle 12.05 -0800, Keith Seitz ha scritto: 2) After /** * foo */ @Override I presume most people would prefer #1? Keith I speak for myself, but I think most of us agree here, doing #1 would make things to lost easily, for example in case of longs comments. It looks like it is a natural place to put the annotation right before the method declaration (after the comments: #2) Mario -- Lima Software - http://www.limasoftware.net/ GNU Classpath Developer - http://www.classpath.org/ Jabber: [EMAIL PROTECTED] - Profile: http://www.gtalkprofile.com/profile/9661.html pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF Please, support open standards: http://opendocumentfellowship.org/petition/ http://www.nosoftwarepatents.com/ signature.asc Description: Questa è una parte del messaggio firmata digitalmente
Re: [cp-patches] Guidelines for annotations?
@Override public void foo(); Me too. Three votes... maybe the motion passes? :) So that's several votes for this style already. +1, FWIW 2) After /** * foo */ @Override +1 for annotations after javadoc, it feels clearer that way. Francis
Re: [cp-patches] Guidelines for annotations?
On Fri, 2007-03-09 at 15:17 -0500, Francis Kung wrote: @Override public void foo(); Me too. Three votes... maybe the motion passes? :) So that's several votes for this style already. +1, FWIW 2) After /** * foo */ @Override +1 for annotations after javadoc, it feels clearer that way. Francis Agreed.
Re: [cp-patches] Guidelines for annotations?
Mario Torre wrote: Il giorno ven, 09/03/2007 alle 12.05 -0800, Keith Seitz ha scritto: 2) After /** * foo */ @Override I presume most people would prefer #1? Keith I speak for myself, but I think most of us agree here, doing #1 would make things to lost easily, for example in case of longs comments. It looks like it is a natural place to put the annotation right before the method declaration (after the comments: #2) [cough] I actually did mean #2 (annotation after javadoc). I reworded my message and flipped the numbers around. Okay, so there seems to be universal agreement on that. All we need now is for Mark to chime in and disagree. :-) Thanks all! Keith
Re: [cp-patches] [RFA] Fix JDWP Values
[my apologies for the delay in getting back to you] Kyle Galloway wrote: Keith Seitz wrote: I see that this method can throw InvalidObjectException if the object ID is not known by the ID manager. How is JdwpInternalErrorException thrown? This gets thrown by JdwpString.readString(). Ah... Missed that. I see what your saying, and I gave it some thought, but there is a big difference between having the value already packaged in an object and having to take it out of the byte buffer. If I were to make a common method, I would first have to go through like this is the ByteBuffer case: if (it's an int) new Integer(bb.getInt) else if (it's a float) new Float (bb.getFloat) etc... which is just as much wasted code space, so I think keeping the object as a special case is the best bet. Hmm. Yeah. I guess I was hoping generics would help here, but it doesn't really. Oh, well, never mind that. I have attached a new patch. Okay, you saw this coming... :-) + @Override + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + protected Object getObject() + { +return new Integer(_value); + } The consensus appears to be to put the annotation just before the method declaration/after the javadoc. Index: gnu/classpath/jdwp/value/ValueFactory.java === RCS file: gnu/classpath/jdwp/value/ValueFactory.java diff -N gnu/classpath/jdwp/value/ValueFactory.java --- /dev/null 1 Jan 1970 00:00:00 - +++ gnu/classpath/jdwp/value/ValueFactory.java 1 Jan 1970 00:00:00 - + public static Value createFromTagged(ByteBuffer bb) +throws JdwpInternalErrorException, InvalidObjectException + { +return create(bb, bb.get()); + } A little (useless?) paranoia here. Perhaps this method should throw JdwpException, just in case the tag is invalid? + private static Value create(ByteBuffer bb, byte tag) +throws JdwpInternalErrorException, InvalidObjectException + { +Value val = null; +switch(tag) +{ [snip] I think we should add a default case an throw InvalidTagException (which doesn't exist yet). Index: gnu/classpath/jdwp/value/Value.java === RCS file: gnu/classpath/jdwp/value/Value.java diff -N gnu/classpath/jdwp/value/Value.java --- /dev/null 1 Jan 1970 00:00:00 - +++ gnu/classpath/jdwp/value/Value.java 1 Jan 1970 00:00:00 - + /** + * Return an object representing this type Returns + /** + * Get an untageed object from the ByteBuffer untagged + /** + * Get an untageed object from the ByteBuffer untagged With the above changes, please commit. Keith
Re: [cp-patches] [RFA] Fix JDWP Values
Keith Seitz wrote: [my apologies for the delay in getting back to you] Kyle Galloway wrote: Keith Seitz wrote: I see that this method can throw InvalidObjectException if the object ID is not known by the ID manager. How is JdwpInternalErrorException thrown? This gets thrown by JdwpString.readString(). Ah... Missed that. I see what your saying, and I gave it some thought, but there is a big difference between having the value already packaged in an object and having to take it out of the byte buffer. If I were to make a common method, I would first have to go through like this is the ByteBuffer case: if (it's an int) new Integer(bb.getInt) else if (it's a float) new Float (bb.getFloat) etc... which is just as much wasted code space, so I think keeping the object as a special case is the best bet. Hmm. Yeah. I guess I was hoping generics would help here, but it doesn't really. Oh, well, never mind that. I have attached a new patch. Okay, you saw this coming... :-) + @Override + /** + * Return an object representing this type + * + * @return an Object represntation of this value + */ + protected Object getObject() + { +return new Integer(_value); + } The consensus appears to be to put the annotation just before the method declaration/after the javadoc. Index: gnu/classpath/jdwp/value/ValueFactory.java === RCS file: gnu/classpath/jdwp/value/ValueFactory.java diff -N gnu/classpath/jdwp/value/ValueFactory.java --- /dev/null1 Jan 1970 00:00:00 - +++ gnu/classpath/jdwp/value/ValueFactory.java1 Jan 1970 00:00:00 - + public static Value createFromTagged(ByteBuffer bb) +throws JdwpInternalErrorException, InvalidObjectException + { +return create(bb, bb.get()); + } A little (useless?) paranoia here. Perhaps this method should throw JdwpException, just in case the tag is invalid? + private static Value create(ByteBuffer bb, byte tag) +throws JdwpInternalErrorException, InvalidObjectException + { +Value val = null; +switch(tag) +{ [snip] I think we should add a default case an throw InvalidTagException (which doesn't exist yet). Index: gnu/classpath/jdwp/value/Value.java === RCS file: gnu/classpath/jdwp/value/Value.java diff -N gnu/classpath/jdwp/value/Value.java --- /dev/null1 Jan 1970 00:00:00 - +++ gnu/classpath/jdwp/value/Value.java1 Jan 1970 00:00:00 - + /** + * Return an object representing this type Returns + /** + * Get an untageed object from the ByteBuffer untagged + /** + * Get an untageed object from the ByteBuffer untagged With the above changes, please commit. Done and done. Thanks, Kyle
[cp-patches] [patch] forward gcj/classpath/doc patch
Hi all, I'm going to commit this one soon. It is a change which is already in gcc. Fails w/o patch under darwin-ppc. Andreas 2007-03-09 Andreas Tobler [EMAIL PROTECTED] Port change from gcc: 2007-03-06 Matthias Klose [EMAIL PROTECTED] * doc/Makefile.am(gkeytool.pod): Don't use sed -i. Index: doc/Makefile.am === RCS file: /cvsroot/classpath/classpath/doc/Makefile.am,v retrieving revision 1.8 diff -u -r1.8 Makefile.am --- doc/Makefile.am 19 Feb 2007 22:16:32 - 1.8 +++ doc/Makefile.am 9 Mar 2007 21:29:38 - @@ -54,10 +54,10 @@ # hack around the cross references and the enumeration gkeytool.pod: $(srcdir)/cp-tools.texinfo - -$(TEXI2POD) -D gkeytool $ $@ - sed -i -e 's/^For more details.*/See ICommon Options for more details./' \ + -$(TEXI2POD) -D gkeytool $ \ + | sed -e 's/^For more details.*/See ICommon Options for more details./' \ -e 's/1\.\([^]*\)/- \1/' \ - $@ +$@ gnative2ascii.pod: $(srcdir)/cp-tools.texinfo -$(TEXI2POD) -D gnative2ascii $ $@