changeset 1463:744a654041ac

Fix security patches for JDK7. 2008-12-02 Andrew John Hughes <ahughes@redhat.com> * patches/icedtea-4486841.patch, * patches/icedtea-6728542-epoll.patch: Removed, already applied to JDK7. * Makefile.am: Remove unneeded patches. * javac.in: Fix use of 'else if' for 'elsif'. * patches/icedtea-6484091.patch, * patches/icedtea-6497740.patch, * patches/icedtea-6592792.patch, * patches/icedtea-6733959.patch, * patches/icedtea-6755943.patch, * patches/icedtea-ecj-pr261.patch: Ported to JDK7.
author Andrew John Hughes <gnu_andrew@member.fsf.org>
date Wed, 03 Dec 2008 14:36:23 +0000
parents 6b24535880de
children 9cac71fc9e47
files ChangeLog Makefile.am javac.in patches/icedtea-4486841.patch patches/icedtea-6484091.patch patches/icedtea-6497740.patch patches/icedtea-6592792.patch patches/icedtea-6728542-epoll.patch patches/icedtea-6733959.patch patches/icedtea-6755943.patch patches/icedtea-ecj-pr261.patch
diffstat 11 files changed, 398 insertions(+), 2056 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 02 13:58:24 2008 +0000
+++ b/ChangeLog	Wed Dec 03 14:36:23 2008 +0000
@@ -1,3 +1,18 @@
+2008-12-02  Andrew John Hughes  <ahughes@redhat.com>
+
+	* patches/icedtea-4486841.patch,
+	* patches/icedtea-6728542-epoll.patch:
+	Removed, already applied to JDK7.
+	* Makefile.am: Remove unneeded patches.
+	* javac.in: Fix use of 'else if' for 'elsif'.
+	* patches/icedtea-6484091.patch,
+	* patches/icedtea-6497740.patch,
+	* patches/icedtea-6592792.patch,
+	* patches/icedtea-6733959.patch,
+	* patches/icedtea-6755943.patch,
+	* patches/icedtea-ecj-pr261.patch:
+	Ported to JDK7.
+
 2008-12-02  Andrew John Hughes  <ahughes@redhat.com>
 
 	Merge from IcedTea6.
--- a/Makefile.am	Tue Dec 02 13:58:24 2008 +0000
+++ b/Makefile.am	Wed Dec 03 14:36:23 2008 +0000
@@ -1852,8 +1852,6 @@
 	patches/icedtea-testenv.patch \
 	$(ZERO_PATCHES_COND) \
 	patches/icedtea-samejvm-safe.patch \
-	patches/icedtea-6728542-epoll.patch \
-	patches/icedtea-4486841.patch \
         patches/icedtea-6484091.patch \
         patches/icedtea-6497740.patch \
         patches/icedtea-6588160.patch \
--- a/javac.in	Tue Dec 02 13:58:24 2008 +0000
+++ b/javac.in	Wed Dec 03 14:36:23 2008 +0000
@@ -35,7 +35,7 @@
 {
     exec '@abs_top_builddir@/native-ecj', '-1.5', '-nowarn', @bcoption, @new_args ;
 }
-else if ( -e "@ECJ@" )
+elsif ( -e "@ECJ@" )
 {
     exec '@ECJ@', '-1.5', '-nowarn', @bcoption, @new_args ;
 }
