Removing references to classes that would create too big transitive dependencies emul
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 29 Sep 2012 08:13:32 +0200
branchemul
changeset 614b334950499d
parent 60 922ba77e0de0
child 63 032f4064b2a7
Removing references to classes that would create too big transitive dependencies
emul/src/main/java/java/lang/AbstractStringBuilder.java
emul/src/main/java/java/lang/String.java
emul/src/main/java/java/lang/Throwable.java
     1.1 --- a/emul/src/main/java/java/lang/AbstractStringBuilder.java	Sat Sep 29 07:50:39 2012 +0200
     1.2 +++ b/emul/src/main/java/java/lang/AbstractStringBuilder.java	Sat Sep 29 08:13:32 2012 +0200
     1.3 @@ -124,7 +124,7 @@
     1.4                  throw new OutOfMemoryError();
     1.5              newCapacity = Integer.MAX_VALUE;
     1.6          }
     1.7 -        value = copyOf(value, newCapacity);
     1.8 +        value = String.copyOf(value, newCapacity);
     1.9      }
    1.10  
    1.11      /**
    1.12 @@ -136,7 +136,7 @@
    1.13       */
    1.14      public void trimToSize() {
    1.15          if (count < value.length) {
    1.16 -            value = copyOf(value, count);
    1.17 +            value = String.copyOf(value, count);
    1.18          }
    1.19      }
    1.20  
    1.21 @@ -1399,10 +1399,4 @@
    1.22          return value;
    1.23      }
    1.24  
    1.25 -    private static char[] copyOf(char[] original, int newLength) {
    1.26 -        char[] copy = new char[newLength];
    1.27 -        System.arraycopy(original, 0, copy, 0,
    1.28 -            Math.min(original.length, newLength));
    1.29 -        return copy;
    1.30 -    }
    1.31  }
     2.1 --- a/emul/src/main/java/java/lang/String.java	Sat Sep 29 07:50:39 2012 +0200
     2.2 +++ b/emul/src/main/java/java/lang/String.java	Sat Sep 29 08:13:32 2012 +0200
     2.3 @@ -27,12 +27,7 @@
     2.4  
     2.5  import java.io.ObjectStreamField;
     2.6  import java.io.UnsupportedEncodingException;
     2.7 -import java.nio.charset.Charset;
     2.8 -import java.util.ArrayList;
     2.9 -import java.util.Arrays;
    2.10  import java.util.Comparator;
    2.11 -import java.util.Formatter;
    2.12 -import java.util.Locale;
    2.13  import java.util.regex.Matcher;
    2.14  import java.util.regex.Pattern;
    2.15  import java.util.regex.PatternSyntaxException;
    2.16 @@ -169,7 +164,7 @@
    2.17              // String itself.  Perhaps this constructor is being called
    2.18              // in order to trim the baggage, so make a copy of the array.
    2.19              int off = original.offset;
    2.20 -            v = Arrays.copyOfRange(originalValue, off, off+size);
    2.21 +            v = copyOfRange(originalValue, off, off+size);
    2.22          } else {
    2.23              // The array representing the String is the same
    2.24              // size as the String, so no point in making a copy.
    2.25 @@ -193,7 +188,7 @@
    2.26          int size = value.length;
    2.27          this.offset = 0;
    2.28          this.count = size;
    2.29 -        this.value = Arrays.copyOf(value, size);
    2.30 +        this.value = copyOf(value, size);
    2.31      }
    2.32  
    2.33      /**
    2.34 @@ -230,7 +225,7 @@
    2.35          }
    2.36          this.offset = 0;
    2.37          this.count = count;
    2.38 -        this.value = Arrays.copyOfRange(value, offset, offset+count);
    2.39 +        this.value = copyOfRange(value, offset, offset+count);
    2.40      }
    2.41  
    2.42      /**
    2.43 @@ -484,6 +479,7 @@
    2.44       *
    2.45       * @since  1.6
    2.46       */
    2.47 +    /* don't want dependnecy on Charset
    2.48      public String(byte bytes[], int offset, int length, Charset charset) {
    2.49          if (charset == null)
    2.50              throw new NullPointerException("charset");
    2.51 @@ -493,6 +489,7 @@
    2.52          this.count = v.length;
    2.53          this.value = v;
    2.54      }
    2.55 +    */
    2.56  
    2.57      /**
    2.58       * Constructs a new {@code String} by decoding the specified array of bytes
    2.59 @@ -543,9 +540,11 @@
    2.60       *
    2.61       * @since  1.6
    2.62       */
    2.63 +    /* don't want dep on Charset
    2.64      public String(byte bytes[], Charset charset) {
    2.65          this(bytes, 0, bytes.length, charset);
    2.66      }
    2.67 +    */
    2.68  
    2.69      /**
    2.70       * Constructs a new {@code String} by decoding the specified subarray of
    2.71 @@ -972,10 +971,12 @@
    2.72       *
    2.73       * @since  1.6
    2.74       */
    2.75 +    /* don't want dep on Charset
    2.76      public byte[] getBytes(Charset charset) {
    2.77          if (charset == null) throw new NullPointerException();
    2.78          return StringCoding.encode(charset, value, offset, count);
    2.79      }
    2.80 +    */
    2.81  
    2.82      /**
    2.83       * Encodes this {@code String} into a sequence of bytes using the
    2.84 @@ -2325,7 +2326,7 @@
    2.85                ((ch-'A')|('Z'-ch)) < 0)) &&
    2.86              (ch < Character.MIN_HIGH_SURROGATE ||
    2.87               ch > Character.MAX_LOW_SURROGATE))
    2.88 -        {
    2.89 +        {/*
    2.90              int off = 0;
    2.91              int next = 0;
    2.92              boolean limited = limit > 0;
    2.93 @@ -2356,7 +2357,7 @@
    2.94                      resultSize--;
    2.95              String[] result = new String[resultSize];
    2.96              return list.subList(0, resultSize).toArray(result);
    2.97 -        }
    2.98 +        */}
    2.99          return Pattern.compile(regex).split(this, limit);
   2.100      }
   2.101  
   2.102 @@ -2454,99 +2455,99 @@
   2.103       * @see     java.lang.String#toUpperCase(Locale)
   2.104       * @since   1.1
   2.105       */
   2.106 -    public String toLowerCase(Locale locale) {
   2.107 -        if (locale == null) {
   2.108 -            throw new NullPointerException();
   2.109 -        }
   2.110 -
   2.111 -        int     firstUpper;
   2.112 -
   2.113 -        /* Now check if there are any characters that need to be changed. */
   2.114 -        scan: {
   2.115 -            for (firstUpper = 0 ; firstUpper < count; ) {
   2.116 -                char c = value[offset+firstUpper];
   2.117 -                if ((c >= Character.MIN_HIGH_SURROGATE) &&
   2.118 -                    (c <= Character.MAX_HIGH_SURROGATE)) {
   2.119 -                    int supplChar = codePointAt(firstUpper);
   2.120 -                    if (supplChar != Character.toLowerCase(supplChar)) {
   2.121 -                        break scan;
   2.122 -                    }
   2.123 -                    firstUpper += Character.charCount(supplChar);
   2.124 -                } else {
   2.125 -                    if (c != Character.toLowerCase(c)) {
   2.126 -                        break scan;
   2.127 -                    }
   2.128 -                    firstUpper++;
   2.129 -                }
   2.130 -            }
   2.131 -            return this;
   2.132 -        }
   2.133 -
   2.134 -        char[]  result = new char[count];
   2.135 -        int     resultOffset = 0;  /* result may grow, so i+resultOffset
   2.136 -                                    * is the write location in result */
   2.137 -
   2.138 -        /* Just copy the first few lowerCase characters. */
   2.139 -        System.arraycopy(value, offset, result, 0, firstUpper);
   2.140 -
   2.141 -        String lang = locale.getLanguage();
   2.142 -        boolean localeDependent =
   2.143 -            (lang == "tr" || lang == "az" || lang == "lt");
   2.144 -        char[] lowerCharArray;
   2.145 -        int lowerChar;
   2.146 -        int srcChar;
   2.147 -        int srcCount;
   2.148 -        for (int i = firstUpper; i < count; i += srcCount) {
   2.149 -            srcChar = (int)value[offset+i];
   2.150 -            if ((char)srcChar >= Character.MIN_HIGH_SURROGATE &&
   2.151 -                (char)srcChar <= Character.MAX_HIGH_SURROGATE) {
   2.152 -                srcChar = codePointAt(i);
   2.153 -                srcCount = Character.charCount(srcChar);
   2.154 -            } else {
   2.155 -                srcCount = 1;
   2.156 -            }
   2.157 -            if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
   2.158 -                lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
   2.159 -            } else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT
   2.160 -                lowerChar = Character.ERROR;
   2.161 -            } else {
   2.162 -                lowerChar = Character.toLowerCase(srcChar);
   2.163 -            }
   2.164 -            if ((lowerChar == Character.ERROR) ||
   2.165 -                (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
   2.166 -                if (lowerChar == Character.ERROR) {
   2.167 -                     if (!localeDependent && srcChar == '\u0130') {
   2.168 -                         lowerCharArray =
   2.169 -                             ConditionalSpecialCasing.toLowerCaseCharArray(this, i, Locale.ENGLISH);
   2.170 -                     } else {
   2.171 -                        lowerCharArray =
   2.172 -                            ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
   2.173 -                     }
   2.174 -                } else if (srcCount == 2) {
   2.175 -                    resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount;
   2.176 -                    continue;
   2.177 -                } else {
   2.178 -                    lowerCharArray = Character.toChars(lowerChar);
   2.179 -                }
   2.180 -
   2.181 -                /* Grow result if needed */
   2.182 -                int mapLen = lowerCharArray.length;
   2.183 -                if (mapLen > srcCount) {
   2.184 -                    char[] result2 = new char[result.length + mapLen - srcCount];
   2.185 -                    System.arraycopy(result, 0, result2, 0,
   2.186 -                        i + resultOffset);
   2.187 -                    result = result2;
   2.188 -                }
   2.189 -                for (int x=0; x<mapLen; ++x) {
   2.190 -                    result[i+resultOffset+x] = lowerCharArray[x];
   2.191 -                }
   2.192 -                resultOffset += (mapLen - srcCount);
   2.193 -            } else {
   2.194 -                result[i+resultOffset] = (char)lowerChar;
   2.195 -            }
   2.196 -        }
   2.197 -        return new String(0, count+resultOffset, result);
   2.198 -    }
   2.199 +//    public String toLowerCase(Locale locale) {
   2.200 +//        if (locale == null) {
   2.201 +//            throw new NullPointerException();
   2.202 +//        }
   2.203 +//
   2.204 +//        int     firstUpper;
   2.205 +//
   2.206 +//        /* Now check if there are any characters that need to be changed. */
   2.207 +//        scan: {
   2.208 +//            for (firstUpper = 0 ; firstUpper < count; ) {
   2.209 +//                char c = value[offset+firstUpper];
   2.210 +//                if ((c >= Character.MIN_HIGH_SURROGATE) &&
   2.211 +//                    (c <= Character.MAX_HIGH_SURROGATE)) {
   2.212 +//                    int supplChar = codePointAt(firstUpper);
   2.213 +//                    if (supplChar != Character.toLowerCase(supplChar)) {
   2.214 +//                        break scan;
   2.215 +//                    }
   2.216 +//                    firstUpper += Character.charCount(supplChar);
   2.217 +//                } else {
   2.218 +//                    if (c != Character.toLowerCase(c)) {
   2.219 +//                        break scan;
   2.220 +//                    }
   2.221 +//                    firstUpper++;
   2.222 +//                }
   2.223 +//            }
   2.224 +//            return this;
   2.225 +//        }
   2.226 +//
   2.227 +//        char[]  result = new char[count];
   2.228 +//        int     resultOffset = 0;  /* result may grow, so i+resultOffset
   2.229 +//                                    * is the write location in result */
   2.230 +//
   2.231 +//        /* Just copy the first few lowerCase characters. */
   2.232 +//        System.arraycopy(value, offset, result, 0, firstUpper);
   2.233 +//
   2.234 +//        String lang = locale.getLanguage();
   2.235 +//        boolean localeDependent =
   2.236 +//            (lang == "tr" || lang == "az" || lang == "lt");
   2.237 +//        char[] lowerCharArray;
   2.238 +//        int lowerChar;
   2.239 +//        int srcChar;
   2.240 +//        int srcCount;
   2.241 +//        for (int i = firstUpper; i < count; i += srcCount) {
   2.242 +//            srcChar = (int)value[offset+i];
   2.243 +//            if ((char)srcChar >= Character.MIN_HIGH_SURROGATE &&
   2.244 +//                (char)srcChar <= Character.MAX_HIGH_SURROGATE) {
   2.245 +//                srcChar = codePointAt(i);
   2.246 +//                srcCount = Character.charCount(srcChar);
   2.247 +//            } else {
   2.248 +//                srcCount = 1;
   2.249 +//            }
   2.250 +//            if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
   2.251 +//                lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
   2.252 +//            } else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT
   2.253 +//                lowerChar = Character.ERROR;
   2.254 +//            } else {
   2.255 +//                lowerChar = Character.toLowerCase(srcChar);
   2.256 +//            }
   2.257 +//            if ((lowerChar == Character.ERROR) ||
   2.258 +//                (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
   2.259 +//                if (lowerChar == Character.ERROR) {
   2.260 +//                     if (!localeDependent && srcChar == '\u0130') {
   2.261 +//                         lowerCharArray =
   2.262 +//                             ConditionalSpecialCasing.toLowerCaseCharArray(this, i, Locale.ENGLISH);
   2.263 +//                     } else {
   2.264 +//                        lowerCharArray =
   2.265 +//                            ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
   2.266 +//                     }
   2.267 +//                } else if (srcCount == 2) {
   2.268 +//                    resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount;
   2.269 +//                    continue;
   2.270 +//                } else {
   2.271 +//                    lowerCharArray = Character.toChars(lowerChar);
   2.272 +//                }
   2.273 +//
   2.274 +//                /* Grow result if needed */
   2.275 +//                int mapLen = lowerCharArray.length;
   2.276 +//                if (mapLen > srcCount) {
   2.277 +//                    char[] result2 = new char[result.length + mapLen - srcCount];
   2.278 +//                    System.arraycopy(result, 0, result2, 0,
   2.279 +//                        i + resultOffset);
   2.280 +//                    result = result2;
   2.281 +//                }
   2.282 +//                for (int x=0; x<mapLen; ++x) {
   2.283 +//                    result[i+resultOffset+x] = lowerCharArray[x];
   2.284 +//                }
   2.285 +//                resultOffset += (mapLen - srcCount);
   2.286 +//            } else {
   2.287 +//                result[i+resultOffset] = (char)lowerChar;
   2.288 +//            }
   2.289 +//        }
   2.290 +//        return new String(0, count+resultOffset, result);
   2.291 +//    }
   2.292  
   2.293      /**
   2.294       * Converts all of the characters in this <code>String</code> to lower
   2.295 @@ -2619,6 +2620,7 @@
   2.296       * @see     java.lang.String#toLowerCase(Locale)
   2.297       * @since   1.1
   2.298       */
   2.299 +    /* not for javascript 
   2.300      public String toUpperCase(Locale locale) {
   2.301          if (locale == null) {
   2.302              throw new NullPointerException();
   2.303 @@ -2626,7 +2628,7 @@
   2.304  
   2.305          int     firstLower;
   2.306  
   2.307 -        /* Now check if there are any characters that need to be changed. */
   2.308 +        // Now check if there are any characters that need to be changed. 
   2.309          scan: {
   2.310              for (firstLower = 0 ; firstLower < count; ) {
   2.311                  int c = (int)value[offset+firstLower];
   2.312 @@ -2648,11 +2650,11 @@
   2.313              return this;
   2.314          }
   2.315  
   2.316 -        char[]  result       = new char[count]; /* may grow */
   2.317 +        char[]  result       = new char[count]; /* may grow *
   2.318          int     resultOffset = 0;  /* result may grow, so i+resultOffset
   2.319 -                                    * is the write location in result */
   2.320 +                                    * is the write location in result *
   2.321  
   2.322 -        /* Just copy the first few upperCase characters. */
   2.323 +        /* Just copy the first few upperCase characters. *
   2.324          System.arraycopy(value, offset, result, 0, firstLower);
   2.325  
   2.326          String lang = locale.getLanguage();
   2.327 @@ -2692,7 +2694,7 @@
   2.328                      upperCharArray = Character.toChars(upperChar);
   2.329                  }
   2.330  
   2.331 -                /* Grow result if needed */
   2.332 +                /* Grow result if needed *
   2.333                  int mapLen = upperCharArray.length;
   2.334                  if (mapLen > srcCount) {
   2.335                      char[] result2 = new char[result.length + mapLen - srcCount];
   2.336 @@ -2710,6 +2712,7 @@
   2.337          }
   2.338          return new String(0, count+resultOffset, result);
   2.339      }
   2.340 +    */
   2.341  
   2.342      /**
   2.343       * Converts all of the characters in this <code>String</code> to upper
   2.344 @@ -2731,7 +2734,7 @@
   2.345       * @see     java.lang.String#toUpperCase(Locale)
   2.346       */
   2.347      public String toUpperCase() {
   2.348 -        return toUpperCase(Locale.getDefault());
   2.349 +        throw new UnsupportedOperationException();
   2.350      }
   2.351  
   2.352      /**
   2.353 @@ -2884,9 +2887,9 @@
   2.354       * @see  java.util.Formatter
   2.355       * @since  1.5
   2.356       */
   2.357 -    public static String format(Locale l, String format, Object ... args) {
   2.358 -        return new Formatter(l).format(format, args).toString();
   2.359 -    }
   2.360 +//    public static String format(Locale l, String format, Object ... args) {
   2.361 +//        return new Formatter(l).format(format, args).toString();
   2.362 +//    }
   2.363  
   2.364      /**
   2.365       * Returns the string representation of the <code>Object</code> argument.
   2.366 @@ -3073,4 +3076,21 @@
   2.367       */
   2.368      public native String intern();
   2.369  
   2.370 +    static char[] copyOfRange(char[] original, int from, int to) {
   2.371 +        int newLength = to - from;
   2.372 +        if (newLength < 0) {
   2.373 +            throw new IllegalArgumentException(from + " > " + to);
   2.374 +        }
   2.375 +        char[] copy = new char[newLength];
   2.376 +        System.arraycopy(original, from, copy, 0,
   2.377 +            Math.min(original.length - from, newLength));
   2.378 +        return copy;
   2.379 +    }
   2.380 +    static char[] copyOf(char[] original, int newLength) {
   2.381 +        char[] copy = new char[newLength];
   2.382 +        System.arraycopy(original, 0, copy, 0,
   2.383 +            Math.min(original.length, newLength));
   2.384 +        return copy;
   2.385 +    }
   2.386 +
   2.387  }
     3.1 --- a/emul/src/main/java/java/lang/Throwable.java	Sat Sep 29 07:50:39 2012 +0200
     3.2 +++ b/emul/src/main/java/java/lang/Throwable.java	Sat Sep 29 08:13:32 2012 +0200
     3.3 @@ -25,7 +25,6 @@
     3.4  
     3.5  package java.lang;
     3.6  import  java.io.*;
     3.7 -import  java.util.*;
     3.8  
     3.9  /**
    3.10   * The {@code Throwable} class is the superclass of all errors and
    3.11 @@ -211,8 +210,9 @@
    3.12  
    3.13      // Setting this static field introduces an acceptable
    3.14      // initialization dependency on a few java.util classes.
    3.15 -    private static final List<Throwable> SUPPRESSED_SENTINEL =
    3.16 -        Collections.unmodifiableList(new ArrayList<Throwable>(0));
    3.17 +// I don't think this dependency is acceptable
    3.18 +//    private static final List<Throwable> SUPPRESSED_SENTINEL =
    3.19 +//        Collections.unmodifiableList(new ArrayList<Throwable>(0));
    3.20  
    3.21      /**
    3.22       * The list of suppressed exceptions, as returned by {@link
    3.23 @@ -224,7 +224,7 @@
    3.24       * @serial
    3.25       * @since 1.7
    3.26       */
    3.27 -    private List<Throwable> suppressedExceptions = SUPPRESSED_SENTINEL;
    3.28 +//    private List<Throwable> suppressedExceptions = SUPPRESSED_SENTINEL;
    3.29  
    3.30      /** Message for trying to suppress a null exception. */
    3.31      private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception.";
    3.32 @@ -363,8 +363,8 @@
    3.33          }
    3.34          detailMessage = message;
    3.35          this.cause = cause;
    3.36 -        if (!enableSuppression)
    3.37 -            suppressedExceptions = null;
    3.38 +//        if (!enableSuppression)
    3.39 +//            suppressedExceptions = null;
    3.40      }
    3.41  
    3.42      /**
    3.43 @@ -645,9 +645,9 @@
    3.44      private void printStackTrace(PrintStreamOrWriter s) {
    3.45          // Guard against malicious overrides of Throwable.equals by
    3.46          // using a Set with identity equality semantics.
    3.47 -        Set<Throwable> dejaVu =
    3.48 -            Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
    3.49 -        dejaVu.add(this);
    3.50 +//        Set<Throwable> dejaVu =
    3.51 +//            Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
    3.52 +//        dejaVu.add(this);
    3.53  
    3.54          synchronized (s.lock()) {
    3.55              // Print our stack trace
    3.56 @@ -657,13 +657,13 @@
    3.57                  s.println("\tat " + traceElement);
    3.58  
    3.59              // Print suppressed exceptions, if any
    3.60 -            for (Throwable se : getSuppressed())
    3.61 -                se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu);
    3.62 +//            for (Throwable se : getSuppressed())
    3.63 +//                se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu);
    3.64  
    3.65              // Print cause, if any
    3.66              Throwable ourCause = getCause();
    3.67 -            if (ourCause != null)
    3.68 -                ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, "", dejaVu);
    3.69 +//            if (ourCause != null)
    3.70 +//                ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, "", dejaVu);
    3.71          }
    3.72      }
    3.73  
    3.74 @@ -675,12 +675,9 @@
    3.75                                           StackTraceElement[] enclosingTrace,
    3.76                                           String caption,
    3.77                                           String prefix,
    3.78 -                                         Set<Throwable> dejaVu) {
    3.79 +                                         Object dejaVu) {
    3.80          assert Thread.holdsLock(s.lock());
    3.81 -        if (dejaVu.contains(this)) {
    3.82 -            s.println("\t[CIRCULAR REFERENCE:" + this + "]");
    3.83 -        } else {
    3.84 -            dejaVu.add(this);
    3.85 +        {
    3.86              // Compute number of frames in common between this and enclosing trace
    3.87              StackTraceElement[] trace = getOurStackTrace();
    3.88              int m = trace.length - 1;
    3.89 @@ -911,25 +908,25 @@
    3.90      private void readObject(ObjectInputStream s)
    3.91          throws IOException, ClassNotFoundException {
    3.92          s.defaultReadObject();     // read in all fields
    3.93 -        if (suppressedExceptions != null) {
    3.94 -            List<Throwable> suppressed = null;
    3.95 -            if (suppressedExceptions.isEmpty()) {
    3.96 -                // Use the sentinel for a zero-length list
    3.97 -                suppressed = SUPPRESSED_SENTINEL;
    3.98 -            } else { // Copy Throwables to new list
    3.99 -                suppressed = new ArrayList<Throwable>(1);
   3.100 -                for (Throwable t : suppressedExceptions) {
   3.101 -                    // Enforce constraints on suppressed exceptions in
   3.102 -                    // case of corrupt or malicious stream.
   3.103 -                    if (t == null)
   3.104 -                        throw new NullPointerException(NULL_CAUSE_MESSAGE);
   3.105 -                    if (t == this)
   3.106 -                        throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
   3.107 -                    suppressed.add(t);
   3.108 -                }
   3.109 -            }
   3.110 -            suppressedExceptions = suppressed;
   3.111 -        } // else a null suppressedExceptions field remains null
   3.112 +//        if (suppressedExceptions != null) {
   3.113 +//            List<Throwable> suppressed = null;
   3.114 +//            if (suppressedExceptions.isEmpty()) {
   3.115 +//                // Use the sentinel for a zero-length list
   3.116 +//                suppressed = SUPPRESSED_SENTINEL;
   3.117 +//            } else { // Copy Throwables to new list
   3.118 +//                suppressed = new ArrayList<Throwable>(1);
   3.119 +//                for (Throwable t : suppressedExceptions) {
   3.120 +//                    // Enforce constraints on suppressed exceptions in
   3.121 +//                    // case of corrupt or malicious stream.
   3.122 +//                    if (t == null)
   3.123 +//                        throw new NullPointerException(NULL_CAUSE_MESSAGE);
   3.124 +//                    if (t == this)
   3.125 +//                        throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
   3.126 +//                    suppressed.add(t);
   3.127 +//                }
   3.128 +//            }
   3.129 +//            suppressedExceptions = suppressed;
   3.130 +//        } // else a null suppressedExceptions field remains null
   3.131  
   3.132          /*
   3.133           * For zero-length stack traces, use a clone of
   3.134 @@ -1044,13 +1041,13 @@
   3.135          if (exception == null)
   3.136              throw new NullPointerException(NULL_CAUSE_MESSAGE);
   3.137  
   3.138 -        if (suppressedExceptions == null) // Suppressed exceptions not recorded
   3.139 -            return;
   3.140 -
   3.141 -        if (suppressedExceptions == SUPPRESSED_SENTINEL)
   3.142 -            suppressedExceptions = new ArrayList<Throwable>(1);
   3.143 -
   3.144 -        suppressedExceptions.add(exception);
   3.145 +//        if (suppressedExceptions == null) // Suppressed exceptions not recorded
   3.146 +//            return;
   3.147 +//
   3.148 +//        if (suppressedExceptions == SUPPRESSED_SENTINEL)
   3.149 +//            suppressedExceptions = new ArrayList<Throwable>(1);
   3.150 +//
   3.151 +//        suppressedExceptions.add(exception);
   3.152      }
   3.153  
   3.154      private static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0];
   3.155 @@ -1071,10 +1068,11 @@
   3.156       * @since 1.7
   3.157       */
   3.158      public final synchronized Throwable[] getSuppressed() {
   3.159 -        if (suppressedExceptions == SUPPRESSED_SENTINEL ||
   3.160 -            suppressedExceptions == null)
   3.161 -            return EMPTY_THROWABLE_ARRAY;
   3.162 -        else
   3.163 -            return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
   3.164 +        return new Throwable[0];
   3.165 +//        if (suppressedExceptions == SUPPRESSED_SENTINEL ||
   3.166 +//            suppressedExceptions == null)
   3.167 +//            return EMPTY_THROWABLE_ARRAY;
   3.168 +//        else
   3.169 +//            return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
   3.170      }
   3.171  }