Moving all arraycopy methods into one System class emul
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 23 Jan 2013 22:55:28 +0100
branchemul
changeset 56053fafe384803
parent 558 df92e9608039
child 561 f06b2d18eb52
Moving all arraycopy methods into one System class
emul/compact/src/main/java/java/io/BufferedReader.java
emul/compact/src/main/java/java/io/InputStreamReader.java
emul/compact/src/main/java/java/io/Reader.java
emul/compact/src/main/java/java/lang/Readable.java
emul/compact/src/main/java/java/util/ArrayList.java
emul/compact/src/main/java/java/util/HashMap.java
emul/compact/src/main/java/java/util/HashSet.java
emul/mini/src/main/java/java/io/ByteArrayInputStream.java
emul/mini/src/main/java/java/io/DataInputStream.java
emul/mini/src/main/java/java/io/PushbackInputStream.java
emul/mini/src/main/java/java/lang/AbstractStringBuilder.java
emul/mini/src/main/java/java/lang/String.java
emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java
     1.1 --- a/emul/compact/src/main/java/java/io/BufferedReader.java	Wed Jan 23 22:33:45 2013 +0100
     1.2 +++ b/emul/compact/src/main/java/java/io/BufferedReader.java	Wed Jan 23 22:55:28 2013 +0100
     1.3 @@ -25,6 +25,8 @@
     1.4  
     1.5  package java.io;
     1.6  
     1.7 +import org.apidesign.bck2brwsr.emul.lang.System;
     1.8 +
     1.9  
    1.10  /**
    1.11   * Reads text from a character-input stream, buffering characters so as to
     2.1 --- a/emul/compact/src/main/java/java/io/InputStreamReader.java	Wed Jan 23 22:33:45 2013 +0100
     2.2 +++ b/emul/compact/src/main/java/java/io/InputStreamReader.java	Wed Jan 23 22:55:28 2013 +0100
     2.3 @@ -109,13 +109,14 @@
     2.4       * @since 1.4
     2.5       * @spec JSR-51
     2.6       */
     2.7 +/* XXX:
     2.8      public InputStreamReader(InputStream in, Charset cs) {
     2.9          super(in);
    2.10          if (cs == null)
    2.11              throw new NullPointerException("charset");
    2.12          sd = StreamDecoder.forInputStreamReader(in, this, cs);
    2.13      }
    2.14 -
    2.15 +*/
    2.16      /**
    2.17       * Creates an InputStreamReader that uses the given charset decoder.  </p>
    2.18       *
    2.19 @@ -125,13 +126,15 @@
    2.20       * @since 1.4
    2.21       * @spec JSR-51
    2.22       */
    2.23 +/* XXX:
    2.24      public InputStreamReader(InputStream in, CharsetDecoder dec) {
    2.25          super(in);
    2.26          if (dec == null)
    2.27              throw new NullPointerException("charset decoder");
    2.28          sd = StreamDecoder.forInputStreamReader(in, this, dec);
    2.29      }
    2.30 -
    2.31 +*/
    2.32 +    
    2.33      /**
    2.34       * Returns the name of the character encoding being used by this stream.
    2.35       *
     3.1 --- a/emul/compact/src/main/java/java/io/Reader.java	Wed Jan 23 22:33:45 2013 +0100
     3.2 +++ b/emul/compact/src/main/java/java/io/Reader.java	Wed Jan 23 22:55:28 2013 +0100
     3.3 @@ -94,14 +94,14 @@
     3.4       * @throws ReadOnlyBufferException if target is a read only buffer
     3.5       * @since 1.5
     3.6       */
     3.7 -    public int read(java.nio.CharBuffer target) throws IOException {
     3.8 -        int len = target.remaining();
     3.9 -        char[] cbuf = new char[len];
    3.10 -        int n = read(cbuf, 0, len);
    3.11 -        if (n > 0)
    3.12 -            target.put(cbuf, 0, n);
    3.13 -        return n;
    3.14 -    }
    3.15 +//    public int read(java.nio.CharBuffer target) throws IOException {
    3.16 +//        int len = target.remaining();
    3.17 +//        char[] cbuf = new char[len];
    3.18 +//        int n = read(cbuf, 0, len);
    3.19 +//        if (n > 0)
    3.20 +//            target.put(cbuf, 0, n);
    3.21 +//        return n;
    3.22 +//    }
    3.23  
    3.24      /**
    3.25       * Reads a single character.  This method will block until a character is
     4.1 --- a/emul/compact/src/main/java/java/lang/Readable.java	Wed Jan 23 22:33:45 2013 +0100
     4.2 +++ b/emul/compact/src/main/java/java/lang/Readable.java	Wed Jan 23 22:55:28 2013 +0100
     4.3 @@ -50,6 +50,6 @@
     4.4       * @throws NullPointerException if cb is null
     4.5       * @throws java.nio.ReadOnlyBufferException if cb is a read only buffer
     4.6       */
     4.7 -    public int read(java.nio.CharBuffer cb) throws IOException;
     4.8 +// XXX:    public int read(java.nio.CharBuffer cb) throws IOException;
     4.9  
    4.10  }
     5.1 --- a/emul/compact/src/main/java/java/util/ArrayList.java	Wed Jan 23 22:33:45 2013 +0100
     5.2 +++ b/emul/compact/src/main/java/java/util/ArrayList.java	Wed Jan 23 22:55:28 2013 +0100
     5.3 @@ -25,6 +25,8 @@
     5.4  
     5.5  package java.util;
     5.6  
     5.7 +import org.apidesign.bck2brwsr.emul.lang.System;
     5.8 +
     5.9  /**
    5.10   * Resizable-array implementation of the <tt>List</tt> interface.  Implements
    5.11   * all optional list operations, and permits all elements, including
    5.12 @@ -689,51 +691,6 @@
    5.13      }
    5.14  
    5.15      /**
    5.16 -     * Save the state of the <tt>ArrayList</tt> instance to a stream (that
    5.17 -     * is, serialize it).
    5.18 -     *
    5.19 -     * @serialData The length of the array backing the <tt>ArrayList</tt>
    5.20 -     *             instance is emitted (int), followed by all of its elements
    5.21 -     *             (each an <tt>Object</tt>) in the proper order.
    5.22 -     */
    5.23 -    private void writeObject(java.io.ObjectOutputStream s)
    5.24 -        throws java.io.IOException{
    5.25 -        // Write out element count, and any hidden stuff
    5.26 -        int expectedModCount = modCount;
    5.27 -        s.defaultWriteObject();
    5.28 -
    5.29 -        // Write out array length
    5.30 -        s.writeInt(elementData.length);
    5.31 -
    5.32 -        // Write out all elements in the proper order.
    5.33 -        for (int i=0; i<size; i++)
    5.34 -            s.writeObject(elementData[i]);
    5.35 -
    5.36 -        if (modCount != expectedModCount) {
    5.37 -            throw new ConcurrentModificationException();
    5.38 -        }
    5.39 -
    5.40 -    }
    5.41 -
    5.42 -    /**
    5.43 -     * Reconstitute the <tt>ArrayList</tt> instance from a stream (that is,
    5.44 -     * deserialize it).
    5.45 -     */
    5.46 -    private void readObject(java.io.ObjectInputStream s)
    5.47 -        throws java.io.IOException, ClassNotFoundException {
    5.48 -        // Read in size, and any hidden stuff
    5.49 -        s.defaultReadObject();
    5.50 -
    5.51 -        // Read in array length and allocate array
    5.52 -        int arrayLength = s.readInt();
    5.53 -        Object[] a = elementData = new Object[arrayLength];
    5.54 -
    5.55 -        // Read in all elements in the proper order.
    5.56 -        for (int i=0; i<size; i++)
    5.57 -            a[i] = s.readObject();
    5.58 -    }
    5.59 -
    5.60 -    /**
    5.61       * Returns a list iterator over the elements in this list (in proper
    5.62       * sequence), starting at the specified position in the list.
    5.63       * The specified index indicates the first element that would be
     6.1 --- a/emul/compact/src/main/java/java/util/HashMap.java	Wed Jan 23 22:33:45 2013 +0100
     6.2 +++ b/emul/compact/src/main/java/java/util/HashMap.java	Wed Jan 23 22:55:28 2013 +0100
     6.3 @@ -980,70 +980,9 @@
     6.4          }
     6.5      }
     6.6  
     6.7 -    /**
     6.8 -     * Save the state of the <tt>HashMap</tt> instance to a stream (i.e.,
     6.9 -     * serialize it).
    6.10 -     *
    6.11 -     * @serialData The <i>capacity</i> of the HashMap (the length of the
    6.12 -     *             bucket array) is emitted (int), followed by the
    6.13 -     *             <i>size</i> (an int, the number of key-value
    6.14 -     *             mappings), followed by the key (Object) and value (Object)
    6.15 -     *             for each key-value mapping.  The key-value mappings are
    6.16 -     *             emitted in no particular order.
    6.17 -     */
    6.18 -    private void writeObject(java.io.ObjectOutputStream s)
    6.19 -        throws IOException
    6.20 -    {
    6.21 -        Iterator<Map.Entry<K,V>> i =
    6.22 -            (size > 0) ? entrySet0().iterator() : null;
    6.23 -
    6.24 -        // Write out the threshold, loadfactor, and any hidden stuff
    6.25 -        s.defaultWriteObject();
    6.26 -
    6.27 -        // Write out number of buckets
    6.28 -        s.writeInt(table.length);
    6.29 -
    6.30 -        // Write out size (number of Mappings)
    6.31 -        s.writeInt(size);
    6.32 -
    6.33 -        // Write out keys and values (alternating)
    6.34 -        if (i != null) {
    6.35 -            while (i.hasNext()) {
    6.36 -                Map.Entry<K,V> e = i.next();
    6.37 -                s.writeObject(e.getKey());
    6.38 -                s.writeObject(e.getValue());
    6.39 -            }
    6.40 -        }
    6.41 -    }
    6.42  
    6.43      private static final long serialVersionUID = 362498820763181265L;
    6.44  
    6.45 -    /**
    6.46 -     * Reconstitute the <tt>HashMap</tt> instance from a stream (i.e.,
    6.47 -     * deserialize it).
    6.48 -     */
    6.49 -    private void readObject(java.io.ObjectInputStream s)
    6.50 -         throws IOException, ClassNotFoundException
    6.51 -    {
    6.52 -        // Read in the threshold, loadfactor, and any hidden stuff
    6.53 -        s.defaultReadObject();
    6.54 -
    6.55 -        // Read in number of buckets and allocate the bucket array;
    6.56 -        int numBuckets = s.readInt();
    6.57 -        table = new Entry[numBuckets];
    6.58 -
    6.59 -        init();  // Give subclass a chance to do its thing.
    6.60 -
    6.61 -        // Read in size (number of Mappings)
    6.62 -        int size = s.readInt();
    6.63 -
    6.64 -        // Read the keys and values, and put the mappings in the HashMap
    6.65 -        for (int i=0; i<size; i++) {
    6.66 -            K key = (K) s.readObject();
    6.67 -            V value = (V) s.readObject();
    6.68 -            putForCreate(key, value);
    6.69 -        }
    6.70 -    }
    6.71  
    6.72      // These methods are used when serializing HashSets
    6.73      int   capacity()     { return table.length; }
     7.1 --- a/emul/compact/src/main/java/java/util/HashSet.java	Wed Jan 23 22:33:45 2013 +0100
     7.2 +++ b/emul/compact/src/main/java/java/util/HashSet.java	Wed Jan 23 22:55:28 2013 +0100
     7.3 @@ -257,56 +257,4 @@
     7.4          }
     7.5      }
     7.6  
     7.7 -    /**
     7.8 -     * Save the state of this <tt>HashSet</tt> instance to a stream (that is,
     7.9 -     * serialize it).
    7.10 -     *
    7.11 -     * @serialData The capacity of the backing <tt>HashMap</tt> instance
    7.12 -     *             (int), and its load factor (float) are emitted, followed by
    7.13 -     *             the size of the set (the number of elements it contains)
    7.14 -     *             (int), followed by all of its elements (each an Object) in
    7.15 -     *             no particular order.
    7.16 -     */
    7.17 -    private void writeObject(java.io.ObjectOutputStream s)
    7.18 -        throws java.io.IOException {
    7.19 -        // Write out any hidden serialization magic
    7.20 -        s.defaultWriteObject();
    7.21 -
    7.22 -        // Write out HashMap capacity and load factor
    7.23 -        s.writeInt(map.capacity());
    7.24 -        s.writeFloat(map.loadFactor());
    7.25 -
    7.26 -        // Write out size
    7.27 -        s.writeInt(map.size());
    7.28 -
    7.29 -        // Write out all elements in the proper order.
    7.30 -        for (E e : map.keySet())
    7.31 -            s.writeObject(e);
    7.32 -    }
    7.33 -
    7.34 -    /**
    7.35 -     * Reconstitute the <tt>HashSet</tt> instance from a stream (that is,
    7.36 -     * deserialize it).
    7.37 -     */
    7.38 -    private void readObject(java.io.ObjectInputStream s)
    7.39 -        throws java.io.IOException, ClassNotFoundException {
    7.40 -        // Read in any hidden serialization magic
    7.41 -        s.defaultReadObject();
    7.42 -
    7.43 -        // Read in HashMap capacity and load factor and create backing HashMap
    7.44 -        int capacity = s.readInt();
    7.45 -        float loadFactor = s.readFloat();
    7.46 -        map = (((HashSet)this) instanceof LinkedHashSet ?
    7.47 -               new LinkedHashMap<E,Object>(capacity, loadFactor) :
    7.48 -               new HashMap<E,Object>(capacity, loadFactor));
    7.49 -
    7.50 -        // Read in size
    7.51 -        int size = s.readInt();
    7.52 -
    7.53 -        // Read in all elements in the proper order.
    7.54 -        for (int i=0; i<size; i++) {
    7.55 -            E e = (E) s.readObject();
    7.56 -            map.put(e, PRESENT);
    7.57 -        }
    7.58 -    }
    7.59  }
     8.1 --- a/emul/mini/src/main/java/java/io/ByteArrayInputStream.java	Wed Jan 23 22:33:45 2013 +0100
     8.2 +++ b/emul/mini/src/main/java/java/io/ByteArrayInputStream.java	Wed Jan 23 22:55:28 2013 +0100
     8.3 @@ -25,6 +25,8 @@
     8.4  
     8.5  package java.io;
     8.6  
     8.7 +import org.apidesign.bck2brwsr.emul.lang.System;
     8.8 +
     8.9  /**
    8.10   * A <code>ByteArrayInputStream</code> contains
    8.11   * an internal buffer that contains bytes that
    8.12 @@ -191,7 +193,7 @@
    8.13          if (len <= 0) {
    8.14              return 0;
    8.15          }
    8.16 -        PushbackInputStream.arraycopy(buf, pos, b, off, len);
    8.17 +        System.arraycopy(buf, pos, b, off, len);
    8.18          pos += len;
    8.19          return len;
    8.20      }
     9.1 --- a/emul/mini/src/main/java/java/io/DataInputStream.java	Wed Jan 23 22:33:45 2013 +0100
     9.2 +++ b/emul/mini/src/main/java/java/io/DataInputStream.java	Wed Jan 23 22:55:28 2013 +0100
     9.3 @@ -26,6 +26,7 @@
     9.4  package java.io;
     9.5  
     9.6  import org.apidesign.bck2brwsr.core.JavaScriptBody;
     9.7 +import org.apidesign.bck2brwsr.emul.lang.System;
     9.8  
     9.9  /**
    9.10   * A data input stream lets an application read primitive Java data
    9.11 @@ -565,7 +566,7 @@
    9.12                  if (--room < 0) {
    9.13                      buf = new char[offset + 128];
    9.14                      room = buf.length - offset - 1;
    9.15 -                    arraycopy(lineBuffer, 0, buf, 0, offset);
    9.16 +                    System.arraycopy(lineBuffer, 0, buf, 0, offset);
    9.17                      lineBuffer = buf;
    9.18                  }
    9.19                  buf[offset++] = (char) c;
    9.20 @@ -696,9 +697,4 @@
    9.21          // The number of chars produced may be less than utflen
    9.22          return new String(chararr, 0, chararr_count);
    9.23      }
    9.24 -    static void arraycopy(char[] value, int srcBegin, char[] dst, int dstBegin, int count) {
    9.25 -        while (count-- > 0) {
    9.26 -            dst[dstBegin++] = value[srcBegin++];
    9.27 -        }
    9.28 -    }
    9.29  }
    10.1 --- a/emul/mini/src/main/java/java/io/PushbackInputStream.java	Wed Jan 23 22:33:45 2013 +0100
    10.2 +++ b/emul/mini/src/main/java/java/io/PushbackInputStream.java	Wed Jan 23 22:55:28 2013 +0100
    10.3 @@ -25,6 +25,8 @@
    10.4  
    10.5  package java.io;
    10.6  
    10.7 +import org.apidesign.bck2brwsr.emul.lang.System;
    10.8 +
    10.9  /**
   10.10   * A <code>PushbackInputStream</code> adds
   10.11   * functionality to another input stream, namely
   10.12 @@ -177,7 +179,7 @@
   10.13              if (len < avail) {
   10.14                  avail = len;
   10.15              }
   10.16 -            arraycopy(buf, pos, b, off, avail);
   10.17 +            System.arraycopy(buf, pos, b, off, avail);
   10.18              pos += avail;
   10.19              off += avail;
   10.20              len -= avail;
   10.21 @@ -232,7 +234,7 @@
   10.22              throw new IOException("Push back buffer is full");
   10.23          }
   10.24          pos -= len;
   10.25 -        arraycopy(b, off, buf, pos, len);
   10.26 +        System.arraycopy(b, off, buf, pos, len);
   10.27      }
   10.28  
   10.29      /**
   10.30 @@ -380,9 +382,4 @@
   10.31          in = null;
   10.32          buf = null;
   10.33      }
   10.34 -    static void arraycopy(byte[] value, int srcBegin, byte[] dst, int dstBegin, int count) {
   10.35 -        while (count-- > 0) {
   10.36 -            dst[dstBegin++] = value[srcBegin++];
   10.37 -        }
   10.38 -    }
   10.39  }
    11.1 --- a/emul/mini/src/main/java/java/lang/AbstractStringBuilder.java	Wed Jan 23 22:33:45 2013 +0100
    11.2 +++ b/emul/mini/src/main/java/java/lang/AbstractStringBuilder.java	Wed Jan 23 22:55:28 2013 +0100
    11.3 @@ -25,6 +25,8 @@
    11.4  
    11.5  package java.lang;
    11.6  
    11.7 +import org.apidesign.bck2brwsr.emul.lang.System;
    11.8 +
    11.9  /**
   11.10   * A mutable sequence of characters.
   11.11   * <p>
   11.12 @@ -350,7 +352,7 @@
   11.13              throw new StringIndexOutOfBoundsException(srcEnd);
   11.14          if (srcBegin > srcEnd)
   11.15              throw new StringIndexOutOfBoundsException("srcBegin > srcEnd");
   11.16 -        arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
   11.17 +        System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
   11.18      }
   11.19  
   11.20      /**
   11.21 @@ -500,7 +502,7 @@
   11.22      public AbstractStringBuilder append(char[] str) {
   11.23          int len = str.length;
   11.24          ensureCapacityInternal(count + len);
   11.25 -        arraycopy(str, 0, value, count, len);
   11.26 +        System.arraycopy(str, 0, value, count, len);
   11.27          count += len;
   11.28          return this;
   11.29      }
   11.30 @@ -530,7 +532,7 @@
   11.31      public AbstractStringBuilder append(char str[], int offset, int len) {
   11.32          if (len > 0)                // let arraycopy report AIOOBE for len < 0
   11.33              ensureCapacityInternal(count + len);
   11.34 -        arraycopy(str, offset, value, count, len);
   11.35 +        System.arraycopy(str, offset, value, count, len);
   11.36          count += len;
   11.37          return this;
   11.38      }
   11.39 @@ -683,7 +685,7 @@
   11.40              throw new StringIndexOutOfBoundsException();
   11.41          int len = end - start;
   11.42          if (len > 0) {
   11.43 -            arraycopy(value, start+len, value, start, count-end);
   11.44 +            System.arraycopy(value, start+len, value, start, count-end);
   11.45              count -= len;
   11.46          }
   11.47          return this;
   11.48 @@ -745,7 +747,7 @@
   11.49      public AbstractStringBuilder deleteCharAt(int index) {
   11.50          if ((index < 0) || (index >= count))
   11.51              throw new StringIndexOutOfBoundsException(index);
   11.52 -        arraycopy(value, index+1, value, index, count-index-1);
   11.53 +        System.arraycopy(value, index+1, value, index, count-index-1);
   11.54          count--;
   11.55          return this;
   11.56      }
   11.57 @@ -783,7 +785,7 @@
   11.58          int newCount = count + len - (end - start);
   11.59          ensureCapacityInternal(newCount);
   11.60  
   11.61 -        arraycopy(value, end, value, start + len, count - end);
   11.62 +        System.arraycopy(value, end, value, start + len, count - end);
   11.63          str.getChars(value, start);
   11.64          count = newCount;
   11.65          return this;
   11.66 @@ -889,8 +891,8 @@
   11.67                  "offset " + offset + ", len " + len + ", str.length "
   11.68                  + str.length);
   11.69          ensureCapacityInternal(count + len);
   11.70 -        arraycopy(value, index, value, index + len, count - index);
   11.71 -        arraycopy(str, offset, value, index, len);
   11.72 +        System.arraycopy(value, index, value, index + len, count - index);
   11.73 +        System.arraycopy(str, offset, value, index, len);
   11.74          count += len;
   11.75          return this;
   11.76      }
   11.77 @@ -956,7 +958,7 @@
   11.78              str = "null";
   11.79          int len = str.length();
   11.80          ensureCapacityInternal(count + len);
   11.81 -        arraycopy(value, offset, value, offset + len, count - offset);
   11.82 +        System.arraycopy(value, offset, value, offset + len, count - offset);
   11.83          str.getChars(value, offset);
   11.84          count += len;
   11.85          return this;
   11.86 @@ -991,8 +993,8 @@
   11.87              throw new StringIndexOutOfBoundsException(offset);
   11.88          int len = str.length;
   11.89          ensureCapacityInternal(count + len);
   11.90 -        arraycopy(value, offset, value, offset + len, count - offset);
   11.91 -        arraycopy(str, 0, value, offset, len);
   11.92 +        System.arraycopy(value, offset, value, offset + len, count - offset);
   11.93 +        System.arraycopy(str, 0, value, offset, len);
   11.94          count += len;
   11.95          return this;
   11.96      }
   11.97 @@ -1082,7 +1084,7 @@
   11.98                  + s.length());
   11.99          int len = end - start;
  11.100          ensureCapacityInternal(count + len);
  11.101 -        arraycopy(value, dstOffset, value, dstOffset + len,
  11.102 +        System.arraycopy(value, dstOffset, value, dstOffset + len,
  11.103                           count - dstOffset);
  11.104          for (int i=start; i<end; i++)
  11.105              value[dstOffset++] = s.charAt(i);
  11.106 @@ -1134,7 +1136,7 @@
  11.107       */
  11.108      public AbstractStringBuilder insert(int offset, char c) {
  11.109          ensureCapacityInternal(count + 1);
  11.110 -        arraycopy(value, offset, value, offset + 1, count - offset);
  11.111 +        System.arraycopy(value, offset, value, offset + 1, count - offset);
  11.112          value[offset] = c;
  11.113          count += 1;
  11.114          return this;
  11.115 @@ -1394,22 +1396,10 @@
  11.116              throw new IllegalArgumentException(from + " > " + to);
  11.117          }
  11.118          char[] copy = new char[newLength];
  11.119 -        arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
  11.120 +        System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
  11.121          return copy;
  11.122      }
  11.123  
  11.124 -    static void arraycopy(char[] value, int srcBegin, char[] dst, int dstBegin, int count) {
  11.125 -        if (srcBegin < dstBegin) {
  11.126 -            while (count-- > 0) {
  11.127 -                dst[dstBegin + count] = value[srcBegin + count];
  11.128 -            }
  11.129 -        } else {
  11.130 -            while (count-- > 0) {
  11.131 -                dst[dstBegin++] = value[srcBegin++];
  11.132 -            }
  11.133 -        }
  11.134 -    }
  11.135 -
  11.136      // access system property
  11.137      static String getProperty(String nm) {
  11.138          return null;
  11.139 @@ -1417,7 +1407,7 @@
  11.140  
  11.141      static char[] copyOf(char[] original, int newLength) {
  11.142          char[] copy = new char[newLength];
  11.143 -        arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
  11.144 +        System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
  11.145          return copy;
  11.146      }
  11.147      
    12.1 --- a/emul/mini/src/main/java/java/lang/String.java	Wed Jan 23 22:33:45 2013 +0100
    12.2 +++ b/emul/mini/src/main/java/java/lang/String.java	Wed Jan 23 22:55:28 2013 +0100
    12.3 @@ -30,6 +30,7 @@
    12.4  import org.apidesign.bck2brwsr.core.JavaScriptBody;
    12.5  import org.apidesign.bck2brwsr.core.JavaScriptOnly;
    12.6  import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
    12.7 +import org.apidesign.bck2brwsr.emul.lang.System;
    12.8  
    12.9  /**
   12.10   * The <code>String</code> class represents character strings. All
   12.11 @@ -787,7 +788,7 @@
   12.12          "}"
   12.13      )
   12.14      void getChars(char dst[], int dstBegin) {
   12.15 -        AbstractStringBuilder.arraycopy(toCharArray(), offset(), dst, dstBegin, length());
   12.16 +        System.arraycopy(toCharArray(), offset(), dst, dstBegin, length());
   12.17      }
   12.18  
   12.19      /**
   12.20 @@ -836,7 +837,7 @@
   12.21          if (srcBegin > srcEnd) {
   12.22              throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
   12.23          }
   12.24 -        AbstractStringBuilder.arraycopy(toCharArray(), offset() + srcBegin, dst, dstBegin,
   12.25 +        System.arraycopy(toCharArray(), offset() + srcBegin, dst, dstBegin,
   12.26               srcEnd - srcBegin);
   12.27      }
   12.28  
   12.29 @@ -2416,7 +2417,7 @@
   12.30  //                                    * is the write location in result */
   12.31  //
   12.32  //        /* Just copy the first few lowerCase characters. */
   12.33 -//        arraycopy(value, offset, result, 0, firstUpper);
   12.34 +//        System.arraycopy(value, offset, result, 0, firstUpper);
   12.35  //
   12.36  //        String lang = locale.getLanguage();
   12.37  //        boolean localeDependent =
   12.38 @@ -2462,7 +2463,7 @@
   12.39  //                int mapLen = lowerCharArray.length;
   12.40  //                if (mapLen > srcCount) {
   12.41  //                    char[] result2 = new char[result.length + mapLen - srcCount];
   12.42 -//                    arraycopy(result, 0, result2, 0,
   12.43 +//                    System.arraycopy(result, 0, result2, 0,
   12.44  //                        i + resultOffset);
   12.45  //                    result = result2;
   12.46  //                }
   12.47 @@ -2584,7 +2585,7 @@
   12.48                                      * is the write location in result *
   12.49  
   12.50          /* Just copy the first few upperCase characters. *
   12.51 -        arraycopy(value, offset, result, 0, firstLower);
   12.52 +        System.arraycopy(value, offset, result, 0, firstLower);
   12.53  
   12.54          String lang = locale.getLanguage();
   12.55          boolean localeDependent =
   12.56 @@ -2627,7 +2628,7 @@
   12.57                  int mapLen = upperCharArray.length;
   12.58                  if (mapLen > srcCount) {
   12.59                      char[] result2 = new char[result.length + mapLen - srcCount];
   12.60 -                    arraycopy(result, 0, result2, 0,
   12.61 +                    System.arraycopy(result, 0, result2, 0,
   12.62                          i + resultOffset);
   12.63                      result = result2;
   12.64                  }
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java	Wed Jan 23 22:55:28 2013 +0100
    13.3 @@ -0,0 +1,64 @@
    13.4 +/**
    13.5 + * Back 2 Browser Bytecode Translator
    13.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    13.7 + *
    13.8 + * This program is free software: you can redistribute it and/or modify
    13.9 + * it under the terms of the GNU General Public License as published by
   13.10 + * the Free Software Foundation, version 2 of the License.
   13.11 + *
   13.12 + * This program is distributed in the hope that it will be useful,
   13.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.15 + * GNU General Public License for more details.
   13.16 + *
   13.17 + * You should have received a copy of the GNU General Public License
   13.18 + * along with this program. Look for COPYING file in the top folder.
   13.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
   13.20 + */
   13.21 +package org.apidesign.bck2brwsr.emul.lang;
   13.22 +
   13.23 +/**
   13.24 + *
   13.25 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   13.26 + */
   13.27 +public class System {
   13.28 +    private System() {
   13.29 +    }
   13.30 +
   13.31 +    public static void arraycopy(char[] value, int srcBegin, char[] dst, int dstBegin, int count) {
   13.32 +        if (srcBegin < dstBegin) {
   13.33 +            while (count-- > 0) {
   13.34 +                dst[dstBegin + count] = value[srcBegin + count];
   13.35 +            }
   13.36 +        } else {
   13.37 +            while (count-- > 0) {
   13.38 +                dst[dstBegin++] = value[srcBegin++];
   13.39 +            }
   13.40 +        }
   13.41 +    }
   13.42 +    
   13.43 +    public static void arraycopy(byte[] value, int srcBegin, byte[] dst, int dstBegin, int count) {
   13.44 +        if (srcBegin < dstBegin) {
   13.45 +            while (count-- > 0) {
   13.46 +                dst[dstBegin + count] = value[srcBegin + count];
   13.47 +            }
   13.48 +        } else {
   13.49 +            while (count-- > 0) {
   13.50 +                dst[dstBegin++] = value[srcBegin++];
   13.51 +            }
   13.52 +        }
   13.53 +    }
   13.54 +
   13.55 +    public static void arraycopy(Object[] value, int srcBegin, Object[] dst, int dstBegin, int count) {
   13.56 +        if (srcBegin < dstBegin) {
   13.57 +            while (count-- > 0) {
   13.58 +                dst[dstBegin + count] = value[srcBegin + count];
   13.59 +            }
   13.60 +        } else {
   13.61 +            while (count-- > 0) {
   13.62 +                dst[dstBegin++] = value[srcBegin++];
   13.63 +            }
   13.64 +        }
   13.65 +    }
   13.66 +    
   13.67 +}