Re: [cp-patches] FYI: Key factories, parameters and parameters generators
Hi Raif, On Fri, 2006-02-24 at 00:23 +1100, Raif S. Naffah wrote: this pacth --already committed-- adds more JCE classes as described above. it also refactors some code into a new utility class, and finally fixes some bugs which were discovered while implementing and using some new Mauve tests (see below). 2006-02-23 Raif S. Naffah [EMAIL PROTECTED] * gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java (DEFAULT_PRIME_SIZE): Made public. (DEFAULT_EXPONENT_SIZE): Likewise. (setup): Handle DHParameterSpec as well. * gnu/javax/crypto/key/dh/GnuDHKey.java (getEncoded): Return defaultFormat instead of Raw. * gnu/javax/crypto/key/dh/DHKeyPairX509Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodePublicKey): Use DerUtil. * gnu/javax/crypto/key/dh/DHKeyPairPKCS8Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodePrivateKey): Use DerUtil. * gnu/javax/crypto/jce/GnuCrypto.java (run): Updated mapping of KeyAgreement.DH. Added mappings for AlgorithmParameters.DH and AlgorithmParameterGenerator.DH. * gnu/javax/crypto/jce/DiffieHellmanImpl.java: New file. * gnu/javax/crypto/jce/sig/DHParametersGenerator.java: Likewise. * gnu/javax/crypto/jce/sig/DHParameters.java: Likewise. * gnu/javax/crypto/jce/sig/DHKeyFactory.java (engineGeneratePrivate): Return result. (engineGeneratePublic): Likewise. * gnu/java/security/util/DerUtil.java: New file. * gnu/java/security/sig/rsa/RSASignatureFactory.java (getNames): Include only valid RSA PKCS1 (v1.5) signature names. * gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureX509Codec.java (RSAPKCS1V1_5SignatureX509Codec): Removed. (checkIsConstructed): Likewise. * gnu/java/security/sig/dss/DSSSignatureX509Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodeSignature): Use DerUtil. * gnu/java/security/key/rsa/RSAKeyPairX509Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodePublicKey): Use DerUtil. * gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodePrivateKey): Use DerUtil. * gnu/java/security/key/dss/DSSKeyPairX509Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodePublicKey): Use DerUtil. * gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java (checkIsConstructed): Removed. (checkIsBigInteger): Likewise. (decodePrivateKey): Use DerUtil. * gnu/java/security/key/dss/DSSKeyPairGenerator.java (DEFAULT_MODULUS_LENGTH): Made it public. * gnu/java/security/key/dss/DSSKey.java (getEncoded): Return defaultFormat instead of Raw. * gnu/java/security/jce/sig/DSSParametersGenerator.java: New file. * gnu/java/security/jce/sig/DSSParameters.java: Likewise.. * gnu/java/security/jce/sig/DSSKeyFactory.java (engineGeneratePrivate): Return result. (engineGeneratePublic): Likewise. * gnu/javax/crypto/DiffieHellmanImpl: Removed. It looks like this patch broke https support for me. The following little program gives an error now: import java.io.*; import java.net.*; public class HTTPS { public static void main(String[] args) throws Exception { URL u = new URL(https://www.paypal.com/;); InputStream in = u.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } } } javax.net.ssl.SSLPeerUnverifiedException: could not verify peer certificate: C=US,ST=California,L=Mountain View,O=Paypal Inc.,OU=Information Systems,OU=Terms of use at www.verisign.com/rpa (c)00,CN=www.paypal.com at gnu.javax.net.ssl.provider.SSLSocket.doClientHandshake (SSLSocket.java:1559) [...] Caused by: java.security.InvalidParameterException: Wrong signature field at gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec.decodeSignature (RSAPKCS1V1_5SignatureX509Codec.java:144) at gnu.java.security.jce.sig.SignatureAdapter.engineVerify (SignatureAdapter.java:226) [...] Apparently because RSAPKCS1V1_5SignatureX509Codec expects DERValue.getValue() to return a BitString. Cheers, Mark signature.asc Description: This is a digitally signed message part
Re: [cp-patches] [generics] some BigDecimal fixes and new methods
On Mon, 2006-02-27 at 16:36 -0500, Anthony Balkissoon wrote: More stuff. Sorry for not sending this BigDecimal stuff all at once but my test cases are small and I prefer to get the stuff committed once its been tested. Also helps me use JAPI to determine what needs to be done. 2006-02-27 Anthony Balkissoon [EMAIL PROTECTED] * java/math/BigDecimal.java: Replaced occurences of BigInteger.valueOf with BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN where appropriate. (add(BigDecimal, MathContext)): New method. (subtract(BigDecimal, MathContext)): Likewise. (precision): Fixed to correctly handle BigIntegers with more than 19 digits. (pow(int, MathContext)): New method. --Tony I'd say these things tend to be better in smaller chunks; people then get their hands on them more quickly too. -- Andrew :-) Department of Computer Science University of Sheffield Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments. See http://www.fsf.org/philosophy/no-word-attachments.html Support OpenDocument instead. http://opendocumentfellowship.org Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... } 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 The views expressed above are representative of my own personal opinions, and not necessarily those of the University of Sheffield.
Re: [cp-patches] FYI: Key factories, parameters and parameters generators
hello Mark, On Tuesday 28 February 2006 19:25, Mark Wielaard wrote: On Fri, 2006-02-24 at 00:23 +1100, Raif S. Naffah wrote: this pacth --already committed... It looks like this patch broke https support for me. The following little program gives an error now: import java.io.*; import java.net.*; public class HTTPS { public static void main(String[] args) throws Exception { URL u = new URL(https://www.paypal.com/;); InputStream in = u.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } } } javax.net.ssl.SSLPeerUnverifiedException: could not verify peer certificate: C=US,ST=California,L=Mountain View,O=Paypal Inc.,OU=Information Systems,OU=Terms of use at www.verisign.com/rpa (c)00,CN=www.paypal.com at gnu.javax.net.ssl.provider.SSLSocket.doClientHandshake (SSLSocket.java:1559) [...] Caused by: java.security.InvalidParameterException: Wrong signature field at gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec.decodeSignat ure (RSAPKCS1V1_5SignatureX509Codec.java:144) at gnu.java.security.jce.sig.SignatureAdapter.engineVerify (SignatureAdapter.java:226) [...] Apparently because RSAPKCS1V1_5SignatureX509Codec expects DERValue.getValue() to return a BitString. Cheers, Mark i'm working on a fix. if it's going to take too long (more than 48 hours) i'll let you know so we can then decide if we should revert it. cheers; rsn pgp3u9PWR8Joc.pgp Description: PGP signature
Re: [cp-patches] [generics] some BigDecimal fixes and new methods
On Mon, 2006-02-27 at 16:36 -0500, Anthony Balkissoon wrote: More stuff. Sorry for not sending this BigDecimal stuff all at once but my test cases are small and I prefer to get the stuff committed once its been tested. Also helps me use JAPI to determine what needs to be done. 2006-02-27 Anthony Balkissoon [EMAIL PROTECTED] * java/math/BigDecimal.java: Replaced occurences of BigInteger.valueOf with BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN where appropriate. (add(BigDecimal, MathContext)): New method. (subtract(BigDecimal, MathContext)): Likewise. (precision): Fixed to correctly handle BigIntegers with more than 19 digits. (pow(int, MathContext)): New method. --Tony I'd say these things tend to be better in smaller chunks; people then get their hands on them more quickly too. -- Andrew :-) Department of Computer Science University of Sheffield Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments. See http://www.fsf.org/philosophy/no-word-attachments.html Support OpenDocument instead. http://opendocumentfellowship.org Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... } 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 The views expressed above are representative of my own personal opinions, and not necessarily those of the University of Sheffield. -- Andrew :-) Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments. See http://www.fsf.org/philosophy/no-word-attachments.html If you use Microsoft Office, support movement towards the end of vendor lock-in: http://opendocumentfellowship.org/petition/ 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 { ... }
[cp-patches] FYI: More LightweightDispatcher work
I have an application here that subverts the EventQueue.dispatchEvent method by fetching the events directly from EventQueue.getNextEvent() and then sending it to Component.dispatchEvent(). Still, it expects that lightweight events get delivered correctly. So I have to call the LightweightDispatcher from Container.dispatchEventImpl (like it was before). However, we still don't need one LightweightDispatcher for each container. I implemented the LightweightDispatcher so that we have one instance per ThreadGroup (like we do with the RepaintManager). This makes sense for applets and otherwise separated applications (OSGI?), so that multiple apps within one VM don't interfere with each other. Then I changed the global event dispatching so that it is triggered from Component.dispatchEventImpl for the same reason as stated above. And I had to add a little tweak to the LightweightDispatcher so that MOUSE_CLICK events are guaranteed to be sent to the same component that received the last MOUSE_RELEASED. The problem here is that when the MOUSE_RELEASED causes some component to disappear (like closing an internal frame), then the MOUSE_CLICKED is mistakenly sent to the component under the disappeared component, which can have _really_ strange effects (in my app here it caused the internal frame to re-popup making it impossible to actually close the frame). 2006-02-28 Roman Kennke [EMAIL PROTECTED] * java/awt/Component.java (dispatchEventImpl): Let the Toolkit dispatch global events. * java/awt/Container.java (dispatchEventImpl): Let the LightweightDispatcher handle events first. * java/awt/EventQueue.java (dispatchEvent): Don't do the global event dispatching here. This is moved to the Component. (globalDispatchEvent): Moved this method to Toolkit. * java/awt/LightweightDispatcher.java (instances): New field. (getInstance): New method. Delivers an instance of LightweightDispatcher. (LightweightDispatcher): Made default constructor private. (dispatchEvent): New method. Replaces the eventDispatched method. This now returns true when the event was actually dispatched. (eventDispatched): Replaced by dispatchEvent. (handleMouseEvent): Send MOUSE_CLICKED to the same component that received the last MOUSE_RELEASED. * java/awt/Toolkit.java (Toolkit): Don't register LightweightDispatcher as global event handler. (globalDispatchEvent): Moved here from EventQueue. /Roman Index: java/awt/Component.java === RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v retrieving revision 1.103 diff -u -r1.103 Component.java --- java/awt/Component.java 24 Feb 2006 18:41:54 - 1.103 +++ java/awt/Component.java 28 Feb 2006 11:26:30 - @@ -4921,6 +4921,10 @@ void dispatchEventImpl(AWTEvent e) { +// Give toolkit a chance to dispatch the event +// to globally registered listeners. +Toolkit.getDefaultToolkit().globalDispatchEvent(e); + // This boolean tells us not to process focus events when the focus // opposite component is the same as the focus component. boolean ignoreFocus = Index: java/awt/Container.java === RCS file: /cvsroot/classpath/classpath/java/awt/Container.java,v retrieving revision 1.82 diff -u -r1.82 Container.java --- java/awt/Container.java 24 Feb 2006 20:31:37 - 1.82 +++ java/awt/Container.java 28 Feb 2006 11:26:31 - @@ -1711,13 +1711,18 @@ void dispatchEventImpl(AWTEvent e) { -if ((e.id = ContainerEvent.CONTAINER_LAST - e.id = ContainerEvent.CONTAINER_FIRST) - (containerListener != null -|| (eventMask AWTEvent.CONTAINER_EVENT_MASK) != 0)) - processEvent(e); -else - super.dispatchEventImpl(e); +boolean dispatched = + LightweightDispatcher.getInstance().dispatchEvent(e); +if (! dispatched) + { +if ((e.id = ContainerEvent.CONTAINER_LAST + e.id = ContainerEvent.CONTAINER_FIRST) + (containerListener != null +|| (eventMask AWTEvent.CONTAINER_EVENT_MASK) != 0)) + processEvent(e); +else + super.dispatchEventImpl(e); + } } /** Index: java/awt/EventQueue.java === RCS file: /cvsroot/classpath/classpath/java/awt/EventQueue.java,v retrieving revision 1.27 diff -u -r1.27 EventQueue.java --- java/awt/EventQueue.java 23 Feb 2006 23:43:51 - 1.27 +++ java/awt/EventQueue.java 28 Feb 2006 11:26:31 - @@ -38,7 +38,6 @@ package java.awt; -import java.awt.event.AWTEventListenerProxy; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.InputMethodEvent; @@ -460,8 +459,6 @@ else if (evt
Re: [cp-patches] RFC: adjust textarea size automatically
Hi, thanks for spotting this. I fixed that. cya Robert Anthony Balkissoon wrote: On Wed, 2006-02-22 at 12:34 +0100, Robert Schuster wrote: 2006-02-22 Robert Schuster [EMAIL PROTECTED] * javax/swing/text/PlainDocument.java: (getPreferredSpan): Added missing 'break'. statement which corrects an unwanted fall through. (updateDamage): Update maxLineLength correctly when text is removed, call preferenceChanged accordingly. (viewToModel): Restrict line number to be within 0 and the number of elements-1. The ChangeLog says PlainDocument but the patch looks like it's for PlainView. --Tony signature.asc Description: OpenPGP digital signature
[cp-patches] FYI: Fix for problem reported by Mark Wielaard, re HTTPS
hello all, the attached patch --already committed-- fixes the problem reported by MW re broken HTTPS connection with new crypto classes. 2006-03-01 Raif S. Naffah [EMAIL PROTECTED] * gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureX509Codec.java: Amended class documentation. (encodeSignature): Emit the ASN.1 raw bytes not the DER-encoded BIT STRING. (decodeSignature): Parse the ASN.1 raw bytes of a BIT STRING and not a BIT STRING construct. * gnu/java/security/sig/dss/DSSSignatureX509Codec.java: Amended class documentation. (encodeSignature): Emit the ASN.1 raw bytes not the DER-encoded BIT STRING. (decodeSignature): Parse the ASN.1 raw bytes of a BIT STRING and not a BIT STRING construct. * gnu/java/security/jce/sig/SignatureAdapter.java (log): New field. (engineVerify): Added logging. i will be checking soon an additional Mauve test (TestOfHttps) to test/verify this fix. all other Mauve (crypto) tests should continue to pass. cheers; rsn Index: SignatureAdapter.java === RCS file: /cvsroot/classpath/classpath/gnu/java/security/jce/sig/SignatureAdapter.java,v retrieving revision 1.1 diff -u -r1.1 SignatureAdapter.java --- SignatureAdapter.java 26 Jan 2006 02:25:10 - 1.1 +++ SignatureAdapter.java 28 Feb 2006 13:26:44 - @@ -53,6 +53,7 @@ import java.security.SignatureSpi; import java.security.spec.AlgorithmParameterSpec; import java.util.HashMap; +import java.util.logging.Logger; /** * The implementation of a generic [EMAIL PROTECTED] java.security.Signature} adapter class @@ -73,6 +74,7 @@ */ class SignatureAdapter extends SignatureSpi implements Cloneable { + private static final Logger log = Logger.getLogger(SignatureAdapter.class.getName()); // Constants and variables // - @@ -223,6 +225,8 @@ public boolean engineVerify(byte[] sigBytes) throws SignatureException { +log.entering(SignatureAdapter, engineVerify); + Object signature = codec.decodeSignature(sigBytes); boolean result = false; try @@ -234,6 +238,7 @@ throw new SignatureException(String.valueOf(x)); } +log.exiting(SignatureAdapter, engineVerify, new Boolean(result)); return result; } Index: DSSSignatureX509Codec.java === RCS file: /cvsroot/classpath/classpath/gnu/java/security/sig/dss/DSSSignatureX509Codec.java,v retrieving revision 1.2 diff -u -r1.2 DSSSignatureX509Codec.java --- DSSSignatureX509Codec.java 23 Feb 2006 12:54:46 - 1.2 +++ DSSSignatureX509Codec.java 28 Feb 2006 13:34:01 - @@ -39,7 +39,6 @@ package gnu.java.security.sig.dss; import gnu.java.security.Registry; -import gnu.java.security.der.BitString; import gnu.java.security.der.DER; import gnu.java.security.der.DERReader; import gnu.java.security.der.DERValue; @@ -55,8 +54,9 @@ /** * An implementation of an [EMAIL PROTECTED] ISignatureCodec} that knows to encode and - * decode DSS signatures into the DER-encoded form of the ASN.1 structure - * defined in RFC-2459 as described in the next paragraphs. + * decode DSS signatures into the raw bytes which would constitute a DER-encoded + * form of the ASN.1 structure defined in RFC-2459, and RFC-2313 as described in + * the next paragraphs. * p * Digital signatures when transmitted in an X.509 certificates are encoded * in DER (Distinguished Encoding Rules) as a BIT STRING; i.e. @@ -70,7 +70,8 @@ * /pre * p * The output of the encoder, and the input of the decoder, of this codec are - * then the bytes of such a BIT STRING. + * then the iraw/i bytes of such a BIT STRING; i.e. not the DER-encoded + * form itself. * p * RFC-2459 states that, for the Digital Signature Standard (DSS), which * generates two MPIs, commonly called coder/code and codes/code, as the @@ -83,6 +84,19 @@ * s INTEGER * } * /pre + * p + * Client code that needs to build a DER BIT STRING bMUST/b construct such + * an ASN.1 value. The following is an example of how to do this: + * p + * pre + * ... + * import gnu.java.security.der.BitString; + * import gnu.java.security.der.DER; + * import gnu.java.security.der.DERValue; + * ... + * DERValue bitString = new DERValue(DER.BIT_STRING, new BitString(sigBytes)); + * ... + * /pre */ public class DSSSignatureX509Codec implements ISignatureCodec @@ -95,15 +109,17 @@ } /** - * Encodes a DSS Signature output as a isignature/i BIT STRING as defined - * in the documentation of this class. + * Encodes a DSS Signature output as the isignature/i raw bytes which can + * be used to construct an ASN.1 DER-encoded BIT STRING as defined in the + * documentation of this class. * * @param signature the output of the DSS signature algorithm; i.e. the value *
[cp-patches] FYI: Simple 1-liner log record formatter
hello all, the following patch --already committed-- adds a new 1-line log-record formatter to the gnu.classpath.debug logging-related package. 2006-03-01 Raif S. Naffah [EMAIL PROTECTED] * gnu/classpath/debug/Simple1LineFormatter.java: New file. cheers; rsn Index: Simple1LineFormatter.java === RCS file: Simple1LineFormatter.java diff -N Simple1LineFormatter.java --- /dev/null 1 Jan 1970 00:00:00 - +++ Simple1LineFormatter.java 1 Jan 1970 00:00:00 - @@ -0,0 +1,153 @@ +/* Simple1LineFormatter.java -- A simple 1-line logging formatter + Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 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 gnu.classpath.debug; + +import gnu.classpath.SystemProperties; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; + +/** + * A simple 1-line formatter to use instead of the 2-line SimpleFormatter used + * by default in the JDK logging handlers. + * p + * The fixed format of this formatter is as follows: + * p + * ol + * liDate: As a -MM-dd string./li + * liTime: As a HH:mm:ss. Z string./li + * liThread identifier, right-justified, and framed in an 11-digit field./li + * liClass name, without its package name, left-justified, and framed in a + * 32-character field./li + * liMethod name, left-justified, and framed in a 32-character field./li + * liLevel name, left-justified, and framed in a 6-character field./li + * liUser message and arguments./li + * liPlatform-dependent line-separator./li + * liOptionally, if the log-record contains a thrown exception, that + * exception's stack trace is appended to the output./li + * /ol + * p + * Here is an example of the output generated by this formatter: + * p + * pre + * 2006-02-27 21:59:12.0881 +1100 -1343151280 EncodedKeyFactoryengineGeneratePublic() FINER - ENTRY [EMAIL PROTECTED] + * 2006-02-27 21:59:12.0887 +1100 -1343151280 EncodedKeyFactoryengineGeneratePublic() FINE - Exception in DSSPublicKey.valueOf(). Ignore + * java.security.InvalidParameterException: Unexpected OID: 1.2.840.113549.1.1.1 + *at gnu.java.security.key.dss.DSSKeyPairX509Codec.decodePublicKey (DSSKeyPairX509Codec.java:205) + *at gnu.java.security.key.dss.DSSPublicKey.valueOf (DSSPublicKey.java:136) + *at gnu.java.security.jce.sig.EncodedKeyFactory.engineGeneratePublic (EncodedKeyFactory.java:218) + *at java.security.KeyFactory.generatePublic (KeyFactory.java:219) + *at gnu.java.security.x509.X509Certificate.parse (X509Certificate.java:657) + *at gnu.java.security.x509.X509Certificate.init (X509Certificate.java:163) + *... + * 2006-02-27 21:59:12.0895 +1100 -1343151280 RSAKeyPairX509Codec decodePublicKey()FINER - ENTRY [EMAIL PROTECTED] + * 2006-02-27 21:59:12.0897 +1100 -1343151280 RSAKeyPairX509Codec decodePublicKey()FINER - RETURN [EMAIL PROTECTED] + * /pre + */ +public class Simple1LineFormatter +extends Formatter +{ + private static final String
[cp-patches] FYI: updated NEWS file
I added a line about Unicode 4.0.0 support to the NEWS file. 2006-02-28 Anthony Balkissoon [EMAIL PROTECTED] * NEWS: Added line about Unicode 4.0.0 support. --Tony ? include/gnu_java_net_PlainDatagramSocketImpl.h ? include/gnu_java_net_PlainSocketImpl.h Index: NEWS === RCS file: /cvsroot/classpath/classpath/NEWS,v retrieving revision 1.114 diff -u -r1.114 NEWS --- NEWS 24 Feb 2006 12:49:44 - 1.114 +++ NEWS 28 Feb 2006 16:14:58 - @@ -7,6 +7,8 @@ `java.security.' `javax.crypto,' and `javax.net.ssl' packages, and are service providers implementing the underlying algorithms. +* Unicode 4.0.0 is supported. + * The new folder tools includes GIOP and RMI stub and tie source code generators, IOR parser and both transient and persistent GIOP naming services.
[cp-patches] FYI: Branch/LeafElement fixes
This makes my recently added testcases for the above said classes PASS, as well as one of the regressions. Basically this adds a little robustness to the getStart/EndOffset() methods in Branch/LeafElement for certain strange situations. 2006-02-28 Roman Kennke [EMAIL PROTECTED] * javax/swing/text/BranchElement.java (startOffset): New field. (endOffset): New field. (BranchElement): Initialize new fields. (getEndOffset): Rewritten to possibly return cached values if element has no children. (getStartOffset): Rewritten to possibly return cached values if element has no children. * javax/swing/text/LeafElement.java (startDelta): New field. (endDelta): New field. (LeafElement): Handle possible delta of start/endOffset when these parameters lie outside the document range. (getStartOffset): Handle possible startDelta. (getEndOffset): Handle possible startDelta. /Roman Index: javax/swing/text/AbstractDocument.java === RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v retrieving revision 1.51 diff -u -r1.51 AbstractDocument.java --- javax/swing/text/AbstractDocument.java 21 Feb 2006 13:56:15 - 1.51 +++ javax/swing/text/AbstractDocument.java 28 Feb 2006 16:15:51 - @@ -1586,6 +1586,18 @@ private Element[] children = new Element[0]; /** + * The cached startOffset value. This is used in the case when a + * BranchElement (temporarily) has no child elements. + */ +private int startOffset; + +/** + * The cached endOffset value. This is used in the case when a + * BranchElement (temporarily) has no child elements. + */ +private int endOffset; + +/** * Creates a new codeBranchElement/code with the specified * parent and attributes. * @@ -1596,6 +1608,8 @@ public BranchElement(Element parent, AttributeSet attributes) { super(parent, attributes); + startOffset = -1; + endOffset = -1; } /** @@ -1668,7 +1682,7 @@ // return 0 if (offset getStartOffset()) return 0; - + // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index children.length - 1; ++index) @@ -1708,12 +1722,15 @@ */ public int getEndOffset() { - int end = 0; - if (getElementCount() == 0) -end = getLength(); // FIXME: That ain't correct, fix it. + if (children.length == 0) +{ + if (endOffset == -1) +throw new NullPointerException(BranchElement has no children.); +} else -end = children[children.length - 1].getEndOffset(); - return end; +endOffset = children[children.length - 1].getEndOffset(); + + return endOffset; } /** @@ -1734,16 +1751,20 @@ * * @return the start offset of this element inside the document model * - * @throws NullPointerException if this branch element has no children + * @throws NullPointerException if this branch element has no children and + * no startOffset value has been cached */ public int getStartOffset() { - int start = 0; - if (getElementCount() == 0) -start = 0; // FIXME: That ain't correct, fix it. + if (children.length == 0) +{ + if (startOffset == -1) +throw new NullPointerException(BranchElement has no children.); +} else -start = children[0].getStartOffset(); - return start; +startOffset = children[0].getStartOffset(); + + return startOffset; } /** @@ -2041,13 +2062,29 @@ /** The serialization UID (compatible with JDK1.5). */ private static final long serialVersionUID = -8906306331347768017L; -/** Manages the start offset of this element. */ -Position startPos; +/** + * Manages the start offset of this element. + */ +private Position startPos; -/** Manages the end offset of this element. */ -Position endPos; +/** + * Manages the end offset of this element. + */ +private Position endPos; /** + * This gets possible added to the startOffset when a startOffset + * outside the document range is requested. + */ +private int startDelta; + +/** + * This gets possible added to the endOffset when a endOffset + * outside the document range is requested. + */ +private int endDelta; + +/** * Creates a new codeLeafElement/code. * * @param parent the parent of this codeLeafElement/code @@ -2059,20 +2096,18 @@ int end) { super(parent, attributes); - { - try + startDelta = 0; + if (start getLength()) +startDelta = start - getLength(); + endDelta
[cp-patches] Re: Patch: RFC: various java.util.prefs fixes
Tom == Tom Tromey [EMAIL PROTECTED] writes: Tom I happened to look at java.util.prefs yesterday and I noticed some Tom problems. This patch attempts to fix all of them (except for the Tom biggest problem, which is that we still only use the memory-based Tom provider). I'm checking this in. Tom One thing I wasn't sure about is whether/how to get the new event Tom dispatch thread into an appropriate ThreadGroup. Perhaps we ought to Tom have some private, classpath-internals thread group for daemon threads Tom like this? I've punted on this problem for now. Tom
[cp-patches] Patch: FYI: eclipse builder fixlet
While preparing for FOSDEM I noticed that we were running the eclipse java builder after building the JNI headers and the native code. This seems wrong, as we need the just-created class files in order to properly build the JNI headers. Fixed as appended. Tom 2006-02-28 Tom Tromey [EMAIL PROTECTED] * .project: Run java builder before header generation. Index: .project === RCS file: /cvsroot/classpath/classpath/.project,v retrieving revision 1.6 diff -u -r1.6 .project --- .project22 Dec 2005 19:23:19 - 1.6 +++ .project28 Feb 2006 16:56:04 - @@ -36,6 +36,11 @@ /arguments /buildCommand buildCommand + nameorg.eclipse.jdt.core.javabuilder/name + arguments + /arguments + /buildCommand + buildCommand nameorg.eclipse.ui.externaltools.ExternalToolBuilder/name triggersauto,full,incremental,/triggers arguments @@ -56,11 +61,6 @@ /arguments /buildCommand buildCommand - nameorg.eclipse.jdt.core.javabuilder/name - arguments - /arguments - /buildCommand - buildCommand nameorg.eclipse.ui.externaltools.ExternalToolBuilder/name triggersauto,full,incremental,/triggers arguments
[cp-patches] FYI: BigInteger serialization fixes PR 26333
I submitted the patch written by Rafael Teixeira: http://developer.classpath.org/pipermail/classpath-patches/2006-February/000473.html that fixes BigInteger serialization. 2006-02-28 Anthony Balkissoon [EMAIL PROTECTED] * java/math/BigInteger.java: Committed patch by Rafael: developer.classpath.org/pipermail/classpath-patches/ 2006-February/000473.html (signum): Return early 0 if words == null and ival == 0. (readObject): Handle special case of magnitude.length or signum being 0. (writeObject): If signum is zero return a zero-sized byte[]. --Tony ? patch.diff ? include/gnu_java_net_PlainDatagramSocketImpl.h ? include/gnu_java_net_PlainSocketImpl.h Index: java/math/BigInteger.java === RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v retrieving revision 1.26 diff -u -r1.26 BigInteger.java --- java/math/BigInteger.java 21 Sep 2005 17:00:33 - 1.26 +++ java/math/BigInteger.java 28 Feb 2006 17:59:13 - @@ -356,9 +356,9 @@ public int signum() { -int top = words == null ? ival : words[ival-1]; -if (top == 0 words == null) +if (ival == 0 words == null) return 0; +int top = words == null ? ival : words[ival-1]; return top 0 ? -1 : 1; } @@ -2227,17 +2227,25 @@ throws IOException, ClassNotFoundException { s.defaultReadObject(); -words = byteArrayToIntArray(magnitude, signum 0 ? -1 : 0); -BigInteger result = make(words, words.length); -this.ival = result.ival; -this.words = result.words; +if (magnitude.length == 0 || signum == 0) + { +this.ival = 0; +this.words = null; + } +else + { +words = byteArrayToIntArray(magnitude, signum 0 ? -1 : 0); +BigInteger result = make(words, words.length); +this.ival = result.ival; +this.words = result.words; + } } private void writeObject(ObjectOutputStream s) throws IOException, ClassNotFoundException { signum = signum(); -magnitude = toByteArray(); +magnitude = signum == 0 ? new byte[0] : toByteArray(); s.defaultWriteObject(); } }
[cp-patches] Patch: ViewportLayout fix
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26003 Audrius submitted this patch in the bug report for #26003. It fixes a problem with the viewport layout. This bug was seen with JTrees. The viewport would reset to (0,0) everytime a node was expanded. Fixed and committed. 2006-02-28 Lillian Angel [EMAIL PROTECTED] PR classpath/26003 * javax/swing/ViewportLayout.java: Patch submitted by Audrius Meskauskas (addLayoutComponent): Added documentation. (removeLayoutComponent): Likewise. (preferredLayoutSize): Likewise. (minimumLayoutSize): Likewise. (layoutContainer): Fixed code, so view is set to the right position when inside a scrollpane. Index: javax/swing/ViewportLayout.java === RCS file: /sources/classpath/classpath/javax/swing/ViewportLayout.java,v retrieving revision 1.24 diff -u -r1.24 ViewportLayout.java --- javax/swing/ViewportLayout.java 30 Jan 2006 14:05:55 - 1.24 +++ javax/swing/ViewportLayout.java 28 Feb 2006 18:10:08 - @@ -1,5 +1,5 @@ /* ViewportLayout.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,9 +46,16 @@ import java.io.Serializable; /** - * ViewportLayout - * @author Andrew Selkirk - * @author Graydon Hoare + * The default layout for [EMAIL PROTECTED] JViewport}. The viewport makes its view the + * same size as itself, but not smaller than its minimum size. + * + * If the port extends extends into space empast/em the edge of the view, + * this layout manager moves the port up or to the left, in view space, by the + * amount of empty space (keep the lower and right edges lined up). + * + * @author Andrew Selkirk + * @author Graydon Hoare + * @author Audrius Meskauskas ([EMAIL PROTECTED]) */ public class ViewportLayout implements LayoutManager, Serializable { @@ -58,17 +65,31 @@ { // Nothing to do here. } - + + /** + * The method is not used with this manager. + */ public void addLayoutComponent(String name, Component c) { // Nothing to do here. } + /** + * The method is not used with this manager. + */ public void removeLayoutComponent(Component c) { // Nothing to do here. } - + + /** + * Get the preferred layout size. If the view implements + * [EMAIL PROTECTED] Scrollable}, this method returns + * [EMAIL PROTECTED] Scrollable#getPreferredScrollableViewportSize}. + * Otherwise, it returns [EMAIL PROTECTED] Component#getPreferredSize()}. + * + * @return the preferred layout size, as described about. + */ public Dimension preferredLayoutSize(Container parent) { JViewport vp = (JViewport)parent; @@ -84,10 +105,13 @@ } /** - * Return the minimumSize for the codeJViewport/code that is laid out - * by this layout manager. + * Get the minimum layout size. Normally this method returns the value, + * returned by the view method [EMAIL PROTECTED] Component#getMinimumSize()}. + * + * If the view is not set, the zero size is returned. * * @param parent the viewport + * @return the minimum layout size. */ public Dimension minimumLayoutSize(Container parent) { @@ -103,15 +127,13 @@ * * ol * - * liIf the port is larger than the view's minimum size, put the port - * at view position code(0,0)/code and make the view's size equal to - * the port's./li - * * liIf the port is smaller than the view, leave the view at its - * minimum size. also, do not move the port, emunless/em the port + * current size. Also, do not move the port, emunless/em the port * extends into space empast/em the edge of the view. If so, move the * port up or to the left, in view space, by the amount of empty space * (keep the lower and right edges lined up)/li + * liIn [EMAIL PROTECTED] JViewport#setViewSize(Dimension)}, the view size is never + * set smaller that its minimum size./li * * /ol * @@ -120,7 +142,6 @@ * @see JViewport#getViewPosition * @see JViewport#setViewPosition */ - public void layoutContainer(Container parent) { // The way to interpret this function is basically to ignore the names @@ -143,23 +164,22 @@ Rectangle portBounds = port.getViewRect(); Dimension viewPref = view.getPreferredSize(); Dimension viewMinimum = view.getMinimumSize(); + Point portLowerRight = new Point(portBounds.x + portBounds.width, portBounds.y + portBounds.height); +int overextension; // vertical implementation of the above rules if ((! (view instanceof Scrollable) viewPref.height portBounds.height || (view instanceof Scrollable ((Scrollable) view).getScrollableTracksViewportHeight( viewPref.height = portBounds.height; - -if
Re: [cp-patches] FYI: BigInteger serialization fixes PR 26333
Tony == Anthony Balkissoon [EMAIL PROTECTED] writes: Tony I submitted the patch written by Rafael Teixeira: Tony http://developer.classpath.org/pipermail/classpath-patches/2006-February/000473.html Tony that fixes BigInteger serialization. You have to be careful with patches like this. Rafael doesn't have paperwork in place. If the patch is too big (the typical heuristic is more than 10 lines) and there is more than one way to write it, then we can't commit it. Instead we have to either get paperwork (which from his email, I gather we would not be able to get) or rewrite the fix from the description of the bug. Tom
[cp-patches] Patch: JList fix
The JFileChooser had an incredibly large width. It should not be sized based on the List's preferred width, it should show a set number of columns at all times. 2006-02-28 Lillian Angel [EMAIL PROTECTED] PR classpath/25675 * javax/swing/JList.java (getPreferredScrollableViewportSize): Added a check to determine if orientation is VERTICAL_WRAP. If it is, we should only show 3 columns. Index: javax/swing/JList.java === RCS file: /sources/classpath/classpath/javax/swing/JList.java,v retrieving revision 1.45 diff -u -r1.45 JList.java --- javax/swing/JList.java 9 Jan 2006 18:40:02 - 1.45 +++ javax/swing/JList.java 28 Feb 2006 18:40:13 - @@ -1793,8 +1793,17 @@ //If the layout orientation is not VERTICAL, then this will //return the value from getPreferredSize. The current ListUI is //expected to override getPreferredSize to return an appropriate value. -if (getLayoutOrientation() != VERTICAL) - return getPreferredSize(); +int orient = getLayoutOrientation(); +Dimension pref = getPreferredSize(); +if (orient == VERTICAL_WRAP) + { +if (fixedCellWidth == -1) + return new Dimension(getCellBounds(0, 0).width * 3, pref.height); +else + return new Dimension(fixedCellWidth, pref.height); + } +if (orient != VERTICAL) + return pref; int size = getModel().getSize();
Re: [cp-patches] Patch: ViewportLayout fix
Hi Lillian, Am Dienstag, den 28.02.2006, 13:15 -0500 schrieb Lillian Angel: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26003 Audrius submitted this patch in the bug report for #26003. It fixes a problem with the viewport layout. This bug was seen with JTrees. The viewport would reset to (0,0) everytime a node was expanded. This patch causes a regression in Mauve (see below). And, IIRC, I already handled this bug and maybe forgot to close it. Could you check this again? gnu.testlet.javax.swing.ViewportLayout.layoutContainer PASS: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 1) PASS: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 2) FAIL: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 3) got java.awt.Dimension[width=100,height=100] but expected java.awt.Dimension[width=50,height=50] PASS: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 4) 1 of 4 tests failed /Roman signature.asc Description: Dies ist ein digital signierter Nachrichtenteil
Re: [cp-patches] Patch: JList fix
On Tue, 2006-02-28 at 20:08 +0100, Roman Kennke wrote: Hi Lillian, The JFileChooser had an incredibly large width. I am quite certain that the solution to the JFileChooser problem is to implement a special list subclass that implements adjusted behaviour. I have fought against this issue some time ago and came to this conclusion. Yes, same. Quite a pain. It should not be sized based on the List's preferred width, it should show a set number of columns at all times. The spec says: If the layout orientation is not VERTICAL, than this will return the value from getPreferredSize. and, AFAICS, this is what the JList should do. If we want the JFileChooser working for 0.21 we should probably go and implement a FileList that has needed behaviour. If you want, we can stick together our heads on IRC and work this out :-) Sure, I agree. Lillian
Re: [cp-patches] Patch: ViewportLayout fix
On Tue, 2006-02-28 at 20:03 +0100, Roman Kennke wrote: Hi Lillian, Am Dienstag, den 28.02.2006, 13:15 -0500 schrieb Lillian Angel: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26003 Audrius submitted this patch in the bug report for #26003. It fixes a problem with the viewport layout. This bug was seen with JTrees. The viewport would reset to (0,0) everytime a node was expanded. This patch causes a regression in Mauve (see below). And, IIRC, I already handled this bug and maybe forgot to close it. Could you check this again? gnu.testlet.javax.swing.ViewportLayout.layoutContainer PASS: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 1) PASS: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 2) FAIL: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 3) got java.awt.Dimension[width=100,height=100] but expected java.awt.Dimension[width=50,height=50] PASS: gnu.testlet.javax.swing.ViewportLayout.layoutContainer (number 4) 1 of 4 tests failed Unfortunately, without Audrius' patch, #3 fails. With it, #4 failed. I fixed it so all the tests pass. 2006-02-28 Lillian Angel [EMAIL PROTECTED] * javax/swing/ViewportLayout.java (layoutContainer): Should not extend container to be minimum size. Mauve test shows that the preferred size and the size of the viewport can be set smaller than the minimum. Index: javax/swing/ViewportLayout.java === RCS file: /sources/classpath/classpath/javax/swing/ViewportLayout.java,v retrieving revision 1.25 diff -u -r1.25 ViewportLayout.java --- javax/swing/ViewportLayout.java 28 Feb 2006 18:14:12 - 1.25 +++ javax/swing/ViewportLayout.java 28 Feb 2006 20:08:29 - @@ -193,18 +193,6 @@ if (overextension 0) portBounds.x -= overextension; -// If the calculated view size was smaller than the minimum size, -// extend till the minimum size. -if (viewPref.heightviewMinimum.height) - { -viewPref.height = viewMinimum.height; - } - -if (viewPref.widthviewMinimum.width) - { -viewPref.width = viewMinimum.width; - } - port.setViewSize(viewPref); port.setViewPosition(portBounds.getLocation()); }
[cp-patches] Patch: DefaultFormatter fix
This fixes the MaskFormatter regression. 2006-02-28 Lillian Angel [EMAIL PROTECTED] * javax/swing/text/DefaultFormatter.java (stringToValue): Added NPE check. Index: javax/swing/text/DefaultFormatter.java === RCS file: /sources/classpath/classpath/javax/swing/text/DefaultFormatter.java,v retrieving revision 1.7 diff -u -r1.7 DefaultFormatter.java --- javax/swing/text/DefaultFormatter.java 20 Jan 2006 12:06:24 - 1.7 +++ javax/swing/text/DefaultFormatter.java 28 Feb 2006 20:25:17 - @@ -367,7 +367,11 @@ Object value = string; Class valueClass = getValueClass(); if (valueClass == null) - valueClass = getFormattedTextField().getValue().getClass(); + { +JFormattedTextField jft = getFormattedTextField(); +if (jft != null) + valueClass = jft.getValue().getClass(); + } if (valueClass != null) try {
[cp-patches] [generics] BigDecimal fix and 4 new methods
More BD stuff. 2006-02-28 Anthony Balkissoon [EMAIL PROTECTED] * java/math/BigDecimal.java: (divide(BigDecimal, int, RoundingMode)): New method. (divide(BigDecimal, RoundingMode)): Likewise. (divide(BigDecimal, int, int)): Removed incorrect throwing of exception when the new scale is 0. (setScale(int, RoundingMode)): New method. (ulp): Likewise. --Tony Index: java/math/BigDecimal.java === RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v retrieving revision 1.17.2.13 diff -u -r1.17.2.13 BigDecimal.java --- java/math/BigDecimal.java 27 Feb 2006 21:35:15 - 1.17.2.13 +++ java/math/BigDecimal.java 28 Feb 2006 20:28:12 - @@ -670,7 +670,38 @@ { return divide (val, scale, roundingMode); } + + /** + * Returns a BigDecimal whose value is (this / val), with the specified scale + * and rounding according to the RoundingMode + * @param val the divisor + * @param scale the scale of the BigDecimal returned + * @param roundingMode the rounding mode to use + * @return a BigDecimal whose value is approximately (this / val) + * @throws ArithmeticException if divisor is zero or the rounding mode is + * UNNECESSARY but the specified scale cannot represent the value exactly + * @since 1.5 + */ + public BigDecimal divide(BigDecimal val, + int scale, RoundingMode roundingMode) + { +return divide (val, scale, roundingMode.ordinal()); + } + /** + * Returns a BigDecimal whose value is (this / val) rounded according to the + * RoundingMode + * @param val the divisor + * @param roundingMode the rounding mode to use + * @return a BigDecimal whose value is approximately (this / val) + * @throws ArithmeticException if divisor is zero or the rounding mode is + * UNNECESSARY but the specified scale cannot represent the value exactly + */ + public BigDecimal divide (BigDecimal val, RoundingMode roundingMode) + { +return divide (val, scale, roundingMode.ordinal()); + } + public BigDecimal divide(BigDecimal val, int newScale, int roundingMode) throws ArithmeticException, IllegalArgumentException { @@ -678,9 +709,6 @@ throw new IllegalArgumentException(illegal rounding mode: + roundingMode); -if (newScale 0) - throw new ArithmeticException (scale is negative: + newScale); - if (intVal.signum () == 0) // handle special case of 0.0/0.0 return newScale == 0 ? ZERO : new BigDecimal (ZERO.intVal, newScale); @@ -1346,6 +1374,23 @@ } /** + * Returns a BigDecimal whose value is the same as this BigDecimal but whose + * representation has a scale of codenewScale/code. If the scale is + * reduced then rounding may occur, according to the RoundingMode. + * @param newScale + * @param roundingMode + * @return a BigDecimal whose scale is as given, whose value is + * codethis/code with possible rounding + * @throws ArithmeticException if the rounding mode is UNNECESSARY but + * rounding is required + * @since 1.5 + */ + public BigDecimal setScale(int newScale, RoundingMode roundingMode) + { +return setScale(newScale, roundingMode.ordinal()); + } + + /** * Returns a new BigDecimal constructed from the BigDecimal(String) * constructor using the Double.toString(double) method to obtain * the String. @@ -1419,4 +1464,15 @@ result = result.round(mc); return result; } + + /** + * Returns the size of a unit in the last place of this BigDecimal. This + * returns a BigDecimal with [unscaledValue, scale] = [1, this.scale()]. + * @return the size of a unit in the last place of codethis/code. + * @since 1.5 + */ + public BigDecimal ulp() + { +return new BigDecimal(BigInteger.ONE, scale); + } }
[cp-patches] FYI: Added docs to ServiceUIFactory
Hi, I added some docs to ServiceUIFactory. 2006-02-28 Wolfgang Baer [EMAIL PROTECTED] * javax/print/ServiceUIFactory.java: Added documentation to class. Wolfgang Index: ServiceUIFactory.java === RCS file: /cvsroot/classpath/classpath/javax/print/ServiceUIFactory.java,v retrieving revision 1.3 diff -u -r1.3 ServiceUIFactory.java --- ServiceUIFactory.java 2 Jul 2005 20:32:46 - 1.3 +++ ServiceUIFactory.java 28 Feb 2006 21:14:39 - @@ -1,5 +1,5 @@ /* ServiceUIFactory.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,18 +39,47 @@ package javax.print; /** + * codeServiceUIFactory/code enables print services to provide additional + * user interface dialogs. + * p + * A print service may provide a codeServiceUIFactory/code implementation + * if its codegetServiceUIFactory()/code method is called. If a factory + * object is returned it can be queried for provided user interface dialogs. + * Different roles are defined to denote dialogs providing informations about + * the print service, dialogs for administration of a print service and for + * end-user browsing dialogs. + * /pp + * The factory can support providing these UI roles in different dialog types + * (AWT, Swing, JComponent, Panel). The support and use of Swing interfaces is + * however preferred. + * /p + * * @author Michael Koch */ public abstract class ServiceUIFactory { + /** A user interface providing informations about the print service. */ public static final int ABOUT_UIROLE = 1; + + /** A user interface to administer the print service. */ public static final int ADMIN_UIROLE = 2; + + /** A user interface for end-user browsing of the print service. */ public static final int MAIN_UIROLE = 3; + + /** Role IDs greater than this may be used for other private roles. */ public static final int RESERVED_UIROLE = 99; + /** Identifies a UI provided as an AWT dialog. */ public static final String DIALOG_UI = java.awt.Dialog; + + /** Identifies a UI provided as a Swing JComponent. */ public static final String JCOMPONENT_UI = javax.swing.JComponent; + + /** Identifies a UI provided as a Swing JDialog. */ public static final String JDIALOG_UI = javax.swing.JDialog; + + /** Identifies a UI provided as an AWT Panel. */ public static final String PANEL_UI = java.awt.Panel; /**
Re: [cp-patches] FYI: BigInteger serialization fixes PR 26333
Hi Tony, On Tue, 2006-02-28 at 13:47 -0500, Anthony Balkissoon wrote: On Tue, 2006-02-28 at 11:21 -0700, Tom Tromey wrote: You have to be careful with patches like this. Rafael doesn't have paperwork in place. If the patch is too big (the typical heuristic is more than 10 lines) and there is more than one way to write it, then we can't commit it. Instead we have to either get paperwork (which from his email, I gather we would not be able to get) or rewrite the fix from the description of the bug. Should I revert this? No, it is small ( 15 lines) and obviously the correct thing to do (hard to express this idea very differently in code - although you did clean it up to be in GNU style - thanks). To make that more clear you could comment the code/method to explain the serialization representation for the end-user. Cheers, Mark (*) See also http://www.gnu.org/prep/maintain/html_node/Legally-Significant.html signature.asc Description: This is a digitally signed message part
[cp-patches] RFC/RFT: HTTP header handling rewrite.
PR libgcj/26487 shows problems with our existing header handling. I hacked up the attached patch, which needs more testing (please test it!) The basic problem is that the headers were being held in a map which scrambled them up if there were more than one header of the same name. My change was to just hold the headers in a list. This makes some searching operations less efficient, but seems the best way to keep the headers from being combined. Let me know what you think. 2006-02-28 David Daney [EMAIL PROTECTED] * gnu/java/net/protocol/http/HTTPURLConnection.java (getRequestProperties): Rewrote. (addRequestProperty): Rewrote. (getHeaderFields): Rewrote. (getHeaderField): Rewrote. (getHeaderFieldKey): Rewrote. (getHeaderField): Removed useless cast. * gnu/java/net/protocol/http/Headers.java: Entire class rewritten. * gnu/java/net/protocol/http/Request.java (dispatch): Use new Headers interface. (notifyHeaderHandlers): Use new Headers interface. ? cis.changelog ? cl ? d ? headers.d Index: gnu/java/net/protocol/http/HTTPURLConnection.java === RCS file: /sources/classpath/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java,v retrieving revision 1.22 diff -c -p -r1.22 HTTPURLConnection.java *** gnu/java/net/protocol/http/HTTPURLConnection.java 27 Feb 2006 23:37:20 - 1.22 --- gnu/java/net/protocol/http/HTTPURLConnection.java 28 Feb 2006 21:39:22 - *** public class HTTPURLConnection *** 422,441 if (connected) throw new IllegalStateException(Already connected); ! HashMap m = new HashMap(requestHeaders); ! Iterator it = m.entrySet().iterator(); ! while (it.hasNext()) ! { ! Map.Entry e = (Map.Entry)it.next(); ! String s = (String)e.getValue(); ! String sa[] = s.split(,); ! ArrayList l = new ArrayList(sa.length); ! for (int i = 0; i sa.length; i++) ! { ! l.add(sa[i].trim()); ! } ! e.setValue(Collections.unmodifiableList(l)); ! } return Collections.unmodifiableMap(m); } --- 422,428 if (connected) throw new IllegalStateException(Already connected); ! Map m = requestHeaders.getAsMap(); return Collections.unmodifiableMap(m); } *** public class HTTPURLConnection *** 449,464 public void addRequestProperty(String key, String value) { super.addRequestProperty(key, value); ! ! String old = requestHeaders.getValue(key); ! if (old == null) ! { ! requestHeaders.put(key, value); ! } ! else ! { ! requestHeaders.put(key, old + , + value); ! } } public OutputStream getOutputStream() --- 436,442 public void addRequestProperty(String key, String value) { super.addRequestProperty(key, value); ! requestHeaders.addValue(key, value); } public OutputStream getOutputStream() *** public class HTTPURLConnection *** 533,549 return null; } } ! Headers headers = response.getHeaders(); ! LinkedHashMap ret = new LinkedHashMap(); ! ret.put(null, Collections.singletonList(getStatusLine(response))); ! for (Iterator i = headers.entrySet().iterator(); i.hasNext(); ) ! { ! Map.Entry entry = (Map.Entry) i.next(); ! String key = (String) entry.getKey(); ! String value = (String) entry.getValue(); ! ret.put(key, Collections.singletonList(value)); ! } ! return Collections.unmodifiableMap(ret); } String getStatusLine(Response response) --- 511,519 return null; } } ! Map m = response.getHeaders().getAsMap(); ! m.put(null, Collections.singletonList(getStatusLine(response))); ! return Collections.unmodifiableMap(m); } String getStatusLine(Response response) *** public class HTTPURLConnection *** 571,590 { return getStatusLine(response); } ! Iterator i = response.getHeaders().entrySet().iterator(); ! Map.Entry entry; ! int count = 1; ! do ! { ! if (!i.hasNext()) ! { ! return null; ! } ! entry = (Map.Entry) i.next(); ! count++; ! } ! while (count = index); ! return (String) entry.getValue(); } public String getHeaderFieldKey(int index) --- 541,547 { return getStatusLine(response); } ! return response.getHeaders().getHeaderValue(index - 1); } public String getHeaderFieldKey(int index) *** public class HTTPURLConnection *** 600,623 return null; } } ! if (index == 0) ! { ! return null; ! } !
[cp-patches] RFC: file resources can be directory too
Hi, following the mauve testlet commit, here is the fix proposition in classpath. Basically, we were explicitly preventing directories to be retrieved as file resources, while I don't see any reason to do so (nor sun implementors afaik). So, I propose this very trivial patch to deal with it. Since it seems that there already were a discussion (or rather fuss) about the nature of resource and how to deal with non plain files, if this patch seems too daring for you, don't hesitate to shout and discuss about it. Olivier 2006-02-28 Olivier Jolly [EMAIL PROTECTED] * java/net/URLClassLoader.java (FileURLLoader.getResource): allows directories as valid resources. Index: URLClassLoader.java === RCS file: /sources/classpath/classpath/java/net/URLClassLoader.java,v retrieving revision 1.44 diff -u -r1.44 URLClassLoader.java --- URLClassLoader.java 18 Jan 2006 00:19:13 - 1.44 +++ URLClassLoader.java 28 Feb 2006 21:26:35 - @@ -539,7 +539,7 @@ try { File file = new File(dir, name).getCanonicalFile(); - if (file.exists() !file.isDirectory()) + if (file.exists()) return new FileResource(this, file); } catch (IOException e)
[cp-patches] FYI: ScrollBar fixes
These fixes let all the MetalScrollBarUI/BasicScrollBarUI Mauve tests PASS. 2006-02-28 Roman Kennke [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicScrollBarUI.java (getPreferredSize): Fixed add a fixed space between the buttons instead of something related to min/max. (installComponents): Create and install buttons here. (installDefaults): Don't create buttons here. * javax/swing/plaf/metal/MetalScrollBarUI.java (getMinimumThumbSize): Return (0,0) when UI is not yet installed. (getPreferredSize): New method. /Roman Index: javax/swing/plaf/basic/BasicScrollBarUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java,v retrieving revision 1.30 diff -u -r1.30 BasicScrollBarUI.java --- javax/swing/plaf/basic/BasicScrollBarUI.java 15 Nov 2005 20:32:46 - 1.30 +++ javax/swing/plaf/basic/BasicScrollBarUI.java 28 Feb 2006 22:25:00 - @@ -653,19 +653,17 @@ if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL) { - width += incrButton.getPreferredSize().getWidth(); - width += decrButton.getPreferredSize().getWidth(); - - width += (scrollbar.getMaximum() - scrollbar.getMinimum()); - height = UIManager.getInt(ScrollBar.width); +width += incrButton.getPreferredSize().getWidth(); +width += decrButton.getPreferredSize().getWidth(); +width += 16; +height = UIManager.getInt(ScrollBar.width); } else { - height += incrButton.getPreferredSize().getHeight(); - height += decrButton.getPreferredSize().getHeight(); - - height += (scrollbar.getMaximum() - scrollbar.getMinimum()); - width = UIManager.getInt(ScrollBar.width); +height += incrButton.getPreferredSize().getHeight(); +height += decrButton.getPreferredSize().getHeight(); +height += 16; +width = UIManager.getInt(ScrollBar.width); } Insets insets = scrollbar.getInsets(); @@ -721,18 +719,6 @@ */ protected void installComponents() { -if (incrButton != null) - scrollbar.add(incrButton); -if (decrButton != null) - scrollbar.add(decrButton); - } - - /** - * This method installs the defaults for the scrollbar specified by the - * Basic Look and Feel. - */ - protected void installDefaults() - { int orientation = scrollbar.getOrientation(); switch (orientation) { @@ -746,6 +732,18 @@ break; } +if (incrButton != null) + scrollbar.add(incrButton); +if (decrButton != null) + scrollbar.add(decrButton); + } + + /** + * This method installs the defaults for the scrollbar specified by the + * Basic Look and Feel. + */ + protected void installDefaults() + { LookAndFeel.installColors(scrollbar, ScrollBar.background, ScrollBar.foreground); LookAndFeel.installBorder(scrollbar, ScrollBar.border); Index: javax/swing/plaf/metal/MetalScrollBarUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java,v retrieving revision 1.12 diff -u -r1.12 MetalScrollBarUI.java --- javax/swing/plaf/metal/MetalScrollBarUI.java 15 Nov 2005 20:51:37 - 1.12 +++ javax/swing/plaf/metal/MetalScrollBarUI.java 28 Feb 2006 22:25:00 - @@ -41,6 +41,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; +import java.awt.Insets; import java.awt.Rectangle; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -48,6 +49,7 @@ import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JScrollBar; +import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicScrollBarUI; @@ -465,11 +467,60 @@ */ protected Dimension getMinimumThumbSize() { -if (isFreeStanding) - return MIN_THUMB_SIZE_FREE_STANDING; +Dimension retVal; +if (scrollbar != null) + { +if (isFreeStanding) + retVal = MIN_THUMB_SIZE_FREE_STANDING; +else + retVal = MIN_THUMB_SIZE; + } else - return MIN_THUMB_SIZE; + retVal = new Dimension(0, 0); +return retVal; } - + + /** + * Returns the codepreferredSize/code for the specified scroll bar. + * For a vertical scrollbar the height is the sum of the preferred heights + * of the buttons plus code30/code. The width is fetched from the + * codeUIManager/code property codeScrollBar.width/code. + * + * For horizontal scrollbars the width is the sum of the preferred widths + * of the buttons plus code30/code. The height is fetched from the + * codeUIManager/code property codeScrollBar.height/code. + * + * @param c the scrollbar for which to calculate the preferred size + * + * @return the codepreferredSize/code for
[cp-patches] FYI: Swing Demo updated...
This patch (committed) removes some redundant demo items and adds in the new SpinnerDemo as a menu / button bar option: 2006-02-28 David Gilbert [EMAIL PROTECTED] * examples/gnu/classpath/examples/swing/Demo.java (mkMenuBar): Removed 'Toggles', 'Checkbox' and 'Radio' actions, connected 'Spinner' action to SpinnerDemo, (mkCheckbox): Removed, (mkRadio): Likewise, (mkSpinner): Likewise, (mkToggle): Likewise, (mkButtonBar): Removed 'Toggles', 'Checkbox' and 'Radio' actions, connected 'Spinner' action to SpinnerDemo. Regards, Dave Index: examples/gnu/classpath/examples/swing/Demo.java === RCS file: /sources/classpath/classpath/examples/gnu/classpath/examples/swing/Demo.java,v retrieving revision 1.32 diff -u -r1.32 Demo.java --- examples/gnu/classpath/examples/swing/Demo.java 30 Jan 2006 22:05:08 - 1.32 +++ examples/gnu/classpath/examples/swing/Demo.java 28 Feb 2006 22:13:27 - @@ -163,18 +163,6 @@ new PopUpAction(Buttons, (new ButtonDemo(Button Demo)).createContent(), examples); - -new PopUpAction(Toggles, - mkToggle(cool and refreshing), - examples); - -new PopUpAction(Checkbox, - mkCheckbox(ice cold), - examples); - -new PopUpAction(Radio, - mkRadio(delicious), - examples); new PopUpAction(Slider, (new SliderDemo(Slider Demo)).createContent(), @@ -214,8 +202,7 @@ examples); new PopUpAction(Spinner, - mkSpinner(), - examples); + new SpinnerDemo(Spinner Demo).createContent(), examples); new PopUpAction(TextField, (new TextFieldDemo(TextField Demo)).createContent(), @@ -733,26 +720,6 @@ SwingUtilities.invokeLater(new LaterMain()); } - public static JCheckBox mkCheckbox(String label) - { -JCheckBox c = new JCheckBox(label); -c.setFont(new Font(Luxi, Font.PLAIN, 14)); -return c; - } - - public static JPanel mkRadio(String label) - { -JPanel p = new JPanel(); -JRadioButton c = new JRadioButton(label); -JRadioButton d = new JRadioButton(not + label); -ButtonGroup bg = new ButtonGroup(); -bg.add(c); -bg.add(d); -p.add(c); -p.add(d); -return p; - } - public static JList mkList(Object[] elts) { JList list = new JList(elts); @@ -776,12 +743,6 @@ return box; } - public static JSpinner mkSpinner() - { -JSpinner spinner = new JSpinner(); -return spinner; - } - public static JButton mkBigButton(String title) { JButton b = new JButton(title); @@ -790,14 +751,6 @@ return b; } - public static JToggleButton mkToggle(String title) - { -JToggleButton b = new JToggleButton(title); -b.setMargin(new Insets(5,5,5,5)); -b.setFont(new Font(Luxi, Font.PLAIN, 14)); -return b; - } - public static JPanel mkPanel(JComponent[] inners) { JPanel p = new JPanel(); @@ -1009,18 +962,6 @@ new PopUpAction(Buttons, (new ButtonDemo(Button Demo)).createContent(), panel); - -new PopUpAction(Toggles, - mkToggle(cool and refreshing), - panel); - -new PopUpAction(Checkbox, - mkCheckbox(ice cold), - panel); - -new PopUpAction(Radio, - mkRadio(delicious), - panel); new PopUpAction(Slider, (new SliderDemo(Slider Demo)).createContent(), @@ -1060,9 +1001,8 @@ indifferent}), panel); -new PopUpAction(Spinner, - mkSpinner(), - panel); +new PopUpAction(Spinner, + new SpinnerDemo(Spinner Demo).createContent(), panel); new PopUpAction(TextField, (new TextFieldDemo(TextField Demo)).createContent(),
Re: [cp-patches] RFC: file resources can be directory too
Olivier Jolly wrote: following the mauve testlet commit, here is the fix proposition in classpath. Basically, we were explicitly preventing directories to be retrieved as file resources, while I don't see any reason to do so (nor sun implementors afaik). So, I propose this very trivial patch to deal with it. Looks like I was the one who disabled this behavior in rev 1.32. Right now I can't remember why. But I think there was some bug in the previous code. Note rev 1.32 removed code in getInputStream() too, which is where ISTR the bug was. I can't access the archives right now (web site too slow) but it might be worth checking them for the original reasoning for the change. Had something to do with something working with file:// URLs but not http:// URLs, or the other way around, or... Otherwise it looks OK to me. -Archie __ Archie Cobbs *CTO, Awarix* http://www.awarix.com