classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Use VMSystem.arraycopy for String/StringBuffer


From: Mark Wielaard
Subject: [cp-patches] Use VMSystem.arraycopy for String/StringBuffer
Date: Fri, 10 Dec 2004 19:27:08 +0100

Hi,

As discussed on the main list we don't want to initialize
java.lang.System early. So this patch makes sure that String and
StringBuffer us VMSystem.arraycopy() directly. It also adds a empty
default implementation of VMSystemProperties.postInit(). And it adds
some more clarification to the NEWS file about the VM interface changes.

2004-12-07  Mark Wielaard  <address@hidden>

        * NEWS: Clarify VMRuntime and String/StringBuffer VMSystem usage.

        * vm/reference/gnu/classpath/VMSystemProperties.java (postInit):
        Provide empty default implementation.

        * java/lang/String.java: Replace all usage of System.arraycopy() with
        VMSystem.arraycopy().
        * java/lang/StringBuffer.java: Likewise.

Committed,

Mark
Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.57
diff -u -r1.57 NEWS
--- NEWS        6 Dec 2004 21:10:01 -0000       1.57
+++ NEWS        10 Dec 2004 18:18:12 -0000
@@ -4,6 +4,11 @@
   system properties initialization in VMRuntime. Note that it is
   now the VMs responsibility to set one additional property:
   gnu.cpu.endian should be set to "big" or "little".
+* VMRuntime.nativeGetLibname() has been renamed to VMRuntime.mapLibraryName()
+  and has only one argument, the name of the library.
+* String and StringBuffer now call VMSystem.arraycopy() directly and don't
+  go through java.lang.System. Be careful to not initialize java.lang.System
+  early in the bootstrap sequence in your VM runtime interface classes.
 
 New in release 0.12 (Nov 14, 2004)
 
Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.59
diff -u -r1.59 String.java
--- java/lang/String.java       17 Nov 2004 14:46:24 -0000      1.59
+++ java/lang/String.java       10 Dec 2004 18:18:13 -0000
@@ -414,7 +414,7 @@
         if ((count << 2) < buffer.value.length)
           {
             value = new char[count];
-            System.arraycopy(buffer.value, 0, value, 0, count);
+            VMSystem.arraycopy(buffer.value, 0, value, 0, count);
           }
         else
           {
@@ -446,7 +446,7 @@
     else
       {
         value = new char[count];
-        System.arraycopy(data, offset, value, 0, count);
+        VMSystem.arraycopy(data, offset, value, 0, count);
         this.offset = 0;
       }
     this.count = count;
@@ -496,7 +496,7 @@
   {
     if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count)
       throw new StringIndexOutOfBoundsException();
-    System.arraycopy(value, srcBegin + offset,
+    VMSystem.arraycopy(value, srcBegin + offset,
                      dst, dstBegin, srcEnd - srcBegin);
   }
 
@@ -1056,8 +1056,8 @@
     if (count == 0)
       return str;
     char[] newStr = new char[count + str.count];
-    System.arraycopy(value, offset, newStr, 0, count);
-    System.arraycopy(str.value, str.offset, newStr, count, str.count);
+    VMSystem.arraycopy(value, offset, newStr, 0, count);
+    VMSystem.arraycopy(str.value, str.offset, newStr, count, str.count);
     // Package constructor avoids an array copy.
     return new String(newStr, 0, newStr.length, true);
   }
@@ -1398,7 +1398,7 @@
     // if (count == value.length)
     //   return (char[]) value.clone();
     char[] copy = new char[count];
-    System.arraycopy(value, offset, copy, 0, count);
+    VMSystem.arraycopy(value, offset, copy, 0, count);
     return copy;
   }
 
@@ -1637,7 +1637,7 @@
       {
        int count = s.count;
        value = new char[count];
-       System.arraycopy(s.value, s.offset, value, 0, count);
+       VMSystem.arraycopy(s.value, s.offset, value, 0, count);
       }
 
     return value;
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/StringBuffer.java,v
retrieving revision 1.28
diff -u -r1.28 StringBuffer.java
--- java/lang/StringBuffer.java 22 Oct 2004 18:02:06 -0000      1.28
+++ java/lang/StringBuffer.java 10 Dec 2004 18:18:13 -0000
@@ -263,7 +263,7 @@
   {
     if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
       throw new StringIndexOutOfBoundsException();
-    System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
+    VMSystem.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
   }
 
   /**
@@ -334,7 +334,7 @@
       {
         int len = stringBuffer.count;
         ensureCapacity_unsynchronized(count + len);
-        System.arraycopy(stringBuffer.value, 0, value, count, len);
+        VMSystem.arraycopy(stringBuffer.value, 0, value, count, len);
         count += len;
       }
     return this;
@@ -374,7 +374,7 @@
     if (offset < 0 || count < 0 || offset > data.length - count)
       throw new StringIndexOutOfBoundsException();
     ensureCapacity_unsynchronized(this.count + count);
-    System.arraycopy(data, offset, value, this.count, count);
+    VMSystem.arraycopy(data, offset, value, this.count, count);
     this.count += count;
     return this;
   }
@@ -483,7 +483,7 @@
     // This will unshare if required.
     ensureCapacity_unsynchronized(count);
     if (count - end != 0)
-      System.arraycopy(value, end, value, start, count - end);
+      VMSystem.arraycopy(value, end, value, start, count - end);
     count -= end - start;
     return this;
   }
@@ -526,7 +526,7 @@
     ensureCapacity_unsynchronized(count + delta);
 
     if (delta != 0 && end < count)
-      System.arraycopy(value, end, value, end + delta, count - end);
+      VMSystem.arraycopy(value, end, value, end + delta, count - end);
 
     str.getChars(0, len, value, start);
     count += delta;
@@ -613,8 +613,8 @@
         || str_offset < 0 || str_offset > str.length - len)
       throw new StringIndexOutOfBoundsException();
     ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    System.arraycopy(str, str_offset, value, offset, len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    VMSystem.arraycopy(str, str_offset, value, offset, len);
     count += len;
     return this;
   }
@@ -653,7 +653,7 @@
       str = "null";
     int len = str.count;
     ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
     str.getChars(0, len, value, offset);
     count += len;
     return this;
@@ -704,7 +704,7 @@
     if (offset < 0 || offset > count)
       throw new StringIndexOutOfBoundsException(offset);
     ensureCapacity_unsynchronized(count + 1);
-    System.arraycopy(value, offset, value, offset + 1, count - offset);
+    VMSystem.arraycopy(value, offset, value, offset + 1, count - offset);
     value[offset] = ch;
     count++;
     return this;
@@ -900,7 +900,7 @@
                    : value.length);
         minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
         char[] nb = new char[minimumCapacity];
-        System.arraycopy(value, 0, nb, 0, count);
+        VMSystem.arraycopy(value, 0, nb, 0, count);
         value = nb;
         shared = false;
       }
Index: vm/reference/gnu/classpath/VMSystemProperties.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/vm/reference/gnu/classpath/VMSystemProperties.java,v
retrieving revision 1.2
diff -u -r1.2 VMSystemProperties.java
--- vm/reference/gnu/classpath/VMSystemProperties.java  7 Dec 2004 08:43:53 
-0000       1.2
+++ vm/reference/gnu/classpath/VMSystemProperties.java  10 Dec 2004 18:18:13 
-0000
@@ -91,5 +91,7 @@
      * a good idea to process the properties specified on the command
      * line here.
      */
-    static native void postInit(Properties properties);
+    static void postInit(Properties properties)
+    {
+    }
 }

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]