--- a/patches/icedtea-4486841.patch	Tue Dec 02 13:58:24 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1234 +0,0 @@
---- old/src/share/classes/sun/nio/cs/UTF_8.java	Thu Oct  9 16:02:01 2008
-+++ openjdk/jdk/src/share/classes/sun/nio/cs/UTF_8.java	Thu Oct  9 16:02:01 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -25,34 +25,36 @@
- 
- package sun.nio.cs;
- 
-+import java.nio.Buffer;
- import java.nio.ByteBuffer;
- import java.nio.CharBuffer;
--import java.nio.BufferOverflowException;
--import java.nio.BufferUnderflowException;
- import java.nio.charset.Charset;
- import java.nio.charset.CharsetDecoder;
- import java.nio.charset.CharsetEncoder;
- import java.nio.charset.CoderResult;
--import java.nio.charset.CharacterCodingException;
--import java.nio.charset.MalformedInputException;
--import java.nio.charset.UnmappableCharacterException;
- 
--
--/*
-- * # Bits   Bit pattern
-- * 1    7   0xxxxxxx
-- * 2   11   110xxxxx 10xxxxxx
-- * 3   16   1110xxxx 10xxxxxx 10xxxxxx
-- * 4   21   11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-- * 5   26   111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-- * 6   31   1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-+/* Legal UTF-8 Byte Sequences
-  *
-- * UCS-2 uses 1-3, UTF-16 uses 1-4, UCS-4 uses 1-6
-+ * #    Code Points      Bits   Bit/Byte pattern
-+ * 1                     7      0xxxxxxx
-+ *      U+0000..U+007F          00..7F
-+ *
-+ * 2                     11     110xxxxx    10xxxxxx
-+ *      U+0080..U+07FF          C2..DF      80..BF
-+ *
-+ * 3                     16     1110xxxx    10xxxxxx    10xxxxxx
-+ *      U+0800..U+0FFF          E0          A0..BF      80..BF
-+ *      U+1000..U+FFFF          E1..EF      80..BF      80..BF
-+ *
-+ * 4                     21     11110xxx    10xxxxxx    10xxxxxx    10xxxxxx
-+ *     U+10000..U+3FFFF         F0          90..BF      80..BF      80..BF
-+ *     U+40000..U+FFFFF         F1..F3      80..BF      80..BF      80..BF
-+ *    U+100000..U10FFFF         F4          80..8F      80..BF      80..BF
-+ *
-  */
- 
- class UTF_8 extends Unicode
- {
--
-     public UTF_8() {
-         super("UTF-8", StandardCharsets.aliases_UTF_8);
-     }
-@@ -69,6 +71,11 @@
-         return new Encoder(this);
-     }
- 
-+    static final void updatePositions(Buffer src, int sp,
-+                                      Buffer dst, int dp) {
-+        src.position(sp - src.arrayOffset());
-+        dst.position(dp - dst.arrayOffset());
-+    }
- 
-     private static class Decoder extends CharsetDecoder {
-         private Decoder(Charset cs) {
-@@ -75,161 +82,182 @@
-             super(cs, 1.0f, 1.0f);
-         }
- 
--        private boolean isContinuation(int b) {
--            return ((b & 0xc0) == 0x80);
-+        private static boolean isNotContinuation(int b) {
-+            return (b & 0xc0) != 0x80;
-         }
- 
--        private final Surrogate.Generator sgg = new Surrogate.Generator();
-+        //  [C2..DF] [80..BF]
-+        private static boolean isMalformed2(int b1, int b2) {
-+            return (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
-+        }
- 
-+        //  [E0]     [A0..BF] [80..BF]
-+        //  [E1..EF] [80..BF] [80..BF]
-+        private static boolean isMalformed3(int b1, int b2, int b3) {
-+            return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
-+                   (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
-+        }
-+
-+        //  [F0]     [90..BF] [80..BF] [80..BF]
-+        //  [F1..F3] [80..BF] [80..BF] [80..BF]
-+        //  [F4]     [80..8F] [80..BF] [80..BF]
-+        //  only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
-+        //  will be checked by Surrogate.neededFor(uc)
-+        private static boolean isMalformed4(int b2, int b3, int b4) {
-+            return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
-+                   (b4 & 0xc0) != 0x80;
-+        }
-+
-+        private static CoderResult lookupN(ByteBuffer src, int n)
-+        {
-+            for (int i = 1; i < n; i++) {
-+               if (isNotContinuation(src.get()))
-+                   return CoderResult.malformedForLength(i);
-+            }
-+            return CoderResult.malformedForLength(n);
-+        }
-+
-+        private static CoderResult malformedN(ByteBuffer src, int nb) {
-+            switch (nb) {
-+            case 1:
-+                int b1 = src.get();
-+                if ((b1 >> 2) == -2) {
-+                    // 5 bytes 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-+                    if (src.remaining() < 4)
-+                        return CoderResult.UNDERFLOW;
-+                    return lookupN(src, 5);
-+                }
-+                if ((b1 >> 1) == -2) {
-+                    // 6 bytes 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-+                    if (src.remaining() < 5)
-+                        return CoderResult.UNDERFLOW;
-+                    return lookupN(src, 6);
-+                }
-+                return CoderResult.malformedForLength(1);
-+            case 2:                    // always 1
-+                return CoderResult.malformedForLength(1);
-+            case 3:
-+                b1 = src.get();
-+                int b2 = src.get();    // no need to lookup b3
-+                return CoderResult.malformedForLength(
-+                    ((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
-+                     isNotContinuation(b2))?1:2);
-+            case 4:  // we don't care the speed here
-+                b1 = src.get() & 0xff;
-+                b2 = src.get() & 0xff;
-+                if (b1 > 0xf4 ||
-+                    (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
-+                    (b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
-+                    isNotContinuation(b2))
-+                    return CoderResult.malformedForLength(1);
-+                if (isNotContinuation(src.get()))
-+                    return CoderResult.malformedForLength(2);
-+                return CoderResult.malformedForLength(3);
-+            default:
-+                assert false;
-+                return null;
-+            }
-+        }
-+
-+        private static CoderResult malformed(ByteBuffer src, int sp,
-+                                             CharBuffer dst, int dp,
-+                                             int nb)
-+        {
-+            src.position(sp - src.arrayOffset());
-+            CoderResult cr = malformedN(src, nb);
-+            updatePositions(src, sp, dst, dp);
-+            return cr;
-+        }
-+
-+        private static CoderResult malformed(ByteBuffer src,
-+                                             int mark, int nb)
-+        {
-+            src.position(mark);
-+            CoderResult cr = malformedN(src, nb);
-+            src.position(mark);
-+            return cr;
-+        }
-+
-+        private static CoderResult xflow(Buffer src, int sp, int sl,
-+                                         Buffer dst, int dp, int nb) {
-+            updatePositions(src, sp, dst, dp);
-+            return (nb == 0 || sl - sp < nb)
-+                   ?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
-+        }
-+
-+        private static CoderResult xflow(Buffer src, int mark, int nb) {
-+            CoderResult cr = (nb == 0 || src.remaining() < (nb - 1))
-+                             ?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
-+            src.position(mark);
-+            return cr;
-+        }
-+
-         private CoderResult decodeArrayLoop(ByteBuffer src,
-                                             CharBuffer dst)
-         {
-+            // This method is optimized for ASCII input.
-             byte[] sa = src.array();
-             int sp = src.arrayOffset() + src.position();
-             int sl = src.arrayOffset() + src.limit();
--            assert (sp <= sl);
--            sp = (sp <= sl ? sp : sl);
-+
-             char[] da = dst.array();
-             int dp = dst.arrayOffset() + dst.position();
-             int dl = dst.arrayOffset() + dst.limit();
--            assert (dp <= dl);
--            dp = (dp <= dl ? dp : dl);
-+            int dlASCII = dp + Math.min(sl - sp, dl - dp);
- 
--            try {
--                while (sp < sl) {
--                    int b1 = sa[sp];
--                    int b2, b3;
--                    switch ((b1 >> 4) & 0x0f) {
-+            // ASCII only loop
-+            while (dp < dlASCII && sa[sp] >= 0)
-+                da[dp++] = (char)sa[sp++];
- 
--                    case 0: case 1: case 2: case 3:
--                    case 4: case 5: case 6: case 7:
--                        // 1 byte, 7 bits: 0xxxxxxx
--                        if (dl - dp < 1)
--                            return CoderResult.OVERFLOW;
--                        da[dp++] = (char)(b1 & 0x7f);
--                        sp++;
--                        continue;
--
--                    case 12: case 13:
--                        // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
--                        if (sl - sp < 2)
--                            return CoderResult.UNDERFLOW;
--                        if (dl - dp < 1)
--                            return CoderResult.OVERFLOW;
--                        if (!isContinuation(b2 = sa[sp + 1]))
--                            return CoderResult.malformedForLength(1);
--                        da[dp++] = ((char)(((b1 & 0x1f) << 6) |
--                                           ((b2 & 0x3f) << 0)));
--                        sp += 2;
--                        continue;
--
--                    case 14:
--                        // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
--                        if (sl - sp < 3)
--                            return CoderResult.UNDERFLOW;
--                        if (dl - dp < 1)
--                            return CoderResult.OVERFLOW;
--                        if (!isContinuation(b2 = sa[sp + 1]))
--                            return CoderResult.malformedForLength(1);
--                        if (!isContinuation(b3 = sa[sp + 2]))
--                            return CoderResult.malformedForLength(2);
--                        da[dp++] = ((char)(((b1 & 0x0f) << 12) |
--                                           ((b2 & 0x3f) << 06) |
--                                           ((b3 & 0x3f) << 0)));
--                        sp += 3;
--                        continue;
--
--                    case 15:
--                        // 4, 5, or 6 bytes
--
--                        int b4, b5, b6, uc, n;
--                        switch (b1 & 0x0f) {
--
--                        case 0: case 1: case 2: case 3:
--                        case 4: case 5: case 6: case 7:
--                            // 4 bytes, 21 bits
--                            if (sl - sp < 4)
--                                return CoderResult.UNDERFLOW;
--                            if (!isContinuation(b2 = sa[sp + 1]))
--                                return CoderResult.malformedForLength(1);
--                            if (!isContinuation(b3 = sa[sp + 2]))
--                                return CoderResult.malformedForLength(2);
--                            if (!isContinuation(b4 = sa[sp + 3]))
--                                return CoderResult.malformedForLength(3);
--                            uc = (((b1 & 0x07) << 18) |
--                                  ((b2 & 0x3f) << 12) |
--                                  ((b3 & 0x3f) << 06) |
--                                  ((b4 & 0x3f) << 00));
--                            n = 4;
--                            break;
--
--                        case 8: case 9: case 10: case 11:
--                            // 5 bytes, 26 bits
--                            if (sl - sp < 5)
--                                return CoderResult.UNDERFLOW;
--                            if (!isContinuation(b2 = sa[sp + 1]))
--                                return CoderResult.malformedForLength(1);
--                            if (!isContinuation(b3 = sa[sp + 2]))
--                                return CoderResult.malformedForLength(2);
--                            if (!isContinuation(b4 = sa[sp + 3]))
--                                return CoderResult.malformedForLength(3);
--                            if (!isContinuation(b5 = sa[sp + 4]))
--                                return CoderResult.malformedForLength(4);
--                            uc = (((b1 & 0x03) << 24) |
--                                  ((b2 & 0x3f) << 18) |
--                                  ((b3 & 0x3f) << 12) |
--                                  ((b4 & 0x3f) << 06) |
--                                  ((b5 & 0x3f) << 00));
--                            n = 5;
--                            break;
--
--                        case 12: case 13:
--                            // 6 bytes, 31 bits
--                            if (sl - sp < 6)
--                                return CoderResult.UNDERFLOW;
--                            if (!isContinuation(b2 = sa[sp + 1]))
--                                return CoderResult.malformedForLength(1);
--                            if (!isContinuation(b3 = sa[sp + 2]))
--                                return CoderResult.malformedForLength(2);
--                            if (!isContinuation(b4 = sa[sp + 3]))
--                                return CoderResult.malformedForLength(3);
--                            if (!isContinuation(b5 = sa[sp + 4]))
--                                return CoderResult.malformedForLength(4);
--                            if (!isContinuation(b6 = sa[sp + 5]))
--                                return CoderResult.malformedForLength(5);
--                            uc = (((b1 & 0x01) << 30) |
--                                  ((b2 & 0x3f) << 24) |
--                                  ((b3 & 0x3f) << 18) |
--                                  ((b4 & 0x3f) << 12) |
--                                  ((b5 & 0x3f) << 06) |
--                                  ((b6 & 0x3f)));
--                            n = 6;
--                            break;
--
--                        default:
--                            return CoderResult.malformedForLength(1);
--
--                        }
--
--                        int gn = sgg.generate(uc, n, da, dp, dl);
--                        if (gn < 0)
--                            return sgg.error();
--                        dp += gn;
--                        sp += n;
--                        continue;
--
--                    default:
--                        return CoderResult.malformedForLength(1);
--
-+            while (sp < sl) {
-+                int b1 = sa[sp];
-+                if (b1  >= 0) {
-+                    // 1 byte, 7 bits: 0xxxxxxx
-+                    if (dp >= dl)
-+                        return xflow(src, sp, sl, dst, dp, 1);
-+                    da[dp++] = (char)b1;
-+                    sp++;
-+                } else if ((b1 >> 5) == -2) {
-+                    // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
-+                    if (sl - sp < 2 || dp >= dl)
-+                        return xflow(src, sp, sl, dst, dp, 2);
-+                    int b2 = sa[sp + 1];
-+                    if (isMalformed2(b1, b2))
-+                        return malformed(src, sp, dst, dp, 2);
-+                    da[dp++] = (char) (((b1 << 6) ^ b2) ^ 0x0f80);
-+                    sp += 2;
-+                } else if ((b1 >> 4) == -2) {
-+                    // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
-+                    if (sl - sp < 3 || dp >= dl)
-+                        return xflow(src, sp, sl, dst, dp, 3);
-+                    int b2 = sa[sp + 1];
-+                    int b3 = sa[sp + 2];
-+                    if (isMalformed3(b1, b2, b3))
-+                        return malformed(src, sp, dst, dp, 3);
-+                    da[dp++] = (char) (((b1 << 12) ^ (b2 << 6) ^ b3) ^ 0x1f80);
-+                    sp += 3;
-+                } else if ((b1 >> 3) == -2) {
-+                    // 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-+                    if (sl - sp < 4 || dl - dp < 2)
-+                        return xflow(src, sp, sl, dst, dp, 4);
-+                    int b2 = sa[sp + 1];
-+                    int b3 = sa[sp + 2];
-+                    int b4 = sa[sp + 3];
-+                    int uc = ((b1 & 0x07) << 18) |
-+                             ((b2 & 0x3f) << 12) |
-+                             ((b3 & 0x3f) << 06) |
-+                             (b4 & 0x3f);
-+                    if (isMalformed4(b2, b3, b4) ||
-+                        !Surrogate.neededFor(uc)) {
-+                        return malformed(src, sp, dst, dp, 4);
-                     }
--
--                }
--
--                return CoderResult.UNDERFLOW;
--            } finally {
--                src.position(sp - src.arrayOffset());
--                dst.position(dp - dst.arrayOffset());
-+                    da[dp++] = Surrogate.high(uc);
-+                    da[dp++] = Surrogate.low(uc);
-+                    sp += 4;
-+                } else
-+                    return malformed(src, sp, dst, dp, 1);
-             }
-+            return xflow(src, sp, sl, dst, dp, 0);
-         }
- 
-         private CoderResult decodeBufferLoop(ByteBuffer src,
-@@ -236,137 +264,57 @@
-                                              CharBuffer dst)
-         {
-             int mark = src.position();
--            try {
--                while (src.hasRemaining()) {
--                    int b1 = src.get();
--                    int b2, b3;
--                    switch ((b1 >> 4) & 0x0f) {
--
--                    case 0: case 1: case 2: case 3:
--                    case 4: case 5: case 6: case 7:
--                        // 1 byte, 7 bits: 0xxxxxxx
--                        if (dst.remaining() < 1)
--                            return CoderResult.OVERFLOW;
--                        dst.put((char)b1);
--                        mark++;
--                        continue;
--
--                    case 12: case 13:
--                        // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
--                        if (src.remaining() < 1)
--                            return CoderResult.UNDERFLOW;
--                        if (dst.remaining() < 1)
--                            return CoderResult.OVERFLOW;
--                        if (!isContinuation(b2 = src.get()))
--                            return CoderResult.malformedForLength(1);
--                        dst.put((char)(((b1 & 0x1f) << 6) |
--                                       ((b2 & 0x3f) << 0)));
--                        mark += 2;
--                        continue;
--
--                    case 14:
--                        // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
--                        if (src.remaining() < 2)
--                            return CoderResult.UNDERFLOW;
--                        if (dst.remaining() < 1)
--                            return CoderResult.OVERFLOW;
--                        if (!isContinuation(b2 = src.get()))
--                            return CoderResult.malformedForLength(1);
--                        if (!isContinuation(b3 = src.get()))
--                            return CoderResult.malformedForLength(2);
--                        dst.put((char)(((b1 & 0x0f) << 12) |
--                                       ((b2 & 0x3f) << 06) |
--                                       ((b3 & 0x3f) << 0)));
--                        mark += 3;
--                        continue;
--
--                    case 15:
--                        // 4, 5, or 6 bytes
--
--                        int b4, b5, b6, uc, n;
--                        switch (b1 & 0x0f) {
--
--                        case 0: case 1: case 2: case 3:
--                        case 4: case 5: case 6: case 7:
--                            // 4 bytes, 21 bits
--                            if (src.remaining() < 3)
--                                return CoderResult.UNDERFLOW;
--                            if (!isContinuation(b2 = src.get()))
--                                return CoderResult.malformedForLength(1);
--                            if (!isContinuation(b3 = src.get()))
--                                return CoderResult.malformedForLength(2);
--                            if (!isContinuation(b4 = src.get()))
--                                return CoderResult.malformedForLength(3);
--                            uc = (((b1 & 0x07) << 18) |
--                                  ((b2 & 0x3f) << 12) |
--                                  ((b3 & 0x3f) << 06) |
--                                  ((b4 & 0x3f) << 00));
--                            n = 4;
--                            break;
--
--                        case 8: case 9: case 10: case 11:
--                            // 5 bytes, 26 bits
--                            if (src.remaining() < 4)
--                                return CoderResult.UNDERFLOW;
--                            if (!isContinuation(b2 = src.get()))
--                                return CoderResult.malformedForLength(1);
--                            if (!isContinuation(b3 = src.get()))
--                                return CoderResult.malformedForLength(2);
--                            if (!isContinuation(b4 = src.get()))
--                                return CoderResult.malformedForLength(3);
--                            if (!isContinuation(b5 = src.get()))
--                                return CoderResult.malformedForLength(4);
--                            uc = (((b1 & 0x03) << 24) |
--                                  ((b2 & 0x3f) << 18) |
--                                  ((b3 & 0x3f) << 12) |
--                                  ((b4 & 0x3f) << 06) |
--                                  ((b5 & 0x3f) << 00));
--                            n = 5;
--                            break;
--
--                        case 12: case 13:
--                            // 6 bytes, 31 bits
--                            if (src.remaining() < 4)
--                                return CoderResult.UNDERFLOW;
--                            if (!isContinuation(b2 = src.get()))
--                                return CoderResult.malformedForLength(1);
--                            if (!isContinuation(b3 = src.get()))
--                                return CoderResult.malformedForLength(2);
--                            if (!isContinuation(b4 = src.get()))
--                                return CoderResult.malformedForLength(3);
--                            if (!isContinuation(b5 = src.get()))
--                                return CoderResult.malformedForLength(4);
--                            if (!isContinuation(b6 = src.get()))
--                                return CoderResult.malformedForLength(5);
--                            uc = (((b1 & 0x01) << 30) |
--                                  ((b2 & 0x3f) << 24) |
--                                  ((b3 & 0x3f) << 18) |
--                                  ((b4 & 0x3f) << 12) |
--                                  ((b5 & 0x3f) << 06) |
--                                  ((b6 & 0x3f)));
--                            n = 6;
--                            break;
--
--                        default:
--                            return CoderResult.malformedForLength(1);
--
--                        }
--
--                        if (sgg.generate(uc, n, dst) < 0)
--                            return sgg.error();
--                        mark += n;
--                        continue;
--
--                    default:
--                        return CoderResult.malformedForLength(1);
--
-+            int limit = src.limit();
-+            while (mark < limit) {
-+                int b1 = src.get();
-+                if (b1 >= 0) {
-+                    // 1 byte, 7 bits: 0xxxxxxx
-+                    if (dst.remaining() < 1)
-+                        return xflow(src, mark, 1);  //overflow
-+                    dst.put((char)b1);
-+                    mark++;
-+                } else if ((b1 >> 5) == -2) {
-+                    // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
-+                    if (limit - mark < 2|| dst.remaining() < 1)
-+                        return xflow(src, mark, 2);
-+                    int b2 = src.get();
-+                    if (isMalformed2(b1, b2))
-+                        return malformed(src, mark, 2);
-+                    dst.put((char) (((b1 << 6) ^ b2) ^ 0x0f80));
-+                    mark += 2;
-+                } else if ((b1 >> 4) == -2) {
-+                    // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
-+                    if (limit - mark < 3 || dst.remaining() < 1)
-+                        return xflow(src, mark, 3);
-+                    int b2 = src.get();
-+                    int b3 = src.get();
-+                    if (isMalformed3(b1, b2, b3))
-+                        return malformed(src, mark, 3);
-+                    dst.put((char) (((b1 << 12) ^ (b2 << 6) ^ b3) ^ 0x1f80));
-+                    mark += 3;
-+                } else if ((b1 >> 3) == -2) {
-+                    // 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-+                    if (limit - mark < 4 || dst.remaining() < 2)
-+                        return xflow(src, mark, 4);
-+                    int b2 = src.get();
-+                    int b3 = src.get();
-+                    int b4 = src.get();
-+                    int uc = ((b1 & 0x07) << 18) |
-+                             ((b2 & 0x3f) << 12) |
-+                             ((b3 & 0x3f) << 06) |
-+                             (b4 & 0x3f);
-+                    if (isMalformed4(b2, b3, b4) ||
-+                        !Surrogate.neededFor(uc)) { // shortest form check
-+                        return malformed(src, mark, 4);
-                     }
--
-+                    dst.put(Surrogate.high(uc));
-+                    dst.put(Surrogate.low(uc));
-+                    mark += 4;
-+                } else {
-+                    return malformed(src, mark, 1);
-                 }
--                return CoderResult.UNDERFLOW;
--            } finally {
--                src.position(mark);
-             }
-+            return xflow(src, mark, 0);
-         }
- 
-         protected CoderResult decodeLoop(ByteBuffer src,
-@@ -377,10 +325,8 @@
-             else
-                 return decodeBufferLoop(src, dst);
-         }
--
-     }
- 
--
-     private static class Encoder extends CharsetEncoder {
- 
-         private Encoder(Charset cs) {
-@@ -391,8 +337,23 @@
-             return !Surrogate.is(c);
-         }
- 
--        private final Surrogate.Parser sgp = new Surrogate.Parser();
-+        public boolean isLegalReplacement(byte[] repl) {
-+            return ((repl.length == 1 && repl[0] >= 0) ||
-+                    super.isLegalReplacement(repl));
-+        }
- 
-+        private static CoderResult overflow(CharBuffer src, int sp,
-+                                            ByteBuffer dst, int dp) {
-+            updatePositions(src, sp, dst, dp);
-+            return CoderResult.OVERFLOW;
-+        }
-+
-+        private static CoderResult overflow(CharBuffer src, int mark) {
-+            src.position(mark);
-+            return CoderResult.OVERFLOW;
-+        }
-+
-+        private Surrogate.Parser sgp;
-         private CoderResult encodeArrayLoop(CharBuffer src,
-                                             ByteBuffer dst)
-         {
-@@ -399,71 +360,56 @@
-             char[] sa = src.array();
-             int sp = src.arrayOffset() + src.position();
-             int sl = src.arrayOffset() + src.limit();
--            assert (sp <= sl);
--            sp = (sp <= sl ? sp : sl);
-+
-             byte[] da = dst.array();
-             int dp = dst.arrayOffset() + dst.position();
-             int dl = dst.arrayOffset() + dst.limit();
--            assert (dp <= dl);
--            dp = (dp <= dl ? dp : dl);
-+            int dlASCII = dp + Math.min(sl - sp, dl - dp);
- 
--            try {
--                while (sp < sl) {
--                    char c = sa[sp];
--
--                    if (c < 0x80) {
--                        // Have at most seven bits
--                        if (dp >= dl)
--                            return CoderResult.OVERFLOW;
--                        da[dp++] = (byte)c;
--                        sp++;
--                        continue;
--                    }
--
--                    if (!Surrogate.is(c)) {
--                        // 2 bytes, 11 bits
--                        if (c < 0x800) {
--                            if (dl - dp < 2)
--                                return CoderResult.OVERFLOW;
--                            da[dp++] = (byte)(0xc0 | ((c >> 06)));
--                            da[dp++] = (byte)(0x80 | ((c >> 00) & 0x3f));
--                            sp++;
--                            continue;
--                        }
--                        if (c <= '\uFFFF') {
--                            // 3 bytes, 16 bits
--                            if (dl - dp < 3)
--                                return CoderResult.OVERFLOW;
--                            da[dp++] = (byte)(0xe0 | ((c >> 12)));
--                            da[dp++] = (byte)(0x80 | ((c >> 06) & 0x3f));
--                            da[dp++] = (byte)(0x80 | ((c >> 00) & 0x3f));
--                            sp++;
--                            continue;
--                        }
--                    }
--
-+            //ASCII only loop
-+            while (dp < dlASCII && sa[sp] < '\u0080')
-+                da[dp++] = (byte) sa[sp++];
-+            while (sp < sl) {
-+                int c = sa[sp];
-+                if (c < 0x80) {
-+                    // Have at most seven bits
-+                    if (dp >= dl)
-+                        return overflow(src, sp, dst, dp);
-+                    da[dp++] = (byte)c;
-+                } else if (c < 0x800) {
-+                    // 2 bytes, 11 bits
-+                    if (dl - dp < 2)
-+                        return overflow(src, sp, dst, dp);
-+                    da[dp++] = (byte)(0xc0 | ((c >> 06)));
-+                    da[dp++] = (byte)(0x80 | (c & 0x3f));
-+                } else if (Surrogate.is(c)) {
-                     // Have a surrogate pair
--                    int uc = sgp.parse(c, sa, sp, sl);
--                    if (uc < 0)
-+                    if (sgp == null)
-+                        sgp = new Surrogate.Parser();
-+                    int uc = sgp.parse((char)c, sa, sp, sl);
-+                    if (uc < 0) {
-+                        updatePositions(src, sp, dst, dp);
-                         return sgp.error();
--                    if (uc < 0x200000) {
--                        if (dl - dp < 4)
--                            return CoderResult.OVERFLOW;
--                        da[dp++] = (byte)(0xf0 | ((uc >> 18)));
--                        da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
--                        da[dp++] = (byte)(0x80 | ((uc >> 06) & 0x3f));
--                        da[dp++] = (byte)(0x80 | ((uc >> 00) & 0x3f));
--                        sp += sgp.increment();
--                        continue;
-                     }
--                    assert false;
--
-+                    if (dl - dp < 4)
-+                        return overflow(src, sp, dst, dp);
-+                    da[dp++] = (byte)(0xf0 | ((uc >> 18)));
-+                    da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
-+                    da[dp++] = (byte)(0x80 | ((uc >> 06) & 0x3f));
-+                    da[dp++] = (byte)(0x80 | (uc & 0x3f));
-+                    sp++;  // 2 chars
-+                } else {
-+                    // 3 bytes, 16 bits
-+                    if (dl - dp < 3)
-+                        return overflow(src, sp, dst, dp);
-+                    da[dp++] = (byte)(0xe0 | ((c >> 12)));
-+                    da[dp++] = (byte)(0x80 | ((c >> 06) & 0x3f));
-+                    da[dp++] = (byte)(0x80 | (c & 0x3f));
-                 }
--                return CoderResult.UNDERFLOW;
--            } finally {
--                src.position(sp - src.arrayOffset());
--                dst.position(dp - dst.arrayOffset());
-+                sp++;
-             }
-+            updatePositions(src, sp, dst, dp);
-+            return CoderResult.UNDERFLOW;
-         }
- 
-         private CoderResult encodeBufferLoop(CharBuffer src,
-@@ -470,62 +416,47 @@
-                                              ByteBuffer dst)
-         {
-             int mark = src.position();
--            try {
--                while (src.hasRemaining()) {
--                    char c = src.get();
--
--                    if (c < 0x80) {
--                        // Have at most seven bits
--                        if (!dst.hasRemaining())
--                            return CoderResult.OVERFLOW;
--                        dst.put((byte)c);
--                        mark++;
--                        continue;
--                    }
--
--                    if (!Surrogate.is(c)) {
--                        if (c < 0x800) {
--                            // 2 bytes, 11 bits
--                            if (dst.remaining() < 2)
--                                return CoderResult.OVERFLOW;
--                            dst.put((byte)(0xc0 | ((c >> 06))));
--                            dst.put((byte)(0x80 | ((c >> 00) & 0x3f)));
--                            mark++;
--                            continue;
--                        }
--                        if (c <= '\uFFFF') {
--                            // 3 bytes, 16 bits
--                            if (dst.remaining() < 3)
--                                return CoderResult.OVERFLOW;
--                            dst.put((byte)(0xe0 | ((c >> 12))));
--                            dst.put((byte)(0x80 | ((c >> 06) & 0x3f)));
--                            dst.put((byte)(0x80 | ((c >> 00) & 0x3f)));
--                            mark++;
--                            continue;
--                        }
--                    }
--
-+            while (src.hasRemaining()) {
-+                int c = src.get();
-+                if (c < 0x80) {
-+                    // Have at most seven bits
-+                    if (!dst.hasRemaining())
-+                        return overflow(src, mark);
-+                    dst.put((byte)c);
-+                } else if (c < 0x800) {
-+                    // 2 bytes, 11 bits
-+                    if (dst.remaining() < 2)
-+                        return overflow(src, mark);
-+                    dst.put((byte)(0xc0 | ((c >> 06))));
-+                    dst.put((byte)(0x80 | (c & 0x3f)));
-+                } else if (Surrogate.is(c)) {
-                     // Have a surrogate pair
--                    int uc = sgp.parse(c, src);
--                    if (uc < 0)
-+                    if (sgp == null)
-+                        sgp = new Surrogate.Parser();
-+                    int uc = sgp.parse((char)c, src);
-+                    if (uc < 0) {
-+                        src.position(mark);
-                         return sgp.error();
--                    if (uc < 0x200000) {
--                        if (dst.remaining() < 4)
--                            return CoderResult.OVERFLOW;
--                        dst.put((byte)(0xf0 | ((uc >> 18))));
--                        dst.put((byte)(0x80 | ((uc >> 12) & 0x3f)));
--                        dst.put((byte)(0x80 | ((uc >> 06) & 0x3f)));
--                        dst.put((byte)(0x80 | ((uc >> 00) & 0x3f)));
--                        mark += sgp.increment();
--                        continue;
-                     }
--                    assert false;
--
-+                    if (dst.remaining() < 4)
-+                        return overflow(src, mark);
-+                    dst.put((byte)(0xf0 | ((uc >> 18))));
-+                    dst.put((byte)(0x80 | ((uc >> 12) & 0x3f)));
-+                    dst.put((byte)(0x80 | ((uc >> 06) & 0x3f)));
-+                    dst.put((byte)(0x80 | (uc & 0x3f)));
-+                    mark++;  //2 chars
-+                } else {
-+                    // 3 bytes, 16 bits
-+                    if (dst.remaining() < 3)
-+                        return overflow(src, mark);
-+                    dst.put((byte)(0xe0 | ((c >> 12))));
-+                    dst.put((byte)(0x80 | ((c >> 06) & 0x3f)));
-+                    dst.put((byte)(0x80 | (c & 0x3f)));
-                 }
--                return CoderResult.UNDERFLOW;
--            } finally {
--                src.position(mark);
-+                mark++;
-             }
-+            src.position(mark);
-+            return CoderResult.UNDERFLOW;
-         }
- 
-         protected final CoderResult encodeLoop(CharBuffer src,
-@@ -536,7 +467,5 @@
-             else
-                 return encodeBufferLoop(src, dst);
-         }
--
-     }
--
- }
---- /dev/null	Thu Oct  9 16:02:14 2008
-+++ openjdk/jdk/test/sun/nio/cs/TestUTF8.java	Thu Oct  9 16:02:14 2008
-@@ -0,0 +1,393 @@
-+/*
-+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ *
-+ * This code is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 only, as
-+ * published by the Free Software Foundation.
-+ *
-+ * This code 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
-+ * version 2 for more details (a copy is included in the LICENSE file that
-+ * accompanied this code).
-+ *
-+ * You should have received a copy of the GNU General Public License version
-+ * 2 along with this work; if not, write to the Free Software Foundation,
-+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-+ * CA 95054 USA or visit www.sun.com if you need additional information or
-+ * have any questions.
-+ */
-+
-+/*
-+ * @test
-+ * @bug 4486841
-+ * @summary Test UTF-8 charset
-+ */
-+
-+import java.nio.charset.*;
-+import java.nio.*;
-+import java.util.*;
-+
-+public class TestUTF8 {
-+    static char[] decode(byte[] bb, String csn, boolean testDirect)
-+        throws Exception {
-+        CharsetDecoder dec = Charset.forName(csn).newDecoder();
-+        ByteBuffer bbf;
-+        CharBuffer cbf;
-+        if (testDirect) {
-+            bbf = ByteBuffer.allocateDirect(bb.length);
-+            cbf = ByteBuffer.allocateDirect(bb.length*2).asCharBuffer();
-+            bbf.put(bb).flip();
-+        } else {
-+            bbf = ByteBuffer.wrap(bb);
-+            cbf = CharBuffer.allocate(bb.length);
-+        }
-+        CoderResult cr = dec.decode(bbf, cbf, true);
-+        if (cr != CoderResult.UNDERFLOW)
-+            throw new RuntimeException("Decoding err: " + csn);
-+        char[] cc = new char[cbf.position()];
-+        cbf.flip(); cbf.get(cc);
-+        return cc;
-+
-+    }
-+
-+    static CoderResult decodeCR(byte[] bb, String csn, boolean testDirect)
-+        throws Exception {
-+        CharsetDecoder dec = Charset.forName(csn).newDecoder();
-+        ByteBuffer bbf;
-+        CharBuffer cbf;
-+        if (testDirect) {
-+            bbf = ByteBuffer.allocateDirect(bb.length);
-+            cbf = ByteBuffer.allocateDirect(bb.length*2).asCharBuffer();
-+            bbf.put(bb).flip();
-+        } else {
-+            bbf = ByteBuffer.wrap(bb);
-+            cbf = CharBuffer.allocate(bb.length);
-+        }
-+        return dec.decode(bbf, cbf, true);
-+    }
-+
-+    static byte[] encode(char[] cc, String csn, boolean testDirect)
-+        throws Exception {
-+        ByteBuffer bbf;
-+        CharBuffer cbf;
-+        CharsetEncoder enc = Charset.forName(csn).newEncoder();
-+        if (testDirect) {
-+            bbf = ByteBuffer.allocateDirect(cc.length * 4);
-+            cbf = ByteBuffer.allocateDirect(cc.length * 2).asCharBuffer();
-+            cbf.put(cc).flip();
-+        } else {
-+            bbf = ByteBuffer.allocate(cc.length * 4);
-+            cbf = CharBuffer.wrap(cc);
-+        }
-+
-+        CoderResult cr = enc.encode(cbf, bbf, true);
-+        if (cr != CoderResult.UNDERFLOW)
-+            throw new RuntimeException("Encoding err: " + csn);
-+        byte[] bb = new byte[bbf.position()];
-+        bbf.flip(); bbf.get(bb);
-+        return bb;
-+    }
-+
-+    static CoderResult encodeCR(char[] cc, String csn, boolean testDirect)
-+        throws Exception {
-+        ByteBuffer bbf;
-+        CharBuffer cbf;
-+        CharsetEncoder enc = Charset.forName(csn).newEncoder();
-+        if (testDirect) {
-+            bbf = ByteBuffer.allocateDirect(cc.length * 4);
-+            cbf = ByteBuffer.allocateDirect(cc.length * 2).asCharBuffer();
-+            cbf.put(cc).flip();
-+        } else {
-+            bbf = ByteBuffer.allocate(cc.length * 4);
-+            cbf = CharBuffer.wrap(cc);
-+        }
-+        return enc.encode(cbf, bbf, true);
-+    }
-+
-+    static char[] getUTFChars() {
-+        char[] cc = new char[0x10000 - 0xe000 + 0xd800 + //bmp
-+                             (0x110000 - 0x10000) * 2];    //supp
-+        int pos = 0;
-+        int i = 0;
-+        for (i = 0; i < 0xd800; i++)
-+            cc[pos++] = (char)i;
-+        for (i = 0xe000; i < 0x10000; i++)
-+            cc[pos++] = (char)i;
-+        for (i = 0x10000; i < 0x110000; i++) {
-+            pos += Character.toChars(i, cc, pos);
-+        }
-+        return cc;
-+    }
-+
-+    static int to3ByteUTF8(char c, byte[] bb, int pos) {
-+        bb[pos++] = (byte)(0xe0 | ((c >> 12)));
-+        bb[pos++] = (byte)(0x80 | ((c >> 06) & 0x3f));
-+        bb[pos++] = (byte)(0x80 | ((c >> 00) & 0x3f));
-+        return 3;
-+    }
-+
-+    static void checkRoundtrip(String csn) throws Exception {
-+        System.out.printf("    Check roundtrip <%s>...", csn);
-+        char[] cc = getUTFChars();
-+        byte[] bb = encode(cc, csn, false);
-+        char[] ccO = decode(bb, csn, false);
-+
-+        if (!Arrays.equals(cc, ccO)) {
-+            System.out.printf("    non-direct failed");
-+        }
-+        bb = encode(cc, csn, true);
-+        ccO = decode(bb, csn, true);
-+        if (!Arrays.equals(cc, ccO)) {
-+            System.out.printf("    (direct) failed");
-+        }
-+        System.out.println();
-+    }
-+
-+    static void check6ByteSurrs(String csn) throws Exception {
-+        System.out.printf("    Check 6-byte Surrogates <%s>...%n", csn);
-+        byte[] bb = new byte[(0x110000 - 0x10000) * 6];
-+        char[] cc = new char[(0x110000 - 0x10000) * 2];
-+        int bpos = 0;
-+        int cpos = 0;
-+        for (int i = 0x10000; i < 0x110000; i++) {
-+            Character.toChars(i, cc, cpos);
-+            bpos += to3ByteUTF8(cc[cpos], bb, bpos);
-+            bpos += to3ByteUTF8(cc[cpos + 1], bb, bpos);
-+            cpos += 2;
-+        }
-+
-+        char[] ccO = decode(bb, csn, false);
-+        if (!Arrays.equals(cc, ccO)) {
-+            System.out.printf("    decoding failed%n");
-+        }
-+        ccO = decode(bb, csn, true);
-+        if (!Arrays.equals(cc, ccO)) {
-+            System.out.printf("    decoding(direct) failed%n");
-+        }
-+    }
-+
-+    static void compare(String csn1, String csn2) throws Exception {
-+        System.out.printf("    Diff <%s> <%s>...%n", csn1, csn2);
-+        char[] cc = getUTFChars();
-+
-+        byte[] bb1 = encode(cc, csn1, false);
-+        byte[] bb2 = encode(cc, csn2, false);
-+        if (!Arrays.equals(bb1, bb2))
-+            System.out.printf("        encoding failed%n");
-+        char[] cc1 = decode(bb1, csn1, false);
-+        char[] cc2 = decode(bb1, csn2, false);
-+        if (!Arrays.equals(cc1, cc2)) {
-+            System.out.printf("        decoding failed%n");
-+        }
-+
-+        bb1 = encode(cc, csn1, true);
-+        bb2 = encode(cc, csn2, true);
-+        if (!Arrays.equals(bb1, bb2))
-+            System.out.printf("        encoding (direct) failed%n");
-+        cc1 = decode(bb1, csn1, true);
-+        cc2 = decode(bb1, csn2, true);
-+        if (!Arrays.equals(cc1, cc2)) {
-+            System.out.printf("        decoding (direct) failed%n");
-+        }
-+    }
-+
-+    // The first byte is the length of malformed bytes
-+    static byte[][] malformed = {
-+        // One-byte sequences:
-+        {1, (byte)0xFF },
-+        {1, (byte)0xC0 },
-+        {1, (byte)0x80 },
-+
-+        {1, (byte)0xFF, (byte)0xFF}, // all ones
-+        {1, (byte)0xA0, (byte)0x80}, // 101x first byte first nibble
-+
-+        // Two-byte sequences:
-+        {1, (byte)0xC0, (byte)0x80}, // invalid first byte
-+        {1, (byte)0xC1, (byte)0xBF}, // invalid first byte
-+        {1, (byte)0xC2, (byte)0x00}, // invalid second byte
-+        {1, (byte)0xC2, (byte)0xC0}, // invalid second byte
-+        {1, (byte)0xD0, (byte)0x00}, // invalid second byte
-+        {1, (byte)0xD0, (byte)0xC0}, // invalid second byte
-+        {1, (byte)0xDF, (byte)0x00}, // invalid second byte
-+        {1, (byte)0xDF, (byte)0xC0}, // invalid second byte
-+
-+        // Three-byte sequences
-+        {1, (byte)0xE0, (byte)0x80, (byte)0x80},  // 111x first byte first nibble
-+        {1, (byte)0xE0, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
-+        {1, (byte)0xE0, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
-+        {1, (byte)0xE0, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
-+
-+        {1, (byte)0xE0, (byte)0xC0, (byte)0xBF }, // invalid second byte
-+        {2, (byte)0xE0, (byte)0xA0, (byte)0x7F }, // invalid third byte
-+        {2, (byte)0xE0, (byte)0xA0, (byte)0xC0 }, // invalid third byte
-+        {1, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
-+        {1, (byte)0xE0, (byte)0xC0, (byte)0x80 }, // invalid second byte
-+        {1, (byte)0xE0, (byte)0x80, (byte)0xC0 }, // invalid first byte
-+
-+        // Four-byte sequences
-+        {1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
-+        {1, (byte)0xF0, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
-+        {1, (byte)0xF0, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+007F zero-padded
-+        {1, (byte)0xF0, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+07FF zero-padded
-+
-+        {1, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
-+        {1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80},  // invalid second byte
-+        {1, (byte)0xF0, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
-+        {2, (byte)0xF0, (byte)0x90, (byte)0xC0, (byte)0x80 }, // invalid third byte
-+        {3, (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0xC0 }, // invalid third byte
-+
-+        {1, (byte)0xF1, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
-+        {2, (byte)0xF1, (byte)0x80, (byte)0xC0, (byte)0x80 }, // invalid third byte
-+        {3, (byte)0xF1, (byte)0x80, (byte)0x80, (byte)0xC0 }, // invalid forth byte
-+        {1, (byte)0xF4, (byte)0x90, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
-+        {1, (byte)0xF4, (byte)0xC0, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
-+        {1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
-+
-+        // Five-byte sequences
-+        {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80},  // invalid first byte
-+        {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
-+        {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
-+        {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
-+        {5, (byte)0xF8, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
-+
-+        {1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80},
-+        {2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80 },
-+        {3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF },
-+        {4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0 },
-+
-+        // Six-byte sequences
-+        {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
-+        {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
-+        {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
-+        {6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
-+        {1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 },
-+        {2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80 },
-+        {3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF, (byte)0x80 },
-+        {4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0, (byte)0x80 },
-+        {5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0x80, (byte)0xC0 },
-+    };
-+
-+    static void checkMalformed(String csn) throws Exception {
-+        boolean failed = false;
-+        System.out.printf("    Check malformed <%s>...%n", csn);
-+        for (boolean direct: new boolean[] {false, true}) {
-+            for (byte[] bins : malformed) {
-+                int mlen = bins[0];
-+                byte[] bin = Arrays.copyOfRange(bins, 1, bins.length);
-+                CoderResult cr = decodeCR(bin, csn, direct);
-+                String ashex = "";
-+                for (int i = 0; i < bin.length; i++) {
-+                    if (i > 0) ashex += " ";
-+                        ashex += Integer.toBinaryString((int)bin[i] & 0xff);
-+                }
-+                if (!cr.isMalformed()) {
-+                    System.out.printf("        FAIL(direct=%b): [%s] not malformed.\n", direct, ashex);
-+                    failed = true;
-+                } else if (cr.length() != mlen) {
-+                    System.out.printf("        FAIL(direct=%b): [%s] malformed[len=%d].\n", direct, ashex, cr.length());
-+                    failed = true;
-+                }
-+            }
-+        }
-+        if (failed)
-+            throw new RuntimeException("Check malformed failed " + csn);
-+    }
-+
-+    static boolean check(CharsetDecoder dec, byte[] utf8s, boolean direct, int[] flow) {
-+        int inPos = flow[0];
-+        int inLen = flow[1];
-+        int outPos = flow[2];
-+        int outLen = flow[3];
-+        int expedInPos = flow[4];
-+        int expedOutPos = flow[5];
-+        CoderResult expedCR = (flow[6]==0)?CoderResult.UNDERFLOW
-+                                          :CoderResult.OVERFLOW;
-+        ByteBuffer bbf;
-+        CharBuffer cbf;
-+        if (direct) {
-+            bbf = ByteBuffer.allocateDirect(inPos + utf8s.length);
-+            cbf = ByteBuffer.allocateDirect((outPos + outLen)*2).asCharBuffer();
-+        } else {
-+            bbf = ByteBuffer.allocate(inPos + utf8s.length);
-+            cbf = CharBuffer.allocate(outPos + outLen);
-+        }
-+        bbf.position(inPos);
-+        bbf.put(utf8s).flip().position(inPos).limit(inPos + inLen);
-+        cbf.position(outPos);
-+        dec.reset();
-+        CoderResult cr = dec.decode(bbf, cbf, false);
-+        if (cr != expedCR ||
-+            bbf.position() != expedInPos ||
-+            cbf.position() != expedOutPos) {
-+            System.out.printf("Expected(direct=%5b): [", direct);
-+            for (int i:flow) System.out.print(" " + i);
-+            System.out.println("]  CR=" + cr +
-+                               ", inPos=" + bbf.position() +
-+                               ", outPos=" + cbf.position());
-+            return false;
-+        }
-+        return true;
-+    }
-+
-+    static void checkUnderOverflow(String csn) throws Exception {
-+        System.out.printf("    Check under/overflow <%s>...%n", csn);
-+        CharsetDecoder dec = Charset.forName(csn).newDecoder();
-+        boolean failed = false;
-+        byte[] utf8s = new String("\u007f\u07ff\ue000\ud800\udc00").getBytes("UTF-8");
-+        int    inlen = utf8s.length;
-+
-+        for (int inoff = 0; inoff < 20; inoff++) {
-+            for (int outoff = 0; outoff < 20; outoff++) {
-+        int[][] Flows = {
-+            //inpos, inLen, outPos,  outLen, inPosEP,   outposEP,   under(0)/over(1)
-+            {inoff,  inlen, outoff,  1,      inoff + 1, outoff + 1, 1},
-+            {inoff,  inlen, outoff,  2,      inoff + 3, outoff + 2, 1},
-+            {inoff,  inlen, outoff,  3,      inoff + 6, outoff + 3, 1},
-+            {inoff,  inlen, outoff,  4,      inoff + 6, outoff + 3, 1},
-+            {inoff,  inlen, outoff,  5,      inoff + 10,outoff + 5, 0},
-+             // underflow
-+            {inoff,  1,     outoff,  5,      inoff + 1, outoff + 1, 0},
-+            {inoff,  2,     outoff,  5,      inoff + 1, outoff + 1, 0},
-+            {inoff,  3,     outoff,  5,      inoff + 3, outoff + 2, 0},
-+            {inoff,  4,     outoff,  5,      inoff + 3, outoff + 2, 0},
-+            {inoff,  5,     outoff,  5,      inoff + 3, outoff + 2, 0},
-+            {inoff,  6,     outoff,  5,      inoff + 6, outoff + 3, 0},
-+            {inoff,  7,     outoff,  5,      inoff + 6, outoff + 3, 0},
-+            {inoff,  8,     outoff,  5,      inoff + 6, outoff + 3, 0},
-+            {inoff,  9,     outoff,  5,      inoff + 6, outoff + 3, 0},
-+            {inoff,  10,    outoff,  5,      inoff + 10,outoff + 5, 0},
-+             // 2-byte underflow/overflow
-+            {inoff,  2,     outoff,  1,      inoff + 1, outoff + 1, 0},
-+            {inoff,  3,     outoff,  1,      inoff + 1, outoff + 1, 1},
-+             // 3-byte underflow/overflow
-+            {inoff,  4,     outoff,  2,      inoff + 3, outoff + 2, 0},
-+            {inoff,  5,     outoff,  2,      inoff + 3, outoff + 2, 0},
-+            {inoff,  6,     outoff,  2,      inoff + 3, outoff + 2, 1},
-+             // 4-byte underflow/overflow
-+            {inoff,  7,     outoff,  4,      inoff + 6, outoff + 3, 0},
-+            {inoff,  8,     outoff,  4,      inoff + 6, outoff + 3, 0},
-+            {inoff,  9,     outoff,  4,      inoff + 6, outoff + 3, 0},
-+            {inoff,  10,    outoff,  4,      inoff + 6, outoff + 3, 1},
-+        };
-+        for (boolean direct: new boolean[] {false, true}) {
-+            for (int[] flow: Flows) {
-+                if (!check(dec, utf8s, direct, flow))
-+                    failed = true;
-+            }
-+        }}}
-+        if (failed)
-+            throw new RuntimeException("Check under/overflow failed " + csn);
-+    }
-+
-+    public static void main(String[] args) throws Exception {
-+        checkRoundtrip("UTF-8");
-+        check6ByteSurrs("UTF-8");
-+        //compare("UTF-8", "UTF-8-OLD");
-+        checkMalformed("UTF-8");
-+        checkUnderOverflow("UTF-8");
-+    }
-+}
--- a/patches/icedtea-6484091.patch	Tue Dec 02 13:58:24 2008 +0000
+++ b/patches/icedtea-6484091.patch	Wed Dec 03 14:36:23 2008 +0000
@@ -1,5 +1,31 @@
---- old/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Tue Nov 18 10:35:29 2008
-+++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Tue Nov 18 10:35:29 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
+--- openjdk.orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	2008-12-02 14:54:58.000000000 +0000
++++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	2008-12-02 15:12:35.000000000 +0000
+@@ -39,6 +39,8 @@
+ import java.io.FileNotFoundException;
+ import java.io.IOException;
+ import java.util.*;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ 
+ import sun.awt.shell.ShellFolder;
+ import sun.awt.OSInfo;
+@@ -1153,7 +1155,11 @@
+ 
+             File[] baseFolders;
+             if (useShellFolder) {
+-                baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
++                baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
++                    public File[] run() {
++                        return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
++                    }
++                });
+             } else {
+                 baseFolders = fsv.getRoots();
+             }
+diff -Nru openjdk.orig/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java
+--- openjdk.orig/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	2008-12-02 14:55:11.000000000 +0000
++++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	2008-12-02 15:12:35.000000000 +0000
 @@ -38,6 +38,8 @@
  import java.io.FileNotFoundException;
  import java.io.IOException;
@@ -22,8 +48,9 @@
              } else {
                  baseFolders = fsv.getRoots();
              }
---- old/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Tue Nov 18 10:35:30 2008
-+++ openjdk/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Tue Nov 18 10:35:30 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java openjdk/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
+--- openjdk.orig/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	2008-12-02 14:55:05.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	2008-12-02 15:12:35.000000000 +0000
 @@ -29,6 +29,8 @@
  import java.beans.*;
  import java.io.*;
@@ -46,46 +73,9 @@
              } else {
                  baseFolders = fsv.getRoots();
              }
---- old/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Tue Nov 18 10:35:31 2008
-+++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Tue Nov 18 10:35:31 2008
-@@ -39,6 +39,8 @@
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.util.*;
-+import java.security.AccessController;
-+import java.security.PrivilegedAction;
- 
- import sun.awt.shell.ShellFolder;
- import sun.awt.OSInfo;
-@@ -1165,7 +1167,11 @@
- 
-             File[] baseFolders;
-             if (useShellFolder) {
--                baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
-+                baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
-+                    public File[] run() {
-+                        return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
-+                    }
-+                });
-             } else {
-                 baseFolders = fsv.getRoots();
-             }
---- old/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Tue Nov 18 10:35:32 2008
-+++ openjdk/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Tue Nov 18 10:35:32 2008
-
-@@ -657,6 +657,10 @@
-      *         <code>null</code> if this shellfolder does not denote a directory.
-      */
-     public File[] listFiles(final boolean includeHiddenFiles) {
-+        SecurityManager security = System.getSecurityManager();
-+        if (security != null) {
-+            security.checkRead(getPath());
-+        }
- 
-         return new ComTask<File[]>() {
-             public File[] call() throws Exception {
---- /dev/null	Tue Nov 18 10:35:33 2008
-+++ openjdk/jdk/test/javax/swing/JFileChooser/6484091/bug6484091.java	Tue Nov 18 10:35:33 2008
+diff -Nru openjdk.orig/jdk/test/javax/swing/JFileChooser/6484091/bug6484091.java openjdk/jdk/test/javax/swing/JFileChooser/6484091/bug6484091.java
+--- openjdk.orig/jdk/test/javax/swing/JFileChooser/6484091/bug6484091.java	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/javax/swing/JFileChooser/6484091/bug6484091.java	2008-12-02 15:12:35.000000000 +0000
 @@ -0,0 +1,40 @@
 +/* @test @(#)bug6484091.java	1.1 08/11/18
 + * @bug 6484091
--- a/patches/icedtea-6497740.patch	Tue Dec 02 13:58:24 2008 +0000
+++ b/patches/icedtea-6497740.patch	Wed Dec 03 14:36:23 2008 +0000
@@ -1,5 +1,6 @@
---- old/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java	Fri Aug 22 18:58:20 2008
-+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java	Fri Aug 22 18:58:20 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java	2008-12-02 15:15:13.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
@@ -25,7 +26,7 @@
  
      // SecureRandom instance, if specified in init
      private SecureRandom random;
-@@ -88,7 +90,7 @@
+@@ -88,19 +90,19 @@
      public void initialize(int keySize, SecureRandom random) {
          token.ensureValid();
          try {
@@ -34,7 +35,6 @@
          } catch (InvalidAlgorithmParameterException e) {
              throw new InvalidParameterException(e.getMessage());
          }
-@@ -95,12 +97,12 @@
          this.keySize = keySize;
          this.params = null;
          this.random = random;
@@ -146,42 +146,9 @@
              // sanity check, nobody really wants keys this large
              if (keySize > 64 * 1024) {
                  throw new InvalidAlgorithmParameterException
---- old/src/share/classes/sun/security/pkcs11/P11KeyStore.java	Fri Aug 22 18:58:29 2008
-+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java	Fri Aug 22 18:58:29 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -80,6 +80,8 @@
- import sun.security.pkcs11.wrapper.*;
- import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
- 
-+import sun.security.rsa.RSAKeyFactory;
-+
- final class P11KeyStore extends KeyStoreSpi {
- 
-     private static final CK_ATTRIBUTE ATTR_CLASS_CERT =
-@@ -1335,6 +1337,15 @@
-             BigInteger modulus = attrs[0].getBigInteger();
-             keyLength = modulus.bitLength();
- 
-+            // This check will combine our "don't care" values here
-+            // with the system-wide min/max values.
-+            try {
-+                RSAKeyFactory.checkKeyLengths(keyLength, null,
-+                    -1, Integer.MAX_VALUE);
-+            } catch (InvalidKeyException e) {
-+                throw new KeyStoreException(e.getMessage());
-+            }
-+
-             return P11Key.privateKey(session,
-                                 oHandle,
-                                 keyType,
---- old/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java	Fri Aug 22 18:58:37 2008
-+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java	Fri Aug 22 18:58:37 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java openjdk/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java	2008-12-02 15:15:13.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
@@ -246,8 +213,9 @@
          CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
              new CK_ATTRIBUTE(CKA_CLASS, CKO_PRIVATE_KEY),
              new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_RSA),
---- old/src/share/classes/sun/security/rsa/RSAKeyFactory.java	Fri Aug 22 18:58:44 2008
-+++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java	Fri Aug 22 18:58:43 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java openjdk/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java	2008-12-02 15:15:10.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
@@ -289,7 +257,7 @@
      // instance used for static translateKey();
      private final static RSAKeyFactory INSTANCE = new RSAKeyFactory();
  
-@@ -76,75 +96,80 @@
+@@ -76,74 +96,79 @@
      }
  
      /**
@@ -297,14 +265,14 @@
 -     * RSAPublicKey or RSAPrivate(Crt)Key. Check the key and convert it
 -     * to a SunRsaSign key if necessary. If the key is not an RSA key
 -     * or cannot be used, throw an InvalidKeyException.
+-     *
+-     * The difference between this method and engineTranslateKey() is that
+-     * we do not convert keys of other providers that are already an
+-     * instance of RSAPublicKey or RSAPrivate(Crt)Key.
 +     * Static method to convert Key into an instance of RSAPublicKeyImpl
 +     * or RSAPrivate(Crt)KeyImpl. If the key is not an RSA key or cannot be
 +     * used, throw an InvalidKeyException.
       *
--     * The difference between this method and engineTranslateKey() is that
--     * we do not convert keys of other providers that are already an
--     * instance of RSAPublicKey or RSAPrivate(Crt)Key.
--     *
       * Used by RSASignature and RSACipher.
       */
      public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
@@ -397,7 +365,7 @@
 +        if ((minModulusLen > 0) && (modulusLen < (minModulusLen))) {
 +            throw new InvalidKeyException( "RSA keys must be at least " +
 +                minModulusLen + " bits long");
-         }
++        }
 +
 +        // Even though our policy file may allow this, we don't want
 +        // either value (mod/exp) to be too big.
@@ -420,12 +388,12 @@
 +                MAX_RESTRICTED_EXPLEN + " bits " +
 +                " if modulus is greater than " +
 +                MAX_MODLEN_RESTRICT_EXP + " bits");
-+        }
+         }
      }
  
-     /**
---- old/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java	Fri Aug 22 18:58:50 2008
-+++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java	Fri Aug 22 18:58:49 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java openjdk/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java	2008-12-02 15:15:10.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
@@ -449,6 +417,11 @@
 -        if (keySize < 512) {
 -            throw new InvalidParameterException
 -                ("Key size must be at least 512 bits");
+-        }
+-        if (keySize > 64 * 1024) {
+-            // do not allow unreasonably large key sizes, probably user error
+-            throw new InvalidParameterException
+-                ("Key size must be 65536 bits or less");
 +
 +        // do not allow unreasonably small or large key sizes,
 +        // probably user error
@@ -458,11 +431,6 @@
 +        } catch (InvalidKeyException e) {
 +            throw new InvalidParameterException(e.getMessage());
          }
--        if (keySize > 64 * 1024) {
--            // do not allow unreasonably large key sizes, probably user error
--            throw new InvalidParameterException
--                ("Key size must be 65536 bits or less");
--        }
 +
          this.keySize = keySize;
          this.random = random;
@@ -525,9 +493,9 @@
      }
  
      // generate the keypair. See JCA doc
---- old/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	Fri Aug 22 18:58:56 2008
-+++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	Fri Aug 22 18:58:56 2008
-
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java openjdk/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	2008-12-02 15:15:10.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
@@ -554,8 +522,9 @@
          // generate the encoding
          algid = rsaId;
          try {
---- old/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java	Fri Aug 22 18:59:02 2008
-+++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java	Fri Aug 22 18:59:01 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java openjdk/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java	2008-12-02 15:15:10.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
@@ -572,8 +541,9 @@
          // generate the encoding
          algid = RSAPrivateCrtKeyImpl.rsaId;
          try {
---- old/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	Fri Aug 22 18:59:07 2008
-+++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	Fri Aug 22 18:59:07 2008
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java openjdk/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java
+--- openjdk.orig/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	2008-12-02 15:15:10.000000000 +0000
++++ openjdk/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
@@ -604,8 +574,9 @@
      }
  
      // see JCA doc
---- old/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java	Fri Aug 22 18:59:11 2008
-+++ openjdk/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java	Fri Aug 22 18:59:11 2008
+diff -Nru openjdk.orig/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java openjdk/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java
+--- openjdk.orig/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java	2008-12-02 15:15:21.000000000 +0000
++++ openjdk/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
@@ -648,7 +619,7 @@
      }
  
      // second initialize method. See JCA doc
-@@ -67,9 +75,9 @@
+@@ -67,21 +75,31 @@
      public void initialize(AlgorithmParameterSpec params, SecureRandom random)
              throws InvalidAlgorithmParameterException {
  
@@ -660,7 +631,6 @@
          } else if (params instanceof RSAKeyGenParameterSpec) {
  
              if (((RSAKeyGenParameterSpec) params).getPublicExponent() != null) {
-@@ -76,12 +84,22 @@
                  throw new InvalidAlgorithmParameterException
                      ("Exponent parameter is not supported");
              }
@@ -703,8 +673,9 @@
      private static native RSAKeyPair generateRSAKeyPair(int keySize,
          String keyContainerName);
  }
---- old/src/windows/classes/sun/security/mscapi/RSASignature.java	Fri Aug 22 18:59:18 2008
-+++ openjdk/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java	Fri Aug 22 18:59:17 2008
+diff -Nru openjdk.orig/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java openjdk/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java
+--- openjdk.orig/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java	2008-12-02 15:15:21.000000000 +0000
++++ openjdk/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java	2008-12-02 15:22:50.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
@@ -712,25 +683,24 @@
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
-@@ -38,7 +38,10 @@
+@@ -38,6 +38,9 @@
  import java.security.Signature;
  import java.security.SignatureSpi;
  import java.security.SignatureException;
 +import java.math.BigInteger;
- 
++
 +import sun.security.rsa.RSAKeyFactory;
-+
+ 
  /**
   * RSA signature implementation. Supports RSA signing using PKCS#1 v1.5 padding.
-  *
-@@ -124,8 +127,17 @@
+@@ -124,7 +127,16 @@
  
              // convert key to MSCAPI format
  
 -            byte[] modulusBytes = rsaKey.getModulus().toByteArray();
 +            BigInteger modulus = rsaKey.getModulus();
 +            BigInteger exponent =  rsaKey.getPublicExponent();
- 
++
 +            // Check against the local and global values to make sure
 +            // the sizes are ok.  Round up to the nearest byte.
 +            RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
@@ -738,10 +708,9 @@
 +
 +            byte[] modulusBytes = modulus.toByteArray();
 +            byte[] exponentBytes = exponent.toByteArray();
-+
+ 
              // Adjust key length due to sign bit
              int keyBitLength = (modulusBytes[0] == 0)
-                 ? (modulusBytes.length - 1) * 8
 @@ -132,8 +144,7 @@
                  : modulusBytes.length * 8;
  
@@ -752,27 +721,67 @@
  
              publicKey = importPublicKey(keyBlob, keyBitLength);
  
-@@ -166,13 +177,12 @@
+@@ -166,12 +177,11 @@
          }
          privateKey = (sun.security.mscapi.RSAPrivateKey) key;
  
 -        // Determine byte length from bit length
 -        int keySize = (privateKey.bitLength() + 7) >> 3;
+-
+-        if (keySize < 64)
+-            throw new InvalidKeyException(
+-                "RSA keys must be at least 512 bits long");
 +        // Check against the local and global values to make sure
 +        // the sizes are ok.  Round up to nearest byte.
 +        RSAKeyFactory.checkKeyLengths(((privateKey.bitLength() + 7) & ~7),
 +            null, RSAKeyPairGenerator.KEY_SIZE_MIN,
 +            RSAKeyPairGenerator.KEY_SIZE_MAX);
  
--        if (keySize < 64)
--            throw new InvalidKeyException(
--                "RSA keys must be at least 512 bits long");
--
          if (needsReset) {
              messageDigest.reset();
-             needsReset = false;
---- /dev/null	Fri Aug 22 18:59:23 2008
-+++ openjdk/jdk/test/closed/sun/security/rsa/TestLimits.java	Fri Aug 22 18:59:22 2008
+diff -Nru openjdk.orig/jdk/test/closed/sun/security/rsa/sunpkcs11-solaris_enableSHA1withRSAsig.cfg openjdk/jdk/test/closed/sun/security/rsa/sunpkcs11-solaris_enableSHA1withRSAsig.cfg
+--- openjdk.orig/jdk/test/closed/sun/security/rsa/sunpkcs11-solaris_enableSHA1withRSAsig.cfg	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/closed/sun/security/rsa/sunpkcs11-solaris_enableSHA1withRSAsig.cfg	2008-12-02 15:22:50.000000000 +0000
+@@ -0,0 +1,36 @@
++#
++# Configuration file to allow the SunPKCS11 provider to utilize
++# the Solaris Cryptographic Framework, if it is available
++#
++
++name = Solaris
++
++description = SunPKCS11 accessing Solaris Cryptographic Framework
++
++library = /usr/lib/$ISA/libpkcs11.so
++
++handleStartupErrors = ignoreAll
++
++attributes = compatibility
++
++disabledMechanisms = {
++  CKM_MD2
++  CKM_MD5
++  CKM_SHA_1
++  CKM_SHA256
++  CKM_SHA384
++  CKM_SHA512
++  CKM_DSA_KEY_PAIR_GEN
++# KEY_AND_MAC_DERIVE disabled due to Solaris bug 6306708
++  CKM_SSL3_KEY_AND_MAC_DERIVE
++  CKM_TLS_KEY_AND_MAC_DERIVE
++# the following mechanisms are disabled due to performance issues (Solaris bug 6337157)
++  CKM_DSA_SHA1
++  CKM_MD5_RSA_PKCS
++# For testing purposes, we'll reenable this suite.
++#  CKM_SHA1_RSA_PKCS
++  CKM_SHA256_RSA_PKCS
++  CKM_SHA384_RSA_PKCS
++  CKM_SHA512_RSA_PKCS
++}
++
+diff -Nru openjdk.orig/jdk/test/closed/sun/security/rsa/TestLimits.java openjdk/jdk/test/closed/sun/security/rsa/TestLimits.java
+--- openjdk.orig/jdk/test/closed/sun/security/rsa/TestLimits.java	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/closed/sun/security/rsa/TestLimits.java	2008-12-02 15:22:50.000000000 +0000
 @@ -0,0 +1,772 @@
 +/**
 + * @test
@@ -1546,44 +1555,3 @@
 +        }
 +    }
 +}
-Binary files /tmp/dnlaqOr and new/test/closed/sun/security/rsa/keystore.bad differ
-Binary files /tmp/dxQaGis and new/test/closed/sun/security/rsa/keystore.good differ
---- /dev/null	Fri Aug 22 18:59:31 2008
-+++ openjdk/jdk/test/closed/sun/security/rsa/sunpkcs11-solaris_enableSHA1withRSAsig.cfg	Fri Aug 22 18:59:29 2008
-@@ -0,0 +1,36 @@
-+#
-+# Configuration file to allow the SunPKCS11 provider to utilize
-+# the Solaris Cryptographic Framework, if it is available
-+#
-+
-+name = Solaris
-+
-+description = SunPKCS11 accessing Solaris Cryptographic Framework
-+
-+library = /usr/lib/$ISA/libpkcs11.so
-+
-+handleStartupErrors = ignoreAll
-+
-+attributes = compatibility
-+
-+disabledMechanisms = {
-+  CKM_MD2
-+  CKM_MD5
-+  CKM_SHA_1
-+  CKM_SHA256
-+  CKM_SHA384
-+  CKM_SHA512
-+  CKM_DSA_KEY_PAIR_GEN
-+# KEY_AND_MAC_DERIVE disabled due to Solaris bug 6306708
-+  CKM_SSL3_KEY_AND_MAC_DERIVE
-+  CKM_TLS_KEY_AND_MAC_DERIVE
-+# the following mechanisms are disabled due to performance issues (Solaris bug 6337157)
-+  CKM_DSA_SHA1
-+  CKM_MD5_RSA_PKCS
-+# For testing purposes, we'll reenable this suite.
-+#  CKM_SHA1_RSA_PKCS
-+  CKM_SHA256_RSA_PKCS
-+  CKM_SHA384_RSA_PKCS
-+  CKM_SHA512_RSA_PKCS
-+}
-+
--- a/patches/icedtea-6592792.patch	Tue Dec 02 13:58:24 2008 +0000
+++ b/patches/icedtea-6592792.patch	Wed Dec 03 14:36:23 2008 +0000
@@ -1,5 +1,6 @@
---- old/src/share/classes/com/sun/xml/internal/ws/spi/ProviderImpl.java	Tue Oct 21 15:06:46 2008
-+++ openjdk/jaxws/src/share/classes/com/sun/xml/internal/ws/spi/ProviderImpl.java	Tue Oct 21 15:06:46 2008
+diff -Nru openjdk.orig/jaxws/src/share/classes/javax/xml/bind/ContextFinder.java openjdk/jaxws/src/share/classes/javax/xml/bind/ContextFinder.java
+--- openjdk.orig/jaxws/src/share/classes/javax/xml/bind/ContextFinder.java	2008-12-02 15:25:05.000000000 +0000
++++ openjdk/jaxws/src/share/classes/javax/xml/bind/ContextFinder.java	2008-12-02 15:29:09.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
@@ -7,77 +8,7 @@
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
-@@ -56,6 +56,8 @@
- import javax.xml.ws.spi.ServiceDelegate;
- import javax.xml.ws.wsaddressing.W3CEndpointReference;
- import java.net.URL;
-+import java.security.AccessController;
-+import java.security.PrivilegedAction;
- import java.util.List;
- 
- /**
-@@ -94,14 +96,20 @@
-         return endpoint;
-     }
- 
--    public EndpointReference readEndpointReference(Source eprInfoset) {
--        Unmarshaller unmarshaller;
--        try {
--            unmarshaller = eprjc.createUnmarshaller();
--            return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
--        } catch (JAXBException e) {
--            throw new WebServiceException("Error creating Marshaller or marshalling.", e);
--        }
-+    public EndpointReference readEndpointReference(final Source eprInfoset) {
-+        // EPR constructors are private, so we need privilege escalation.
-+        // this unmarshalling can only access instances of a fixed, known set of classes,
-+        // so doing that shouldn't introduce security vulnerability.
-+        return AccessController.doPrivileged(new PrivilegedAction<EndpointReference>() {
-+            public EndpointReference run() {
-+                try {
-+                    Unmarshaller unmarshaller = eprjc.createUnmarshaller();
-+                    return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
-+                } catch (JAXBException e) {
-+                    throw new WebServiceException("Error creating Marshaller or marshalling.", e);
-+                }
-+            }
-+        });
-     }
- 
-     public <T> T getPort(EndpointReference endpointReference, Class<T> clazz, WebServiceFeature... webServiceFeatures) {
-@@ -185,10 +193,17 @@
-     }
- 
-     private static JAXBContext getEPRJaxbContext() {
--        try {
--            return JAXBContext.newInstance(MemberSubmissionEndpointReference.class, W3CEndpointReference.class);
--        } catch (JAXBException e) {
--            throw new WebServiceException("Error creating JAXBContext for W3CEndpointReference. ", e);
--        }
-+        // EPRs have package and private fields, so we need privilege escalation.
-+        // this access only fixed, known set of classes, so doing that
-+        // shouldn't introduce security vulnerability.
-+        return AccessController.doPrivileged(new PrivilegedAction<JAXBContext>() {
-+            public JAXBContext run() {
-+                try {
-+                    return JAXBContext.newInstance(MemberSubmissionEndpointReference.class, W3CEndpointReference.class);
-+                } catch (JAXBException e) {
-+                    throw new WebServiceException("Error creating JAXBContext for W3CEndpointReference. ", e);
-+                }
-+            }
-+        });
-     }
- }
---- old/src/share/classes/javax/xml/bind/ContextFinder.java	Tue Oct 21 15:06:50 2008
-+++ openjdk/jaxws/src/share/classes/javax/xml/bind/ContextFinder.java	Tue Oct 21 15:06:49 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -130,12 +130,7 @@
+@@ -128,12 +128,7 @@
          throws JAXBException
      {
          try {
@@ -91,7 +22,7 @@
  
              /*
               * javax.xml.bind.context.factory points to a class which has a
-@@ -207,11 +202,7 @@
+@@ -205,11 +200,7 @@
          ClassLoader cl = Thread.currentThread().getContextClassLoader();
          Class spi;
          try {
@@ -104,7 +35,7 @@
          } catch (ClassNotFoundException e) {
              throw new JAXBException(e);
          }
-@@ -488,4 +479,31 @@
+@@ -483,4 +474,31 @@
       * For this reason, we have to hard-code the class name into the API.
       */
      private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "com.sun.xml.internal.bind.v2.ContextFactory";
@@ -136,8 +67,9 @@
 +        }
 +    }
  }
---- old/src/share/classes/javax/xml/ws/spi/FactoryFinder.java	Tue Oct 21 15:06:52 2008
-+++ openjdk/jaxws/src/share/classes/javax/xml/ws/spi/FactoryFinder.java	Tue Oct 21 15:06:52 2008
+diff -Nru openjdk.orig/jaxws/src/share/classes/javax/xml/ws/spi/FactoryFinder.java openjdk/jaxws/src/share/classes/javax/xml/ws/spi/FactoryFinder.java
+--- openjdk.orig/jaxws/src/share/classes/javax/xml/ws/spi/FactoryFinder.java	2008-12-02 15:25:04.000000000 +0000
++++ openjdk/jaxws/src/share/classes/javax/xml/ws/spi/FactoryFinder.java	2008-12-02 15:29:09.000000000 +0000
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
@@ -193,8 +125,9 @@
 +        }
 +    }
  }
---- old/src/share/lib/security/java.security	Tue Oct 21 15:09:46 2008
-+++ openjdk/jdk/src/share/lib/security/java.security	Tue Oct 21 15:09:46 2008
+diff -Nru openjdk.orig/jdk/src/share/lib/security/java.security openjdk/jdk/src/share/lib/security/java.security
+--- openjdk.orig/jdk/src/share/lib/security/java.security	2008-11-20 08:44:48.000000000 +0000
++++ openjdk/jdk/src/share/lib/security/java.security	2008-12-02 15:29:09.000000000 +0000
 @@ -127,7 +127,7 @@
  # passed to checkPackageAccess unless the
  # corresponding RuntimePermission ("accessClassInPackage."+package) has
@@ -204,8 +137,21 @@
  
  #
  # List of comma-separated packages that start with or equal this string
---- old/src/share/lib/security/java.security-solaris	Tue Oct 21 15:09:49 2008
-+++ openjdk/jdk/src/share/lib/security/java.security-solaris	Tue Oct 21 15:09:49 2008
+diff -Nru openjdk.orig/jdk/src/share/lib/security/java.security-solaris openjdk/jdk/src/share/lib/security/java.security-solaris
+--- openjdk.orig/jdk/src/share/lib/security/java.security-solaris	2008-11-20 08:44:48.000000000 +0000
++++ openjdk/jdk/src/share/lib/security/java.security-solaris	2008-12-02 15:29:09.000000000 +0000
+@@ -128,7 +128,7 @@
+ # passed to checkPackageAccess unless the
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+-package.access=sun.
++package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.
+ 
+ #
+ # List of comma-separated packages that start with or equal this string
+diff -Nru openjdk.orig/jdk/src/share/lib/security/java.security-windows openjdk/jdk/src/share/lib/security/java.security-windows
+--- openjdk.orig/jdk/src/share/lib/security/java.security-windows	2008-11-20 08:44:48.000000000 +0000
++++ openjdk/jdk/src/share/lib/security/java.security-windows	2008-12-02 15:29:09.000000000 +0000
 @@ -128,7 +128,7 @@
  # passed to checkPackageAccess unless the
  # corresponding RuntimePermission ("accessClassInPackage."+package) has
@@ -215,19 +161,74 @@
  
  #
  # List of comma-separated packages that start with or equal this string
---- old/src/share/lib/security/java.security-windows	Tue Oct 21 15:09:52 2008
-+++ openjdk/jdk/src/share/lib/security/java.security-windows	Tue Oct 21 15:09:52 2008
-@@ -128,7 +128,7 @@
- # passed to checkPackageAccess unless the
- # corresponding RuntimePermission ("accessClassInPackage."+package) has
- # been granted.
--package.access=sun.
-+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.
- 
- #
- # List of comma-separated packages that start with or equal this string
---- /dev/null	Tue Oct 21 15:09:20 2008
-+++ openjdk/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test.java	Tue Oct 21 15:09:56 2008
+diff -Nru openjdk.orig/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test6592792.sh openjdk/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test6592792.sh
+--- openjdk.orig/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test6592792.sh	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test6592792.sh	2008-12-02 15:29:09.000000000 +0000
+@@ -0,0 +1,61 @@
++#!/bin/sh
++
++if [ "${TESTSRC}" = "" ]
++then TESTSRC=.
++fi
++
++if [ "${TESTJAVA}" = "" ]
++then
++  PARENT=`dirname \`which java\``
++  TESTJAVA=`dirname ${PARENT}`
++  echo "TESTJAVA not set, selecting " ${TESTJAVA}
++  echo "If this is incorrect, try setting the variable manually."
++fi
++
++if [ "${TESTCLASSES}" = "" ]
++then
++  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
++  exit 1
++fi
++
++BIT_FLAG=""
++
++# set platform-dependent variables
++OS=`uname -s`
++case "$OS" in
++  SunOS | Linux )
++    NULL=/dev/null
++    PS=":"
++    FS="/"
++    ## for solaris, linux it's HOME
++    FILE_LOCATION=$HOME
++    if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
++    then
++        BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT`
++    fi
++    ;;
++  Windows_* )
++    NULL=NUL
++    PS=";"
++    FS="\\"
++    ;;
++  * )
++    echo "Unrecognized system!"
++    exit 1;
++    ;;
++esac
++
++JEMMYPATH=${CPAPPEND}
++CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH
++
++THIS_DIR=`pwd`
++
++${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version
++
++${TESTJAVA}${FS}bin${FS}javac ${BIT_FLAG} -d . -cp ${TESTJAVA}${FS}jre${FS}lib${FS}rt.jar ${TESTSRC}${FS}Test.java
++
++${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -cp . Test
++
++STATUS=$?
++
++exit $STATUS
+diff -Nru openjdk.orig/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test.java openjdk/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test.java
+--- openjdk.orig/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test.java	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test.java	2008-12-02 15:29:09.000000000 +0000
 @@ -0,0 +1,65 @@
 +/*
 + *  @test
@@ -294,67 +295,3 @@
 +      } 
 +   }
 +}
---- /dev/null	Tue Oct 21 15:09:21 2008
-+++ openjdk/jdk/test/com/sun/org/apache/xml/internal/ws/server/Test6592792.sh	Tue Oct 21 15:09:56 2008
-@@ -0,0 +1,61 @@
-+#!/bin/sh
-+
-+if [ "${TESTSRC}" = "" ]
-+then TESTSRC=.
-+fi
-+
-+if [ "${TESTJAVA}" = "" ]
-+then
-+  PARENT=`dirname \`which java\``
-+  TESTJAVA=`dirname ${PARENT}`
-+  echo "TESTJAVA not set, selecting " ${TESTJAVA}
-+  echo "If this is incorrect, try setting the variable manually."
-+fi
-+
-+if [ "${TESTCLASSES}" = "" ]
-+then
-+  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-+  exit 1
-+fi
-+
-+BIT_FLAG=""
-+
-+# set platform-dependent variables
-+OS=`uname -s`
-+case "$OS" in
-+  SunOS | Linux )
-+    NULL=/dev/null
-+    PS=":"
-+    FS="/"
-+    ## for solaris, linux it's HOME
-+    FILE_LOCATION=$HOME
-+    if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
-+    then
-+        BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT`
-+    fi
-+    ;;
-+  Windows_* )
-+    NULL=NUL
-+    PS=";"
-+    FS="\\"
-+    ;;
-+  * )
-+    echo "Unrecognized system!"
-+    exit 1;
-+    ;;
-+esac
-+
-+JEMMYPATH=${CPAPPEND}
-+CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH
-+
-+THIS_DIR=`pwd`
-+
-+${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version
-+
-+${TESTJAVA}${FS}bin${FS}javac ${BIT_FLAG} -d . -cp ${TESTJAVA}${FS}jre${FS}lib${FS}rt.jar ${TESTSRC}${FS}Test.java
-+
-+${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -cp . Test
-+
-+STATUS=$?
-+
-+exit $STATUS
--- a/patches/icedtea-6728542-epoll.patch	Tue Dec 02 13:58:24 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-
-# HG changeset patch
-# User alanb
-# Date 1219738992 -3600
-# Node ID 2a5377a6492e1738b4310c400d041a0f94071abf
-# Parent 872241636752db4f3c8401242a2dfe9f4ee38615
-6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
-Reviewed-by: sherman
-
---- openjdk/jdk/make/java/nio/mapfile-linux	Mon Aug 25 08:11:08 2008 -0700
-+++ openjdk/jdk/make/java/nio/mapfile-linux	Tue Aug 26 09:23:12 2008 +0100
-@@ -18,6 +18,8 @@ SUNWprivate_1.1 {
- 		Java_sun_nio_ch_EPollArrayWrapper_fdLimit;
- 		Java_sun_nio_ch_EPollArrayWrapper_init;
- 		Java_sun_nio_ch_EPollArrayWrapper_interrupt;
-+		Java_sun_nio_ch_EPollArrayWrapper_offsetofData;
-+		Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent;
-                 Java_sun_nio_ch_FileChannelImpl_close0;
-                 Java_sun_nio_ch_FileChannelImpl_force0;
-                 Java_sun_nio_ch_FileChannelImpl_initIDs;
---- openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java	Mon Aug 25 08:11:08 2008 -0700
-+++ openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java	Tue Aug 26 09:23:12 2008 +0100
-@@ -69,11 +69,11 @@ class EPollArrayWrapper {
-     static final int EPOLL_CTL_MOD      = 3;
- 
-     // Miscellaneous constants
--    static final short SIZE_EPOLLEVENT  = 12;
--    static final short EVENT_OFFSET     = 0;
--    static final short DATA_OFFSET      = 4;
--    static final short FD_OFFSET        = 4;
--    static final int   NUM_EPOLLEVENTS  = Math.min(fdLimit(), 8192);
-+    static final int SIZE_EPOLLEVENT  = sizeofEPollEvent();
-+    static final int EVENT_OFFSET     = 0;
-+    static final int DATA_OFFSET      = offsetofData();
-+    static final int FD_OFFSET        = DATA_OFFSET;
-+    static final int NUM_EPOLLEVENTS  = Math.min(fdLimit(), 8192);
- 
-     // Base address of the native pollArray
-     private final long pollArrayAddress;
-@@ -280,6 +280,8 @@ class EPollArrayWrapper {
-     private native void epollCtl(int epfd, int opcode, int fd, int events);
-     private native int epollWait(long pollAddress, int numfds, long timeout,
-                                  int epfd) throws IOException;
-+    private static native int sizeofEPollEvent();
-+    private static native int offsetofData();
-     private static native int fdLimit();
-     private static native void interrupt(int fd);
-     private static native void init();
---- openjdk/jdk/src/solaris/native/sun/nio/ch/EPollArrayWrapper.c	Mon Aug 25 08:11:08 2008 -0700
-+++ openjdk/jdk/src/solaris/native/sun/nio/ch/EPollArrayWrapper.c	Tue Aug 26 09:23:12 2008 +0100
-@@ -48,10 +48,18 @@ typedef union epoll_data {
-     __uint64_t u64;
- } epoll_data_t;
- 
-+
-+/* x86-64 has same alignment as 32-bit */
-+#ifdef __x86_64__
-+#define EPOLL_PACKED __attribute__((packed))
-+#else
-+#define EPOLL_PACKED
-+#endif
-+
- struct epoll_event {
-     __uint32_t events;  /* Epoll events */
-     epoll_data_t data;  /* User data variable */
--} __attribute__ ((__packed__));
-+} EPOLL_PACKED;
- 
- #ifdef  __cplusplus
- }
-@@ -143,6 +151,18 @@ Java_sun_nio_ch_EPollArrayWrapper_fdLimi
-     return (jint)rlp.rlim_max;
- }
- 
-+JNIEXPORT jint JNICALL
-+Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent(JNIEnv* env, jclass this)
-+{
-+    return sizeof(struct epoll_event);
-+}
-+
-+JNIEXPORT jint JNICALL
-+Java_sun_nio_ch_EPollArrayWrapper_offsetofData(JNIEnv* env, jclass this)
-+{
-+    return offsetof(struct epoll_event, data);
-+}
-+
- JNIEXPORT void JNICALL
- Java_sun_nio_ch_EPollArrayWrapper_epollCtl(JNIEnv *env, jobject this, jint epfd,
-                                            jint opcode, jint fd, jint events)
-
--- a/patches/icedtea-6733959.patch	Tue Dec 02 13:58:24 2008 +0000
+++ b/patches/icedtea-6733959.patch	Wed Dec 03 14:36:23 2008 +0000
@@ -1,24 +1,137 @@
---- old/src/share/bin/java.c	Tue Sep 30 13:28:32 2008
-+++ openjdk/jdk/src/share/bin/java.c	Tue Sep 30 13:28:32 2008
-@@ -1056,8 +1056,14 @@
-      * to avoid locating, expanding and parsing the manifest extra
-      * times.
+diff -Nru openjdk.orig/jdk/src/share/bin/java.c openjdk/jdk/src/share/bin/java.c
+--- openjdk.orig/jdk/src/share/bin/java.c	2008-12-02 16:28:05.000000000 +0000
++++ openjdk/jdk/src/share/bin/java.c	2008-12-02 17:08:57.000000000 +0000
+@@ -885,8 +885,14 @@
+      * "Valid" returns (other than unrecoverable errors) follow.  Set
+      * main_class as a side-effect of this routine.
       */
 -    if (info.main_class != NULL)
--	(void)strcat(env_entry, info.main_class);
 +    if (info.main_class != NULL) {
-+        if (strlen(info.main_class) <= MAXNAMELEN) {
-+            (void)strcat(env_entry, info.main_class);
-+        } else {
-+            ReportErrorMessage("Error: main-class: attribute exceeds system limits\n", JNI_TRUE);
-+	    exit(1);
-+        }
++      if (strlen(info.main_class) <= MAXNAMELEN) {
+         *main_class = JLI_StringDup(info.main_class);
++      } else {
++        JLI_ReportErrorMessage("Error: main-class: attribute exceeds system limits\n", JNI_TRUE);
++	exit(1);
++      }
 +    }
-     (void)putenv(env_entry);
-     ExecJRE(jre, new_argv);
-     JLI_FreeManifest();
---- /dev/null	Tue Sep 30 13:28:33 2008
-+++ openjdk/jdk/test/tools/launcher/ZipMeUp.java	Tue Sep 30 13:28:33 2008
+ 
+     /*
+      * If no version selection information is found either on the command
+diff -Nru openjdk.orig/jdk/test/tools/launcher/MultipleJRE.sh openjdk/jdk/test/tools/launcher/MultipleJRE.sh
+--- openjdk.orig/jdk/test/tools/launcher/MultipleJRE.sh	2008-12-03 12:35:03.000000000 +0000
++++ openjdk/jdk/test/tools/launcher/MultipleJRE.sh	2008-12-02 17:07:57.000000000 +0000
+@@ -49,10 +49,23 @@
+   exit 1
+ fi
+ 
++JAVAEXE="$TESTJAVA/bin/java"
+ JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES"
+ JAR="$TESTJAVA/bin/jar"
+ OS=`uname -s`;
+ 
++# Tests whether we are on windows (true) or not.
++IsWindows() {
++    case "$OS" in
++        Windows* | CYGWIN* )
++            printf "true"
++        ;;
++        * )
++            printf "false"
++        ;;
++    esac
++}
++
+ #
+ # Shell routine to test for the proper rejection of syntactically incorrect
+ # version specifications.
+@@ -262,6 +275,29 @@
+ 	fi
+ }
+ 
++# Tests very long Main-Class attribute in the jar.
++TestLongMainClass() {
++    JVER=$1
++    if [ "$JVER" = "mklink" ]; then
++        JVER=XX
++        JDKXX=jdk/j2re$JVER
++        rm -rf jdk
++        mkdir jdk
++        ln -s $TESTJAVA $JDKXX
++        JAVA_VERSION_PATH="`pwd`/jdk"
++        export JAVA_VERSION_PATH
++    fi
++    $JAVAEXE -cp $TESTCLASSES ZipMeUp UglyBetty.jar 4097 
++    message="`$JAVAEXE -version:$JVER -jar UglyBetty.jar 2>&1`"
++    echo $message | grep "Error: main-class: attribute exceeds system limits" > /dev/null 2>&1
++    if [ $? -ne 0 ]; then
++        printf "Long manifest test did not get expected error"
++        exit 1
++    fi
++    unset JAVA_VERSION_PATH
++    rm -rf jdk
++}
++
+ #
+ # Main test sequence starts here
+ #
+@@ -280,14 +316,12 @@
+ LaunchVM "" "${RELEASE}"
+ CreateJar "" "0"
+ LaunchVM "" "${RELEASE}"
+-case "$OS" in
+-	Windows* | CYGWIN* )
+-		MAXIMUM_PATH=255;
+-	;;
+-	*)
+-		MAXIMUM_PATH=1024;
+-	;;
+-esac
++if [ `IsWindows` = "true" ]; then
++    MAXIMUM_PATH=115;  # 115 = 255 - 140
++else
++    MAXIMUM_PATH=884;  # 884 = 1024 - 140
++fi
++
+ 
+ PATH_LENGTH=`printf "%s" "$UGLYCLASS" | wc -c`
+ if [ ${PATH_LENGTH} -lt ${MAXIMUM_PATH} ]; then
+@@ -357,15 +391,28 @@
+ TestSyntax "1.2+.3"				# Embedded modifier
+ TestSyntax "1.2.4+&1.2*&1++"			# Long and invalid
+ 
++# On windows we see if there is another jre installed, usually
++# there is, then we test using that, otherwise links are created
++# to get through to SelectVersion.
++if [ `IsWindows` = "false" ]; then
++   TestLongMainClass "mklink"
++else
++    $JAVAEXE -version:1.0+
++    if [ $? -eq 0 ]; then
++        TestLongMainClass "1.0+"
++    else
++        printf  "Warning: TestLongMainClass skipped as there is no"
++       printf  "viable MJRE installed.\n"
++    fi
++fi
++
+ #
+ # Because scribbling in the registry can be rather destructive, only a
+ # subset of the tests are run on Windows.
+ #
+-case "$OS" in
+-	Windows* | CYGWIN* )
+-		exit 0;
+-	;;
+-esac
++if [ `IsWindows` = "true" ]; then
++   exit 0;
++fi
+ 
+ #
+ # Additional version specifiers containing spaces.  (Sigh, unable to
+diff -Nru openjdk.orig/jdk/test/tools/launcher/ZipMeUp.java openjdk/jdk/test/tools/launcher/ZipMeUp.java
+--- openjdk.orig/jdk/test/tools/launcher/ZipMeUp.java	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/tools/launcher/ZipMeUp.java	2008-12-02 17:07:57.000000000 +0000
 @@ -0,0 +1,90 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
@@ -110,114 +223,3 @@
 +        System.exit(0);
 +    }
 +}
---- MultipleJRE.sh	2008-11-21 14:18:54.000000000 -0500
-+++ openjdk/jdk/test/tools/launcher/MultipleJRE.sh	2008-11-21 14:23:48.000000000 -0500
-@@ -48,10 +48,23 @@
-   exit 1
- fi
- 
-+JAVAEXE="$TESTJAVA/bin/java"
- JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES"
- JAR="$TESTJAVA/bin/jar"
- OS=`uname -s`;
- 
-+# Tests whether we are on windows (true) or not.
-+IsWindows() {
-+    case "$OS" in
-+        Windows* | CYGWIN* )
-+            printf "true"
-+        ;;
-+        * )
-+            printf "false"
-+        ;;
-+    esac
-+}
-+
- #
- # Shell routine to test for the proper rejection of syntactically incorrect
- # version specifications.
-@@ -261,6 +274,29 @@
- 	fi
- }
- 
-+# Tests very long Main-Class attribute in the jar.
-+TestLongMainClass() {
-+    JVER=$1
-+    if [ "$JVER" = "mklink" ]; then
-+        JVER=XX
-+        JDKXX=jdk/j2re$JVER
-+        rm -rf jdk
-+        mkdir jdk
-+        ln -s $TESTJAVA $JDKXX
-+        JAVA_VERSION_PATH="`pwd`/jdk"
-+        export JAVA_VERSION_PATH
-+    fi
-+    $JAVAEXE -cp $TESTCLASSES ZipMeUp UglyBetty.jar 4097 
-+    message="`$JAVAEXE -version:$JVER -jar UglyBetty.jar 2>&1`"
-+    echo $message | grep "Error: main-class: attribute exceeds system limits" > /dev/null 2>&1
-+    if [ $? -ne 0 ]; then
-+        printf "Long manifest test did not get expected error"
-+        exit 1
-+    fi
-+    unset JAVA_VERSION_PATH
-+    rm -rf jdk
-+}
-+
- #
- # Main test sequence starts here
- #
-@@ -279,14 +315,12 @@
- LaunchVM "" "${RELEASE}"
- CreateJar "" "0"
- LaunchVM "" "${RELEASE}"
--case "$OS" in
--	Windows* | CYGWIN* )
--		MAXIMUM_PATH=255;
--	;;
--	*)
--		MAXIMUM_PATH=1024;
--	;;
--esac
-+if [ `IsWindows` = "true" ]; then
-+    MAXIMUM_PATH=115;  # 115 = 255 - 140
-+else
-+    MAXIMUM_PATH=884;  # 884 = 1024 - 140
-+fi
-+
- 
- PATH_LENGTH=`printf "%s" "$UGLYCLASS" | wc -c`
- if [ ${PATH_LENGTH} -lt ${MAXIMUM_PATH} ]; then
-@@ -356,15 +390,28 @@
- TestSyntax "1.2+.3"				# Embedded modifier
- TestSyntax "1.2.4+&1.2*&1++"			# Long and invalid
- 
-+# On windows we see if there is another jre installed, usually
-+# there is, then we test using that, otherwise links are created
-+# to get through to SelectVersion.
-+if [ `IsWindows` = "false" ]; then
-+   TestLongMainClass "mklink"
-+else
-+    $JAVAEXE -version:1.0+
-+    if [ $? -eq 0 ]; then
-+        TestLongMainClass "1.0+"
-+    else
-+        printf  "Warning: TestLongMainClass skipped as there is no"
-+       printf  "viable MJRE installed.\n"
-+    fi
-+fi
-+
- #
- # Because scribbling in the registry can be rather destructive, only a
- # subset of the tests are run on Windows.
- #
--case "$OS" in
--	Windows* | CYGWIN* )
--		exit 0;
--	;;
--esac
-+if [ `IsWindows` = "true" ]; then
-+   exit 0;
-+fi
- 
- #
- # Additional version specifiers containing spaces.  (Sigh, unable to
--- a/patches/icedtea-6755943.patch	Tue Dec 02 13:58:24 2008 +0000
+++ b/patches/icedtea-6755943.patch	Wed Dec 03 14:36:23 2008 +0000
@@ -1,250 +1,6 @@
---- old/src/share/native/com/sun/java/util/jar/pack/bytes.cpp	Fri Oct 17 10:50:38 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.cpp	Fri Oct 17 10:50:38 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2001-2003 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -56,7 +56,7 @@
-     return;
-   }
-   byte* oldptr = ptr;
--  ptr = (byte*)::realloc(ptr, len_+1);
-+  ptr = (len_ >= PSIZE_MAX) ? null : (byte*)::realloc(ptr, len_+1);
-   if (ptr != null)  {
-     mtrace('r', oldptr, 0);
-     mtrace('m', ptr, len_+1);
-@@ -126,7 +126,7 @@
- // Make sure there are 'o' bytes beyond the fill pointer,
- // advance the fill pointer, and return the old fill pointer.
- byte* fillbytes::grow(size_t s) {
--  size_t nlen = b.len+s;
-+  size_t nlen = add_size(b.len, s);
-   if (nlen <= allocated) {
-     b.len = nlen;
-     return limit()-s;
---- old/src/share/native/com/sun/java/util/jar/pack/defines.h	Fri Oct 17 10:50:38 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	Fri Oct 17 10:50:38 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -47,11 +47,13 @@
- #define NOT_PRODUCT(xxx)
- #define assert(p) (0)
- #define printcr false &&
-+#define VERSION_STRING "%s version %s\n"
- #else
- #define IF_PRODUCT(xxx)
- #define NOT_PRODUCT(xxx) xxx
- #define assert(p) ((p) || (assert_failed(#p), 1))
- #define printcr u->verbose && u->printcr_if_verbose
-+#define VERSION_STRING "%s version non-product %s\n"
- extern "C" void breakpoint();
- extern void assert_failed(const char*);
- #define BREAK (breakpoint())
-@@ -79,9 +81,9 @@
- 
- #define lengthof(array) (sizeof(array)/sizeof(array[0]))
- 
--#define NEW(T, n)    (T*) must_malloc(sizeof(T)*(n))
--#define U_NEW(T, n)  (T*) u->alloc(sizeof(T)*(n))
--#define T_NEW(T, n)  (T*) u->temp_alloc(sizeof(T)*(n))
-+#define NEW(T, n)    (T*) must_malloc(scale_size(n, sizeof(T)))
-+#define U_NEW(T, n)  (T*) u->alloc(scale_size(n, sizeof(T)))
-+#define T_NEW(T, n)  (T*) u->temp_alloc(scale_size(n, sizeof(T)))
- 
- 
- // bytes and byte arrays
---- old/src/share/native/com/sun/java/util/jar/pack/main.cpp	Fri Oct 17 10:50:39 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp	Fri Oct 17 10:50:39 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -300,7 +300,7 @@
-     case 'J':  argp += 1; break;  // skip ignored -Jxxx parameter
- 
-     case 'V':
--      fprintf(u.errstrm, "%s version %s\n", nbasename(argv[0]), sccsver);
-+      fprintf(u.errstrm, VERSION_STRING, nbasename(argv[0]), sccsver);
-       exit(0);
- 
-     case 'h':
---- old/src/share/native/com/sun/java/util/jar/pack/unpack.cpp	Fri Oct 17 10:50:40 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp	Fri Oct 17 10:50:40 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -618,18 +618,17 @@
-   if ((archive_options & AO_HAVE_FILE_HEADERS) != 0) {
-     uint hi = hdr.getInt();
-     uint lo = hdr.getInt();
--    archive_size = band::makeLong(hi, lo);
-+    julong x = band::makeLong(hi, lo);
-+    archive_size = (size_t) x;
-+    if (archive_size != x) {
-+      // Silly size specified; force overflow.
-+      archive_size = PSIZE_MAX+1;
-+    }
-     hdrVals += 2;
-   } else {
-     hdrValsSkipped += 2;
-   }
- 
--  if (archive_size != (size_t)archive_size) {
--    // Silly size specified.
--    abort("archive too large");
--    return;
--  }
--
-   // Now we can size the whole archive.
-   // Read everything else into a mega-buffer.
-   rp = hdr.rp;
-@@ -643,8 +642,8 @@
-       abort("EOF reading fixed input buffer");
-       return;
-     }
--  } else if (archive_size > 0) {
--    input.set(U_NEW(byte, (size_t) header_size_0 + archive_size + C_SLOP),
-+  } else if (archive_size != 0) {
-+    input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
-               (size_t) header_size_0 + archive_size);
-     assert(input.limit()[0] == 0);
-     // Move all the bytes we read initially into the real buffer.
-@@ -654,7 +653,6 @@
-   } else {
-     // It's more complicated and painful.
-     // A zero archive_size means that we must read until EOF.
--    assert(archive_size == 0);
-     input.init(CHUNK*2);
-     CHECK;
-     input.b.len = input.allocated;
-@@ -664,7 +662,7 @@
-     rplimit += header_size;
-     while (ensure_input(input.limit() - rp)) {
-       size_t dataSoFar = input_remaining();
--      size_t nextSize = dataSoFar + CHUNK;
-+      size_t nextSize = add_size(dataSoFar, CHUNK);
-       input.ensureSize(nextSize);
-       CHECK;
-       input.b.len = input.allocated;
-@@ -949,10 +947,12 @@
-   // First band:  Read lengths of shared prefixes.
-   if (len > PREFIX_SKIP_2)
-     cp_Utf8_prefix.readData(len - PREFIX_SKIP_2);
-+    NOT_PRODUCT(else cp_Utf8_prefix.readData(0));  // for asserts
- 
-   // Second band:  Read lengths of unshared suffixes:
-   if (len > SUFFIX_SKIP_1)
-     cp_Utf8_suffix.readData(len - SUFFIX_SKIP_1);
-+    NOT_PRODUCT(else cp_Utf8_suffix.readData(0));  // for asserts
- 
-   bytes* allsuffixes = T_NEW(bytes, len);
-   CHECK;
---- old/src/share/native/com/sun/java/util/jar/pack/unpack.h	Fri Oct 17 10:50:41 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h	Fri Oct 17 10:50:41 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2002-2005 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -204,7 +204,7 @@
- 
-   // archive header fields
-   int      magic, minver, majver;
--  julong   archive_size;
-+  size_t   archive_size;
-   int      archive_next_count, archive_options, archive_modtime;
-   int      band_headers_size;
-   int      file_count, attr_definition_count, ic_count, class_count;
---- old/src/share/native/com/sun/java/util/jar/pack/utils.cpp	Fri Oct 17 10:50:41 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp	Fri Oct 17 10:50:41 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -46,14 +46,13 @@
- 
- #include "unpack.h"
- 
--void* must_malloc(int size) {
--  int msize = size;
--  assert(size >= 0);
-+void* must_malloc(size_t size) {
-+  size_t msize = size;
-   #ifdef USE_MTRACE
--  if (msize < sizeof(int))
-+  if (msize >= 0 && msize < sizeof(int))
-     msize = sizeof(int);  // see 0xbaadf00d below
-   #endif
--  void* ptr = malloc(msize);
-+  void* ptr = (msize > PSIZE_MAX) ? null : malloc(msize);
-   if (ptr != null) {
-     memset(ptr, 0, size);
-   } else {
---- old/src/share/native/com/sun/java/util/jar/pack/utils.h	Fri Oct 17 10:50:42 2008
-+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h	Fri Oct 17 10:50:42 2008
-@@ -1,5 +1,5 @@
- /*
-- * Copyright 2001-2003 Sun Microsystems, Inc.  All Rights Reserved.
-+ * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  *
-  * This code is free software; you can redistribute it and/or modify it
-@@ -25,7 +25,7 @@
- 
- //Definitions of our util functions
- 
--void* must_malloc(int size);
-+void* must_malloc(size_t size);
- #ifndef USE_MTRACE
- #define mtrace(c, ptr, size) (0)
- #else
-@@ -32,6 +32,24 @@
- void mtrace(char c, void* ptr, size_t size);
- #endif
- 
-+// overflow management
-+#define OVERFLOW ((size_t)-1)
-+#define PSIZE_MAX (OVERFLOW/2)  /* normal size limit */
-+
-+inline size_t scale_size(size_t size, size_t scale) {
-+  return (size > PSIZE_MAX / scale) ? OVERFLOW : size * scale;
-+}
-+
-+inline size_t add_size(size_t size1, size_t size2) {
-+  return ((size1 | size2 | (size1 + size2)) > PSIZE_MAX)
-+    ? OVERFLOW
-+    : size1 + size2;
-+}
-+
-+inline size_t add_size(size_t size1, size_t size2, int size3) {
-+  return add_size(add_size(size1, size2), size3);
-+}
-+
- // These may be expensive, because they have to go via Java TSD,
- // if the optional u argument is missing.
- struct unpacker;
---- /dev/null	Fri Oct 17 10:50:42 2008
-+++ openjdk/jdk/test/tools/pack200/MemoryAllocatorTest.java	Fri Oct 17 10:50:42 2008
+diff -Nru openjdk.orig/jdk/test/tools/pack200/MemoryAllocatorTest.java openjdk/jdk/test/tools/pack200/MemoryAllocatorTest.java
+--- openjdk.orig/jdk/test/tools/pack200/MemoryAllocatorTest.java	1970-01-01 01:00:00.000000000 +0100
++++ openjdk/jdk/test/tools/pack200/MemoryAllocatorTest.java	2008-12-02 15:42:47.000000000 +0000
 @@ -0,0 +1,369 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
--- a/patches/icedtea-ecj-pr261.patch	Tue Dec 02 13:58:24 2008 +0000
+++ b/patches/icedtea-ecj-pr261.patch	Wed Dec 03 14:36:23 2008 +0000
@@ -1,7 +1,26 @@
-diff -r fa4572c7c75f openjdk-ecj/jdk/make/java/nio/Makefile
---- openjdk-ecj/jdk/make/java/nio/Makefile	Thu Nov 27 08:42:23 2008 +0000
-+++ openjdk-ecj/jdk/make/java/nio/Makefile	Thu Nov 27 10:12:08 2008 +0000
-@@ -85,6 +85,9 @@ ifeq ($(PLATFORM), linux)
+diff -Nru openjdk-ecj.orig/jdk/make/java/nio/FILES_java.gmk openjdk-ecj/jdk/make/java/nio/FILES_java.gmk
+--- openjdk-ecj.orig/jdk/make/java/nio/FILES_java.gmk	2008-11-20 08:44:11.000000000 +0000
++++ openjdk-ecj/jdk/make/java/nio/FILES_java.gmk	2008-12-02 16:00:15.000000000 +0000
+@@ -32,6 +32,7 @@
+ 	java/nio/StringCharBuffer.java \
+ 	\
+ 	java/nio/channels/ByteChannel.java \
++	java/nio/channels/CancelledKeyException.java \
+ 	java/nio/channels/Channel.java \
+ 	java/nio/channels/Channels.java \
+ 	java/nio/channels/DatagramChannel.java \
+@@ -42,6 +43,7 @@
+ 	java/nio/channels/MembershipKey.java \
+ 	java/nio/channels/MulticastChannel.java \
+ 	java/nio/channels/NetworkChannel.java \
++	java/nio/channels/Pipe.java \
+ 	java/nio/channels/ReadableByteChannel.java \
+ 	java/nio/channels/ScatteringByteChannel.java \
+ 	java/nio/channels/SelectableChannel.java \
+diff -Nru openjdk-ecj.orig/jdk/make/java/nio/Makefile openjdk-ecj/jdk/make/java/nio/Makefile
+--- openjdk-ecj.orig/jdk/make/java/nio/Makefile	2008-12-02 15:52:07.000000000 +0000
++++ openjdk-ecj/jdk/make/java/nio/Makefile	2008-12-02 15:59:32.000000000 +0000
+@@ -85,6 +85,9 @@
  ifeq ($(PLATFORM), linux)
  FILES_java += \
          sun/nio/ch/AbstractPollSelectorImpl.java \
@@ -11,30 +30,11 @@
  	sun/nio/ch/EPollArrayWrapper.java \
  	sun/nio/ch/EPollSelectorProvider.java \
  	sun/nio/ch/EPollSelectorImpl.java \
-@@ -99,6 +102,7 @@ FILES_c += \
- 	NativeThread.c
+@@ -99,6 +102,7 @@
+         PollArrayWrapper.c
  
  FILES_export += \
 +	sun/nio/ch/DevPollArrayWrapper.java \
          sun/nio/ch/EPollArrayWrapper.java \
  	sun/nio/ch/InheritedChannel.java \
  	sun/nio/ch/NativeThread.java
-diff -r 3ee709488c6c openjdk-ecj/jdk/make/java/nio/FILES_java.gmk
---- openjdk-ecj/jdk/make/java/nio/FILES_java.gmk	Thu Nov 27 10:16:56 2008 +0000
-+++ openjdk-ecj/jdk/make/java/nio/FILES_java.gmk	Thu Nov 27 11:08:57 2008 +0000
-@@ -31,6 +31,7 @@ FILES_src = \
- 	java/nio/StringCharBuffer.java \
- 	\
- 	java/nio/channels/ByteChannel.java \
-+	java/nio/channels/CancelledKeyException.java \
- 	java/nio/channels/Channel.java \
- 	java/nio/channels/Channels.java \
- 	java/nio/channels/DatagramChannel.java \
-@@ -38,6 +39,7 @@ FILES_src = \
- 	java/nio/channels/FileLock.java \
- 	java/nio/channels/GatheringByteChannel.java \
- 	java/nio/channels/InterruptibleChannel.java \
-+	java/nio/channels/Pipe.java \
- 	java/nio/channels/ReadableByteChannel.java \
- 	java/nio/channels/ScatteringByteChannel.java \
- 	java/nio/channels/SelectableChannel.java \