Less dependencies on other packages emul
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 29 Sep 2012 07:49:34 +0200
branchemul
changeset 582ca1bb929895
parent 57 f38a4a9f67c3
child 60 922ba77e0de0
Less dependencies on other packages
emul/pom.xml
emul/src/main/java/java/lang/AbstractStringBuilder.java
     1.1 --- a/emul/pom.xml	Sat Sep 29 06:47:28 2012 +0200
     1.2 +++ b/emul/pom.xml	Sat Sep 29 07:49:34 2012 +0200
     1.3 @@ -33,6 +33,8 @@
     1.4                    <compilerArguments>
     1.5                        <bootclasspath>non-existing</bootclasspath>
     1.6                    </compilerArguments>
     1.7 +                 <source>1.7</source>
     1.8 +                 <target>1.7</target>
     1.9                </configuration>
    1.10            </plugin>
    1.11        </plugins>
     2.1 --- a/emul/src/main/java/java/lang/AbstractStringBuilder.java	Sat Sep 29 06:47:28 2012 +0200
     2.2 +++ b/emul/src/main/java/java/lang/AbstractStringBuilder.java	Sat Sep 29 07:49:34 2012 +0200
     2.3 @@ -25,9 +25,6 @@
     2.4  
     2.5  package java.lang;
     2.6  
     2.7 -import sun.misc.FloatingDecimal;
     2.8 -import java.util.Arrays;
     2.9 -
    2.10  /**
    2.11   * A mutable sequence of characters.
    2.12   * <p>
    2.13 @@ -127,7 +124,7 @@
    2.14                  throw new OutOfMemoryError();
    2.15              newCapacity = Integer.MAX_VALUE;
    2.16          }
    2.17 -        value = Arrays.copyOf(value, newCapacity);
    2.18 +        value = copyOf(value, newCapacity);
    2.19      }
    2.20  
    2.21      /**
    2.22 @@ -139,7 +136,7 @@
    2.23       */
    2.24      public void trimToSize() {
    2.25          if (count < value.length) {
    2.26 -            value = Arrays.copyOf(value, count);
    2.27 +            value = copyOf(value, count);
    2.28          }
    2.29      }
    2.30  
    2.31 @@ -654,8 +651,7 @@
    2.32       * @return  a reference to this object.
    2.33       */
    2.34      public AbstractStringBuilder append(float f) {
    2.35 -        new FloatingDecimal(f).appendTo(this);
    2.36 -        return this;
    2.37 +        throw new UnsupportedOperationException();
    2.38      }
    2.39  
    2.40      /**
    2.41 @@ -671,8 +667,7 @@
    2.42       * @return  a reference to this object.
    2.43       */
    2.44      public AbstractStringBuilder append(double d) {
    2.45 -        new FloatingDecimal(d).appendTo(this);
    2.46 -        return this;
    2.47 +        throw new UnsupportedOperationException();
    2.48      }
    2.49  
    2.50      /**
    2.51 @@ -1404,4 +1399,10 @@
    2.52          return value;
    2.53      }
    2.54  
    2.55 +    private static char[] copyOf(char[] original, int newLength) {
    2.56 +        char[] copy = new char[newLength];
    2.57 +        System.arraycopy(original, 0, copy, 0,
    2.58 +            Math.min(original.length, newLength));
    2.59 +        return copy;
    2.60 +    }
    2.61  }